@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 @@
|
|
|
1
|
+
export declare function createInstance(obj: any): any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInstance = createInstance;
|
|
4
|
+
const classOf_1 = require("./classOf");
|
|
5
|
+
function createInstance(obj) {
|
|
6
|
+
return obj ? ((0, classOf_1.classOf)(obj) !== Object ? Object.create(obj) : {}) : {};
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum DecoratorTypes {
|
|
2
|
+
PARAM = "parameter",
|
|
3
|
+
PARAM_CTOR = "parameter.constructor",
|
|
4
|
+
PARAM_STC = "parameter.static",
|
|
5
|
+
PROP = "property",
|
|
6
|
+
PROP_STC = "property.static",
|
|
7
|
+
METHOD = "method",
|
|
8
|
+
METHOD_STC = "method.static",
|
|
9
|
+
CLASS = "class"
|
|
10
|
+
}
|
|
11
|
+
export declare function decoratorTypeOf(args: any[]): DecoratorTypes;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecoratorTypes = void 0;
|
|
4
|
+
exports.decoratorTypeOf = decoratorTypeOf;
|
|
5
|
+
const classOf_1 = require("./classOf");
|
|
6
|
+
var DecoratorTypes;
|
|
7
|
+
(function (DecoratorTypes) {
|
|
8
|
+
DecoratorTypes["PARAM"] = "parameter";
|
|
9
|
+
DecoratorTypes["PARAM_CTOR"] = "parameter.constructor";
|
|
10
|
+
DecoratorTypes["PARAM_STC"] = "parameter.static";
|
|
11
|
+
DecoratorTypes["PROP"] = "property";
|
|
12
|
+
DecoratorTypes["PROP_STC"] = "property.static";
|
|
13
|
+
DecoratorTypes["METHOD"] = "method";
|
|
14
|
+
DecoratorTypes["METHOD_STC"] = "method.static";
|
|
15
|
+
DecoratorTypes["CLASS"] = "class";
|
|
16
|
+
})(DecoratorTypes || (exports.DecoratorTypes = DecoratorTypes = {}));
|
|
17
|
+
function decoratorTypeOf(args) {
|
|
18
|
+
const [target, propertyKey, descriptor] = args;
|
|
19
|
+
const staticType = (type) => {
|
|
20
|
+
return target !== (0, classOf_1.classOf)(target) ? type : `${type}.static`;
|
|
21
|
+
};
|
|
22
|
+
if (typeof descriptor === "number") {
|
|
23
|
+
return propertyKey ? staticType("parameter") : DecoratorTypes.PARAM_CTOR;
|
|
24
|
+
}
|
|
25
|
+
if (descriptor && descriptor.value) {
|
|
26
|
+
return staticType("method");
|
|
27
|
+
}
|
|
28
|
+
if ((propertyKey && descriptor === undefined) || descriptor) {
|
|
29
|
+
return staticType("property");
|
|
30
|
+
}
|
|
31
|
+
return DecoratorTypes.CLASS;
|
|
32
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepClone = deepClone;
|
|
4
|
+
const isArray_1 = require("./isArray");
|
|
5
|
+
const isDate_1 = require("./isDate");
|
|
6
|
+
const isFunction_1 = require("./isFunction");
|
|
7
|
+
const isNil_1 = require("./isNil");
|
|
8
|
+
const isPrimitive_1 = require("./isPrimitive");
|
|
9
|
+
const isSymbol_1 = require("./isSymbol");
|
|
10
|
+
const isBuffer_1 = require("./isBuffer");
|
|
11
|
+
const isRegExp_1 = require("./isRegExp");
|
|
12
|
+
const isBasicType = (source) => (0, isNil_1.isNil)(source) || (0, isPrimitive_1.isPrimitive)(source) || (0, isSymbol_1.isSymbol)(source) || (0, isFunction_1.isFunction)(source);
|
|
13
|
+
/**
|
|
14
|
+
* Return a cloned value
|
|
15
|
+
* @param source
|
|
16
|
+
* @param stack
|
|
17
|
+
*/
|
|
18
|
+
function deepClone(source, stack = new WeakMap()) {
|
|
19
|
+
let dest;
|
|
20
|
+
if (isBasicType(source)) {
|
|
21
|
+
return source;
|
|
22
|
+
}
|
|
23
|
+
if ((0, isBuffer_1.isBuffer)(source)) {
|
|
24
|
+
const copy = Buffer.alloc(source.length);
|
|
25
|
+
source.copy(copy);
|
|
26
|
+
return copy;
|
|
27
|
+
}
|
|
28
|
+
if ((0, isDate_1.isDate)(source)) {
|
|
29
|
+
return new Date(source);
|
|
30
|
+
}
|
|
31
|
+
if ((0, isRegExp_1.isRegExp)(source)) {
|
|
32
|
+
return new RegExp(source);
|
|
33
|
+
}
|
|
34
|
+
const stacked = stack.get(source);
|
|
35
|
+
if (stacked) {
|
|
36
|
+
// See issue #1619
|
|
37
|
+
return stacked;
|
|
38
|
+
}
|
|
39
|
+
if ((0, isArray_1.isArray)(source)) {
|
|
40
|
+
dest = [];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
dest = {};
|
|
44
|
+
stack.set(source, dest);
|
|
45
|
+
}
|
|
46
|
+
for (const key in source) {
|
|
47
|
+
// Use getOwnPropertyDescriptor instead of source[key] to prevent from triggering setter/getter.
|
|
48
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
49
|
+
if (descriptor) {
|
|
50
|
+
if (!(0, isFunction_1.isFunction)(descriptor.value)) {
|
|
51
|
+
dest[key] = deepClone(descriptor.value, stack);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
Object.defineProperty(dest, key, descriptor);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!(0, isArray_1.isArray)(source)) {
|
|
59
|
+
const prototype = Reflect.getPrototypeOf(source);
|
|
60
|
+
Reflect.setPrototypeOf(dest, prototype);
|
|
61
|
+
}
|
|
62
|
+
return dest;
|
|
63
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type DeepMergeReducerCB = (collection: any[], value: any, options?: DeepMergeOptions) => any;
|
|
2
|
+
export type DeepMergeComparatorCB = (item: any, ref: any) => boolean;
|
|
3
|
+
export interface DeepMergeOptions {
|
|
4
|
+
reducers?: Record<string, DeepMergeReducerCB>;
|
|
5
|
+
parentKey?: string;
|
|
6
|
+
cleanUndefinedProps?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function mergeReducerBuilder(cb: DeepMergeComparatorCB): (collection: any[], value: any, options: DeepMergeOptions) => any[];
|
|
9
|
+
export declare function deepMerge<T = any, C = any>(source: T & any, obj: C & any, options?: DeepMergeOptions): (T & C) | undefined | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeReducerBuilder = mergeReducerBuilder;
|
|
4
|
+
exports.deepMerge = deepMerge;
|
|
5
|
+
const createInstance_1 = require("./createInstance");
|
|
6
|
+
const isFunction_1 = require("./isFunction");
|
|
7
|
+
const isPrimitive_1 = require("./isPrimitive");
|
|
8
|
+
const isSymbol_1 = require("./isSymbol");
|
|
9
|
+
const objectKeys_1 = require("./objectKeys");
|
|
10
|
+
function mergeReducerBuilder(cb) {
|
|
11
|
+
return (collection, value, options) => {
|
|
12
|
+
const index = collection.findIndex((item) => cb(item, value));
|
|
13
|
+
if (index === -1) {
|
|
14
|
+
return [...collection, value];
|
|
15
|
+
}
|
|
16
|
+
collection[index] = deepMerge(collection[index], value, options);
|
|
17
|
+
return collection;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const defaultReducer = mergeReducerBuilder((a, b) => a === b);
|
|
21
|
+
function getReducer({ reducers, parentKey }) {
|
|
22
|
+
if (!reducers) {
|
|
23
|
+
return defaultReducer;
|
|
24
|
+
}
|
|
25
|
+
if (parentKey && reducers[parentKey]) {
|
|
26
|
+
return reducers[parentKey];
|
|
27
|
+
}
|
|
28
|
+
return reducers["default"] || defaultReducer;
|
|
29
|
+
}
|
|
30
|
+
function shouldReturnObj(obj, source) {
|
|
31
|
+
return (0, isPrimitive_1.isPrimitive)(obj) || (0, isSymbol_1.isSymbol)(obj) || (0, isFunction_1.isFunction)(obj) || source === undefined;
|
|
32
|
+
}
|
|
33
|
+
function shouldReturnSource(obj, source) {
|
|
34
|
+
return obj === undefined || obj === null || (obj === "" && source !== "");
|
|
35
|
+
}
|
|
36
|
+
function deepMerge(source, obj, options = {}) {
|
|
37
|
+
if (shouldReturnSource(obj, source)) {
|
|
38
|
+
return source;
|
|
39
|
+
}
|
|
40
|
+
if (shouldReturnObj(obj, source)) {
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(source)) {
|
|
44
|
+
const reducer = getReducer(options);
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return [].concat(obj).reduce((out, value) => reducer(out, value, options), [...source]);
|
|
47
|
+
}
|
|
48
|
+
return [...(0, objectKeys_1.objectKeys)(source), ...(0, objectKeys_1.objectKeys)(obj)].reduce((out, key) => {
|
|
49
|
+
const src = source && source[key];
|
|
50
|
+
const value = deepMerge(src, obj && obj[key], {
|
|
51
|
+
...options,
|
|
52
|
+
parentKey: key
|
|
53
|
+
});
|
|
54
|
+
if (options.cleanUndefinedProps && value === undefined) {
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
...out,
|
|
59
|
+
[key]: value
|
|
60
|
+
};
|
|
61
|
+
}, (0, createInstance_1.createInstance)(source));
|
|
62
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the descriptor for a given class and propertyKey
|
|
3
|
+
* @param target
|
|
4
|
+
* @param {string} propertyKey
|
|
5
|
+
* @returns {PropertyDescriptor}
|
|
6
|
+
*/
|
|
7
|
+
export declare function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor;
|
|
8
|
+
export declare function isMethodDescriptor(target: any, propertyKey: string | symbol): any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.descriptorOf = descriptorOf;
|
|
4
|
+
exports.isMethodDescriptor = isMethodDescriptor;
|
|
5
|
+
/**
|
|
6
|
+
* Return the descriptor for a given class and propertyKey
|
|
7
|
+
* @param target
|
|
8
|
+
* @param {string} propertyKey
|
|
9
|
+
* @returns {PropertyDescriptor}
|
|
10
|
+
*/
|
|
11
|
+
function descriptorOf(target, propertyKey) {
|
|
12
|
+
return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey);
|
|
13
|
+
}
|
|
14
|
+
function isMethodDescriptor(target, propertyKey) {
|
|
15
|
+
return descriptorOf(target, propertyKey)?.value;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getClassOrSymbol(target: any): any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getClassOrSymbol = getClassOrSymbol;
|
|
4
|
+
const classOf_1 = require("./classOf");
|
|
5
|
+
const isClass_1 = require("./isClass");
|
|
6
|
+
function getClassOrSymbol(target) {
|
|
7
|
+
return (0, isClass_1.isClass)(target) ? (0, classOf_1.classOf)(target) : target;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getConstructorArgNames(target: any): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConstructorArgNames = getConstructorArgNames;
|
|
4
|
+
const toStringConstructor_1 = require("./toStringConstructor");
|
|
5
|
+
function getConstructorArgNames(target) {
|
|
6
|
+
return (0, toStringConstructor_1.toStringConstructor)(target)
|
|
7
|
+
.split("constructor(")[1]
|
|
8
|
+
.split(")")[0]
|
|
9
|
+
.split(", ")
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.map((s) => s.trim());
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMethodArgTypes(target: any, methodName: string): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMethodArgTypes = getMethodArgTypes;
|
|
4
|
+
function getMethodArgTypes(target, methodName) {
|
|
5
|
+
if (!target[methodName]) {
|
|
6
|
+
throw new Error(`Method ${methodName} not found`);
|
|
7
|
+
}
|
|
8
|
+
return Reflect.getMetadata('design:paramtypes', target, methodName) || [];
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get value from scope
|
|
3
|
+
* @param {string} expression
|
|
4
|
+
* @param scope
|
|
5
|
+
* @returns {any}
|
|
6
|
+
*/
|
|
7
|
+
export declare function getValue<T = any>(scope: any, expression: string | undefined): T | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Get value from scope
|
|
10
|
+
* @param {string} expression
|
|
11
|
+
* @param scope
|
|
12
|
+
* @param defaultValue
|
|
13
|
+
* @param separator
|
|
14
|
+
* @returns {any}
|
|
15
|
+
*/
|
|
16
|
+
export declare function getValue<T = any>(scope: any, expression: string | undefined, defaultValue: T, separator?: string): T;
|
|
17
|
+
/**
|
|
18
|
+
* Get value from scope
|
|
19
|
+
* @param {string} expression
|
|
20
|
+
* @param scope
|
|
21
|
+
* @returns {any}
|
|
22
|
+
*/
|
|
23
|
+
export declare function getValue<T = any>(expression: string | undefined, scope: any): T | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get value from scope
|
|
26
|
+
* @param {string} expression
|
|
27
|
+
* @param scope
|
|
28
|
+
* @param defaultValue
|
|
29
|
+
* @param separator
|
|
30
|
+
* @returns {any}
|
|
31
|
+
*/
|
|
32
|
+
export declare function getValue<T = any>(expression: string | undefined, scope: any, defaultValue: T, separator?: string): T;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValue = getValue;
|
|
4
|
+
const isFunction_1 = require("./isFunction");
|
|
5
|
+
const isObject_1 = require("./isObject");
|
|
6
|
+
const isString_1 = require("./isString");
|
|
7
|
+
const mapOptions = (args) => {
|
|
8
|
+
const [expression, scope, defaultValue, separator = "."] = args;
|
|
9
|
+
if ((0, isObject_1.isObject)(scope) || (0, isString_1.isString)(expression)) {
|
|
10
|
+
return {
|
|
11
|
+
expression,
|
|
12
|
+
scope,
|
|
13
|
+
defaultValue,
|
|
14
|
+
separator
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
expression: scope,
|
|
19
|
+
scope: expression,
|
|
20
|
+
defaultValue,
|
|
21
|
+
separator
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
function getValue(...args) {
|
|
25
|
+
const options = mapOptions(args);
|
|
26
|
+
let scope = options.scope;
|
|
27
|
+
const { expression, defaultValue, separator } = options;
|
|
28
|
+
if (!expression) {
|
|
29
|
+
return scope;
|
|
30
|
+
}
|
|
31
|
+
if (!scope) {
|
|
32
|
+
return defaultValue;
|
|
33
|
+
}
|
|
34
|
+
const keys = expression.split(separator);
|
|
35
|
+
const getValue = (key) => {
|
|
36
|
+
if (scope) {
|
|
37
|
+
if (scope[key] !== undefined || ((0, isObject_1.isObject)(scope) && key in scope)) {
|
|
38
|
+
return scope[key];
|
|
39
|
+
}
|
|
40
|
+
if ((0, isFunction_1.isFunction)(scope.get)) {
|
|
41
|
+
return scope.get(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
while ((scope = getValue(keys.shift())) && keys.length) { }
|
|
46
|
+
return scope === undefined ? defaultValue : scope;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasJsonMethod(obj: any): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './isObject';
|
|
2
|
+
export * from './classOf';
|
|
3
|
+
export * from './isString';
|
|
4
|
+
export * from './isFunction';
|
|
5
|
+
export * from './getConstructorArgNames';
|
|
6
|
+
export * from './getValue';
|
|
7
|
+
export * from './isClassValidator';
|
|
8
|
+
export * from './getMethodArgTypes';
|
|
9
|
+
export * from './getClassOrSymbol';
|
|
10
|
+
export * from './isRequestScope';
|
|
11
|
+
export * from './nameOf';
|
|
12
|
+
export * from './isPrimitiveType';
|
|
13
|
+
export * from './setValue';
|
|
14
|
+
export * from './isClass';
|
|
15
|
+
export * from './methodsOf';
|
|
@@ -0,0 +1,31 @@
|
|
|
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("./isObject"), exports);
|
|
18
|
+
__exportStar(require("./classOf"), exports);
|
|
19
|
+
__exportStar(require("./isString"), exports);
|
|
20
|
+
__exportStar(require("./isFunction"), exports);
|
|
21
|
+
__exportStar(require("./getConstructorArgNames"), exports);
|
|
22
|
+
__exportStar(require("./getValue"), exports);
|
|
23
|
+
__exportStar(require("./isClassValidator"), exports);
|
|
24
|
+
__exportStar(require("./getMethodArgTypes"), exports);
|
|
25
|
+
__exportStar(require("./getClassOrSymbol"), exports);
|
|
26
|
+
__exportStar(require("./isRequestScope"), exports);
|
|
27
|
+
__exportStar(require("./nameOf"), exports);
|
|
28
|
+
__exportStar(require("./isPrimitiveType"), exports);
|
|
29
|
+
__exportStar(require("./setValue"), exports);
|
|
30
|
+
__exportStar(require("./isClass"), exports);
|
|
31
|
+
__exportStar(require("./methodsOf"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true if value is an array
|
|
3
|
+
* @param target
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export declare function isArray<T = any>(target: unknown): target is T[];
|
|
7
|
+
/**
|
|
8
|
+
* Return true if the clazz is an array.
|
|
9
|
+
* @param target
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
export declare function isArrayOrArrayClass<T = any>(target: unknown): target is T[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isArray = isArray;
|
|
4
|
+
exports.isArrayOrArrayClass = isArrayOrArrayClass;
|
|
5
|
+
/**
|
|
6
|
+
* Return true if value is an array
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isArray(target) {
|
|
11
|
+
return Array.isArray(target);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Return true if the clazz is an array.
|
|
15
|
+
* @param target
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
* @ignore
|
|
18
|
+
*/
|
|
19
|
+
function isArrayOrArrayClass(target) {
|
|
20
|
+
return target === Array || isArray(target);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isArrowFn(target: any): target is Function;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isArrowFn = isArrowFn;
|
|
4
|
+
const isFunction_1 = require("./isFunction");
|
|
5
|
+
function isArrowFn(target) {
|
|
6
|
+
return target && (0, isFunction_1.isFunction)(target) && !target.prototype;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBoolean = isBoolean;
|
|
4
|
+
exports.isBooleanOrBooleanClass = isBooleanOrBooleanClass;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isBoolean(target) {
|
|
11
|
+
return typeof target === "boolean" || target instanceof Boolean || target === Boolean;
|
|
12
|
+
}
|
|
13
|
+
function isBooleanOrBooleanClass(target) {
|
|
14
|
+
return typeof target === "boolean" || target instanceof Boolean || target === Boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBuffer = isBuffer;
|
|
4
|
+
exports.isUint8Array = isUint8Array;
|
|
5
|
+
/**
|
|
6
|
+
* Tests to see if the object is Buffer
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isBuffer(target) {
|
|
11
|
+
// is Class
|
|
12
|
+
if (target && "isBuffer" in target && typeof target.isBuffer === "function") {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return isUint8Array(target);
|
|
16
|
+
}
|
|
17
|
+
function isUint8Array(target) {
|
|
18
|
+
return !!(target && (target === Uint8Array || target instanceof Uint8Array));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isClass(target: any): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClass = isClass;
|
|
4
|
+
const isArray_1 = require("./isArray");
|
|
5
|
+
const isArrowFn_1 = require("./isArrowFn");
|
|
6
|
+
const isBuffer_1 = require("./isBuffer");
|
|
7
|
+
const isDate_1 = require("./isDate");
|
|
8
|
+
const isPlainObject_1 = require("./isPlainObject");
|
|
9
|
+
const isPrimitive_1 = require("./isPrimitive");
|
|
10
|
+
const isPromise_1 = require("./isPromise");
|
|
11
|
+
const isSymbol_1 = require("./isSymbol");
|
|
12
|
+
function isClass(target) {
|
|
13
|
+
if (!target) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if ((0, isArrowFn_1.isArrowFn)(target)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return !((0, isSymbol_1.isSymbol)(target) ||
|
|
20
|
+
(0, isPrimitive_1.isPrimitiveOrPrimitiveClass)(target) ||
|
|
21
|
+
(0, isPlainObject_1.isClassObject)(target) ||
|
|
22
|
+
(0, isDate_1.isDate)(target) ||
|
|
23
|
+
(0, isPromise_1.isPromise)(target) ||
|
|
24
|
+
(0, isArray_1.isArrayOrArrayClass)(target) ||
|
|
25
|
+
(0, isBuffer_1.isBuffer)(target));
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClassValidator = isClassValidator;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
/**
|
|
6
|
+
* Verifica se a classe possui implementação do class-validator ou class-transformer.
|
|
7
|
+
*
|
|
8
|
+
* @param token
|
|
9
|
+
*/
|
|
10
|
+
function isClassValidator(token) {
|
|
11
|
+
const validationMetadata = (0, class_validator_1.getMetadataStorage)();
|
|
12
|
+
return validationMetadata.getTargetValidationMetadatas(token, '', false, false, []).length > 0;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCollection = isCollection;
|
|
4
|
+
const isArray_1 = require("./isArray");
|
|
5
|
+
/**
|
|
6
|
+
* Return true if the target.
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isCollection(target) {
|
|
11
|
+
return ((0, isArray_1.isArrayOrArrayClass)(target) ||
|
|
12
|
+
target === Map ||
|
|
13
|
+
target instanceof Map ||
|
|
14
|
+
target === Set ||
|
|
15
|
+
target instanceof Set ||
|
|
16
|
+
target === WeakMap ||
|
|
17
|
+
target instanceof WeakMap ||
|
|
18
|
+
target === WeakSet ||
|
|
19
|
+
target instanceof WeakSet);
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDate = isDate;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param target
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
function isDate(target) {
|
|
10
|
+
return target === Date || (target instanceof Date && !isNaN(+target));
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmpty = isEmpty;
|
|
4
|
+
const isNil_1 = require("./isNil");
|
|
5
|
+
/**
|
|
6
|
+
* Return true if the value is an empty string, null or undefined.
|
|
7
|
+
* @param value
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isEmpty(value) {
|
|
11
|
+
return value === "" || (0, isNil_1.isNil)(value);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFunction(target: any): target is Function;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isInheritedFrom(target: any, from: any, deep?: number): boolean;
|