@loopback/metadata 4.0.0-alpha.8 → 4.1.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 -91
  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 -4735
  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,13 +1,15 @@
1
1
  "use strict";
2
- // Copyright IBM Corp. 2017,2018. All Rights Reserved.
2
+ // Copyright IBM Corp. 2017,2020. All Rights Reserved.
3
3
  // Node module: @loopback/metadata
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MethodMultiDecoratorFactory = exports.MethodParameterDecoratorFactory = exports.ParameterDecoratorFactory = exports.MethodDecoratorFactory = exports.PropertyDecoratorFactory = exports.ClassDecoratorFactory = exports.DecoratorFactory = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
10
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
11
  const reflect_1 = require("./reflect");
8
- const _ = require("lodash");
9
- const debugModule = require("debug");
10
- const debug = debugModule('loopback:metadata:decorator');
12
+ const debug = (0, debug_1.default)('loopback:metadata:decorator');
11
13
  /**
12
14
  * Base factory class for decorator functions
13
15
  *
@@ -33,36 +35,43 @@ const debug = debugModule('loopback:metadata:decorator');
33
35
  class DecoratorFactory {
34
36
  /**
35
37
  * 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
38
+ * @param key - Metadata key
39
+ * @param spec - Metadata object from the decorator function
40
+ * @param options - Options for the decorator. Default to
39
41
  * `{allowInheritance: true}` if not provided
40
42
  */
41
- constructor(key, spec, options) {
43
+ constructor(key, spec, options = {}) {
44
+ var _a;
42
45
  this.key = key;
43
46
  this.spec = spec;
44
47
  this.options = options;
45
- this.options = Object.assign({ allowInheritance: true, cloneInputSpec: true }, options);
48
+ this.options = Object.assign({
49
+ allowInheritance: true,
50
+ cloneInputSpec: true,
51
+ }, options);
52
+ const defaultDecoratorName = this.constructor.name.replace(/Factory$/, '');
53
+ this.decoratorName = (_a = this.options.decoratorName) !== null && _a !== void 0 ? _a : defaultDecoratorName;
46
54
  if (this.options.cloneInputSpec) {
47
55
  this.spec = DecoratorFactory.cloneDeep(spec);
48
56
  }
49
57
  }
50
58
  allowInheritance() {
51
- return !!(this.options && this.options.allowInheritance);
59
+ var _a;
60
+ return !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowInheritance);
52
61
  }
53
62
  /**
54
63
  * Inherit metadata from base classes. By default, this method merges base
55
64
  * metadata into the spec if `allowInheritance` is set to `true`. To customize
56
65
  * the behavior, this method can be overridden by sub classes.
57
66
  *
58
- * @param inheritedMetadata Metadata from base classes for the member
67
+ * @param inheritedMetadata - Metadata from base classes for the member
59
68
  */
