@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.
- 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 -91
- 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 -4735
- 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
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { NamespacedReflect } from './reflect';
|
|
2
|
+
import { DecoratorType, DesignTimeMethodMetadata, MetadataKey, MetadataMap } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Options for inspection
|
|
5
|
+
*/
|
|
6
|
+
export interface InspectionOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Only inspect own metadata of a given target. The prototype chain will not
|
|
9
|
+
* be checked. The implementation uses `Reflect.getOwnMetadata()` if the flag
|
|
10
|
+
* is set to `true`. Otherwise, it uses `Reflect.getMetadata()`.
|
|
11
|
+
*
|
|
12
|
+
* The flag is `false` by default for `MetadataInspector`.
|
|
13
|
+
*/
|
|
14
|
+
ownMetadataOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Inspector for metadata applied by decorators
|
|
18
|
+
*/
|
|
19
|
+
export declare class MetadataInspector {
|
|
20
|
+
/**
|
|
21
|
+
* Expose Reflector, which is a wrapper of `Reflect` and it uses `loopback`
|
|
22
|
+
* as the namespace prefix for all metadata keys
|
|
23
|
+
*/
|
|
24
|
+
static readonly Reflector: NamespacedReflect;
|
|
25
|
+
/**
|
|
26
|
+
* Expose the reflector for TypeScript design-time metadata
|
|
27
|
+
*/
|
|
28
|
+
static readonly DesignTimeReflector: NamespacedReflect;
|
|
29
|
+
/**
|
|
30
|
+
* Get the metadata associated with the given key for a given class
|
|
31
|
+
* @param key - Metadata key
|
|
32
|
+
* @param target - Class that contains the metadata
|
|
33
|
+
* @param options - Options for inspection
|
|
34
|
+
*/
|
|
35
|
+
static getClassMetadata<T>(key: MetadataKey<T, ClassDecorator>, target: Function, options?: InspectionOptions): T | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Define metadata for the given target
|
|
38
|
+
* @param key - Metadata key
|
|
39
|
+
* @param value - Metadata value
|
|
40
|
+
* @param target - Target for the metadata
|
|
41
|
+
* @param member - Optional property or method name
|
|
42
|
+
*/
|
|
43
|
+
static defineMetadata<T>(key: MetadataKey<T, DecoratorType>, value: T, target: Object, member?: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get the metadata associated with the given key for all methods of the
|
|
46
|
+
* target class or prototype
|
|
47
|
+
* @param key - Metadata key
|
|
48
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
49
|
+
* @param options - Options for inspection
|
|
50
|
+
*/
|
|
51
|
+
static getAllMethodMetadata<T>(key: MetadataKey<T, MethodDecorator>, target: Object, options?: InspectionOptions): MetadataMap<T> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get the metadata associated with the given key for a given method of the
|
|
54
|
+
* target class or prototype
|
|
55
|
+
* @param key - Metadata key
|
|
56
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
57
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
58
|
+
* the constructor
|
|
59
|
+
* @param options - Options for inspection
|
|
60
|
+
*/
|
|
61
|
+
static getMethodMetadata<T>(key: MetadataKey<T, MethodDecorator>, target: Object, methodName?: string, options?: InspectionOptions): T | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Get the metadata associated with the given key for all properties of the
|
|
64
|
+
* target class or prototype
|
|
65
|
+
* @param key - Metadata key
|
|
66
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
67
|
+
* @param options - Options for inspection
|
|
68
|
+
*/
|
|
69
|
+
static getAllPropertyMetadata<T>(key: MetadataKey<T, PropertyDecorator>, target: Object, options?: InspectionOptions): MetadataMap<T> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get the metadata associated with the given key for a given property of the
|
|
72
|
+
* target class or prototype
|
|
73
|
+
* @param key - Metadata key
|
|
74
|
+
* @param target - Class for static properties or prototype for instance
|
|
75
|
+
* properties
|
|
76
|
+
* @param propertyName - Property name
|
|
77
|
+
* @param options - Options for inspection
|
|
78
|
+
*/
|
|
79
|
+
static getPropertyMetadata<T>(key: MetadataKey<T, PropertyDecorator>, target: Object, propertyName: string, options?: InspectionOptions): T | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Get the metadata associated with the given key for all parameters of a
|
|
82
|
+
* given method
|
|
83
|
+
* @param key - Metadata key
|
|
84
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
85
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
86
|
+
* the constructor
|
|
87
|
+
* @param options - Options for inspection
|
|
88
|
+
*/
|
|
89
|
+
static getAllParameterMetadata<T>(key: MetadataKey<T, ParameterDecorator>, target: Object, methodName?: string, options?: InspectionOptions): T[] | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Get the metadata associated with the given key for a parameter of a given
|
|
92
|
+
* method by index
|
|
93
|
+
* @param key - Metadata key
|
|
94
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
95
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
96
|
+
* the constructor
|
|
97
|
+
* @param index - Index of the parameter, starting with 0
|
|
98
|
+
* @param options - Options for inspection
|
|
99
|
+
*/
|
|
100
|
+
static getParameterMetadata<T>(key: MetadataKey<T, ParameterDecorator>, target: Object, methodName: string, index: number, options?: InspectionOptions): T | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Get TypeScript design time type for a property
|
|
103
|
+
* @param target - Class or prototype
|
|
104
|
+
* @param propertyName - Property name
|
|
105
|
+
* @returns Design time metadata. The return value is `undefined` when:
|
|
106
|
+
* - The property has type `undefined`, `null`
|
|
107
|
+
* - The TypeScript project has not enabled the compiler option `emitDecoratorMetadata`.
|
|
108
|
+
* - The code is written in vanilla JavaScript.
|
|
109
|
+
*/
|
|
110
|
+
static getDesignTypeForProperty(target: Object, propertyName: string): Function | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Get TypeScript design time type for a method.
|
|
113
|
+
* @param target - Class or prototype
|
|
114
|
+
* @param methodName - Method name
|
|
115
|
+
* @returns Design time metadata. The return value is `undefined`
|
|
116
|
+
* in projects that do not enable `emitDecoratorMetadata`
|
|
117
|
+
* in TypeScript compiler options or are written in vanilla JavaScript.
|
|
118
|
+
*/
|
|
119
|
+
static getDesignTypeForMethod(target: Object, methodName: string): DesignTimeMethodMetadata | undefined;
|
|
120
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataInspector = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Copyright IBM Corp. 2017,2019. All Rights Reserved.
|
|
6
|
+
// Node module: @loopback/metadata
|
|
7
|
+
// This file is licensed under the MIT License.
|
|
8
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
9
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
10
|
+
const decorator_factory_1 = require("./decorator-factory");
|
|
11
|
+
const reflect_1 = require("./reflect");
|
|
12
|
+
const debug = (0, debug_1.default)('loopback:metadata:inspector');
|
|
13
|
+
/**
|
|
14
|
+
* TypeScript reflector without a namespace. The TypeScript compiler can be
|
|
15
|
+
* configured to add design time metadata.
|
|
16
|
+
*
|
|
17
|
+
* See https://www.typescriptlang.org/docs/handbook/decorators.html
|
|
18
|
+
*/
|
|
19
|
+
const TSReflector = new reflect_1.NamespacedReflect();
|
|
20
|
+
/**
|
|
21
|
+
* Inspector for metadata applied by decorators
|
|
22
|
+
*/
|
|
23
|
+
class MetadataInspector {
|
|
24
|
+
/**
|
|
25
|
+
* Get the metadata associated with the given key for a given class
|
|
26
|
+
* @param key - Metadata key
|
|
27
|
+
* @param target - Class that contains the metadata
|
|
28
|
+
* @param options - Options for inspection
|
|
29
|
+
*/
|
|
30
|
+
static getClassMetadata(key, target, options) {
|
|
31
|
+
return (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
32
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
33
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Define metadata for the given target
|
|
37
|
+
* @param key - Metadata key
|
|
38
|
+
* @param value - Metadata value
|
|
39
|
+
* @param target - Target for the metadata
|
|
40
|
+
* @param member - Optional property or method name
|
|
41
|
+
*/
|
|
42
|
+
static defineMetadata(key, value, target, member) {
|
|
43
|
+
reflect_1.Reflector.defineMetadata(key.toString(), value, target, member);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the metadata associated with the given key for all methods of the
|
|
47
|
+
* target class or prototype
|
|
48
|
+
* @param key - Metadata key
|
|
49
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
50
|
+
* @param options - Options for inspection
|
|
51
|
+
*/
|
|
52
|
+
static getAllMethodMetadata(key, target, options) {
|
|
53
|
+
return (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
54
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
55
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the metadata associated with the given key for a given method of the
|
|
59
|
+
* target class or prototype
|
|
60
|
+
* @param key - Metadata key
|
|
61
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
62
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
63
|
+
* the constructor
|
|
64
|
+
* @param options - Options for inspection
|
|
65
|
+
*/
|
|
66
|
+
static getMethodMetadata(key, target, methodName, options) {
|
|
67
|
+
methodName = methodName !== null && methodName !== void 0 ? methodName : '';
|
|
68
|
+
const meta = (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
69
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
70
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
71
|
+
return meta === null || meta === void 0 ? void 0 : meta[methodName];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the metadata associated with the given key for all properties of the
|
|
75
|
+
* target class or prototype
|
|
76
|
+
* @param key - Metadata key
|
|
77
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
78
|
+
* @param options - Options for inspection
|
|
79
|
+
*/
|
|
80
|
+
static getAllPropertyMetadata(key, target, options) {
|
|
81
|
+
return (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
82
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
83
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the metadata associated with the given key for a given property of the
|
|
87
|
+
* target class or prototype
|
|
88
|
+
* @param key - Metadata key
|
|
89
|
+
* @param target - Class for static properties or prototype for instance
|
|
90
|
+
* properties
|
|
91
|
+
* @param propertyName - Property name
|
|
92
|
+
* @param options - Options for inspection
|
|
93
|
+
*/
|
|
94
|
+
static getPropertyMetadata(key, target, propertyName, options) {
|
|
95
|
+
const meta = (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
96
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
97
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
98
|
+
return meta === null || meta === void 0 ? void 0 : meta[propertyName];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the metadata associated with the given key for all parameters of a
|
|
102
|
+
* given method
|
|
103
|
+
* @param key - Metadata key
|
|
104
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
105
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
106
|
+
* the constructor
|
|
107
|
+
* @param options - Options for inspection
|
|
108
|
+
*/
|
|
109
|
+
static getAllParameterMetadata(key, target, methodName, options) {
|
|
110
|
+
methodName = methodName !== null && methodName !== void 0 ? methodName : '';
|
|
111
|
+
const meta = (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
112
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
113
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
114
|
+
return meta === null || meta === void 0 ? void 0 : meta[methodName];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get the metadata associated with the given key for a parameter of a given
|
|
118
|
+
* method by index
|
|
119
|
+
* @param key - Metadata key
|
|
120
|
+
* @param target - Class for static methods or prototype for instance methods
|
|
121
|
+
* @param methodName - Method name. If not present, default to '' to use
|
|
122
|
+
* the constructor
|
|
123
|
+
* @param index - Index of the parameter, starting with 0
|
|
124
|
+
* @param options - Options for inspection
|
|
125
|
+
*/
|
|
126
|
+
static getParameterMetadata(key, target, methodName, index, options) {
|
|
127
|
+
methodName = methodName || '';
|
|
128
|
+
const meta = (options === null || options === void 0 ? void 0 : options.ownMetadataOnly)
|
|
129
|
+
? reflect_1.Reflector.getOwnMetadata(key.toString(), target)
|
|
130
|
+
: reflect_1.Reflector.getMetadata(key.toString(), target);
|
|
131
|
+
const params = meta === null || meta === void 0 ? void 0 : meta[methodName];
|
|
132
|
+
return params === null || params === void 0 ? void 0 : params[index];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get TypeScript design time type for a property
|
|
136
|
+
* @param target - Class or prototype
|
|
137
|
+
* @param propertyName - Property name
|
|
138
|
+
* @returns Design time metadata. The return value is `undefined` when:
|
|
139
|
+
* - The property has type `undefined`, `null`
|
|
140
|
+
* - The TypeScript project has not enabled the compiler option `emitDecoratorMetadata`.
|
|
141
|
+
* - The code is written in vanilla JavaScript.
|
|
142
|
+
*/
|
|
143
|
+
static getDesignTypeForProperty(target, propertyName) {
|
|
144
|
+
return TSReflector.getMetadata('design:type', target, propertyName);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get TypeScript design time type for a method.
|
|
148
|
+
* @param target - Class or prototype
|
|
149
|
+
* @param methodName - Method name
|
|
150
|
+
* @returns Design time metadata. The return value is `undefined`
|
|
151
|
+
* in projects that do not enable `emitDecoratorMetadata`
|
|
152
|
+
* in TypeScript compiler options or are written in vanilla JavaScript.
|
|
153
|
+
*/
|
|
154
|
+
static getDesignTypeForMethod(target, methodName) {
|
|
155
|
+
const type = TSReflector.getMetadata('design:type', target, methodName);
|
|
156
|
+
const parameterTypes = TSReflector.getMetadata('design:paramtypes', target, methodName);
|
|
157
|
+
const returnType = TSReflector.getMetadata('design:returntype', target, methodName);
|
|
158
|
+
if (type === undefined &&
|
|
159
|
+
parameterTypes === undefined &&
|
|
160
|
+
returnType === undefined) {
|
|
161
|
+
/* istanbul ignore next */
|
|
162
|
+
if (debug.enabled) {
|
|
163
|
+
const targetName = decorator_factory_1.DecoratorFactory.getTargetName(target, methodName);
|
|
164
|
+
debug('No design-time type metadata found while inspecting %s. ' +
|
|
165
|
+
'Did you forget to enable TypeScript compiler option `emitDecoratorMetadata`?', targetName);
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
type,
|
|
171
|
+
parameterTypes,
|
|
172
|
+
returnType,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.MetadataInspector = MetadataInspector;
|
|
177
|
+
/**
|
|
178
|
+
* Expose Reflector, which is a wrapper of `Reflect` and it uses `loopback`
|
|
179
|
+
* as the namespace prefix for all metadata keys
|
|
180
|
+
*/
|
|
181
|
+
MetadataInspector.Reflector = reflect_1.Reflector;
|
|
182
|
+
/**
|
|
183
|
+
* Expose the reflector for TypeScript design-time metadata
|
|
184
|
+
*/
|
|
185
|
+
MetadataInspector.DesignTimeReflector = TSReflector;
|
|
186
|
+
//# sourceMappingURL=inspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../src/inspector.ts"],"names":[],"mappings":";;;;AAAA,sDAAsD;AACtD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;AAChE,+DAAgC;AAChC,2DAAqD;AACrD,uCAAuD;AAQvD,MAAM,KAAK,GAAG,IAAA,eAAW,EAAC,6BAA6B,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,GAAG,IAAI,2BAAiB,EAAE,CAAC;AAgB5C;;GAEG;AACH,MAAa,iBAAiB;IAW5B;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CACrB,GAAmC,EACnC,MAAgB,EAChB,OAA2B;QAE3B,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe;YAC7B,CAAC,CAAC,mBAAS,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC;YAClD,CAAC,CAAC,mBAAS,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CACnB,GAAkC,EAClC,KAAQ,EACR,MAAc,EACd,MAAe;QAEf,mBAAS,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CACzB,GAAoC,EACpC,MAAc,EACd,OAA2B;QAE3B,OAAO,CAAA,OA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I,CAAG,UAAU,CAAC,CAAC;QAClC,OAAO,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAK,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,wBAAwB,CAC7B,MAAc,EACd,YAAoB;QAEpB,OAAO,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,sBAAsB,CAC3B,MAAc,EACd,UAAkB;QAElB,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,cAAc,GAAG,WAAW,CAAC,WAAW,CAC5C,mBAAmB,EACnB,MAAM,EACN,UAAU,CACX,CAAC;QACF,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,mBAAmB,EACnB,MAAM,EACN,UAAU,CACX,CAAC;QAEF,IACE,IAAI,KAAK,SAAS;YAClB,cAAc,KAAK,SAAS;YAC5B,UAAU,KAAK,SAAS,EACxB;YACA,0BAA0B;YAC1B,IAAI,KAAK,CAAC,OAAO,EAAE;gBACjB,MAAM,UAAU,GAAG,oCAAgB,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;gBACtE,KAAK,CACH,0DAA0D;oBACxD,8EAA8E,EAChF,UAAU,CACX,CAAC;aACH;YAED,OAAO,SAAS,CAAC;SAClB;QAED,OAAO;YACL,IAAI;YACJ,cAAc;YACd,UAAU;SACX,CAAC;IACJ,CAAC;;AAtOH,8CAuOC;AAtOC;;;GAGG;AACa,2BAAS,GAAG,mBAAS,CAAC;AACtC;;GAEG;AACa,qCAAmB,GAAG,WAAW,CAAC"}
|
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
export declare class NamespacedReflect {
|
|
3
|
-
private namespace
|
|
3
|
+
private namespace?;
|
|
4
4
|
/**
|
|
5
|
-
* @param namespace
|
|
5
|
+
* @param namespace - Namespace to bind this reflect context
|
|
6
6
|
*/
|
|
7
7
|
constructor(namespace?: string | undefined);
|
|
8
|
-
private getMetadataKey
|
|
8
|
+
private getMetadataKey;
|
|
9
9
|
/**
|
|
10
10
|
* define metadata for a target class or it's property/method
|
|
11
11
|
*/
|
|
12
|
-
defineMetadata(metadataKey: string, metadataValue: any, target: Object, propertyKey?: string
|
|
12
|
+
defineMetadata(metadataKey: string, metadataValue: any, target: Object, propertyKey?: string): void;
|
|
13
13
|
/**
|
|
14
14
|
* lookup metadata from a target object and its prototype chain
|
|
15
15
|
*/
|
|
16
|
-
getMetadata(metadataKey: string, target: Object, propertyKey?: string
|
|
16
|
+
getMetadata(metadataKey: string, target: Object, propertyKey?: string): any;
|
|
17
17
|
/**
|
|
18
18
|
* get own metadata for a target object or it's property/method
|
|
19
19
|
*/
|
|
20
|
-
getOwnMetadata(metadataKey: string, target: Object, propertyKey?: string
|
|
20
|
+
getOwnMetadata(metadataKey: string, target: Object, propertyKey?: string): any;
|
|
21
21
|
/**
|
|
22
22
|
* Check if the target has corresponding metadata
|
|
23
|
-
* @param metadataKey Key
|
|
24
|
-
* @param target Target
|
|
25
|
-
* @param propertyKey Optional property key
|
|
23
|
+
* @param metadataKey - Key
|
|
24
|
+
* @param target - Target
|
|
25
|
+
* @param propertyKey - Optional property key
|
|
26
26
|
*/
|
|
27
|
-
hasMetadata(metadataKey: string, target: Object, propertyKey?: string
|
|
28
|
-
hasOwnMetadata(metadataKey: string, target: Object, propertyKey?: string
|
|
29
|
-
deleteMetadata(metadataKey: string, target: Object, propertyKey?: string
|
|
30
|
-
getMetadataKeys(target: Object, propertyKey?: string
|
|
31
|
-
getOwnMetadataKeys(target: Object, propertyKey?: string
|
|
32
|
-
decorate(decorators: (PropertyDecorator | MethodDecorator)[]
|
|
27
|
+
hasMetadata(metadataKey: string, target: Object, propertyKey?: string): boolean;
|
|
28
|
+
hasOwnMetadata(metadataKey: string, target: Object, propertyKey?: string): boolean;
|
|
29
|
+
deleteMetadata(metadataKey: string, target: Object, propertyKey?: string): boolean;
|
|
30
|
+
getMetadataKeys(target: Object, propertyKey?: string): string[];
|
|
31
|
+
getOwnMetadataKeys(target: Object, propertyKey?: string): string[];
|
|
32
|
+
decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, targetKey?: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | Function;
|
|
33
|
+
decorate(decorators: ClassDecorator[], target: Object): PropertyDescriptor | Function;
|
|
33
34
|
metadata(metadataKey: string, metadataValue: any): {
|
|
34
35
|
(target: Function): void;
|
|
35
36
|
(target: Object, targetKey: string | symbol): void;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
2
|
+
// Copyright IBM Corp. 2017,2019. 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.Reflector = exports.NamespacedReflect = void 0;
|
|
7
8
|
require("reflect-metadata");
|
|
8
|
-
/*
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
10
|
/*
|
|
10
11
|
* namespaced wrapper to handle reflect api
|
|
11
12
|
*/
|
|
12
13
|
class NamespacedReflect {
|
|
13
14
|
/**
|
|
14
|
-
* @param namespace
|
|
15
|
+
* @param namespace - Namespace to bind this reflect context
|
|
15
16
|
*/
|
|
16
17
|
constructor(namespace) {
|
|
17
18
|
this.namespace = namespace;
|
|
@@ -54,9 +55,9 @@ class NamespacedReflect {
|
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Check if the target has corresponding metadata
|
|
57
|
-
* @param metadataKey Key
|
|
58
|
-
* @param target Target
|
|
59
|
-
* @param propertyKey Optional property key
|
|
58
|
+
* @param metadataKey - Key
|
|
59
|
+
* @param target - Target
|
|
60
|
+
* @param propertyKey - Optional property key
|
|
60
61
|
*/
|
|
61
62
|
hasMetadata(metadataKey, target, propertyKey) {
|
|
62
63
|
metadataKey = this.getMetadataKey(metadataKey);
|
|
@@ -131,13 +132,11 @@ class NamespacedReflect {
|
|
|
131
132
|
return Reflect.decorate(decorators, target);
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
|
-
/* tslint:disable-next-line:no-any */
|
|
135
135
|
metadata(metadataKey, metadataValue) {
|
|
136
136
|
metadataKey = this.getMetadataKey(metadataKey);
|
|
137
137
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
exports.NamespacedReflect = NamespacedReflect;
|
|
141
|
-
/* tslint:disable-next-line:variable-name */
|
|
142
141
|
exports.Reflector = new NamespacedReflect('loopback');
|
|
143
142
|
//# sourceMappingURL=reflect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflect.js","sourceRoot":"","sources":["../src/reflect.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,4BAA0B;AAE1B,uDAAuD;AAEvD;;GAEG;AACH,MAAa,iBAAiB;IAC5B;;OAEG;IACH,YAAoB,SAAkB;QAAlB,cAAS,GAAT,SAAS,CAAS;IAAG,CAAC;IAElC,cAAc,CAAC,WAAmB;QACxC,qDAAqD;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAC3E,CAAC;IAED;;OAEG;IACH,cAAc,CACZ,WAAmB,EACnB,aAAkB,EAClB,MAAc,EACd,WAAoB;QAEpB,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,WAAW,EAAE;YAC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
1
|
+
/**
|
|
2
|
+
* Decorator function types
|
|
3
|
+
*/
|
|
4
|
+
export declare type DecoratorType = ClassDecorator | PropertyDecorator | MethodDecorator | ParameterDecorator;
|
|
5
|
+
/**
|
|
6
|
+
* A strongly-typed metadata accessor via reflection
|
|
7
|
+
* @typeParam T - Type of the metadata value
|
|
8
|
+
* @typeParam D - Type of the decorator
|
|
9
|
+
*/
|
|
10
|
+
export declare class MetadataAccessor<T, D extends DecoratorType = DecoratorType> {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
private constructor();
|
|
13
|
+
toString(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a strongly-typed metadata accessor
|
|
16
|
+
* @param key - The metadata key
|
|
17
|
+
* @typeParam V - Type of the metadata value
|
|
18
|
+
* @typeParam DT - Type of the decorator
|
|
19
|
+
*/
|
|
20
|
+
static create<V, DT extends DecoratorType>(key: string): MetadataAccessor<V, DT>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Key for metadata access via reflection
|
|
24
|
+
* @typeParam T - Type of the metadata value
|
|
25
|
+
* @typeParam D - Type of the decorator
|
|
26
|
+
*/
|
|
27
|
+
export declare type MetadataKey<T, D extends DecoratorType> = MetadataAccessor<T, D> | string;
|
|
28
|
+
/**
|
|
29
|
+
* An object mapping keys to corresponding metadata
|
|
30
|
+
*/
|
|
31
|
+
export interface MetadataMap<T> {
|
|
32
|
+
[propertyOrMethodName: string]: T;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Design time metadata for a method.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* class MyController
|
|
40
|
+
* {
|
|
41
|
+
* myMethod(x: string, y: number, z: MyClass): boolean {
|
|
42
|
+
* // ...
|
|
43
|
+
* return true;
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* The `myMethod` above has design-time metadata as follows:
|
|
49
|
+
* ```ts
|
|
50
|
+
* {
|
|
51
|
+
* type: Function,
|
|
52
|
+
* parameterTypes: [String, Number, MyClass],
|
|
53
|
+
* returnType: Boolean
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export interface DesignTimeMethodMetadata {
|
|
58
|
+
/**
|
|
59
|
+
* Type of the method itself. It is `Function` for methods, `undefined` for the constructor.
|
|
60
|
+
*/
|
|
61
|
+
type: Function | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* An array of parameter types.
|
|
64
|
+
*/
|
|
65
|
+
parameterTypes: Function[];
|
|
66
|
+
/**
|
|
67
|
+
* Return type, may be `undefined` (e.g. for constructors).
|
|
68
|
+
*/
|
|
69
|
+
returnType: Function | undefined;
|
|
70
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2018,2019. 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
|
+
exports.MetadataAccessor = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A strongly-typed metadata accessor via reflection
|
|
10
|
+
* @typeParam T - Type of the metadata value
|
|
11
|
+
* @typeParam D - Type of the decorator
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
class MetadataAccessor {
|
|
15
|
+
constructor(key) {
|
|
16
|
+
this.key = key;
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
return this.key;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a strongly-typed metadata accessor
|
|
23
|
+
* @param key - The metadata key
|
|
24
|
+
* @typeParam V - Type of the metadata value
|
|
25
|
+
* @typeParam DT - Type of the decorator
|
|
26
|
+
*/
|
|
27
|
+
static create(key) {
|
|
28
|
+
return new MetadataAccessor(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.MetadataAccessor = MetadataAccessor;
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;;;AAWhE;;;;GAIG;AACH,6DAA6D;AAC7D,MAAa,gBAAgB;IAC3B,YAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEnD,QAAQ;QACN,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAA8B,GAAW;QACpD,OAAO,IAAI,gBAAgB,CAAQ,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF;AAhBD,4CAgBC"}
|
package/package.json
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/metadata",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"description": "Utilities to help developers implement TypeScript decorators, define/merge metadata, and inspect metadata",
|
|
4
|
+
"version": "4.1.0",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"LoopBack",
|
|
7
|
+
"Decorators",
|
|
8
|
+
"Reflect"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"author": "IBM Corp.",
|
|
14
|
+
"copyright.owner": "IBM Corp.",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/loopbackio/loopback-next.git",
|
|
18
|
+
"directory": "packages/metadata"
|
|
19
|
+
},
|
|
5
20
|
"engines": {
|
|
6
|
-
"node": "
|
|
21
|
+
"node": "12 || 14 || 16 || 17"
|
|
7
22
|
},
|
|
8
23
|
"scripts": {
|
|
9
|
-
"acceptance": "lb-mocha \"
|
|
10
|
-
"build": "
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"clean": "lb-clean loopback-metadata*.tgz dist dist6 package api-docs",
|
|
16
|
-
"prepublishOnly": "npm run build && npm run build:apidocs",
|
|
17
|
-
"pretest": "npm run build:current",
|
|
18
|
-
"test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"",
|
|
19
|
-
"unit": "lb-mocha \"DIST/test/unit/**/*.js\"",
|
|
24
|
+
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
|
|
25
|
+
"build": "lb-tsc",
|
|
26
|
+
"clean": "lb-clean loopback-metadata*.tgz dist *.tsbuildinfo package",
|
|
27
|
+
"pretest": "npm run build",
|
|
28
|
+
"test": "lb-mocha \"dist/__tests__/**/*.js\"",
|
|
29
|
+
"unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"",
|
|
20
30
|
"verify": "npm pack && tar xf loopback-metadata*.tgz && tree package && npm run clean"
|
|
21
31
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"debug": "^3.1.0",
|
|
27
|
-
"lodash": "^4.17.4",
|
|
28
|
-
"reflect-metadata": "^0.1.10"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@loopback/build": "^4.0.0-alpha.12",
|
|
32
|
-
"@loopback/testlab": "^4.0.0-alpha.22",
|
|
33
|
-
"@types/debug": "^0.0.30",
|
|
34
|
-
"@types/lodash": "^4.14.96"
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
35
34
|
},
|
|
36
|
-
"keywords": [
|
|
37
|
-
"LoopBack",
|
|
38
|
-
"Decorators",
|
|
39
|
-
"Reflect"
|
|
40
|
-
],
|
|
41
35
|
"files": [
|
|
42
36
|
"README.md",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"dist6/src",
|
|
47
|
-
"api-docs",
|
|
48
|
-
"src"
|
|
37
|
+
"dist",
|
|
38
|
+
"src",
|
|
39
|
+
"!*/__tests__"
|
|
49
40
|
],
|
|
50
|
-
"
|
|
51
|
-
"
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"debug": "^4.3.3",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"reflect-metadata": "^0.1.13",
|
|
45
|
+
"tslib": "^2.3.1"
|
|
52
46
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@loopback/build": "^8.1.0",
|
|
49
|
+
"@loopback/eslint-config": "^12.0.2",
|
|
50
|
+
"@loopback/testlab": "^4.1.0",
|
|
51
|
+
"@types/debug": "^4.1.7",
|
|
52
|
+
"@types/lodash": "^4.14.178",
|
|
53
|
+
"@types/node": "^12.20.43"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "e16818ccb01edc0269ef6c45b022c5f1b67f852c"
|
|
57
56
|
}
|