@carno.js/core 0.2.3
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 +674 -0
- package/dist/Carno.d.ts +65 -0
- package/dist/Carno.js +307 -0
- package/dist/Cheetah.d.ts +65 -0
- package/dist/Cheetah.js +307 -0
- package/dist/cache/bento-cache.driver.d.ts +13 -0
- package/dist/cache/bento-cache.driver.js +55 -0
- package/dist/cache/cache.service.d.ts +8 -0
- package/dist/cache/cache.service.js +6 -0
- package/dist/commons/decorators/Injectable.decorator.d.ts +20 -0
- package/dist/commons/decorators/Injectable.decorator.js +33 -0
- package/dist/commons/decorators/controller.decorator.d.ts +8 -0
- package/dist/commons/decorators/controller.decorator.js +22 -0
- package/dist/commons/decorators/http.decorators.d.ts +13 -0
- package/dist/commons/decorators/http.decorators.js +44 -0
- package/dist/commons/decorators/index.d.ts +5 -0
- package/dist/commons/decorators/index.js +21 -0
- package/dist/commons/decorators/inject.decorator.d.ts +1 -0
- package/dist/commons/decorators/inject.decorator.js +5 -0
- package/dist/commons/decorators/middleware.decorator.d.ts +2 -0
- package/dist/commons/decorators/middleware.decorator.js +30 -0
- package/dist/commons/decorators/service.decorator.d.ts +2 -0
- package/dist/commons/decorators/service.decorator.js +7 -0
- package/dist/commons/http-code.enum.d.ts +50 -0
- package/dist/commons/http-code.enum.js +54 -0
- package/dist/commons/index.d.ts +3 -0
- package/dist/commons/index.js +19 -0
- package/dist/commons/registries/ProviderControl.d.ts +77 -0
- package/dist/commons/registries/ProviderControl.js +112 -0
- package/dist/commons/registries/ProviderRegistry.d.ts +7 -0
- package/dist/commons/registries/ProviderRegistry.js +20 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +10 -0
- package/dist/container/ContainerConfiguration.d.ts +45 -0
- package/dist/container/ContainerConfiguration.js +121 -0
- package/dist/container/DependencyResolver.d.ts +18 -0
- package/dist/container/DependencyResolver.js +81 -0
- package/dist/container/InjectorService.d.ts +34 -0
- package/dist/container/InjectorService.js +157 -0
- package/dist/container/MethodInvoker.d.ts +17 -0
- package/dist/container/MethodInvoker.js +69 -0
- package/dist/container/RouteResolver.d.ts +27 -0
- package/dist/container/RouteResolver.js +173 -0
- package/dist/container/container.d.ts +41 -0
- package/dist/container/container.js +71 -0
- package/dist/container/createContainer.d.ts +3 -0
- package/dist/container/createContainer.js +12 -0
- package/dist/container/createInjector.d.ts +2 -0
- package/dist/container/createInjector.js +7 -0
- package/dist/container/index.d.ts +6 -0
- package/dist/container/index.js +22 -0
- package/dist/container/middleware.resolver.d.ts +9 -0
- package/dist/container/middleware.resolver.js +35 -0
- package/dist/default-routes-carno.d.ts +3 -0
- package/dist/default-routes-carno.js +29 -0
- package/dist/default-routes-cheetah.d.ts +3 -0
- package/dist/default-routes-cheetah.js +29 -0
- package/dist/domain/CarnoClosure.d.ts +1 -0
- package/dist/domain/CarnoClosure.js +2 -0
- package/dist/domain/CarnoMiddleware.d.ts +5 -0
- package/dist/domain/CarnoMiddleware.js +2 -0
- package/dist/domain/CheetahClosure.d.ts +1 -0
- package/dist/domain/CheetahClosure.js +2 -0
- package/dist/domain/CheetahMiddleware.d.ts +5 -0
- package/dist/domain/CheetahMiddleware.js +2 -0
- package/dist/domain/Context.d.ts +26 -0
- package/dist/domain/Context.js +107 -0
- package/dist/domain/LocalsContainer.d.ts +4 -0
- package/dist/domain/LocalsContainer.js +10 -0
- package/dist/domain/Metadata.d.ts +449 -0
- package/dist/domain/Metadata.js +511 -0
- package/dist/domain/cors-config.d.ts +12 -0
- package/dist/domain/cors-config.js +18 -0
- package/dist/domain/http-method.d.ts +7 -0
- package/dist/domain/http-method.js +11 -0
- package/dist/domain/index.d.ts +10 -0
- package/dist/domain/index.js +26 -0
- package/dist/domain/provider-scope.d.ts +5 -0
- package/dist/domain/provider-scope.js +9 -0
- package/dist/domain/provider-type.d.ts +6 -0
- package/dist/domain/provider-type.js +10 -0
- package/dist/domain/provider.d.ts +37 -0
- package/dist/domain/provider.js +70 -0
- package/dist/events/hooks.decorator.d.ts +3 -0
- package/dist/events/hooks.decorator.js +29 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +18 -0
- package/dist/events/on-event.d.ts +13 -0
- package/dist/events/on-event.js +11 -0
- package/dist/exceptions/HttpException.d.ts +9 -0
- package/dist/exceptions/HttpException.js +26 -0
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +17 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +32 -0
- package/dist/route/Matcher.d.ts +16 -0
- package/dist/route/Matcher.js +48 -0
- package/dist/route/RouteExecutor.d.ts +13 -0
- package/dist/route/RouteExecutor.js +70 -0
- package/dist/route/memoirist.d.ts +25 -0
- package/dist/route/memoirist.js +250 -0
- package/dist/services/logger.service.d.ts +23 -0
- package/dist/services/logger.service.js +54 -0
- package/dist/services/request-logger.service.d.ts +15 -0
- package/dist/services/request-logger.service.js +50 -0
- package/dist/testing/core-testing.d.ts +24 -0
- package/dist/testing/core-testing.js +98 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +17 -0
- package/dist/utils/ancestorOf.d.ts +2 -0
- package/dist/utils/ancestorOf.js +10 -0
- package/dist/utils/ancestorsOf.d.ts +6 -0
- package/dist/utils/ancestorsOf.js +20 -0
- package/dist/utils/classOf.d.ts +13 -0
- package/dist/utils/classOf.js +21 -0
- package/dist/utils/cleanObject.d.ts +6 -0
- package/dist/utils/cleanObject.js +22 -0
- package/dist/utils/constructorOf.d.ts +11 -0
- package/dist/utils/constructorOf.js +18 -0
- package/dist/utils/createInstance.d.ts +1 -0
- package/dist/utils/createInstance.js +7 -0
- package/dist/utils/decoratorTypeOf.d.ts +11 -0
- package/dist/utils/decoratorTypeOf.js +32 -0
- package/dist/utils/deepClone.d.ts +6 -0
- package/dist/utils/deepClone.js +63 -0
- package/dist/utils/deepMerge.d.ts +9 -0
- package/dist/utils/deepMerge.js +62 -0
- package/dist/utils/descriptorOf.d.ts +8 -0
- package/dist/utils/descriptorOf.js +16 -0
- package/dist/utils/getClassOrSymbol.d.ts +1 -0
- package/dist/utils/getClassOrSymbol.js +8 -0
- package/dist/utils/getConstructorArgNames.d.ts +1 -0
- package/dist/utils/getConstructorArgNames.js +12 -0
- package/dist/utils/getMethodArgTypes.d.ts +1 -0
- package/dist/utils/getMethodArgTypes.js +9 -0
- package/dist/utils/getValue.d.ts +32 -0
- package/dist/utils/getValue.js +47 -0
- package/dist/utils/hasJsonMethod.d.ts +1 -0
- package/dist/utils/hasJsonMethod.js +6 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/isArray.d.ts +13 -0
- package/dist/utils/isArray.js +21 -0
- package/dist/utils/isArrowFn.d.ts +1 -0
- package/dist/utils/isArrowFn.js +7 -0
- package/dist/utils/isBoolean.d.ts +7 -0
- package/dist/utils/isBoolean.js +15 -0
- package/dist/utils/isBuffer.d.ts +7 -0
- package/dist/utils/isBuffer.js +19 -0
- package/dist/utils/isClass.d.ts +1 -0
- package/dist/utils/isClass.js +26 -0
- package/dist/utils/isClassValidator.d.ts +6 -0
- package/dist/utils/isClassValidator.js +13 -0
- package/dist/utils/isCollection.d.ts +6 -0
- package/dist/utils/isCollection.js +20 -0
- package/dist/utils/isDate.d.ts +6 -0
- package/dist/utils/isDate.js +11 -0
- package/dist/utils/isEmpty.d.ts +6 -0
- package/dist/utils/isEmpty.js +12 -0
- package/dist/utils/isFunction.d.ts +1 -0
- package/dist/utils/isFunction.js +6 -0
- package/dist/utils/isInheritedFrom.d.ts +1 -0
- package/dist/utils/isInheritedFrom.js +24 -0
- package/dist/utils/isMomentObject.d.ts +1 -0
- package/dist/utils/isMomentObject.js +6 -0
- package/dist/utils/isMongooseObject.d.ts +2 -0
- package/dist/utils/isMongooseObject.js +11 -0
- package/dist/utils/isNil.d.ts +1 -0
- package/dist/utils/isNil.js +6 -0
- package/dist/utils/isNumber.d.ts +7 -0
- package/dist/utils/isNumber.js +15 -0
- package/dist/utils/isObject.d.ts +1 -0
- package/dist/utils/isObject.js +6 -0
- package/dist/utils/isObservable.d.ts +1 -0
- package/dist/utils/isObservable.js +6 -0
- package/dist/utils/isPlainObject.d.ts +7 -0
- package/dist/utils/isPlainObject.js +16 -0
- package/dist/utils/isPrimitive.d.ts +14 -0
- package/dist/utils/isPrimitive.js +28 -0
- package/dist/utils/isPrimitiveType.d.ts +1 -0
- package/dist/utils/isPrimitiveType.js +11 -0
- package/dist/utils/isPromise.d.ts +7 -0
- package/dist/utils/isPromise.js +14 -0
- package/dist/utils/isProtectedKey.d.ts +5 -0
- package/dist/utils/isProtectedKey.js +10 -0
- package/dist/utils/isRegExp.d.ts +1 -0
- package/dist/utils/isRegExp.js +6 -0
- package/dist/utils/isRequestScope.d.ts +11 -0
- package/dist/utils/isRequestScope.js +23 -0
- package/dist/utils/isSerializable.d.ts +1 -0
- package/dist/utils/isSerializable.js +11 -0
- package/dist/utils/isStream.d.ts +1 -0
- package/dist/utils/isStream.js +6 -0
- package/dist/utils/isString.d.ts +6 -0
- package/dist/utils/isString.js +14 -0
- package/dist/utils/isSymbol.d.ts +6 -0
- package/dist/utils/isSymbol.js +14 -0
- package/dist/utils/methodsOf.d.ts +9 -0
- package/dist/utils/methodsOf.js +24 -0
- package/dist/utils/nameOf.d.ts +14 -0
- package/dist/utils/nameOf.js +31 -0
- package/dist/utils/objectKeys.d.ts +1 -0
- package/dist/utils/objectKeys.js +7 -0
- package/dist/utils/primitiveOf.d.ts +1 -0
- package/dist/utils/primitiveOf.js +18 -0
- package/dist/utils/prototypeOf.d.ts +6 -0
- package/dist/utils/prototypeOf.js +12 -0
- package/dist/utils/setValue.d.ts +1 -0
- package/dist/utils/setValue.js +32 -0
- package/dist/utils/toMap.d.ts +3 -0
- package/dist/utils/toMap.js +34 -0
- package/dist/utils/toStringConstructor.d.ts +1 -0
- package/dist/utils/toStringConstructor.js +10 -0
- package/package.json +55 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Metadata = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const classOf_1 = require("../utils/classOf");
|
|
7
|
+
/**
|
|
8
|
+
* Metadata key
|
|
9
|
+
* @private
|
|
10
|
+
* @type {string}
|
|
11
|
+
*/
|
|
12
|
+
const DESIGN_PARAM_TYPES = "design:paramtypes";
|
|
13
|
+
/**
|
|
14
|
+
* Metadata key
|
|
15
|
+
* @private
|
|
16
|
+
* @type {string}
|
|
17
|
+
*/
|
|
18
|
+
const DESIGN_TYPE = "design:type";
|
|
19
|
+
/**
|
|
20
|
+
* Metadata key
|
|
21
|
+
* @private
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
const DESIGN_RETURN_TYPE = "design:returntype";
|
|
25
|
+
/**
|
|
26
|
+
* Properties collections
|
|
27
|
+
* @private
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
const PROPERTIES = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* @stable
|
|
33
|
+
*/
|
|
34
|
+
class Metadata {
|
|
35
|
+
/**
|
|
36
|
+
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
37
|
+
* @param key A key used to store and retrieve metadata.
|
|
38
|
+
* @param target The target object on which the metadata is defined.
|
|
39
|
+
* @param propertyKey The property key for the target.
|
|
40
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* ```typescript
|
|
44
|
+
* class Example {
|
|
45
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
46
|
+
* // static staticProperty;
|
|
47
|
+
* // property;
|
|
48
|
+
*
|
|
49
|
+
* static staticMethod(p) { }
|
|
50
|
+
* method(p) { }
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // constructor
|
|
54
|
+
* result = Metadata.get("custom:annotation", Example);
|
|
55
|
+
*
|
|
56
|
+
* // property (on constructor)
|
|
57
|
+
* result = Metadata.get("custom:annotation", Example, "staticProperty");
|
|
58
|
+
*
|
|
59
|
+
* // property (on prototype)
|
|
60
|
+
* result = Metadata.get("custom:annotation", Example.prototype, "property");
|
|
61
|
+
*
|
|
62
|
+
* // method (on constructor)
|
|
63
|
+
* result = Metadata.get("custom:annotation", Example, "staticMethod");
|
|
64
|
+
*
|
|
65
|
+
* // method (on prototype)
|
|
66
|
+
* result = Metadata.get("custom:annotation", Example.prototype, "method");
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
static get(key, target, propertyKey) {
|
|
71
|
+
return Reflect.getMetadata(key, (0, classOf_1.classOf)(target), propertyKey);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
75
|
+
* @param key A key used to store and retrieve metadata.
|
|
76
|
+
* @param target The target object on which the metadata is defined.
|
|
77
|
+
* @param propertyKey The property key for the target.
|
|
78
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
79
|
+
* @example
|
|
80
|
+
*
|
|
81
|
+
* ```typescript
|
|
82
|
+
* class Example {
|
|
83
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
84
|
+
* // static staticProperty;
|
|
85
|
+
* // property;
|
|
86
|
+
*
|
|
87
|
+
* static staticMethod(p) { }
|
|
88
|
+
* method(p) { }
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* // constructor
|
|
92
|
+
* result = Metadata.getOwn("custom:annotation", Example);
|
|
93
|
+
*
|
|
94
|
+
* // property (on constructor)
|
|
95
|
+
* result = Metadata.getOwn("custom:annotation", Example, "staticProperty");
|
|
96
|
+
*
|
|
97
|
+
* // property (on prototype)
|
|
98
|
+
* result = Metadata.getOwn("custom:annotation", Example.prototype, "property");
|
|
99
|
+
*
|
|
100
|
+
* // method (on constructor)
|
|
101
|
+
* result = Metadata.getOwn("custom:annotation", Example, "staticMethod");
|
|
102
|
+
*
|
|
103
|
+
* // method (on prototype)
|
|
104
|
+
* result = Metadata.getOwn("custom:annotation", Example.prototype, "method");
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
static getOwn(key, target, propertyKey) {
|
|
109
|
+
return Reflect.getOwnMetadata(key, (0, classOf_1.classOf)(target), propertyKey);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.
|
|
113
|
+
* @param target The target object on which the metadata is defined.
|
|
114
|
+
* @param propertyKey The property key for the target.
|
|
115
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
116
|
+
* @example
|
|
117
|
+
*
|
|
118
|
+
* ```typescript
|
|
119
|
+
* class Example {
|
|
120
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
121
|
+
* // static staticProperty;
|
|
122
|
+
* // property;
|
|
123
|
+
*
|
|
124
|
+
* static staticMethod(p) { }
|
|
125
|
+
* method(p) { }
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* // on contructor
|
|
129
|
+
* result = Metadata.getType(Example);
|
|
130
|
+
*
|
|
131
|
+
* // property (on constructor)
|
|
132
|
+
* result = Metadata.getType(Example, "staticProperty");
|
|
133
|
+
*
|
|
134
|
+
* // method (on constructor)
|
|
135
|
+
* result = Metadata.getType(Example, "staticMethod");
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
static getType(target, propertyKey) {
|
|
140
|
+
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.
|
|
144
|
+
* @param target The target object on which the metadata is defined.
|
|
145
|
+
* @param propertyKey The property key for the target.
|
|
146
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* ```typescript
|
|
150
|
+
* class Example {
|
|
151
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
152
|
+
* // static staticProperty;
|
|
153
|
+
* // property;
|
|
154
|
+
*
|
|
155
|
+
* static staticMethod(p) { }
|
|
156
|
+
* method(p) { }
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* // on contructor
|
|
160
|
+
* result = Metadata.getOwnType(Example);
|
|
161
|
+
*
|
|
162
|
+
* // property (on constructor)
|
|
163
|
+
* result = Metadata.getOwnType(Example, "staticProperty");
|
|
164
|
+
*
|
|
165
|
+
* // method (on constructor)
|
|
166
|
+
* result = Metadata.getOwnType(Example, "staticMethod");
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
static getOwnType(target, propertyKey) {
|
|
171
|
+
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.
|
|
175
|
+
* @param target The target object on which the metadata is defined.
|
|
176
|
+
* @param propertyKey The property key for the target.
|
|
177
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
178
|
+
* @example
|
|
179
|
+
*
|
|
180
|
+
* ```typescript
|
|
181
|
+
* class Example {
|
|
182
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
183
|
+
* // static staticProperty;
|
|
184
|
+
* // property;
|
|
185
|
+
*
|
|
186
|
+
* static staticMethod(p) { }
|
|
187
|
+
* method(p) { }
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* // on contructor
|
|
191
|
+
* result = Metadata.getReturnType(Example);
|
|
192
|
+
*
|
|
193
|
+
* // property (on constructor)
|
|
194
|
+
* result = Metadata.getReturnType(Example, "staticProperty");
|
|
195
|
+
*
|
|
196
|
+
* // method (on constructor)
|
|
197
|
+
* result = Metadata.getReturnType(Example, "staticMethod");
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
static getReturnType(target, propertyKey) {
|
|
202
|
+
return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.
|
|
206
|
+
* @param target The target object on which the metadata is defined.
|
|
207
|
+
* @param propertyKey The property key for the target.
|
|
208
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
209
|
+
* @example
|
|
210
|
+
*
|
|
211
|
+
* ```typescript
|
|
212
|
+
* class Example {
|
|
213
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
214
|
+
* // static staticProperty;
|
|
215
|
+
* // property;
|
|
216
|
+
*
|
|
217
|
+
* static staticMethod(p) { }
|
|
218
|
+
* method(p) { }
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* // on contructor
|
|
222
|
+
* result = Metadata.getOwnReturnType(Example);
|
|
223
|
+
*
|
|
224
|
+
* // property (on constructor)
|
|
225
|
+
* result = Metadata.getOwnReturnType(Example, "staticProperty");
|
|
226
|
+
*
|
|
227
|
+
* // method (on constructor)
|
|
228
|
+
* result = Metadata.getOwnReturnType(Example, "staticMethod");
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
*/
|
|
232
|
+
static getOwnReturnType(target, propertyKey) {
|
|
233
|
+
return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
|
237
|
+
* @param key A key used to store and retrieve metadata.
|
|
238
|
+
* @param target The target object on which the metadata is defined.
|
|
239
|
+
* @param propertyKey The property key for the target.
|
|
240
|
+
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
|
241
|
+
* @example
|
|
242
|
+
*
|
|
243
|
+
* ```typescript
|
|
244
|
+
* class Example {
|
|
245
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
246
|
+
* // static staticProperty;
|
|
247
|
+
* // property;
|
|
248
|
+
*
|
|
249
|
+
* static staticMethod(p) { }
|
|
250
|
+
* method(p) { }
|
|
251
|
+
* }
|
|
252
|
+
*
|
|
253
|
+
* // constructor
|
|
254
|
+
* result = Metadata.has("custom:annotation", Example);
|
|
255
|
+
*
|
|
256
|
+
* // property (on constructor)
|
|
257
|
+
* result = Metadata.has("custom:annotation", Example, "staticProperty");
|
|
258
|
+
*
|
|
259
|
+
* // property (on prototype)
|
|
260
|
+
* result = Metadata.has("custom:annotation", Example.prototype, "property");
|
|
261
|
+
*
|
|
262
|
+
* // method (on constructor)
|
|
263
|
+
* result = Metadata.has("custom:annotation", Example, "staticMethod");
|
|
264
|
+
*
|
|
265
|
+
* // method (on prototype)
|
|
266
|
+
* result = Metadata.has("custom:annotation", Example.prototype, "method");
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
270
|
+
static has(key, target, propertyKey) {
|
|
271
|
+
try {
|
|
272
|
+
return Reflect.hasMetadata(key, (0, classOf_1.classOf)(target), propertyKey);
|
|
273
|
+
}
|
|
274
|
+
catch (er) { }
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
|
279
|
+
* @param key A key used to store and retrieve metadata.
|
|
280
|
+
* @param target The target object on which the metadata is defined.
|
|
281
|
+
* @param propertyKey The property key for the target.
|
|
282
|
+
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
|
283
|
+
* @example
|
|
284
|
+
*
|
|
285
|
+
* ```typescript
|
|
286
|
+
* class Example {
|
|
287
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
288
|
+
* // static staticProperty;
|
|
289
|
+
* // property;
|
|
290
|
+
*
|
|
291
|
+
* static staticMethod(p) { }
|
|
292
|
+
* method(p) { }
|
|
293
|
+
* }
|
|
294
|
+
*
|
|
295
|
+
* // constructor
|
|
296
|
+
* result = Metadata.has("custom:annotation", Example);
|
|
297
|
+
*
|
|
298
|
+
* // property (on constructor)
|
|
299
|
+
* result = Metadata.hasOwn("custom:annotation", Example, "staticProperty");
|
|
300
|
+
*
|
|
301
|
+
* // property (on prototype)
|
|
302
|
+
* result = Metadata.hasOwn("custom:annotation", Example.prototype, "property");
|
|
303
|
+
*
|
|
304
|
+
* // method (on constructor)
|
|
305
|
+
* result = Metadata.hasOwn("custom:annotation", Example, "staticMethod");
|
|
306
|
+
*
|
|
307
|
+
* // method (on prototype)
|
|
308
|
+
* result = Metadata.hasOwn("custom:annotation", Example.prototype, "method");
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
*/
|
|
312
|
+
static hasOwn(key, target, propertyKey) {
|
|
313
|
+
return Reflect.hasOwnMetadata(key, (0, classOf_1.classOf)(target), propertyKey);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Deletes the metadata entry from the target object with the provided key.
|
|
317
|
+
* @param key A key used to store and retrieve metadata.
|
|
318
|
+
* @param target The target object on which the metadata is defined.
|
|
319
|
+
* @param propertyKey The property key for the target.
|
|
320
|
+
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
|
321
|
+
* @example
|
|
322
|
+
*
|
|
323
|
+
* ```typescript
|
|
324
|
+
* class Example {
|
|
325
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
326
|
+
* // static staticProperty;
|
|
327
|
+
* // property;
|
|
328
|
+
*
|
|
329
|
+
* static staticMethod(p) { }
|
|
330
|
+
* method(p) { }
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
333
|
+
* // constructor
|
|
334
|
+
* result = Metadata.delete("custom:annotation", Example);
|
|
335
|
+
*
|
|
336
|
+
* // property (on constructor)
|
|
337
|
+
* result = Metadata.delete("custom:annotation", Example, "staticProperty");
|
|
338
|
+
*
|
|
339
|
+
* // property (on prototype)
|
|
340
|
+
* result = Metadata.delete("custom:annotation", Example.prototype, "property");
|
|
341
|
+
*
|
|
342
|
+
* // method (on constructor)
|
|
343
|
+
* result = Metadata.delete("custom:annotation", Example, "staticMethod");
|
|
344
|
+
*
|
|
345
|
+
* // method (on prototype)
|
|
346
|
+
* result = Metadata.delete("custom:annotation", Example.prototype, "method");
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
*/
|
|
350
|
+
static delete(key, target, propertyKey) {
|
|
351
|
+
return Reflect.deleteMetadata(key, (0, classOf_1.classOf)(target), propertyKey);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
355
|
+
* @param target The target object on which the metadata is defined.
|
|
356
|
+
* @param propertyKey The property key for the target.
|
|
357
|
+
* @param value A value that contains attached metadata.
|
|
358
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
359
|
+
* @example
|
|
360
|
+
*
|
|
361
|
+
* ```typescript
|
|
362
|
+
* class Example {
|
|
363
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
364
|
+
* // static staticProperty;
|
|
365
|
+
* // property;
|
|
366
|
+
*
|
|
367
|
+
* static staticMethod(p) { }
|
|
368
|
+
* method(p) { }
|
|
369
|
+
* }
|
|
370
|
+
*
|
|
371
|
+
* // on contructor
|
|
372
|
+
* result = Metadata.setParamTypes(Example, undefined, [Object]);
|
|
373
|
+
*
|
|
374
|
+
* // property (on constructor)
|
|
375
|
+
* result = Metadata.setParamTypes(Example, "staticProperty", [Object]);
|
|
376
|
+
*
|
|
377
|
+
* // property (on prototype)
|
|
378
|
+
* result = Metadata.setParamTypes(Example.prototype, "property", [Object]);
|
|
379
|
+
*
|
|
380
|
+
* // method (on constructor)
|
|
381
|
+
* result = Metadata.setParamTypes(Example, "staticMethod", [Object]);
|
|
382
|
+
*
|
|
383
|
+
* // method (on prototype)
|
|
384
|
+
* result = Metadata.setParamTypes(Example.prototype, "method", [Object]);
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
*/
|
|
388
|
+
static setParamTypes(target, propertyKey, value) {
|
|
389
|
+
return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Define a unique metadata entry on the target.
|
|
393
|
+
* @param key A key used to store and retrieve metadata.
|
|
394
|
+
* @param value A value that contains attached metadata.
|
|
395
|
+
* @param target The target object on which to define metadata.
|
|
396
|
+
* @param propertyKey The property key for the target.
|
|
397
|
+
* @example
|
|
398
|
+
*
|
|
399
|
+
* ```typescript
|
|
400
|
+
* class Example {
|
|
401
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
402
|
+
* // static staticProperty;
|
|
403
|
+
* // property;
|
|
404
|
+
*
|
|
405
|
+
* static staticMethod(p) { }
|
|
406
|
+
* method(p) { }
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* // constructor
|
|
410
|
+
* Reflect.defineMetadata("custom:annotation", options, Example);
|
|
411
|
+
*
|
|
412
|
+
* // property (on constructor)
|
|
413
|
+
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticProperty");
|
|
414
|
+
*
|
|
415
|
+
* // property (on prototype)
|
|
416
|
+
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "property");
|
|
417
|
+
*
|
|
418
|
+
* // method (on constructor)
|
|
419
|
+
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticMethod");
|
|
420
|
+
*
|
|
421
|
+
* // method (on prototype)
|
|
422
|
+
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "method");
|
|
423
|
+
*
|
|
424
|
+
* // decorator factory as metadata-producing annotation.
|
|
425
|
+
* function MyAnnotation(options): PropertyDecorator {
|
|
426
|
+
* return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
*/
|
|
431
|
+
static set(key, value, target, propertyKey) {
|
|
432
|
+
const targets = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];
|
|
433
|
+
const classConstructor = (0, classOf_1.classOf)(target);
|
|
434
|
+
if (targets.indexOf(classConstructor) === -1) {
|
|
435
|
+
targets.push(classConstructor);
|
|
436
|
+
PROPERTIES.set(key, targets);
|
|
437
|
+
}
|
|
438
|
+
Reflect.defineMetadata(key, value, (0, classOf_1.classOf)(target), propertyKey);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
442
|
+
* @param targetPrototype
|
|
443
|
+
* @param propertyKey The property key for the target.
|
|
444
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
445
|
+
* @example
|
|
446
|
+
*
|
|
447
|
+
* ```typescript
|
|
448
|
+
* class Example {
|
|
449
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
450
|
+
* // static staticProperty;
|
|
451
|
+
* // property;
|
|
452
|
+
*
|
|
453
|
+
* static staticMethod(p) { }
|
|
454
|
+
* method(p) { }
|
|
455
|
+
* }
|
|
456
|
+
*
|
|
457
|
+
* // on contructor
|
|
458
|
+
* result = Metadata.getParamTypes(Example.prototype);
|
|
459
|
+
*
|
|
460
|
+
* // property (on constructor)
|
|
461
|
+
* result = Metadata.getParamTypes(Example.prototype, "staticProperty");
|
|
462
|
+
*
|
|
463
|
+
* // method (on constructor)
|
|
464
|
+
* result = Metadata.getParamTypes(Example.prototype, "staticMethod");
|
|
465
|
+
* ```
|
|
466
|
+
*
|
|
467
|
+
*/
|
|
468
|
+
static getParamTypes(targetPrototype, propertyKey) {
|
|
469
|
+
return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey) || [];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
473
|
+
* @param target The target object on which the metadata is defined.
|
|
474
|
+
* @param propertyKey The property key for the target.
|
|
475
|
+
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
476
|
+
* @example
|
|
477
|
+
*
|
|
478
|
+
* ```typescript
|
|
479
|
+
* class Example {
|
|
480
|
+
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
481
|
+
* // static staticProperty;
|
|
482
|
+
* // property;
|
|
483
|
+
*
|
|
484
|
+
* static staticMethod(p) { }
|
|
485
|
+
* method(p) { }
|
|
486
|
+
* }
|
|
487
|
+
*
|
|
488
|
+
* // on contructor
|
|
489
|
+
* result = Metadata.getParamTypes(Example);
|
|
490
|
+
*
|
|
491
|
+
* // property (on constructor)
|
|
492
|
+
* result = Metadata.getParamTypes(Example, "staticProperty");
|
|
493
|
+
*
|
|
494
|
+
* // method (on constructor)
|
|
495
|
+
* result = Metadata.getParamTypes(Example, "staticMethod");
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
498
|
+
*/
|
|
499
|
+
static getOwnParamTypes(target, propertyKey) {
|
|
500
|
+
return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey) || [];
|
|
501
|
+
}
|
|
502
|
+
static getParamDecoratorFunc(target, propertyKey) {
|
|
503
|
+
return Reflect.getMetadata(constants_1.ROUTE_PARAM, target.constructor, propertyKey);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
exports.Metadata = Metadata;
|
|
507
|
+
/**
|
|
508
|
+
* Get all metadata for a metadataKey.
|
|
509
|
+
* @param metadataKey
|
|
510
|
+
*/
|
|
511
|
+
Metadata.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type CorsOrigin = string | string[] | RegExp | ((origin: string) => boolean);
|
|
2
|
+
export interface CorsConfig {
|
|
3
|
+
origins: CorsOrigin;
|
|
4
|
+
methods?: string[];
|
|
5
|
+
allowedHeaders?: string[];
|
|
6
|
+
exposedHeaders?: string[];
|
|
7
|
+
credentials?: boolean;
|
|
8
|
+
maxAge?: number;
|
|
9
|
+
preflightContinue?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_CORS_METHODS: string[];
|
|
12
|
+
export declare const DEFAULT_CORS_ALLOWED_HEADERS: string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_CORS_ALLOWED_HEADERS = exports.DEFAULT_CORS_METHODS = void 0;
|
|
4
|
+
exports.DEFAULT_CORS_METHODS = [
|
|
5
|
+
"GET",
|
|
6
|
+
"HEAD",
|
|
7
|
+
"PUT",
|
|
8
|
+
"PATCH",
|
|
9
|
+
"POST",
|
|
10
|
+
"DELETE",
|
|
11
|
+
];
|
|
12
|
+
exports.DEFAULT_CORS_ALLOWED_HEADERS = [
|
|
13
|
+
"Content-Type",
|
|
14
|
+
"Authorization",
|
|
15
|
+
"X-Requested-With",
|
|
16
|
+
"Accept",
|
|
17
|
+
"Origin",
|
|
18
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpMethod = void 0;
|
|
4
|
+
var HttpMethod;
|
|
5
|
+
(function (HttpMethod) {
|
|
6
|
+
HttpMethod["GET"] = "get";
|
|
7
|
+
HttpMethod["PUT"] = "put";
|
|
8
|
+
HttpMethod["POST"] = "post";
|
|
9
|
+
HttpMethod["DELETE"] = "delete";
|
|
10
|
+
HttpMethod["PATCH"] = "patch";
|
|
11
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './provider-scope';
|
|
2
|
+
export * from './provider-type';
|
|
3
|
+
export * from './Context';
|
|
4
|
+
export * from './LocalsContainer';
|
|
5
|
+
export * from './Metadata';
|
|
6
|
+
export * from './provider';
|
|
7
|
+
export * from './CarnoMiddleware';
|
|
8
|
+
export * from './CarnoClosure';
|
|
9
|
+
export * from './http-method';
|
|
10
|
+
export * from './cors-config';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./provider-scope"), exports);
|
|
18
|
+
__exportStar(require("./provider-type"), exports);
|
|
19
|
+
__exportStar(require("./Context"), exports);
|
|
20
|
+
__exportStar(require("./LocalsContainer"), exports);
|
|
21
|
+
__exportStar(require("./Metadata"), exports);
|
|
22
|
+
__exportStar(require("./provider"), exports);
|
|
23
|
+
__exportStar(require("./CarnoMiddleware"), exports);
|
|
24
|
+
__exportStar(require("./CarnoClosure"), exports);
|
|
25
|
+
__exportStar(require("./http-method"), exports);
|
|
26
|
+
__exportStar(require("./cors-config"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderScope = void 0;
|
|
4
|
+
var ProviderScope;
|
|
5
|
+
(function (ProviderScope) {
|
|
6
|
+
ProviderScope["REQUEST"] = "request";
|
|
7
|
+
ProviderScope["INSTANCE"] = "instance";
|
|
8
|
+
ProviderScope["SINGLETON"] = "singleton";
|
|
9
|
+
})(ProviderScope || (exports.ProviderScope = ProviderScope = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderType = void 0;
|
|
4
|
+
var ProviderType;
|
|
5
|
+
(function (ProviderType) {
|
|
6
|
+
ProviderType["ROUTES"] = "routes";
|
|
7
|
+
ProviderType["SERVICE"] = "service";
|
|
8
|
+
ProviderType["PROVIDER"] = "provider";
|
|
9
|
+
ProviderType["CONTROLLER"] = "controller";
|
|
10
|
+
})(ProviderType || (exports.ProviderType = ProviderType = {}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ProviderType } from "./provider-type";
|
|
2
|
+
import { ProviderScope } from "./provider-scope";
|
|
3
|
+
import { TokenProvider, Type } from "../commons/registries/ProviderControl";
|
|
4
|
+
export type ProviderHookCallback<T = any> = (instance: T, ...args: any[]) => Promise<void> | void;
|
|
5
|
+
export declare class Provider {
|
|
6
|
+
/**
|
|
7
|
+
* Token group provider to retrieve all provider from the same type
|
|
8
|
+
*/
|
|
9
|
+
type: TokenProvider | ProviderType;
|
|
10
|
+
deps: TokenProvider[];
|
|
11
|
+
instance: any;
|
|
12
|
+
private _provide;
|
|
13
|
+
private _useClass;
|
|
14
|
+
private _useValue?;
|
|
15
|
+
hooks?: Record<string, ProviderHookCallback>;
|
|
16
|
+
path?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Scope used by the injector to build the provider.
|
|
19
|
+
*/
|
|
20
|
+
scope?: ProviderScope;
|
|
21
|
+
children?: any[];
|
|
22
|
+
parent?: Function;
|
|
23
|
+
constructor(token: TokenProvider, options?: Partial<Provider>);
|
|
24
|
+
get token(): any;
|
|
25
|
+
get useClass(): Type;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
28
|
+
* @param value
|
|
29
|
+
*/
|
|
30
|
+
set useClass(value: Type);
|
|
31
|
+
get useValue(): () => any;
|
|
32
|
+
set useValue(value: () => any);
|
|
33
|
+
get provide(): TokenProvider;
|
|
34
|
+
set provide(value: TokenProvider);
|
|
35
|
+
clone(): Provider;
|
|
36
|
+
isChild(): boolean;
|
|
37
|
+
}
|