60
69
  inherit(inheritedMetadata) {
61
70
  if (!this.allowInheritance())
62
71
  return this.spec;
63
72
  if (inheritedMetadata == null)
64
73
  return this.spec;
65
- if (this.spec == undefined)
74
+ if (this.spec == null)
66
75
  return inheritedMetadata;
67
76
  if (typeof inheritedMetadata !== 'object')
68
77
  return this.spec;
@@ -73,20 +82,24 @@ class DecoratorFactory {
73
82
  return Object.assign(inheritedMetadata, this.spec);
74
83
  }
75
84
  /**
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
85
+ * Get the qualified name of a decoration target.
86
+ *
87
+ * @remarks
88
+ *
89
+ * Example of target names:
90
+ *
91
+ * - class MyClass
92
+ * - MyClass.constructor[0] // First parameter of the constructor
93
+ * - MyClass.myStaticProperty
94
+ * - MyClass.myStaticMethod()
95
+ * - MyClass.myStaticMethod[0] // First parameter of the myStaticMethod
96
+ * - MyClass.prototype.myProperty
97
+ * - MyClass.prototype.myMethod()
98
+ * - MyClass.prototype.myMethod[1] // Second parameter of myMethod
99
+ *
100
+ * @param target - Class or prototype of a class
101
+ * @param member - Optional property/method name
102
+ * @param descriptorOrIndex - Optional method descriptor or parameter index
90
103
  */
91
104
  static getTargetName(target, member, descriptorOrIndex) {
92
105
  let name = target instanceof Function
@@ -95,40 +108,42 @@ class DecoratorFactory {
95
108
  if (member == null && descriptorOrIndex == null) {
96
109
  return `class ${name}`;
97
110
  }
98
- if (member == null)
111
+ if (member == null || member === '')
99
112
  member = 'constructor';
113
+ const memberAccessor = typeof member === 'symbol' ? '[' + member.toString() + ']' : '.' + member;
100
114
  if (typeof descriptorOrIndex === 'number') {
101
115
  // Parameter
102
- name = `${name}.${member}[${descriptorOrIndex}]`;
116
+ name = `${name}${memberAccessor}[${descriptorOrIndex}]`;
103
117
  }
104
118
  else if (descriptorOrIndex != null) {
105
- name = `${name}.${member}()`;
119
+ name = `${name}${memberAccessor}()`;
106
120
  }
107
121
  else {
108
- name = `${name}.${member}`;
122
+ name = `${name}${memberAccessor}`;
109
123
  }
110
124
  return name;
111
125
  }
112
126
  /**
113
127
  * Get the number of parameters for a given constructor or method
114
- * @param target Class or the prototype
115
- * @param member Method name
128
+ * @param target - Class or the prototype
129
+ * @param member - Method name
116
130
  */
117
131
  static getNumberOfParameters(target, member) {
118
- if (target instanceof Function && !member) {
132
+ if (typeof target === 'function' && !member) {
119
133
  // constructor
120
134
  return target.length;
121
135
  }
122
136
  else {
123
137
  // target[member] is a function
124
- return target[member].length;
138
+ const method = target[member];
139
+ return method.length;
125
140
  }
126
141
  }
127
142
  /**
128
143
  * Set a reference to the target class or prototype for a given spec if
129
144
  * it's an object
130
- * @param spec Metadata spec
131
- * @param target Target of the decoration. It is a class or the prototype of
145
+ * @param spec - Metadata spec
146
+ * @param target - Target of the decoration. It is a class or the prototype of
132
147
  * a class.
133
148
  */
134
149
  withTarget(spec, target) {
@@ -137,13 +152,15 @@ class DecoratorFactory {
137
152
  Object.defineProperty(spec, DecoratorFactory.TARGET, {
138
153
  value: target,
139
154
  enumerable: false,
155
+ // Make sure it won't be redefined on the same object
156
+ configurable: false,
140
157
  });
141
158
  }
142
159
  return spec;
143
160
  }
144
161
  /**
145
162
  * Get the optional decoration target of a given spec
146
- * @param spec Metadata spec
163
+ * @param spec - Metadata spec
147
164
  */
148
165
  getTarget(spec) {
149
166
  if (typeof spec === 'object' && spec != null) {
@@ -162,13 +179,13 @@ class DecoratorFactory {
162
179
  *
163
180
  * It MUST be overridden by subclasses to process inherited metadata.
164
181
  *
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
182
+ * @param inheritedMetadata - Metadata inherited from the base classes
183
+ * @param target - Decoration target
184
+ * @param member - Optional property or method
185
+ * @param descriptorOrIndex - Optional parameter index or method descriptor
169
186
  */
170
187
  mergeWithInherited(inheritedMetadata, target, member, descriptorOrIndex) {
171
- throw new Error('mergeWithInherited() is not implemented');
188
+ throw new Error(`mergeWithInherited() is not implemented for ${this.decoratorName}`);
172
189
  }
173
190
  /**
174
191
  * This method is called by the default implementation of the decorator
@@ -178,26 +195,37 @@ class DecoratorFactory {
178
195
  *
179
196
  * It MUST be overridden by subclasses to process own metadata.
180
197
  *
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
198
+ * @param ownMetadata - Own Metadata exists locally on the target
199
+ * @param target - Decoration target
200
+ * @param member - Optional property or method
201
+ * @param descriptorOrIndex - Optional parameter index or method descriptor
185
202
  */
186
203
  mergeWithOwn(ownMetadata, target, member, descriptorOrIndex) {
187
- throw new Error('mergeWithOwn() is not implemented');
204
+ throw new Error(`mergeWithOwn() is not implemented for ${this.decoratorName}`);
205
+ }
206
+ /**
207
+ * Create an error to report if the decorator is applied to the target more
208
+ * than once
209
+ * @param target - Decoration target
210
+ * @param member - Optional property or method
211
+ * @param descriptorOrIndex - Optional parameter index or method descriptor
212
+ */
213
+ duplicateDecorationError(target, member, descriptorOrIndex) {
214
+ const targetName = DecoratorFactory.getTargetName(target, member, descriptorOrIndex);
215
+ return new Error(`${this.decoratorName} cannot be applied more than once on ${targetName}`);
188
216
  }
189
217
  /**
190
218
  * Create a decorator function of the given type. Each sub class MUST
191
219
  * implement this method.
192
220
  */
193
221
  create() {
194
- throw new Error('create() is not implemented');
222
+ throw new Error(`create() is not implemented for ${this.decoratorName}`);
195
223
  }
196
224
  /**
197
225
  * 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
226
+ * @param target - Decorator target
227
+ * @param member - Optional property or method
228
+ * @param descriptorOrIndex - Optional method descriptor or parameter index
201
229
  */
202
230
  decorate(target, member, descriptorOrIndex) {
203
231
  const targetName = DecoratorFactory.getTargetName(target, member, descriptorOrIndex);
@@ -207,6 +235,7 @@ class DecoratorFactory {
207
235
  // mutated by sub classes
208
236
  meta = DecoratorFactory.cloneDeep(reflect_1.Reflector.getMetadata(this.key, target));
209
237
  meta = this.mergeWithInherited(meta, target, member, descriptorOrIndex);
238
+ /* istanbul ignore if */
210
239
  if (debug.enabled) {
211
240
  debug('%s: %j', targetName, meta);
212
241
  }
@@ -214,6 +243,7 @@ class DecoratorFactory {
214
243
  }
215
244
  else {
216
245
  meta = this.mergeWithOwn(meta, target, member, descriptorOrIndex);
246
+ /* istanbul ignore if */
217
247
  if (debug.enabled) {
218
248
  debug('%s: %j', targetName, meta);
219
249
  }
@@ -222,36 +252,56 @@ class DecoratorFactory {
222
252
  }
223
253
  /**
224
254
  * 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
255
+ * @param key - Metadata key
256
+ * @param spec - Metadata object from the decorator function
257
+ * @param options - Options for the decorator
228
258
  */
229
259
  static _createDecorator(key, spec, options) {
230
- const inst = new this(key, spec, options);
260
+ const inst = new this(key.toString(), spec, options);
231
261
  return inst.create();
232
262
  }
233
263
  static cloneDeep(val) {
234
264
  if (typeof val !== 'object')
235
265
  return val;
236
- return _.cloneDeepWith(val, v => {
237
- // Do not clone functions
238
- if (typeof v === 'function')
266
+ return lodash_1.default.cloneDeepWith(val, v => {
267
+ if (typeof v !== 'object')
239
268
  return v;
240
- if (v &&
241
- typeof v.constructor === 'function' &&
242
- v.constructor.prototype === v) {
243
- // Do not clone class prototype
269
+ if (v == null)
270
+ return v;
271
+ if (v.constructor != null &&
272
+ !DecoratorFactory._cloneableTypes.includes(v.constructor)) {
273
+ // Do not clone instances of classes/constructors, such as Date
244
274
  return v;
245
275
  }
246
276
  return undefined;
247
277
  });
248
278
  }
249
279
  }
280
+ exports.DecoratorFactory = DecoratorFactory;
250
281
  /**
251
282
  * A constant to reference the target of a decoration
252
283
  */
253
284
  DecoratorFactory.TARGET = '__decoratorTarget';
254
- exports.DecoratorFactory = DecoratorFactory;
285
+ // See https://github.com/lodash/lodash/blob/master/.internal/baseClone.js
286
+ DecoratorFactory._cloneableTypes = [
287
+ Object,
288
+ Array,
289
+ Set,
290
+ Map,
291
+ RegExp,
292
+ Date,
293
+ Buffer,
294
+ ArrayBuffer,
295
+ Float32Array,
296
+ Float64Array,
297
+ Int8Array,
298
+ Int16Array,
299
+ Int32Array,
300
+ Uint8Array,
301
+ Uint8ClampedArray,
302
+ Uint16Array,
303
+ Uint32Array,
304
+ ];
255
305
  /**
256
306
  * Factory for class decorators
257
307
  */
@@ -261,8 +311,7 @@ class ClassDecoratorFactory extends DecoratorFactory {
261
311
  }
262
312
  mergeWithOwn(ownMetadata, target, member, descriptorOrIndex) {
263
313
  if (ownMetadata != null) {
264
- throw new Error('Decorator cannot be applied more than once on ' +
265
- DecoratorFactory.getTargetName(target));
314
+ throw this.duplicateDecorationError(target, member, descriptorOrIndex);
266
315
  }
267
316
  return this.withTarget(this.spec, target);
268
317
  }
@@ -271,9 +320,9 @@ class ClassDecoratorFactory extends DecoratorFactory {
271
320
  }
272
321
  /**
273
322
  * 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
323
+ * @param key - Metadata key
324
+ * @param spec - Metadata object from the decorator function
325
+ * @param options - Options for the decorator
277
326
  */
278
327
  static createDecorator(key, spec, options) {
279
328
  return super._createDecorator(key, spec, options);
@@ -293,8 +342,7 @@ class PropertyDecoratorFactory extends DecoratorFactory {
293
342
  mergeWithOwn(ownMetadata, target, propertyName, descriptorOrParameterIndex) {
294
343
  ownMetadata = ownMetadata || {};
295
344
  if (ownMetadata[propertyName] != null) {
296
- const targetName = DecoratorFactory.getTargetName(target, propertyName);
297
- throw new Error('Decorator cannot be applied more than once on ' + targetName);
345
+ throw this.duplicateDecorationError(target, propertyName, descriptorOrParameterIndex);
298
346
  }
299
347
  ownMetadata[propertyName] = this.withTarget(this.spec, target);
300
348
  return ownMetadata;
@@ -304,9 +352,9 @@ class PropertyDecoratorFactory extends DecoratorFactory {
304
352
  }
305
353
  /**
306
354
  * 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
355
+ * @param key - Metadata key
356
+ * @param spec - Metadata object from the decorator function
357
+ * @param options - Options for the decorator
310
358
  */
311
359
  static createDecorator(key, spec, options) {
312
360
  return super._createDecorator(key, spec, options);
@@ -327,8 +375,7 @@ class MethodDecoratorFactory extends DecoratorFactory {
327
375
  ownMetadata = ownMetadata || {};
328
376
  const methodMeta = ownMetadata[methodName];
329
377
  if (this.getTarget(methodMeta) === target) {
330
- throw new Error('Decorator cannot be applied more than once on ' +
331
- DecoratorFactory.getTargetName(target, methodName, methodDescriptor));
378
+ throw this.duplicateDecorationError(target, methodName, methodDescriptor);
332
379
  }
333
380
  // Set the method metadata
334
381
  ownMetadata[methodName] = this.withTarget(this.spec, target);
@@ -339,9 +386,9 @@ class MethodDecoratorFactory extends DecoratorFactory {
339
386
  }
340
387
  /**
341
388
  * 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
389
+ * @param key - Metadata key
390
+ * @param spec - Metadata object from the decorator function
391
+ * @param options - Options for the decorator
345
392
  */
346
393
  static createDecorator(key, spec, options) {
347
394
  return super._createDecorator(key, spec, options);
@@ -375,8 +422,7 @@ class ParameterDecoratorFactory extends DecoratorFactory {
375
422
  const methodMeta = this.getOrInitMetadata(ownMetadata, target, methodName);
376
423
  const index = parameterIndex;
377
424
  if (this.getTarget(methodMeta[index]) === target) {
378
- throw new Error('Decorator cannot be applied more than once on ' +
379
- DecoratorFactory.getTargetName(target, methodName, parameterIndex));
425
+ throw this.duplicateDecorationError(target, methodName, parameterIndex);
380
426
  }
381
427
  // Set the parameter metadata
382
428
  methodMeta[index] = this.withTarget(this.inherit(methodMeta[index]), target);
@@ -387,9 +433,9 @@ class ParameterDecoratorFactory extends DecoratorFactory {
387
433
  }
388
434
  /**
389
435
  * 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
436
+ * @param key - Metadata key
437
+ * @param spec - Metadata object from the decorator function
438
+ * @param options - Options for the decorator
393
439
  */
394
440
  static createDecorator(key, spec, options) {
395
441
  return super._createDecorator(key, spec, options);
@@ -397,8 +443,11 @@ class ParameterDecoratorFactory extends DecoratorFactory {
397
443
  }
398
444
  exports.ParameterDecoratorFactory = ParameterDecoratorFactory;
399
445
  /**
400
- * Factory for method level parameter decorator. For example, the following
401
- * code uses `@param` to declare two parameters for `greet()`.
446
+ * Factory for method level parameter decorator.
447
+ *
448
+ * @example
449
+ * For example, the following code uses `@param` to declare two parameters for
450
+ * `greet()`.
402
451
  * ```ts
403
452
  * class MyController {
404
453
  * @param('name') // Parameter 0
@@ -424,7 +473,7 @@ class MethodParameterDecoratorFactory extends DecoratorFactory {
424
473
  if (index < 0) {
425
474
  // Excessive decorations than the number of parameters detected
426
475
  const method = DecoratorFactory.getTargetName(target, methodName, methodDescriptor);
427
- throw new Error(`The decorator is used more than ${numOfParams} time(s) on ${method}`);
476
+ throw new Error(`${this.decoratorName} is used more than ${numOfParams} time(s) on ${method}`);
428
477
  }
429
478
  return index;
430
479
  }
@@ -444,7 +493,7 @@ class MethodParameterDecoratorFactory extends DecoratorFactory {
444
493
  mergeWithOwn(ownMetadata, target, methodName, methodDescriptor) {
445
494
  ownMetadata = ownMetadata || {};
446
495
  const index = this.getParameterIndex(target, methodName, methodDescriptor);
447
- let params = ownMetadata[methodName] || new Array(index + 1).fill(undefined);
496
+ const params = ownMetadata[methodName] || new Array(index + 1).fill(undefined);
448
497
  params[index] = this.withTarget(this.inherit(params[index]), target);
449
498
  ownMetadata[methodName] = params;
450
499
  // Cache the index to help us position the next parameter
@@ -456,13 +505,71 @@ class MethodParameterDecoratorFactory extends DecoratorFactory {
456
505
  }
457
506
  /**
458
507
  * 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
508
+ * @param key - Metadata key
509
+ * @param spec - Metadata object from the decorator function
510
+ * @param options - Options for the decorator
462
511
  */
463
512
  static createDecorator(key, spec, options) {
464
513
  return super._createDecorator(key, spec, options);
465
514
  }
466
515
  }
467
516
  exports.MethodParameterDecoratorFactory = MethodParameterDecoratorFactory;
517
+ /**
518
+ * Factory for an append-array of method-level decorators
519
+ * The `@response` metadata for a method is an array.
520
+ * Each item in the array should be a single value, containing
521
+ * a response code and a single spec or Model. This should allow:
522
+ *
523
+ * @example
524
+ * ```ts
525
+ * @response(200, MyFirstModel)
526
+ * @response(403, [NotAuthorizedReasonOne, NotAuthorizedReasonTwo])
527
+ * @response(404, NotFoundOne)
528
+ * @response(404, NotFoundTwo)
529
+ * @response(409, {schema: {}})
530
+ * public async myMethod() {}
531
+ * ```
532
+ *
533
+ * In the case that a ResponseObject is passed, it becomes the
534
+ * default for description/content, and if possible, further Models are
535
+ * incorporated as a `oneOf: []` array.
536
+ *
537
+ * In the case that a ReferenceObject is passed, it and it alone is used, since
538
+ * references can be external and we cannot `oneOf` their content.
539
+ *
540
+ * The factory creates and updates an array of items T[], and the getter
541
+ * provides the values as that array.
542
+ */
543
+ class MethodMultiDecoratorFactory extends MethodDecoratorFactory {
544
+ mergeWithInherited(inheritedMetadata, target, methodName) {
545
+ inheritedMetadata = inheritedMetadata || {};
546
+ inheritedMetadata[methodName] = this._mergeArray(inheritedMetadata[methodName], this.withTarget(this.spec, target));
547
+ return inheritedMetadata;
548
+ }
549
+ mergeWithOwn(ownMetadata, target, methodName, methodDescriptor) {
550
+ ownMetadata = ownMetadata || {};
551
+ ownMetadata[methodName] = this._mergeArray(ownMetadata[methodName], this.withTarget(this.spec, target));
552
+ return ownMetadata;
553
+ }
554
+ _mergeArray(result, methodMeta) {
555
+ if (!result) {
556
+ if (Array.isArray(methodMeta)) {
557
+ result = methodMeta;
558
+ }
559
+ else {
560
+ result = [methodMeta];
561
+ }
562
+ }
563
+ else {
564
+ if (Array.isArray(methodMeta)) {
565
+ result.push(...methodMeta);
566
+ }
567
+ else {
568
+ result.push(methodMeta);
569
+ }
570
+ }
571
+ return result;
572
+ }
573
+ }
574
+ exports.MethodMultiDecoratorFactory = MethodMultiDecoratorFactory;
468
575
  //# sourceMappingURL=decorator-factory.js.map
@@ -0,0 +1 @@
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,+DAAgC;AAChC,iEAAuB;AACvB,uCAAoC;AAEpC,MAAM,KAAK,GAAG,IAAA,eAAW,EAAC,6BAA6B,CAAC,CAAC;AA8BzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,gBAAgB;IAY3B;;;;;;OAMG;IACH,YACY,GAAW,EACX,IAAO,EACP,UAA4B,EAAE;;QAF9B,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAG;QACP,YAAO,GAAP,OAAO,CAAuB;QAExC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B;YACE,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,IAAI;SACrB,EACD,OAAO,CACR,CAAC;QACF,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,aAAa,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,aAAa,mCAAI,oBAAoB,CAAC;QACxE,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAC/B,IAAI,CAAC,IAAI,GAAG,gB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I,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CACnC,CAAC;QACF,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,WAAW,CAAC,MAAW,EAAE,UAAmB;QAClD,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;gBAC7B,MAAM,GAAG,UAAU,CAAC;aACrB;iBAAM;gBACL,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC;aACvB;SACF;aAAM;YACL,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;gBAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;aAC5B;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACzB;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjDD,kEAiDC"}
package/dist/index.d.ts CHANGED
@@ -1 +1,22 @@
1
- export * from './src';
1
+ /**
2
+ * A package with utilities to help developers implement
3
+ * {@link https://www.typescriptlang.org/docs/handbook/decorators.html |TypeScript decorators},
4
+ * define/merge metadata, and inspect metadata.
5
+ *
6
+ * @remarks
7
+ * Utilities:
8
+ *
9
+ * - Reflector: Wrapper of
10
+ * {@link https://github.com/rbuckton/reflect-metadata | reflect-metadata}.
11
+ * - Decorator factories: A set of factories for class/method/property/parameter
12
+ * decorators to apply metadata to a given class and its static or instance
13
+ * members.
14
+ * - MetadataInspector: High level APIs to inspect a class and/or its members to
15
+ * get metadata applied by decorators.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ export * from './decorator-factory';
20
+ export * from './inspector';
21
+ export * from './reflect';
22
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,13 +1,30 @@
1
1
  "use strict";
2
- // Copyright IBM Corp. 2017,2018. All Rights Reserved.
2
+ // Copyright IBM Corp. 2017,2020. All Rights Reserved.
3
3
  // Node module: @loopback/metadata
4
4
  // This file is licensed under the MIT License.
5
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
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
- // DO NOT EDIT THIS FILE
11
- // Add any aditional (re)exports to src/index.ts instead.
12
- __export(require("./src"));
7
+ const tslib_1 = require("tslib");
8
+ /**
9
+ * A package with utilities to help developers implement
10
+ * {@link https://www.typescriptlang.org/docs/handbook/decorators.html |TypeScript decorators},
11
+ * define/merge metadata, and inspect metadata.
12
+ *
13
+ * @remarks
14
+ * Utilities:
15
+ *
16
+ * - Reflector: Wrapper of
17
+ * {@link https://github.com/rbuckton/reflect-metadata | reflect-metadata}.
18
+ * - Decorator factories: A set of factories for class/method/property/parameter
19
+ * decorators to apply metadata to a given class and its static or instance
20
+ * members.
21
+ * - MetadataInspector: High level APIs to inspect a class and/or its members to
22
+ * get metadata applied by decorators.
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ (0, tslib_1.__exportStar)(require("./decorator-factory"), exports);
27
+ (0, tslib_1.__exportStar)(require("./inspector"), exports);
28
+ (0, tslib_1.__exportStar)(require("./reflect"), exports);
29
+ (0, tslib_1.__exportStar)(require("./types"), exports);
13
30
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;;;;;;;;;GAiBG;AAEH,mEAAoC;AACpC,2DAA4B;AAC5B,yDAA0B;AAC1B,uDAAwB"}