@tsed/core 7.0.0-alpha.2 → 7.0.0-beta.11
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/jest.config.js +14 -0
- package/lib/cjs/decorators/configurable.js +14 -0
- package/lib/cjs/decorators/configurable.js.map +1 -0
- package/lib/cjs/decorators/deprecated.js +44 -0
- package/lib/cjs/decorators/deprecated.js.map +1 -0
- package/lib/cjs/decorators/enumerable.js +14 -0
- package/lib/cjs/decorators/enumerable.js.map +1 -0
- package/lib/cjs/decorators/notConfigurable.js +9 -0
- package/lib/cjs/decorators/notConfigurable.js.map +1 -0
- package/lib/cjs/decorators/notEnumerable.js +9 -0
- package/lib/cjs/decorators/notEnumerable.js.map +1 -0
- package/lib/cjs/decorators/readOnly.js +9 -0
- package/lib/cjs/decorators/readOnly.js.map +1 -0
- package/lib/cjs/decorators/storeFn.js +22 -0
- package/lib/cjs/decorators/storeFn.js.map +1 -0
- package/lib/cjs/decorators/storeMerge.js +11 -0
- package/lib/cjs/decorators/storeMerge.js.map +1 -0
- package/lib/cjs/decorators/storeSet.js +11 -0
- package/lib/cjs/decorators/storeSet.js.map +1 -0
- package/lib/cjs/decorators/writable.js +14 -0
- package/lib/cjs/decorators/writable.js.map +1 -0
- package/lib/cjs/domain/AnyToPromise.js +148 -0
- package/lib/cjs/domain/AnyToPromise.js.map +1 -0
- package/lib/cjs/domain/DecoratorTypes.js +15 -0
- package/lib/cjs/domain/DecoratorTypes.js.map +1 -0
- package/lib/cjs/domain/Env.js +19 -0
- package/lib/cjs/domain/Env.js.map +1 -0
- package/lib/cjs/domain/Hooks.js +89 -0
- package/lib/cjs/domain/Hooks.js.map +1 -0
- package/lib/cjs/domain/Metadata.js +508 -0
- package/lib/cjs/domain/Metadata.js.map +1 -0
- package/lib/cjs/domain/Store.js +157 -0
- package/lib/cjs/domain/Store.js.map +1 -0
- package/lib/cjs/domain/Type.js +7 -0
- package/lib/cjs/domain/Type.js.map +1 -0
- package/lib/cjs/errors/UnsupportedDecoratorType.js +23 -0
- package/lib/cjs/errors/UnsupportedDecoratorType.js.map +1 -0
- package/lib/cjs/index.js +85 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/AnyDecorator.js +3 -0
- package/lib/cjs/interfaces/AnyDecorator.js.map +1 -0
- package/lib/cjs/interfaces/DecoratorParameters.js +3 -0
- package/lib/cjs/interfaces/DecoratorParameters.js.map +1 -0
- package/lib/cjs/interfaces/HashOf.js +3 -0
- package/lib/cjs/interfaces/HashOf.js.map +1 -0
- package/lib/cjs/interfaces/MetadataTypes.js +3 -0
- package/lib/cjs/interfaces/MetadataTypes.js.map +1 -0
- package/lib/cjs/interfaces/ValueOf.js +3 -0
- package/lib/cjs/interfaces/ValueOf.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/catchError.js +22 -0
- package/lib/cjs/utils/catchError.js.map +1 -0
- package/lib/cjs/utils/decorators/decorateMethodsOf.js +24 -0
- package/lib/cjs/utils/decorators/decorateMethodsOf.js.map +1 -0
- package/lib/cjs/utils/decorators/decoratorArgs.js +9 -0
- package/lib/cjs/utils/decorators/decoratorArgs.js.map +1 -0
- package/lib/cjs/utils/decorators/decoratorTypeOf.js +23 -0
- package/lib/cjs/utils/decorators/decoratorTypeOf.js.map +1 -0
- package/lib/cjs/utils/decorators/inheritedDescriptorOf.js +15 -0
- package/lib/cjs/utils/decorators/inheritedDescriptorOf.js.map +1 -0
- package/lib/cjs/utils/decorators/useDecorators.js +14 -0
- package/lib/cjs/utils/decorators/useDecorators.js.map +1 -0
- package/lib/cjs/utils/decorators/useMethodDecorators.js +15 -0
- package/lib/cjs/utils/decorators/useMethodDecorators.js.map +1 -0
- package/lib/cjs/utils/http/getHostInfoFromPort.js +21 -0
- package/lib/cjs/utils/http/getHostInfoFromPort.js.map +1 -0
- package/lib/cjs/utils/imports/importPackage.js +39 -0
- package/lib/cjs/utils/imports/importPackage.js.map +1 -0
- package/lib/cjs/utils/objects/ancestorOf.js +12 -0
- package/lib/cjs/utils/objects/ancestorOf.js.map +1 -0
- package/lib/cjs/utils/objects/ancestorsOf.js +22 -0
- package/lib/cjs/utils/objects/ancestorsOf.js.map +1 -0
- package/lib/cjs/utils/objects/classOf.js +23 -0
- package/lib/cjs/utils/objects/classOf.js.map +1 -0
- package/lib/cjs/utils/objects/cleanObject.js +24 -0
- package/lib/cjs/utils/objects/cleanObject.js.map +1 -0
- package/lib/cjs/utils/objects/constructorOf.js +20 -0
- package/lib/cjs/utils/objects/constructorOf.js.map +1 -0
- package/lib/cjs/utils/objects/createInstance.js +9 -0
- package/lib/cjs/utils/objects/createInstance.js.map +1 -0
- package/lib/cjs/utils/objects/deepClone.js +63 -0
- package/lib/cjs/utils/objects/deepClone.js.map +1 -0
- package/lib/cjs/utils/objects/deepMerge.js +63 -0
- package/lib/cjs/utils/objects/deepMerge.js.map +1 -0
- package/lib/cjs/utils/objects/descriptorOf.js +19 -0
- package/lib/cjs/utils/objects/descriptorOf.js.map +1 -0
- package/lib/cjs/utils/objects/getClassOrSymbol.js +10 -0
- package/lib/cjs/utils/objects/getClassOrSymbol.js.map +1 -0
- package/lib/cjs/utils/objects/getConstructorArgNames.js +14 -0
- package/lib/cjs/utils/objects/getConstructorArgNames.js.map +1 -0
- package/lib/cjs/utils/objects/getEnumerableKeys.js +20 -0
- package/lib/cjs/utils/objects/getEnumerableKeys.js.map +1 -0
- package/lib/cjs/utils/objects/getValue.js +49 -0
- package/lib/cjs/utils/objects/getValue.js.map +1 -0
- package/lib/cjs/utils/objects/isArray.js +23 -0
- package/lib/cjs/utils/objects/isArray.js.map +1 -0
- package/lib/cjs/utils/objects/isArrowFn.js +9 -0
- package/lib/cjs/utils/objects/isArrowFn.js.map +1 -0
- package/lib/cjs/utils/objects/isBoolean.js +17 -0
- package/lib/cjs/utils/objects/isBoolean.js.map +1 -0
- package/lib/cjs/utils/objects/isBuffer.js +13 -0
- package/lib/cjs/utils/objects/isBuffer.js.map +1 -0
- package/lib/cjs/utils/objects/isClass.js +28 -0
- package/lib/cjs/utils/objects/isClass.js.map +1 -0
- package/lib/cjs/utils/objects/isCollection.js +22 -0
- package/lib/cjs/utils/objects/isCollection.js.map +1 -0
- package/lib/cjs/utils/objects/isDate.js +13 -0
- package/lib/cjs/utils/objects/isDate.js.map +1 -0
- package/lib/cjs/utils/objects/isEmpty.js +14 -0
- package/lib/cjs/utils/objects/isEmpty.js.map +1 -0
- package/lib/cjs/utils/objects/isEnumerable.js +22 -0
- package/lib/cjs/utils/objects/isEnumerable.js.map +1 -0
- package/lib/cjs/utils/objects/isFunction.js +8 -0
- package/lib/cjs/utils/objects/isFunction.js.map +1 -0
- package/lib/cjs/utils/objects/isInheritedFrom.js +26 -0
- package/lib/cjs/utils/objects/isInheritedFrom.js.map +1 -0
- package/lib/cjs/utils/objects/isNil.js +8 -0
- package/lib/cjs/utils/objects/isNil.js.map +1 -0
- package/lib/cjs/utils/objects/isNumber.js +17 -0
- package/lib/cjs/utils/objects/isNumber.js.map +1 -0
- package/lib/cjs/utils/objects/isObject.js +8 -0
- package/lib/cjs/utils/objects/isObject.js.map +1 -0
- package/lib/cjs/utils/objects/isObservable.js +8 -0
- package/lib/cjs/utils/objects/isObservable.js.map +1 -0
- package/lib/cjs/utils/objects/isPlainObject.js +18 -0
- package/lib/cjs/utils/objects/isPlainObject.js.map +1 -0
- package/lib/cjs/utils/objects/isPrimitive.js +30 -0
- package/lib/cjs/utils/objects/isPrimitive.js.map +1 -0
- package/lib/cjs/utils/objects/isPromise.js +16 -0
- package/lib/cjs/utils/objects/isPromise.js.map +1 -0
- package/lib/cjs/utils/objects/isProtectedKey.js +12 -0
- package/lib/cjs/utils/objects/isProtectedKey.js.map +1 -0
- package/lib/cjs/utils/objects/isSerializable.js +13 -0
- package/lib/cjs/utils/objects/isSerializable.js.map +1 -0
- package/lib/cjs/utils/objects/isStream.js +8 -0
- package/lib/cjs/utils/objects/isStream.js.map +1 -0
- package/lib/cjs/utils/objects/isString.js +16 -0
- package/lib/cjs/utils/objects/isString.js.map +1 -0
- package/lib/cjs/utils/objects/isSymbol.js +16 -0
- package/lib/cjs/utils/objects/isSymbol.js.map +1 -0
- package/lib/cjs/utils/objects/methodsOf.js +25 -0
- package/lib/cjs/utils/objects/methodsOf.js.map +1 -0
- package/lib/cjs/utils/objects/nameOf.js +32 -0
- package/lib/cjs/utils/objects/nameOf.js.map +1 -0
- package/lib/cjs/utils/objects/objectKeys.js +9 -0
- package/lib/cjs/utils/objects/objectKeys.js.map +1 -0
- package/lib/cjs/utils/objects/primitiveOf.js +20 -0
- package/lib/cjs/utils/objects/primitiveOf.js.map +1 -0
- package/lib/cjs/utils/objects/prototypeOf.js +14 -0
- package/lib/cjs/utils/objects/prototypeOf.js.map +1 -0
- package/lib/cjs/utils/objects/setValue.js +34 -0
- package/lib/cjs/utils/objects/setValue.js.map +1 -0
- package/lib/cjs/utils/objects/toMap.js +32 -0
- package/lib/cjs/utils/objects/toMap.js.map +1 -0
- package/lib/cjs/utils/objects/toStringConstructor.js +12 -0
- package/lib/cjs/utils/objects/toStringConstructor.js.map +1 -0
- package/lib/cjs/utils/proxyDelegation.js +54 -0
- package/lib/cjs/utils/proxyDelegation.js.map +1 -0
- package/lib/cjs/utils/uniq.js +16 -0
- package/lib/cjs/utils/uniq.js.map +1 -0
- package/lib/esm/decorators/configurable.js +10 -0
- package/lib/esm/decorators/configurable.js.map +1 -0
- package/lib/esm/decorators/deprecated.js +40 -0
- package/lib/esm/decorators/deprecated.js.map +1 -0
- package/lib/esm/decorators/enumerable.js +10 -0
- package/lib/esm/decorators/enumerable.js.map +1 -0
- package/lib/esm/decorators/notConfigurable.js +5 -0
- package/lib/esm/decorators/notConfigurable.js.map +1 -0
- package/lib/esm/decorators/notEnumerable.js +5 -0
- package/lib/esm/decorators/notEnumerable.js.map +1 -0
- package/lib/esm/decorators/readOnly.js +5 -0
- package/lib/esm/decorators/readOnly.js.map +1 -0
- package/lib/esm/decorators/storeFn.js +18 -0
- package/lib/esm/decorators/storeFn.js.map +1 -0
- package/lib/esm/decorators/storeMerge.js +7 -0
- package/lib/esm/decorators/storeMerge.js.map +1 -0
- package/lib/esm/decorators/storeSet.js +7 -0
- package/lib/esm/decorators/storeSet.js.map +1 -0
- package/lib/esm/decorators/writable.js +10 -0
- package/lib/esm/decorators/writable.js.map +1 -0
- package/lib/esm/domain/AnyToPromise.js +144 -0
- package/lib/esm/domain/AnyToPromise.js.map +1 -0
- package/lib/esm/domain/DecoratorTypes.js +12 -0
- package/lib/esm/domain/DecoratorTypes.js.map +1 -0
- package/lib/esm/domain/Env.js +16 -0
- package/lib/esm/domain/Env.js.map +1 -0
- package/lib/esm/domain/Hooks.js +85 -0
- package/lib/esm/domain/Hooks.js.map +1 -0
- package/lib/esm/domain/Metadata.js +504 -0
- package/lib/esm/domain/Metadata.js.map +1 -0
- package/lib/esm/domain/Store.js +153 -0
- package/lib/esm/domain/Store.js.map +1 -0
- package/lib/esm/domain/Type.js +4 -0
- package/lib/esm/domain/Type.js.map +1 -0
- package/lib/esm/errors/UnsupportedDecoratorType.js +19 -0
- package/lib/esm/errors/UnsupportedDecoratorType.js.map +1 -0
- package/lib/esm/index.js +82 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/AnyDecorator.js +2 -0
- package/lib/esm/interfaces/AnyDecorator.js.map +1 -0
- package/lib/esm/interfaces/DecoratorParameters.js +2 -0
- package/lib/esm/interfaces/DecoratorParameters.js.map +1 -0
- package/lib/esm/interfaces/HashOf.js +2 -0
- package/lib/esm/interfaces/HashOf.js.map +1 -0
- package/lib/esm/interfaces/MetadataTypes.js +2 -0
- package/lib/esm/interfaces/MetadataTypes.js.map +1 -0
- package/lib/esm/interfaces/ValueOf.js +2 -0
- package/lib/esm/interfaces/ValueOf.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/catchError.js +17 -0
- package/lib/esm/utils/catchError.js.map +1 -0
- package/lib/esm/utils/decorators/decorateMethodsOf.js +20 -0
- package/lib/esm/utils/decorators/decorateMethodsOf.js.map +1 -0
- package/lib/esm/utils/decorators/decoratorArgs.js +5 -0
- package/lib/esm/utils/decorators/decoratorArgs.js.map +1 -0
- package/lib/esm/utils/decorators/decoratorTypeOf.js +19 -0
- package/lib/esm/utils/decorators/decoratorTypeOf.js.map +1 -0
- package/lib/esm/utils/decorators/inheritedDescriptorOf.js +11 -0
- package/lib/esm/utils/decorators/inheritedDescriptorOf.js.map +1 -0
- package/lib/esm/utils/decorators/useDecorators.js +10 -0
- package/lib/esm/utils/decorators/useDecorators.js.map +1 -0
- package/lib/esm/utils/decorators/useMethodDecorators.js +10 -0
- package/lib/esm/utils/decorators/useMethodDecorators.js.map +1 -0
- package/lib/esm/utils/http/getHostInfoFromPort.js +17 -0
- package/lib/esm/utils/http/getHostInfoFromPort.js.map +1 -0
- package/lib/esm/utils/imports/importPackage.js +12 -0
- package/lib/esm/utils/imports/importPackage.js.map +1 -0
- package/lib/esm/utils/objects/ancestorOf.js +7 -0
- package/lib/esm/utils/objects/ancestorOf.js.map +1 -0
- package/lib/esm/utils/objects/ancestorsOf.js +18 -0
- package/lib/esm/utils/objects/ancestorsOf.js.map +1 -0
- package/lib/esm/utils/objects/classOf.js +18 -0
- package/lib/esm/utils/objects/classOf.js.map +1 -0
- package/lib/esm/utils/objects/cleanObject.js +20 -0
- package/lib/esm/utils/objects/cleanObject.js.map +1 -0
- package/lib/esm/utils/objects/constructorOf.js +15 -0
- package/lib/esm/utils/objects/constructorOf.js.map +1 -0
- package/lib/esm/utils/objects/createInstance.js +5 -0
- package/lib/esm/utils/objects/createInstance.js.map +1 -0
- package/lib/esm/utils/objects/deepClone.js +59 -0
- package/lib/esm/utils/objects/deepClone.js.map +1 -0
- package/lib/esm/utils/objects/deepMerge.js +58 -0
- package/lib/esm/utils/objects/deepMerge.js.map +1 -0
- package/lib/esm/utils/objects/descriptorOf.js +14 -0
- package/lib/esm/utils/objects/descriptorOf.js.map +1 -0
- package/lib/esm/utils/objects/getClassOrSymbol.js +6 -0
- package/lib/esm/utils/objects/getClassOrSymbol.js.map +1 -0
- package/lib/esm/utils/objects/getConstructorArgNames.js +10 -0
- package/lib/esm/utils/objects/getConstructorArgNames.js.map +1 -0
- package/lib/esm/utils/objects/getEnumerableKeys.js +16 -0
- package/lib/esm/utils/objects/getEnumerableKeys.js.map +1 -0
- package/lib/esm/utils/objects/getValue.js +45 -0
- package/lib/esm/utils/objects/getValue.js.map +1 -0
- package/lib/esm/utils/objects/isArray.js +18 -0
- package/lib/esm/utils/objects/isArray.js.map +1 -0
- package/lib/esm/utils/objects/isArrowFn.js +5 -0
- package/lib/esm/utils/objects/isArrowFn.js.map +1 -0
- package/lib/esm/utils/objects/isBoolean.js +12 -0
- package/lib/esm/utils/objects/isBoolean.js.map +1 -0
- package/lib/esm/utils/objects/isBuffer.js +9 -0
- package/lib/esm/utils/objects/isBuffer.js.map +1 -0
- package/lib/esm/utils/objects/isClass.js +24 -0
- package/lib/esm/utils/objects/isClass.js.map +1 -0
- package/lib/esm/utils/objects/isCollection.js +18 -0
- package/lib/esm/utils/objects/isCollection.js.map +1 -0
- package/lib/esm/utils/objects/isDate.js +9 -0
- package/lib/esm/utils/objects/isDate.js.map +1 -0
- package/lib/esm/utils/objects/isEmpty.js +10 -0
- package/lib/esm/utils/objects/isEmpty.js.map +1 -0
- package/lib/esm/utils/objects/isEnumerable.js +18 -0
- package/lib/esm/utils/objects/isEnumerable.js.map +1 -0
- package/lib/esm/utils/objects/isFunction.js +4 -0
- package/lib/esm/utils/objects/isFunction.js.map +1 -0
- package/lib/esm/utils/objects/isInheritedFrom.js +22 -0
- package/lib/esm/utils/objects/isInheritedFrom.js.map +1 -0
- package/lib/esm/utils/objects/isNil.js +4 -0
- package/lib/esm/utils/objects/isNil.js.map +1 -0
- package/lib/esm/utils/objects/isNumber.js +12 -0
- package/lib/esm/utils/objects/isNumber.js.map +1 -0
- package/lib/esm/utils/objects/isObject.js +4 -0
- package/lib/esm/utils/objects/isObject.js.map +1 -0
- package/lib/esm/utils/objects/isObservable.js +4 -0
- package/lib/esm/utils/objects/isObservable.js.map +1 -0
- package/lib/esm/utils/objects/isPlainObject.js +13 -0
- package/lib/esm/utils/objects/isPlainObject.js.map +1 -0
- package/lib/esm/utils/objects/isPrimitive.js +24 -0
- package/lib/esm/utils/objects/isPrimitive.js.map +1 -0
- package/lib/esm/utils/objects/isPromise.js +12 -0
- package/lib/esm/utils/objects/isPromise.js.map +1 -0
- package/lib/esm/utils/objects/isProtectedKey.js +8 -0
- package/lib/esm/utils/objects/isProtectedKey.js.map +1 -0
- package/lib/esm/utils/objects/isSerializable.js +9 -0
- package/lib/esm/utils/objects/isSerializable.js.map +1 -0
- package/lib/esm/utils/objects/isStream.js +4 -0
- package/lib/esm/utils/objects/isStream.js.map +1 -0
- package/lib/esm/utils/objects/isString.js +11 -0
- package/lib/esm/utils/objects/isString.js.map +1 -0
- package/lib/esm/utils/objects/isSymbol.js +11 -0
- package/lib/esm/utils/objects/isSymbol.js.map +1 -0
- package/lib/esm/utils/objects/methodsOf.js +21 -0
- package/lib/esm/utils/objects/methodsOf.js.map +1 -0
- package/lib/esm/utils/objects/nameOf.js +26 -0
- package/lib/esm/utils/objects/nameOf.js.map +1 -0
- package/lib/esm/utils/objects/objectKeys.js +5 -0
- package/lib/esm/utils/objects/objectKeys.js.map +1 -0
- package/lib/esm/utils/objects/primitiveOf.js +16 -0
- package/lib/esm/utils/objects/primitiveOf.js.map +1 -0
- package/lib/esm/utils/objects/prototypeOf.js +10 -0
- package/lib/esm/utils/objects/prototypeOf.js.map +1 -0
- package/lib/esm/utils/objects/setValue.js +30 -0
- package/lib/esm/utils/objects/setValue.js.map +1 -0
- package/lib/esm/utils/objects/toMap.js +28 -0
- package/lib/esm/utils/objects/toMap.js.map +1 -0
- package/lib/esm/utils/objects/toStringConstructor.js +8 -0
- package/lib/esm/utils/objects/toStringConstructor.js.map +1 -0
- package/lib/esm/utils/proxyDelegation.js +50 -0
- package/lib/esm/utils/proxyDelegation.js.map +1 -0
- package/lib/esm/utils/uniq.js +11 -0
- package/lib/esm/utils/uniq.js.map +1 -0
- package/lib/{decorators → types/decorators}/configurable.d.ts +0 -1
- package/lib/{decorators → types/decorators}/deprecated.d.ts +0 -0
- package/lib/{decorators → types/decorators}/enumerable.d.ts +0 -1
- package/lib/{decorators → types/decorators}/notConfigurable.d.ts +0 -1
- package/lib/{decorators → types/decorators}/notEnumerable.d.ts +0 -1
- package/lib/{decorators → types/decorators}/readOnly.d.ts +0 -1
- package/lib/{decorators → types/decorators}/storeFn.d.ts +0 -0
- package/lib/{decorators → types/decorators}/storeMerge.d.ts +0 -0
- package/lib/{decorators → types/decorators}/storeSet.d.ts +0 -0
- package/lib/{decorators → types/decorators}/writable.d.ts +0 -1
- package/lib/{domain → types/domain}/AnyToPromise.d.ts +0 -0
- package/lib/{domain → types/domain}/DecoratorTypes.d.ts +0 -0
- package/lib/{domain → types/domain}/Env.d.ts +0 -0
- package/lib/{domain → types/domain}/Hooks.d.ts +0 -0
- package/lib/{domain → types/domain}/Metadata.d.ts +0 -0
- package/lib/{domain → types/domain}/Store.d.ts +0 -0
- package/lib/{domain → types/domain}/Type.d.ts +0 -0
- package/lib/{errors → types/errors}/UnsupportedDecoratorType.d.ts +0 -0
- package/lib/types/index.d.ts +81 -0
- package/lib/{interfaces → types/interfaces}/AnyDecorator.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/DecoratorParameters.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/HashOf.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MetadataTypes.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/ValueOf.d.ts +0 -0
- package/lib/{utils → types/utils}/catchError.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/decorateMethodsOf.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/decoratorArgs.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/decoratorTypeOf.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/inheritedDescriptorOf.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/useDecorators.d.ts +0 -0
- package/lib/{utils → types/utils}/decorators/useMethodDecorators.d.ts +0 -0
- package/lib/types/utils/http/getHostInfoFromPort.d.ts +6 -0
- package/lib/types/utils/imports/importPackage.d.ts +1 -0
- package/lib/{utils → types/utils}/objects/ancestorOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/ancestorsOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/classOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/cleanObject.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/constructorOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/createInstance.d.ts +0 -0
- package/lib/types/utils/objects/deepClone.d.ts +6 -0
- package/lib/{utils → types/utils}/objects/deepMerge.d.ts +1 -1
- package/lib/{utils → types/utils}/objects/descriptorOf.d.ts +1 -0
- package/lib/{utils → types/utils}/objects/getClassOrSymbol.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/getConstructorArgNames.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/getEnumerableKeys.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/getValue.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isArray.d.ts +0 -0
- package/lib/types/utils/objects/isArrowFn.d.ts +1 -0
- package/lib/{utils → types/utils}/objects/isBoolean.d.ts +0 -0
- package/lib/types/utils/objects/isBuffer.d.ts +7 -0
- package/lib/{utils → types/utils}/objects/isClass.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isCollection.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isDate.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isEmpty.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isEnumerable.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isFunction.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isInheritedFrom.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isNil.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isNumber.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isObject.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isObservable.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isPlainObject.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isPrimitive.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isPromise.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isProtectedKey.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isSerializable.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isStream.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isString.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/isSymbol.d.ts +0 -0
- package/lib/types/utils/objects/methodsOf.d.ts +9 -0
- package/lib/{utils → types/utils}/objects/nameOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/objectKeys.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/primitiveOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/prototypeOf.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/setValue.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/toMap.d.ts +0 -0
- package/lib/{utils → types/utils}/objects/toStringConstructor.d.ts +0 -0
- package/lib/{utils → types/utils}/proxyDelegation.d.ts +0 -0
- package/lib/{utils → types/utils}/uniq.d.ts +0 -0
- package/package.json +16 -12
- package/readme.md +1 -2
- package/tsconfig.compile.esm.json +12 -0
- package/lib/decorators/index.d.ts +0 -14
- package/lib/domain/Entity.d.ts +0 -97
- package/lib/domain/index.d.ts +0 -8
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -2298
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2210
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -4
- package/lib/utils/index.d.ts +0 -11
- package/lib/utils/objects/deepClone.d.ts +0 -5
- package/lib/utils/objects/index.d.ts +0 -42
- package/lib/utils/objects/isArrowFn.d.ts +0 -1
- package/lib/utils/objects/methodsOf.d.ts +0 -5
package/lib/index.modern.js
DELETED
|
@@ -1,2210 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
|
|
3
|
-
function catchError(cb) {
|
|
4
|
-
try {
|
|
5
|
-
cb();
|
|
6
|
-
} catch (er) {
|
|
7
|
-
return er;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
async function catchAsyncError(cb) {
|
|
11
|
-
try {
|
|
12
|
-
await cb();
|
|
13
|
-
} catch (er) {
|
|
14
|
-
return er;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _extends() {
|
|
19
|
-
_extends = Object.assign || function (target) {
|
|
20
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
-
var source = arguments[i];
|
|
22
|
-
|
|
23
|
-
for (var key in source) {
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
-
target[key] = source[key];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return _extends.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var id = 0;
|
|
37
|
-
|
|
38
|
-
function _classPrivateFieldLooseKey(name) {
|
|
39
|
-
return "__private_" + id++ + "_" + name;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) {
|
|
43
|
-
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
|
|
44
|
-
throw new TypeError("attempted to use private field on non-instance");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return receiver;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create a complete and iterable trap.
|
|
52
|
-
* @param self
|
|
53
|
-
* @param options
|
|
54
|
-
* @ignore
|
|
55
|
-
*/
|
|
56
|
-
function proxyDelegation(self, options = {}) {
|
|
57
|
-
const {
|
|
58
|
-
handlers = {},
|
|
59
|
-
remove,
|
|
60
|
-
ownKeys
|
|
61
|
-
} = options;
|
|
62
|
-
|
|
63
|
-
const get = options.getter || ((target, propertyKey) => target.get(propertyKey));
|
|
64
|
-
|
|
65
|
-
const set = options.setter || ((target, propertyKey, value) => !!target.set(propertyKey, value));
|
|
66
|
-
|
|
67
|
-
const itsOwnProp = (target, p) => Reflect.has(target, p) || typeof p === "symbol";
|
|
68
|
-
|
|
69
|
-
return new Proxy(self, _extends({
|
|
70
|
-
getOwnPropertyDescriptor(target, p) {
|
|
71
|
-
return Reflect.getOwnPropertyDescriptor(target, p);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
has(target, p) {
|
|
75
|
-
if (itsOwnProp(target, p)) {
|
|
76
|
-
return Reflect.has(target, p);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return get(target, p) !== undefined;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
get(target, p, receiver) {
|
|
83
|
-
if (itsOwnProp(target, p)) {
|
|
84
|
-
return Reflect.get(target, p, receiver);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return get(target, p);
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
set(target, p, value, receiver) {
|
|
91
|
-
if (itsOwnProp(target, p)) {
|
|
92
|
-
return Reflect.set(target, p, value, receiver);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return !!set(target, p, value, receiver);
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
deleteProperty(target, p) {
|
|
99
|
-
if (itsOwnProp(target, p) || !remove) {
|
|
100
|
-
return Reflect.deleteProperty(target, p);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return remove(target, p);
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
defineProperty(target, p, attributes) {
|
|
107
|
-
return Reflect.defineProperty(target, p, attributes);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
ownKeys(target) {
|
|
111
|
-
return Reflect.ownKeys(target).concat(ownKeys && ownKeys(target) || []);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
}, handlers));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function uniq(list) {
|
|
118
|
-
return Array.from(new Set(list).values());
|
|
119
|
-
}
|
|
120
|
-
function uniqBy(list, key = "id") {
|
|
121
|
-
const map = new Map();
|
|
122
|
-
list.forEach(item => {
|
|
123
|
-
map.set(item[key], item);
|
|
124
|
-
});
|
|
125
|
-
return Array.from(map.values());
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Get the provide constructor if target is an instance.
|
|
130
|
-
* @param target
|
|
131
|
-
* @returns {*}
|
|
132
|
-
*/
|
|
133
|
-
function getClass(target) {
|
|
134
|
-
return target.prototype ? target : target.constructor;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get the provide constructor if target is an instance.
|
|
138
|
-
* @param target
|
|
139
|
-
* @returns {*}
|
|
140
|
-
* @alias getClass
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
function classOf(target) {
|
|
144
|
-
return getClass(target);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function ancestorOf(target) {
|
|
148
|
-
return Object.getPrototypeOf(target);
|
|
149
|
-
}
|
|
150
|
-
function getInheritedClass(target) {
|
|
151
|
-
return ancestorOf(target);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Get the provide name.
|
|
156
|
-
* @param targetClass
|
|
157
|
-
*/
|
|
158
|
-
function nameOfClass(targetClass) {
|
|
159
|
-
return typeof targetClass === "function" ? targetClass.name : targetClass.constructor.name;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get symbol name.
|
|
163
|
-
* @param sym
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
const nameOfSymbol = sym => sym.toString().replace("Symbol(", "").replace(")", "");
|
|
167
|
-
/**
|
|
168
|
-
* Get object name
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
function nameOf(obj) {
|
|
172
|
-
switch (typeof obj) {
|
|
173
|
-
default:
|
|
174
|
-
return "" + obj;
|
|
175
|
-
|
|
176
|
-
case "symbol":
|
|
177
|
-
return nameOfSymbol(obj);
|
|
178
|
-
|
|
179
|
-
case "function":
|
|
180
|
-
return nameOfClass(obj);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
186
|
-
* @param target
|
|
187
|
-
* @returns {Array}
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
function ancestorsOf(target) {
|
|
191
|
-
const classes = [];
|
|
192
|
-
let currentTarget = classOf(target);
|
|
193
|
-
|
|
194
|
-
while (nameOf(currentTarget) !== "") {
|
|
195
|
-
classes.unshift(currentTarget);
|
|
196
|
-
currentTarget = getInheritedClass(currentTarget);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return classes;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Return the prototype of the given class.
|
|
204
|
-
* @param target
|
|
205
|
-
* @returns {any}
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
function prototypeOf(target) {
|
|
209
|
-
return classOf(target) === target ? target.prototype : target;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Return all methods for a given class.
|
|
214
|
-
* @param target
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
function methodsOf(target) {
|
|
218
|
-
const methods = new Map();
|
|
219
|
-
target = classOf(target);
|
|
220
|
-
ancestorsOf(target).forEach(target => {
|
|
221
|
-
const keys = Reflect.ownKeys(prototypeOf(target));
|
|
222
|
-
keys.forEach(propertyKey => {
|
|
223
|
-
if (propertyKey !== "constructor") {
|
|
224
|
-
methods.set(propertyKey, {
|
|
225
|
-
target,
|
|
226
|
-
propertyKey
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
return Array.from(methods.values());
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Return the descriptor for a given class and propertyKey
|
|
236
|
-
* @param target
|
|
237
|
-
* @param {string} propertyKey
|
|
238
|
-
* @returns {PropertyDescriptor}
|
|
239
|
-
*/
|
|
240
|
-
function descriptorOf(target, propertyKey) {
|
|
241
|
-
return Object.getOwnPropertyDescriptor(target && target.prototype || target, propertyKey);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
var DecoratorTypes;
|
|
245
|
-
|
|
246
|
-
(function (DecoratorTypes) {
|
|
247
|
-
DecoratorTypes["PARAM"] = "parameter";
|
|
248
|
-
DecoratorTypes["PARAM_CTOR"] = "parameter.constructor";
|
|
249
|
-
DecoratorTypes["PARAM_STC"] = "parameter.static";
|
|
250
|
-
DecoratorTypes["PROP"] = "property";
|
|
251
|
-
DecoratorTypes["PROP_STC"] = "property.static";
|
|
252
|
-
DecoratorTypes["METHOD"] = "method";
|
|
253
|
-
DecoratorTypes["METHOD_STC"] = "method.static";
|
|
254
|
-
DecoratorTypes["CLASS"] = "class";
|
|
255
|
-
})(DecoratorTypes || (DecoratorTypes = {}));
|
|
256
|
-
|
|
257
|
-
function decoratorTypeOf(args) {
|
|
258
|
-
const [target, propertyKey, descriptor] = args;
|
|
259
|
-
|
|
260
|
-
const staticType = type => {
|
|
261
|
-
return target !== classOf(target) ? type : `${type}.static`;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
if (typeof descriptor === "number") {
|
|
265
|
-
return propertyKey ? staticType("parameter") : "parameter.constructor";
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (descriptor && descriptor.value) {
|
|
269
|
-
return staticType("method");
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (propertyKey && descriptor === undefined || descriptor) {
|
|
273
|
-
return staticType("property");
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return DecoratorTypes.CLASS;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Return true if value is an array
|
|
281
|
-
* @param target
|
|
282
|
-
* @returns {boolean}
|
|
283
|
-
*/
|
|
284
|
-
function isArray(target) {
|
|
285
|
-
return Array.isArray(target);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Return true if the clazz is an array.
|
|
289
|
-
* @param target
|
|
290
|
-
* @returns {boolean}
|
|
291
|
-
* @ignore
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
function isArrayOrArrayClass(target) {
|
|
295
|
-
return target === Array || isArray(target);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
*
|
|
300
|
-
* @param target
|
|
301
|
-
* @returns {boolean}
|
|
302
|
-
*/
|
|
303
|
-
function isDate(target) {
|
|
304
|
-
return target === Date || target instanceof Date && !isNaN(+target);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function isFunction(target) {
|
|
308
|
-
return typeof target === "function";
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function isNil(value) {
|
|
312
|
-
return value === undefined || value === null;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
*
|
|
317
|
-
* @param target
|
|
318
|
-
* @returns {boolean}
|
|
319
|
-
*/
|
|
320
|
-
function isBoolean(target) {
|
|
321
|
-
return typeof target === "boolean" || target instanceof Boolean || target === Boolean;
|
|
322
|
-
}
|
|
323
|
-
function isBooleanOrBooleanClass(target) {
|
|
324
|
-
return typeof target === "boolean" || target instanceof Boolean || target === Boolean;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
*
|
|
329
|
-
* @param target
|
|
330
|
-
* @returns {boolean}
|
|
331
|
-
*/
|
|
332
|
-
function isNumber(target) {
|
|
333
|
-
return typeof target === "number";
|
|
334
|
-
}
|
|
335
|
-
function isNumberOrNumberClass(target) {
|
|
336
|
-
return typeof target === "number" || target instanceof Number || target === Number;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* @param target
|
|
341
|
-
* @returns {boolean}
|
|
342
|
-
*/
|
|
343
|
-
function isString(target) {
|
|
344
|
-
return typeof target === "string";
|
|
345
|
-
}
|
|
346
|
-
function isStringOrStringClass(target) {
|
|
347
|
-
return typeof target === "string" || target instanceof String || target === String;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Return true if the given obj is a primitive.
|
|
352
|
-
* @param target
|
|
353
|
-
* @returns {boolean}
|
|
354
|
-
* @ignore
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
function isPrimitiveOrPrimitiveClass(target) {
|
|
358
|
-
return isStringOrStringClass(target) || isNumberOrNumberClass(target) || isBooleanOrBooleanClass(target);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Return true if the given obj is a primitive.
|
|
362
|
-
* @param target
|
|
363
|
-
* @returns {boolean}
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
function isPrimitive(target) {
|
|
367
|
-
return isString(target) || isNumber(target) || isBoolean(target);
|
|
368
|
-
}
|
|
369
|
-
function isPrimitiveClass(target) {
|
|
370
|
-
return [String, Number, Boolean].includes(target);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
*
|
|
375
|
-
* @param target
|
|
376
|
-
*/
|
|
377
|
-
function isSymbol(target) {
|
|
378
|
-
return typeof target === "symbol";
|
|
379
|
-
}
|
|
380
|
-
function isSymbolOrSymbolClass(target) {
|
|
381
|
-
return typeof target === "symbol" || target instanceof Symbol || target === Symbol;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const isBasicType = source => isNil(source) || isPrimitive(source) || isSymbol(source) || isFunction(source);
|
|
385
|
-
/**
|
|
386
|
-
* Return a cloned value
|
|
387
|
-
* @param source
|
|
388
|
-
*/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
function deepClone(source) {
|
|
392
|
-
let dest;
|
|
393
|
-
|
|
394
|
-
if (isBasicType(source)) {
|
|
395
|
-
return source;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (isDate(source)) {
|
|
399
|
-
return new Date(source);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
dest = isArray(source) ? [] : {};
|
|
403
|
-
|
|
404
|
-
for (const key in source) {
|
|
405
|
-
// Use getOwnPropertyDescriptor instead of source[key] to prevent from triggering setter/getter.
|
|
406
|
-
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
407
|
-
|
|
408
|
-
if (descriptor) {
|
|
409
|
-
if (!isFunction(descriptor.value)) {
|
|
410
|
-
dest[key] = deepClone(descriptor.value);
|
|
411
|
-
} else {
|
|
412
|
-
Object.defineProperty(dest, key, descriptor);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (!isArray(source)) {
|
|
418
|
-
const prototype = Reflect.getPrototypeOf(source);
|
|
419
|
-
Reflect.setPrototypeOf(dest, prototype);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return dest;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function createInstance(obj) {
|
|
426
|
-
return obj ? classOf(obj) !== Object ? Object.create(obj) : {} : {};
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Prevent prototype pollution vulnerability
|
|
431
|
-
* @param key
|
|
432
|
-
*/
|
|
433
|
-
function isProtectedKey(key) {
|
|
434
|
-
return ["__proto__", "constructor", "prototype"].includes(key);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function objectKeys(obj) {
|
|
438
|
-
return Object.keys(obj).filter(key => !isProtectedKey(key));
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function mergeReducerBuilder(cb) {
|
|
442
|
-
return (collection, value, options) => {
|
|
443
|
-
const index = collection.findIndex(item => cb(item, value));
|
|
444
|
-
|
|
445
|
-
if (index === -1) {
|
|
446
|
-
return [...collection, value];
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
collection[index] = deepMerge(collection[index], value, options);
|
|
450
|
-
return collection;
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
const defaultReducer = mergeReducerBuilder((a, b) => a === b);
|
|
454
|
-
|
|
455
|
-
function getReducer({
|
|
456
|
-
reducers,
|
|
457
|
-
parentKey
|
|
458
|
-
}) {
|
|
459
|
-
if (!reducers) {
|
|
460
|
-
return defaultReducer;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if (parentKey && reducers[parentKey]) {
|
|
464
|
-
return reducers[parentKey];
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
return reducers["default"] || defaultReducer;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
function shouldReturnObj(obj, source) {
|
|
471
|
-
return isPrimitive(obj) || isSymbol(obj) || isFunction(obj) || source === undefined;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function shouldReturnSource(obj, source) {
|
|
475
|
-
return obj === undefined || obj === null || obj === "" && source !== "";
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function deepMerge(source, obj, options = {}) {
|
|
479
|
-
if (shouldReturnSource(obj, source)) {
|
|
480
|
-
return source;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (shouldReturnObj(obj, source)) {
|
|
484
|
-
return obj;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (Array.isArray(source)) {
|
|
488
|
-
const reducer = getReducer(options);
|
|
489
|
-
return [].concat(obj).reduce((out, value) => reducer(out, value, options), [...source]);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
return [...objectKeys(source), ...objectKeys(obj)].reduce((out, key) => {
|
|
493
|
-
const src = source && source[key];
|
|
494
|
-
const value = deepMerge(src, obj && obj[key], _extends({}, options, {
|
|
495
|
-
parentKey: key
|
|
496
|
-
}));
|
|
497
|
-
|
|
498
|
-
if (options.cleanUndefinedProps && value === undefined) {
|
|
499
|
-
return out;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return _extends({}, out, {
|
|
503
|
-
[key]: value
|
|
504
|
-
});
|
|
505
|
-
}, createInstance(source));
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Metadata key
|
|
510
|
-
* @private
|
|
511
|
-
* @type {string}
|
|
512
|
-
*/
|
|
513
|
-
|
|
514
|
-
const DESIGN_PARAM_TYPES = "design:paramtypes";
|
|
515
|
-
/**
|
|
516
|
-
* Metadata key
|
|
517
|
-
* @private
|
|
518
|
-
* @type {string}
|
|
519
|
-
*/
|
|
520
|
-
|
|
521
|
-
const DESIGN_TYPE = "design:type";
|
|
522
|
-
/**
|
|
523
|
-
* Metadata key
|
|
524
|
-
* @private
|
|
525
|
-
* @type {string}
|
|
526
|
-
*/
|
|
527
|
-
|
|
528
|
-
const DESIGN_RETURN_TYPE = "design:returntype";
|
|
529
|
-
/**
|
|
530
|
-
* Properties collections
|
|
531
|
-
* @private
|
|
532
|
-
* @type {string}
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
const PROPERTIES = new Map();
|
|
536
|
-
/**
|
|
537
|
-
* @stable
|
|
538
|
-
*/
|
|
539
|
-
|
|
540
|
-
class Metadata {
|
|
541
|
-
/**
|
|
542
|
-
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
543
|
-
* @param key A key used to store and retrieve metadata.
|
|
544
|
-
* @param target The target object on which the metadata is defined.
|
|
545
|
-
* @param propertyKey The property key for the target.
|
|
546
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
547
|
-
* @example
|
|
548
|
-
*
|
|
549
|
-
* ```typescript
|
|
550
|
-
* class Example {
|
|
551
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
552
|
-
* // static staticProperty;
|
|
553
|
-
* // property;
|
|
554
|
-
*
|
|
555
|
-
* static staticMethod(p) { }
|
|
556
|
-
* method(p) { }
|
|
557
|
-
* }
|
|
558
|
-
*
|
|
559
|
-
* // constructor
|
|
560
|
-
* result = Metadata.get("custom:annotation", Example);
|
|
561
|
-
*
|
|
562
|
-
* // property (on constructor)
|
|
563
|
-
* result = Metadata.get("custom:annotation", Example, "staticProperty");
|
|
564
|
-
*
|
|
565
|
-
* // property (on prototype)
|
|
566
|
-
* result = Metadata.get("custom:annotation", Example.prototype, "property");
|
|
567
|
-
*
|
|
568
|
-
* // method (on constructor)
|
|
569
|
-
* result = Metadata.get("custom:annotation", Example, "staticMethod");
|
|
570
|
-
*
|
|
571
|
-
* // method (on prototype)
|
|
572
|
-
* result = Metadata.get("custom:annotation", Example.prototype, "method");
|
|
573
|
-
* ```
|
|
574
|
-
*
|
|
575
|
-
*/
|
|
576
|
-
static get(key, target, propertyKey) {
|
|
577
|
-
return Reflect.getMetadata(key, classOf(target), propertyKey);
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
581
|
-
* @param key A key used to store and retrieve metadata.
|
|
582
|
-
* @param target The target object on which the metadata is defined.
|
|
583
|
-
* @param propertyKey The property key for the target.
|
|
584
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
585
|
-
* @example
|
|
586
|
-
*
|
|
587
|
-
* ```typescript
|
|
588
|
-
* class Example {
|
|
589
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
590
|
-
* // static staticProperty;
|
|
591
|
-
* // property;
|
|
592
|
-
*
|
|
593
|
-
* static staticMethod(p) { }
|
|
594
|
-
* method(p) { }
|
|
595
|
-
* }
|
|
596
|
-
*
|
|
597
|
-
* // constructor
|
|
598
|
-
* result = Metadata.getOwn("custom:annotation", Example);
|
|
599
|
-
*
|
|
600
|
-
* // property (on constructor)
|
|
601
|
-
* result = Metadata.getOwn("custom:annotation", Example, "staticProperty");
|
|
602
|
-
*
|
|
603
|
-
* // property (on prototype)
|
|
604
|
-
* result = Metadata.getOwn("custom:annotation", Example.prototype, "property");
|
|
605
|
-
*
|
|
606
|
-
* // method (on constructor)
|
|
607
|
-
* result = Metadata.getOwn("custom:annotation", Example, "staticMethod");
|
|
608
|
-
*
|
|
609
|
-
* // method (on prototype)
|
|
610
|
-
* result = Metadata.getOwn("custom:annotation", Example.prototype, "method");
|
|
611
|
-
* ```
|
|
612
|
-
*
|
|
613
|
-
*/
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
static getOwn(key, target, propertyKey) {
|
|
617
|
-
return Reflect.getOwnMetadata(key, classOf(target), propertyKey);
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.
|
|
621
|
-
* @param target The target object on which the metadata is defined.
|
|
622
|
-
* @param propertyKey The property key for the target.
|
|
623
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
624
|
-
* @example
|
|
625
|
-
*
|
|
626
|
-
* ```typescript
|
|
627
|
-
* class Example {
|
|
628
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
629
|
-
* // static staticProperty;
|
|
630
|
-
* // property;
|
|
631
|
-
*
|
|
632
|
-
* static staticMethod(p) { }
|
|
633
|
-
* method(p) { }
|
|
634
|
-
* }
|
|
635
|
-
*
|
|
636
|
-
* // on contructor
|
|
637
|
-
* result = Metadata.getType(Example);
|
|
638
|
-
*
|
|
639
|
-
* // property (on constructor)
|
|
640
|
-
* result = Metadata.getType(Example, "staticProperty");
|
|
641
|
-
*
|
|
642
|
-
* // method (on constructor)
|
|
643
|
-
* result = Metadata.getType(Example, "staticMethod");
|
|
644
|
-
* ```
|
|
645
|
-
*
|
|
646
|
-
*/
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
static getType(target, propertyKey) {
|
|
650
|
-
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.
|
|
654
|
-
* @param target The target object on which the metadata is defined.
|
|
655
|
-
* @param propertyKey The property key for the target.
|
|
656
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
657
|
-
* @example
|
|
658
|
-
*
|
|
659
|
-
* ```typescript
|
|
660
|
-
* class Example {
|
|
661
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
662
|
-
* // static staticProperty;
|
|
663
|
-
* // property;
|
|
664
|
-
*
|
|
665
|
-
* static staticMethod(p) { }
|
|
666
|
-
* method(p) { }
|
|
667
|
-
* }
|
|
668
|
-
*
|
|
669
|
-
* // on contructor
|
|
670
|
-
* result = Metadata.getOwnType(Example);
|
|
671
|
-
*
|
|
672
|
-
* // property (on constructor)
|
|
673
|
-
* result = Metadata.getOwnType(Example, "staticProperty");
|
|
674
|
-
*
|
|
675
|
-
* // method (on constructor)
|
|
676
|
-
* result = Metadata.getOwnType(Example, "staticMethod");
|
|
677
|
-
* ```
|
|
678
|
-
*
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
static getOwnType(target, propertyKey) {
|
|
683
|
-
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.
|
|
687
|
-
* @param target The target object on which the metadata is defined.
|
|
688
|
-
* @param propertyKey The property key for the target.
|
|
689
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
690
|
-
* @example
|
|
691
|
-
*
|
|
692
|
-
* ```typescript
|
|
693
|
-
* class Example {
|
|
694
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
695
|
-
* // static staticProperty;
|
|
696
|
-
* // property;
|
|
697
|
-
*
|
|
698
|
-
* static staticMethod(p) { }
|
|
699
|
-
* method(p) { }
|
|
700
|
-
* }
|
|
701
|
-
*
|
|
702
|
-
* // on contructor
|
|
703
|
-
* result = Metadata.getReturnType(Example);
|
|
704
|
-
*
|
|
705
|
-
* // property (on constructor)
|
|
706
|
-
* result = Metadata.getReturnType(Example, "staticProperty");
|
|
707
|
-
*
|
|
708
|
-
* // method (on constructor)
|
|
709
|
-
* result = Metadata.getReturnType(Example, "staticMethod");
|
|
710
|
-
* ```
|
|
711
|
-
*
|
|
712
|
-
*/
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
static getReturnType(target, propertyKey) {
|
|
716
|
-
return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.
|
|
720
|
-
* @param target The target object on which the metadata is defined.
|
|
721
|
-
* @param propertyKey The property key for the target.
|
|
722
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
723
|
-
* @example
|
|
724
|
-
*
|
|
725
|
-
* ```typescript
|
|
726
|
-
* class Example {
|
|
727
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
728
|
-
* // static staticProperty;
|
|
729
|
-
* // property;
|
|
730
|
-
*
|
|
731
|
-
* static staticMethod(p) { }
|
|
732
|
-
* method(p) { }
|
|
733
|
-
* }
|
|
734
|
-
*
|
|
735
|
-
* // on contructor
|
|
736
|
-
* result = Metadata.getOwnReturnType(Example);
|
|
737
|
-
*
|
|
738
|
-
* // property (on constructor)
|
|
739
|
-
* result = Metadata.getOwnReturnType(Example, "staticProperty");
|
|
740
|
-
*
|
|
741
|
-
* // method (on constructor)
|
|
742
|
-
* result = Metadata.getOwnReturnType(Example, "staticMethod");
|
|
743
|
-
* ```
|
|
744
|
-
*
|
|
745
|
-
*/
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
static getOwnReturnType(target, propertyKey) {
|
|
749
|
-
return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
|
753
|
-
* @param key A key used to store and retrieve metadata.
|
|
754
|
-
* @param target The target object on which the metadata is defined.
|
|
755
|
-
* @param propertyKey The property key for the target.
|
|
756
|
-
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
|
757
|
-
* @example
|
|
758
|
-
*
|
|
759
|
-
* ```typescript
|
|
760
|
-
* class Example {
|
|
761
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
762
|
-
* // static staticProperty;
|
|
763
|
-
* // property;
|
|
764
|
-
*
|
|
765
|
-
* static staticMethod(p) { }
|
|
766
|
-
* method(p) { }
|
|
767
|
-
* }
|
|
768
|
-
*
|
|
769
|
-
* // constructor
|
|
770
|
-
* result = Metadata.has("custom:annotation", Example);
|
|
771
|
-
*
|
|
772
|
-
* // property (on constructor)
|
|
773
|
-
* result = Metadata.has("custom:annotation", Example, "staticProperty");
|
|
774
|
-
*
|
|
775
|
-
* // property (on prototype)
|
|
776
|
-
* result = Metadata.has("custom:annotation", Example.prototype, "property");
|
|
777
|
-
*
|
|
778
|
-
* // method (on constructor)
|
|
779
|
-
* result = Metadata.has("custom:annotation", Example, "staticMethod");
|
|
780
|
-
*
|
|
781
|
-
* // method (on prototype)
|
|
782
|
-
* result = Metadata.has("custom:annotation", Example.prototype, "method");
|
|
783
|
-
* ```
|
|
784
|
-
*
|
|
785
|
-
*/
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
static has(key, target, propertyKey) {
|
|
789
|
-
try {
|
|
790
|
-
return Reflect.hasMetadata(key, classOf(target), propertyKey);
|
|
791
|
-
} catch (er) {}
|
|
792
|
-
|
|
793
|
-
return false;
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
|
797
|
-
* @param key A key used to store and retrieve metadata.
|
|
798
|
-
* @param target The target object on which the metadata is defined.
|
|
799
|
-
* @param propertyKey The property key for the target.
|
|
800
|
-
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
|
801
|
-
* @example
|
|
802
|
-
*
|
|
803
|
-
* ```typescript
|
|
804
|
-
* class Example {
|
|
805
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
806
|
-
* // static staticProperty;
|
|
807
|
-
* // property;
|
|
808
|
-
*
|
|
809
|
-
* static staticMethod(p) { }
|
|
810
|
-
* method(p) { }
|
|
811
|
-
* }
|
|
812
|
-
*
|
|
813
|
-
* // constructor
|
|
814
|
-
* result = Metadata.has("custom:annotation", Example);
|
|
815
|
-
*
|
|
816
|
-
* // property (on constructor)
|
|
817
|
-
* result = Metadata.hasOwn("custom:annotation", Example, "staticProperty");
|
|
818
|
-
*
|
|
819
|
-
* // property (on prototype)
|
|
820
|
-
* result = Metadata.hasOwn("custom:annotation", Example.prototype, "property");
|
|
821
|
-
*
|
|
822
|
-
* // method (on constructor)
|
|
823
|
-
* result = Metadata.hasOwn("custom:annotation", Example, "staticMethod");
|
|
824
|
-
*
|
|
825
|
-
* // method (on prototype)
|
|
826
|
-
* result = Metadata.hasOwn("custom:annotation", Example.prototype, "method");
|
|
827
|
-
* ```
|
|
828
|
-
*
|
|
829
|
-
*/
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
static hasOwn(key, target, propertyKey) {
|
|
833
|
-
return Reflect.hasOwnMetadata(key, classOf(target), propertyKey);
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* Deletes the metadata entry from the target object with the provided key.
|
|
837
|
-
* @param key A key used to store and retrieve metadata.
|
|
838
|
-
* @param target The target object on which the metadata is defined.
|
|
839
|
-
* @param propertyKey The property key for the target.
|
|
840
|
-
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
|
841
|
-
* @example
|
|
842
|
-
*
|
|
843
|
-
* ```typescript
|
|
844
|
-
* class Example {
|
|
845
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
846
|
-
* // static staticProperty;
|
|
847
|
-
* // property;
|
|
848
|
-
*
|
|
849
|
-
* static staticMethod(p) { }
|
|
850
|
-
* method(p) { }
|
|
851
|
-
* }
|
|
852
|
-
*
|
|
853
|
-
* // constructor
|
|
854
|
-
* result = Metadata.delete("custom:annotation", Example);
|
|
855
|
-
*
|
|
856
|
-
* // property (on constructor)
|
|
857
|
-
* result = Metadata.delete("custom:annotation", Example, "staticProperty");
|
|
858
|
-
*
|
|
859
|
-
* // property (on prototype)
|
|
860
|
-
* result = Metadata.delete("custom:annotation", Example.prototype, "property");
|
|
861
|
-
*
|
|
862
|
-
* // method (on constructor)
|
|
863
|
-
* result = Metadata.delete("custom:annotation", Example, "staticMethod");
|
|
864
|
-
*
|
|
865
|
-
* // method (on prototype)
|
|
866
|
-
* result = Metadata.delete("custom:annotation", Example.prototype, "method");
|
|
867
|
-
* ```
|
|
868
|
-
*
|
|
869
|
-
*/
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
static delete(key, target, propertyKey) {
|
|
873
|
-
return Reflect.deleteMetadata(key, classOf(target), propertyKey);
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
877
|
-
* @param target The target object on which the metadata is defined.
|
|
878
|
-
* @param propertyKey The property key for the target.
|
|
879
|
-
* @param value A value that contains attached metadata.
|
|
880
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
881
|
-
* @example
|
|
882
|
-
*
|
|
883
|
-
* ```typescript
|
|
884
|
-
* class Example {
|
|
885
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
886
|
-
* // static staticProperty;
|
|
887
|
-
* // property;
|
|
888
|
-
*
|
|
889
|
-
* static staticMethod(p) { }
|
|
890
|
-
* method(p) { }
|
|
891
|
-
* }
|
|
892
|
-
*
|
|
893
|
-
* // on contructor
|
|
894
|
-
* result = Metadata.setParamTypes(Example, undefined, [Object]);
|
|
895
|
-
*
|
|
896
|
-
* // property (on constructor)
|
|
897
|
-
* result = Metadata.setParamTypes(Example, "staticProperty", [Object]);
|
|
898
|
-
*
|
|
899
|
-
* // property (on prototype)
|
|
900
|
-
* result = Metadata.setParamTypes(Example.prototype, "property", [Object]);
|
|
901
|
-
*
|
|
902
|
-
* // method (on constructor)
|
|
903
|
-
* result = Metadata.setParamTypes(Example, "staticMethod", [Object]);
|
|
904
|
-
*
|
|
905
|
-
* // method (on prototype)
|
|
906
|
-
* result = Metadata.setParamTypes(Example.prototype, "method", [Object]);
|
|
907
|
-
* ```
|
|
908
|
-
*
|
|
909
|
-
*/
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
static setParamTypes(target, propertyKey, value) {
|
|
913
|
-
return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Define a unique metadata entry on the target.
|
|
917
|
-
* @param key A key used to store and retrieve metadata.
|
|
918
|
-
* @param value A value that contains attached metadata.
|
|
919
|
-
* @param target The target object on which to define metadata.
|
|
920
|
-
* @param propertyKey The property key for the target.
|
|
921
|
-
* @example
|
|
922
|
-
*
|
|
923
|
-
* ```typescript
|
|
924
|
-
* class Example {
|
|
925
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
926
|
-
* // static staticProperty;
|
|
927
|
-
* // property;
|
|
928
|
-
*
|
|
929
|
-
* static staticMethod(p) { }
|
|
930
|
-
* method(p) { }
|
|
931
|
-
* }
|
|
932
|
-
*
|
|
933
|
-
* // constructor
|
|
934
|
-
* Reflect.defineMetadata("custom:annotation", options, Example);
|
|
935
|
-
*
|
|
936
|
-
* // property (on constructor)
|
|
937
|
-
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticProperty");
|
|
938
|
-
*
|
|
939
|
-
* // property (on prototype)
|
|
940
|
-
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "property");
|
|
941
|
-
*
|
|
942
|
-
* // method (on constructor)
|
|
943
|
-
* Reflect.defineMetadata("custom:annotation", Number, Example, "staticMethod");
|
|
944
|
-
*
|
|
945
|
-
* // method (on prototype)
|
|
946
|
-
* Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "method");
|
|
947
|
-
*
|
|
948
|
-
* // decorator factory as metadata-producing annotation.
|
|
949
|
-
* function MyAnnotation(options): PropertyDecorator {
|
|
950
|
-
* return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
|
951
|
-
* }
|
|
952
|
-
* ```
|
|
953
|
-
*
|
|
954
|
-
*/
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
static set(key, value, target, propertyKey) {
|
|
958
|
-
const targets = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];
|
|
959
|
-
const classConstructor = classOf(target);
|
|
960
|
-
|
|
961
|
-
if (targets.indexOf(classConstructor) === -1) {
|
|
962
|
-
targets.push(classConstructor);
|
|
963
|
-
PROPERTIES.set(key, targets);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
Reflect.defineMetadata(key, value, classOf(target), propertyKey);
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
970
|
-
* @param targetPrototype
|
|
971
|
-
* @param propertyKey The property key for the target.
|
|
972
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
973
|
-
* @example
|
|
974
|
-
*
|
|
975
|
-
* ```typescript
|
|
976
|
-
* class Example {
|
|
977
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
978
|
-
* // static staticProperty;
|
|
979
|
-
* // property;
|
|
980
|
-
*
|
|
981
|
-
* static staticMethod(p) { }
|
|
982
|
-
* method(p) { }
|
|
983
|
-
* }
|
|
984
|
-
*
|
|
985
|
-
* // on contructor
|
|
986
|
-
* result = Metadata.getParamTypes(Example.prototype);
|
|
987
|
-
*
|
|
988
|
-
* // property (on constructor)
|
|
989
|
-
* result = Metadata.getParamTypes(Example.prototype, "staticProperty");
|
|
990
|
-
*
|
|
991
|
-
* // method (on constructor)
|
|
992
|
-
* result = Metadata.getParamTypes(Example.prototype, "staticMethod");
|
|
993
|
-
* ```
|
|
994
|
-
*
|
|
995
|
-
*/
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
static getParamTypes(targetPrototype, propertyKey) {
|
|
999
|
-
return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey) || [];
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.
|
|
1003
|
-
* @param target The target object on which the metadata is defined.
|
|
1004
|
-
* @param propertyKey The property key for the target.
|
|
1005
|
-
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
1006
|
-
* @example
|
|
1007
|
-
*
|
|
1008
|
-
* ```typescript
|
|
1009
|
-
* class Example {
|
|
1010
|
-
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
1011
|
-
* // static staticProperty;
|
|
1012
|
-
* // property;
|
|
1013
|
-
*
|
|
1014
|
-
* static staticMethod(p) { }
|
|
1015
|
-
* method(p) { }
|
|
1016
|
-
* }
|
|
1017
|
-
*
|
|
1018
|
-
* // on contructor
|
|
1019
|
-
* result = Metadata.getParamTypes(Example);
|
|
1020
|
-
*
|
|
1021
|
-
* // property (on constructor)
|
|
1022
|
-
* result = Metadata.getParamTypes(Example, "staticProperty");
|
|
1023
|
-
*
|
|
1024
|
-
* // method (on constructor)
|
|
1025
|
-
* result = Metadata.getParamTypes(Example, "staticMethod");
|
|
1026
|
-
* ```
|
|
1027
|
-
*
|
|
1028
|
-
*/
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
static getOwnParamTypes(target, propertyKey) {
|
|
1032
|
-
return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey) || [];
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* Get all metadata for a metadataKey.
|
|
1038
|
-
* @param metadataKey
|
|
1039
|
-
*/
|
|
1040
|
-
|
|
1041
|
-
Metadata.getTargetsFromPropertyKey = metadataKey => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
|
|
1042
|
-
|
|
1043
|
-
/**
|
|
1044
|
-
* @ignore
|
|
1045
|
-
*/
|
|
1046
|
-
|
|
1047
|
-
const CLASS_STORE = "tsed:class:store";
|
|
1048
|
-
/**
|
|
1049
|
-
* @ignore
|
|
1050
|
-
*/
|
|
1051
|
-
|
|
1052
|
-
const METHOD_STORE = "tsed:method:store";
|
|
1053
|
-
/**
|
|
1054
|
-
* @ignore
|
|
1055
|
-
*/
|
|
1056
|
-
|
|
1057
|
-
const PROPERTY_STORE = "tsed:property:store";
|
|
1058
|
-
/**
|
|
1059
|
-
* @ignore
|
|
1060
|
-
*/
|
|
1061
|
-
|
|
1062
|
-
const PARAM_STORE = "tsed:param:store";
|
|
1063
|
-
const stores = new Map();
|
|
1064
|
-
|
|
1065
|
-
function storeGet(key, ...args) {
|
|
1066
|
-
if (isSymbol(args[0])) {
|
|
1067
|
-
if (!stores.has(args[0])) {
|
|
1068
|
-
stores.set(args[0], new Store());
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
return stores.get(args[0]);
|
|
1072
|
-
} else {
|
|
1073
|
-
const registry = Metadata;
|
|
1074
|
-
|
|
1075
|
-
if (!registry.hasOwn(key, ...args)) {
|
|
1076
|
-
registry.set(key, new Store(), ...args);
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
return registry.getOwn(key, ...args);
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function defineStore(args) {
|
|
1084
|
-
const [target, propertyKey, descriptor] = args;
|
|
1085
|
-
|
|
1086
|
-
switch (decoratorTypeOf(args)) {
|
|
1087
|
-
case DecoratorTypes.PARAM_CTOR:
|
|
1088
|
-
case DecoratorTypes.PARAM_STC:
|
|
1089
|
-
case DecoratorTypes.PARAM:
|
|
1090
|
-
const store = storeGet(PARAM_STORE, target, propertyKey);
|
|
1091
|
-
|
|
1092
|
-
if (!store.has("" + descriptor)) {
|
|
1093
|
-
store.set("" + descriptor, new Store());
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
return store.get("" + descriptor);
|
|
1097
|
-
|
|
1098
|
-
case DecoratorTypes.PROP:
|
|
1099
|
-
case DecoratorTypes.PROP_STC:
|
|
1100
|
-
return storeGet(PROPERTY_STORE, target, propertyKey);
|
|
1101
|
-
|
|
1102
|
-
case DecoratorTypes.METHOD:
|
|
1103
|
-
case DecoratorTypes.METHOD_STC:
|
|
1104
|
-
return storeGet(METHOD_STORE, target, propertyKey);
|
|
1105
|
-
|
|
1106
|
-
case DecoratorTypes.CLASS:
|
|
1107
|
-
return storeGet(CLASS_STORE, target);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
class Store {
|
|
1112
|
-
constructor() {
|
|
1113
|
-
this._entries = new Map();
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Create or get a Store from args {target + methodName + descriptor}
|
|
1117
|
-
* @param args
|
|
1118
|
-
* @returns {Store}
|
|
1119
|
-
*/
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
static from(...args) {
|
|
1123
|
-
return defineStore(args);
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Create store on the method.
|
|
1127
|
-
* @param target
|
|
1128
|
-
* @param {string} propertyKey
|
|
1129
|
-
* @returns {Store}
|
|
1130
|
-
*/
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
static fromMethod(target, propertyKey) {
|
|
1134
|
-
return Store.from(target, propertyKey, descriptorOf(target, propertyKey));
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
static mergeStoreFrom(target, source, ...args) {
|
|
1138
|
-
const store = Store.from(target, ...args);
|
|
1139
|
-
|
|
1140
|
-
Store.from(source, ...args)._entries.forEach((value, key) => {
|
|
1141
|
-
store.merge(key, value);
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
return store;
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
static mergeStoreMethodFrom(target, source, propertyKey) {
|
|
1148
|
-
return this.mergeStoreFrom(target, source, propertyKey, descriptorOf(target, propertyKey));
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* The get() method returns a specified element from a Map object.
|
|
1152
|
-
* @param key Required. The key of the element to return from the Map object.
|
|
1153
|
-
* @param defaultValue
|
|
1154
|
-
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
1155
|
-
*/
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
get(key, defaultValue) {
|
|
1159
|
-
return this._entries.get(nameOf(key)) || defaultValue;
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
1163
|
-
* @param key
|
|
1164
|
-
* @returns {boolean}
|
|
1165
|
-
*/
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
has(key) {
|
|
1169
|
-
return this._entries.has(nameOf(key));
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* The set() method adds or updates an element with a specified key and value to a Map object.
|
|
1173
|
-
* @param key Required. The key of the element to add to the Map object.
|
|
1174
|
-
* @param metadata Required. The value of the element to add to the Map object.
|
|
1175
|
-
*/
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
set(key, metadata) {
|
|
1179
|
-
this._entries.set(nameOf(key), metadata);
|
|
1180
|
-
|
|
1181
|
-
return this;
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* The delete() method removes the specified element from a Map object.
|
|
1185
|
-
* @param key Required. The key of the element to remove from the Map object.
|
|
1186
|
-
* @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
|
|
1187
|
-
*/
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
delete(key) {
|
|
1191
|
-
return this._entries.delete(nameOf(key));
|
|
1192
|
-
}
|
|
1193
|
-
/**
|
|
1194
|
-
* Merge given value with existing value.
|
|
1195
|
-
* @param key
|
|
1196
|
-
* @param value
|
|
1197
|
-
* @param inverse Change the merge order. Get the existing value and apply over given value
|
|
1198
|
-
* @returns {Store}
|
|
1199
|
-
*/
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
merge(key, value, inverse = false) {
|
|
1203
|
-
let _value_ = this.get(key);
|
|
1204
|
-
|
|
1205
|
-
if (_value_) {
|
|
1206
|
-
value = deepClone(value);
|
|
1207
|
-
_value_ = deepClone(_value_);
|
|
1208
|
-
value = inverse ? deepMerge(value, _value_) : deepMerge(_value_, value);
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
this.set(key, value);
|
|
1212
|
-
return this;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
toJson() {
|
|
1216
|
-
return [...this._entries.entries()].reduce((obj, [key, value]) => {
|
|
1217
|
-
return _extends({}, obj, {
|
|
1218
|
-
[key]: value
|
|
1219
|
-
});
|
|
1220
|
-
}, {});
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
function decorateMethodsOf(klass, decorator) {
|
|
1226
|
-
methodsOf(klass).forEach(({
|
|
1227
|
-
target,
|
|
1228
|
-
propertyKey
|
|
1229
|
-
}) => {
|
|
1230
|
-
if (target !== classOf(klass)) {
|
|
1231
|
-
Object.defineProperty(prototypeOf(klass), propertyKey, {
|
|
1232
|
-
value(...args) {
|
|
1233
|
-
return prototypeOf(target)[propertyKey].apply(this, args);
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
});
|
|
1237
|
-
Store.mergeStoreMethodFrom(klass, target, propertyKey);
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
decorator(prototypeOf(klass), propertyKey, descriptorOf(klass, propertyKey));
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
function decoratorArgs(target, propertyKey) {
|
|
1245
|
-
return [target, propertyKey, descriptorOf(target, propertyKey)];
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
function inheritedDescriptorOf(target, propertyKey) {
|
|
1249
|
-
for (const klass of ancestorsOf(target)) {
|
|
1250
|
-
const descriptor = Object.getOwnPropertyDescriptor(klass && klass.prototype || klass, propertyKey);
|
|
1251
|
-
|
|
1252
|
-
if (descriptor) {
|
|
1253
|
-
return descriptor;
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
return undefined;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
function useDecorators(...decorators) {
|
|
1261
|
-
return (...args) => {
|
|
1262
|
-
decorators.filter(o => !!o).forEach(decorator => {
|
|
1263
|
-
decorator(...args);
|
|
1264
|
-
});
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
function useMethodDecorator(decorator) {
|
|
1269
|
-
return (target, propertyKey) => decorator(target, propertyKey, descriptorOf(target, propertyKey));
|
|
1270
|
-
}
|
|
1271
|
-
function useMethodDecorators(...decorators) {
|
|
1272
|
-
return (target, propertyKey) => {
|
|
1273
|
-
decorators.filter(Boolean).forEach(decorator => decorator(target, propertyKey, descriptorOf(target, propertyKey)));
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
/**
|
|
1278
|
-
* Remove undefined value
|
|
1279
|
-
* @param obj
|
|
1280
|
-
* @param ignore
|
|
1281
|
-
*/
|
|
1282
|
-
|
|
1283
|
-
function cleanObject(obj, ignore = []) {
|
|
1284
|
-
return Object.entries(obj).reduce((obj, [key, value]) => {
|
|
1285
|
-
if (isProtectedKey(key) || ignore.includes(key)) {
|
|
1286
|
-
return obj;
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
return value === undefined ? obj : _extends({}, obj, {
|
|
1290
|
-
[key]: value
|
|
1291
|
-
});
|
|
1292
|
-
}, {});
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
/**
|
|
1296
|
-
* Get the class constructor
|
|
1297
|
-
* @param target
|
|
1298
|
-
*/
|
|
1299
|
-
function getConstructor(target) {
|
|
1300
|
-
return typeof target === "function" ? target : target.constructor;
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
* Get the class constructor
|
|
1304
|
-
* @param target
|
|
1305
|
-
*/
|
|
1306
|
-
|
|
1307
|
-
function constructorOf(target) {
|
|
1308
|
-
return getConstructor(target);
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
function isArrowFn(target) {
|
|
1312
|
-
return target && isFunction(target) && !target.prototype;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
/**
|
|
1316
|
-
*
|
|
1317
|
-
* @param target
|
|
1318
|
-
* @returns {boolean}
|
|
1319
|
-
*/
|
|
1320
|
-
|
|
1321
|
-
function isClassObject(target) {
|
|
1322
|
-
return target === Object;
|
|
1323
|
-
}
|
|
1324
|
-
function isPlainObject(target) {
|
|
1325
|
-
return isClassObject(classOf(target)) && target !== Object;
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Tests to see if the object is an ES2015 (ES6) Promise
|
|
1330
|
-
* @see {@link https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects}
|
|
1331
|
-
* @param target
|
|
1332
|
-
* @returns {boolean}
|
|
1333
|
-
*/
|
|
1334
|
-
function isPromise(target) {
|
|
1335
|
-
return target === Promise || target instanceof Promise || !!target && typeof target.subscribe !== "function" && typeof target.then === "function";
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
function isClass(target) {
|
|
1339
|
-
if (!target) {
|
|
1340
|
-
return false;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
if (isArrowFn(target)) {
|
|
1344
|
-
return false;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
return !(isSymbol(target) || isPrimitiveOrPrimitiveClass(target) || isClassObject(target) || isDate(target) || isPromise(target) || isArrayOrArrayClass(target));
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
function getClassOrSymbol(target) {
|
|
1351
|
-
return isClass(target) ? classOf(target) : target;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
function toStringConstructor(target) {
|
|
1355
|
-
const ctr = constructorOf(target);
|
|
1356
|
-
const strings = ctr.toString().split("\n");
|
|
1357
|
-
const ctrString = strings.find(s => s.indexOf("constructor(") > -1) || "constructor()";
|
|
1358
|
-
return `${ctrString.replace("{", "").trim()}`;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
function getConstructorArgNames(target) {
|
|
1362
|
-
return toStringConstructor(target).replace("constructor(", "").replace(")", "").split(", ").filter(Boolean);
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
*
|
|
1367
|
-
* @param obj
|
|
1368
|
-
* @param key
|
|
1369
|
-
*/
|
|
1370
|
-
|
|
1371
|
-
function isEnumerable(obj, key) {
|
|
1372
|
-
const klass = classOf(obj);
|
|
1373
|
-
|
|
1374
|
-
if (klass) {
|
|
1375
|
-
const descriptor = inheritedDescriptorOf(klass, key);
|
|
1376
|
-
|
|
1377
|
-
if (descriptor) {
|
|
1378
|
-
return descriptor.enumerable;
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
return Object.prototype.propertyIsEnumerable.call(obj, key);
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* Return all enumerable keys of the given object
|
|
1387
|
-
* @param obj
|
|
1388
|
-
*/
|
|
1389
|
-
|
|
1390
|
-
function getEnumerableKeys(obj) {
|
|
1391
|
-
const keys = [];
|
|
1392
|
-
|
|
1393
|
-
for (const key in obj) {
|
|
1394
|
-
if (!isProtectedKey(key) && isEnumerable(obj, key)) {
|
|
1395
|
-
keys.push(key);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
return keys;
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
function isObject(target) {
|
|
1403
|
-
return typeof target === "object";
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
const mapOptions = args => {
|
|
1407
|
-
const [expression, scope, defaultValue, separator = "."] = args;
|
|
1408
|
-
|
|
1409
|
-
if (isObject(scope) || isString(expression)) {
|
|
1410
|
-
return {
|
|
1411
|
-
expression,
|
|
1412
|
-
scope,
|
|
1413
|
-
defaultValue,
|
|
1414
|
-
separator
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
return {
|
|
1419
|
-
expression: scope,
|
|
1420
|
-
scope: expression,
|
|
1421
|
-
defaultValue,
|
|
1422
|
-
separator
|
|
1423
|
-
};
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
function getValue(...args) {
|
|
1427
|
-
const options = mapOptions(args);
|
|
1428
|
-
let scope = options.scope;
|
|
1429
|
-
const {
|
|
1430
|
-
expression,
|
|
1431
|
-
defaultValue,
|
|
1432
|
-
separator
|
|
1433
|
-
} = options;
|
|
1434
|
-
|
|
1435
|
-
if (!expression) {
|
|
1436
|
-
return scope;
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
if (!scope) {
|
|
1440
|
-
return defaultValue;
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
const keys = expression.split(separator);
|
|
1444
|
-
|
|
1445
|
-
const getValue = key => {
|
|
1446
|
-
if (scope) {
|
|
1447
|
-
if (scope[key] !== undefined || key in scope) {
|
|
1448
|
-
return scope[key];
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
if (isFunction(scope.get)) {
|
|
1452
|
-
return scope.get(key);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
};
|
|
1456
|
-
|
|
1457
|
-
while ((scope = getValue(keys.shift())) && keys.length) {}
|
|
1458
|
-
|
|
1459
|
-
return scope === undefined ? defaultValue : scope;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
/**
|
|
1463
|
-
* Return true if the target.
|
|
1464
|
-
* @param target
|
|
1465
|
-
* @returns {boolean}
|
|
1466
|
-
*/
|
|
1467
|
-
|
|
1468
|
-
function isCollection(target) {
|
|
1469
|
-
return isArrayOrArrayClass(target) || target === Map || target instanceof Map || target === Set || target instanceof Set || target === WeakMap || target instanceof WeakMap || target === WeakSet || target instanceof WeakSet;
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
/**
|
|
1473
|
-
* Return true if the value is an empty string, null or undefined.
|
|
1474
|
-
* @param value
|
|
1475
|
-
* @returns {boolean}
|
|
1476
|
-
*/
|
|
1477
|
-
|
|
1478
|
-
function isEmpty(value) {
|
|
1479
|
-
return value === "" || isNil(value);
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
function isInheritedFrom(target, from, deep = 5) {
|
|
1483
|
-
if (!target || !from) {
|
|
1484
|
-
return false;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
target = classOf(target);
|
|
1488
|
-
from = classOf(from);
|
|
1489
|
-
|
|
1490
|
-
while (nameOf(target) !== "") {
|
|
1491
|
-
if (!deep) {
|
|
1492
|
-
return false;
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
if (target === from) {
|
|
1496
|
-
return true;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
target = ancestorOf(target);
|
|
1500
|
-
deep--;
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
|
-
return false;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
function isObservable(obj) {
|
|
1507
|
-
return !!obj && typeof obj.lift === "function" && typeof obj.subscribe === "function";
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
function isStream(obj) {
|
|
1511
|
-
return obj !== null && typeof obj === "object" && typeof obj.pipe === "function";
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
function isSerializable(data) {
|
|
1515
|
-
return !(Buffer.isBuffer(data) || isStream(data) || isBoolean(data) || isNumber(data) || isString(data) || isNil(data));
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
function primitiveOf(target) {
|
|
1519
|
-
if (isStringOrStringClass(target)) {
|
|
1520
|
-
return "string";
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
if (isNumberOrNumberClass(target)) {
|
|
1524
|
-
return "number";
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
if (isBooleanOrBooleanClass(target)) {
|
|
1528
|
-
return "boolean";
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
return "any";
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
function setValue(scope, expression, value, separator = ".") {
|
|
1535
|
-
const keys = expression.split(separator);
|
|
1536
|
-
|
|
1537
|
-
const setValue = (key, add) => {
|
|
1538
|
-
if (isProtectedKey(key)) {
|
|
1539
|
-
return false;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
if (add) {
|
|
1543
|
-
if (typeof scope.set === "function") {
|
|
1544
|
-
scope.set(key, value);
|
|
1545
|
-
} else {
|
|
1546
|
-
scope[key] = value;
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
return false;
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
if (typeof scope.set === "function") {
|
|
1553
|
-
if (!scope.has(key)) {
|
|
1554
|
-
scope.set(key, {});
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
scope = scope.get(key);
|
|
1558
|
-
} else {
|
|
1559
|
-
scope = scope[key] = scope[key] || {};
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
return true;
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
while (setValue(keys.shift(), !keys.length)) {}
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
function createIdentityFn(keyOrFn) {
|
|
1569
|
-
if (!keyOrFn) {
|
|
1570
|
-
return (v, k) => String(k);
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
if (isString(keyOrFn)) {
|
|
1574
|
-
return item => {
|
|
1575
|
-
return item[keyOrFn];
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
return keyOrFn;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
function toMap(input, keyOrFn) {
|
|
1583
|
-
if (isArray(input)) {
|
|
1584
|
-
const _identity = createIdentityFn(keyOrFn || "id");
|
|
1585
|
-
|
|
1586
|
-
return input.reduce((map, value, index) => {
|
|
1587
|
-
const ids = [].concat(_identity(value, index));
|
|
1588
|
-
ids.forEach(id => map.set(id, value));
|
|
1589
|
-
return map;
|
|
1590
|
-
}, new Map());
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
const identity = createIdentityFn(keyOrFn);
|
|
1594
|
-
return Object.entries(input).reduce((map, [key, value]) => {
|
|
1595
|
-
return map.set(identity(value, key), value);
|
|
1596
|
-
}, new Map());
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
class Entity {
|
|
1600
|
-
constructor({
|
|
1601
|
-
target,
|
|
1602
|
-
propertyKey,
|
|
1603
|
-
descriptor,
|
|
1604
|
-
index
|
|
1605
|
-
}) {
|
|
1606
|
-
this._target = target;
|
|
1607
|
-
this.propertyKey = propertyKey;
|
|
1608
|
-
this.propertyName = String(propertyKey);
|
|
1609
|
-
this.descriptor = descriptor;
|
|
1610
|
-
this.index = index;
|
|
1611
|
-
this.decoratorType = decoratorTypeOf([target, propertyKey, descriptor || index]);
|
|
1612
|
-
this.token = target && classOf(target);
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* Reference to the class
|
|
1616
|
-
*/
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
get target() {
|
|
1620
|
-
return this._target;
|
|
1621
|
-
}
|
|
1622
|
-
/**
|
|
1623
|
-
* Return the class name of the entity.
|
|
1624
|
-
* @returns {string}
|
|
1625
|
-
*/
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
get targetName() {
|
|
1629
|
-
return nameOf(this.token);
|
|
1630
|
-
}
|
|
1631
|
-
/**
|
|
1632
|
-
*
|
|
1633
|
-
* @returns {Type<any>}
|
|
1634
|
-
*/
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
get type() {
|
|
1638
|
-
return this._type;
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Get original type without transformation
|
|
1642
|
-
* @param value
|
|
1643
|
-
*/
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
set type(value) {
|
|
1647
|
-
this._type = value;
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* Return the itemSchema target type. if the type is a function used for recursive model, the function will be called to
|
|
1651
|
-
* get the right type.
|
|
1652
|
-
*/
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
get computedType() {
|
|
1656
|
-
return this._type;
|
|
1657
|
-
}
|
|
1658
|
-
/**
|
|
1659
|
-
*
|
|
1660
|
-
* @returns {boolean}
|
|
1661
|
-
*/
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
get isCollection() {
|
|
1665
|
-
return !!this.collectionType;
|
|
1666
|
-
}
|
|
1667
|
-
/**
|
|
1668
|
-
*
|
|
1669
|
-
* @returns {boolean}
|
|
1670
|
-
*/
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
get isArray() {
|
|
1674
|
-
return isArrayOrArrayClass(this.collectionType);
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
*
|
|
1678
|
-
* @returns {boolean}
|
|
1679
|
-
*/
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
get isPrimitive() {
|
|
1683
|
-
return isPrimitiveOrPrimitiveClass(this._type);
|
|
1684
|
-
}
|
|
1685
|
-
/**
|
|
1686
|
-
*
|
|
1687
|
-
* @returns {boolean}
|
|
1688
|
-
*/
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
get isDate() {
|
|
1692
|
-
return isDate(this.computedType);
|
|
1693
|
-
}
|
|
1694
|
-
/**
|
|
1695
|
-
*
|
|
1696
|
-
* @returns {boolean}
|
|
1697
|
-
*/
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
get isObject() {
|
|
1701
|
-
return isObject(this.computedType);
|
|
1702
|
-
}
|
|
1703
|
-
/**
|
|
1704
|
-
*
|
|
1705
|
-
*/
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
get isClass() {
|
|
1709
|
-
return isClass(this.computedType);
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
/**
|
|
1715
|
-
*
|
|
1716
|
-
*/
|
|
1717
|
-
var Env;
|
|
1718
|
-
|
|
1719
|
-
(function (Env) {
|
|
1720
|
-
Env["PROD"] = "production";
|
|
1721
|
-
Env["DEV"] = "development";
|
|
1722
|
-
Env["TEST"] = "test";
|
|
1723
|
-
})(Env || (Env = {}));
|
|
1724
|
-
/**
|
|
1725
|
-
* Fallback
|
|
1726
|
-
* @type {Env}
|
|
1727
|
-
*/
|
|
1728
|
-
// tslint:disable-next-line: variable-name
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
const EnvTypes = Env;
|
|
1732
|
-
|
|
1733
|
-
class Hooks {
|
|
1734
|
-
constructor() {
|
|
1735
|
-
this.listeners = new Map();
|
|
1736
|
-
}
|
|
1737
|
-
/**
|
|
1738
|
-
* Listen a hook event
|
|
1739
|
-
* @param event
|
|
1740
|
-
* @param cb
|
|
1741
|
-
*/
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
on(event, cb) {
|
|
1745
|
-
if (!this.listeners.has(event)) {
|
|
1746
|
-
this.listeners.set(event, []);
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
this.listeners.get(event).push(cb);
|
|
1750
|
-
return this;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* Remove a listener attached to an event
|
|
1754
|
-
* @param event
|
|
1755
|
-
* @param cb
|
|
1756
|
-
*/
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
off(event, cb) {
|
|
1760
|
-
if (this.listeners.has(event)) {
|
|
1761
|
-
this.listeners.set(event, this.listeners.get(event).filter(item => item === cb));
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
return this;
|
|
1765
|
-
}
|
|
1766
|
-
/**
|
|
1767
|
-
* Trigger an event and call listener.
|
|
1768
|
-
* @param event
|
|
1769
|
-
* @param args
|
|
1770
|
-
* @param callThis
|
|
1771
|
-
*/
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
emit(event, args = [], callThis = null) {
|
|
1775
|
-
if (this.listeners.has(event)) {
|
|
1776
|
-
for (const cb of this.listeners.get(event)) {
|
|
1777
|
-
cb.call(callThis, ...args);
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
/**
|
|
1782
|
-
* Trigger an event, listener alter given value and return it.
|
|
1783
|
-
* @param event
|
|
1784
|
-
* @param value
|
|
1785
|
-
* @param args
|
|
1786
|
-
* @param callThis
|
|
1787
|
-
*/
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
alter(event, value, args = [], callThis = null) {
|
|
1791
|
-
if (this.listeners.has(event)) {
|
|
1792
|
-
for (const cb of this.listeners.get(event)) {
|
|
1793
|
-
value = cb.call(callThis, value, ...args);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
return value;
|
|
1798
|
-
}
|
|
1799
|
-
/**
|
|
1800
|
-
* Trigger an event and call async listener.
|
|
1801
|
-
* @param event
|
|
1802
|
-
* @param args
|
|
1803
|
-
* @param callThis
|
|
1804
|
-
*/
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
async asyncEmit(event, args = [], callThis = null) {
|
|
1808
|
-
if (this.listeners.has(event)) {
|
|
1809
|
-
for (const cb of this.listeners.get(event)) {
|
|
1810
|
-
await cb.call(callThis, ...args);
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* Trigger an event, async listener alter given value and return it.
|
|
1816
|
-
* @param event
|
|
1817
|
-
* @param value
|
|
1818
|
-
* @param args
|
|
1819
|
-
* @param callThis
|
|
1820
|
-
*/
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
async asyncAlter(event, value, args = [], callThis = null) {
|
|
1824
|
-
if (this.listeners.has(event)) {
|
|
1825
|
-
for (const cb of this.listeners.get(event)) {
|
|
1826
|
-
value = await cb.call(callThis, value, ...args);
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
return value;
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
const Type = Function; // @ts-ignore
|
|
1836
|
-
|
|
1837
|
-
global.Type = Type;
|
|
1838
|
-
|
|
1839
|
-
/**
|
|
1840
|
-
* @ignore
|
|
1841
|
-
*/
|
|
1842
|
-
|
|
1843
|
-
function isResponse(obj) {
|
|
1844
|
-
return obj.data && obj.headers && obj.status && obj.statusText;
|
|
1845
|
-
}
|
|
1846
|
-
/**
|
|
1847
|
-
* @ignore
|
|
1848
|
-
*/
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
var AnyToPromiseStatus;
|
|
1852
|
-
|
|
1853
|
-
(function (AnyToPromiseStatus) {
|
|
1854
|
-
AnyToPromiseStatus["PENDING"] = "PENDING";
|
|
1855
|
-
AnyToPromiseStatus["CANCELED"] = "CANCELED";
|
|
1856
|
-
AnyToPromiseStatus["RESOLVED"] = "RESOLVED";
|
|
1857
|
-
AnyToPromiseStatus["REJECTED"] = "REJECTED";
|
|
1858
|
-
})(AnyToPromiseStatus || (AnyToPromiseStatus = {}));
|
|
1859
|
-
|
|
1860
|
-
var AnyToPromiseResponseTypes;
|
|
1861
|
-
|
|
1862
|
-
(function (AnyToPromiseResponseTypes) {
|
|
1863
|
-
AnyToPromiseResponseTypes["STREAM"] = "STREAM";
|
|
1864
|
-
AnyToPromiseResponseTypes["BUFFER"] = "BUFFER";
|
|
1865
|
-
AnyToPromiseResponseTypes["DATA"] = "DATA";
|
|
1866
|
-
})(AnyToPromiseResponseTypes || (AnyToPromiseResponseTypes = {}));
|
|
1867
|
-
|
|
1868
|
-
var _resolves = /*#__PURE__*/_classPrivateFieldLooseKey("resolves");
|
|
1869
|
-
|
|
1870
|
-
var _rejects = /*#__PURE__*/_classPrivateFieldLooseKey("rejects");
|
|
1871
|
-
|
|
1872
|
-
var _hasNextFunction = /*#__PURE__*/_classPrivateFieldLooseKey("hasNextFunction");
|
|
1873
|
-
|
|
1874
|
-
var _promise = /*#__PURE__*/_classPrivateFieldLooseKey("promise");
|
|
1875
|
-
|
|
1876
|
-
class AnyToPromise {
|
|
1877
|
-
constructor({
|
|
1878
|
-
hasNextFunction = false
|
|
1879
|
-
} = {}) {
|
|
1880
|
-
Object.defineProperty(this, _resolves, {
|
|
1881
|
-
writable: true,
|
|
1882
|
-
value: void 0
|
|
1883
|
-
});
|
|
1884
|
-
Object.defineProperty(this, _rejects, {
|
|
1885
|
-
writable: true,
|
|
1886
|
-
value: void 0
|
|
1887
|
-
});
|
|
1888
|
-
Object.defineProperty(this, _hasNextFunction, {
|
|
1889
|
-
writable: true,
|
|
1890
|
-
value: void 0
|
|
1891
|
-
});
|
|
1892
|
-
Object.defineProperty(this, _promise, {
|
|
1893
|
-
writable: true,
|
|
1894
|
-
value: void 0
|
|
1895
|
-
});
|
|
1896
|
-
this.status = AnyToPromiseStatus.PENDING;
|
|
1897
|
-
_classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = false;
|
|
1898
|
-
_classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = hasNextFunction;
|
|
1899
|
-
_classPrivateFieldLooseBase(this, _promise)[_promise] = new Promise((resolve, reject) => {
|
|
1900
|
-
_classPrivateFieldLooseBase(this, _resolves)[_resolves] = resolve;
|
|
1901
|
-
_classPrivateFieldLooseBase(this, _rejects)[_rejects] = reject;
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
isDone() {
|
|
1906
|
-
return this.status !== AnyToPromiseStatus.PENDING;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
get next() {
|
|
1910
|
-
_classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = true;
|
|
1911
|
-
return error => {
|
|
1912
|
-
if (this.isDone()) {
|
|
1913
|
-
return;
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
return error ? this.reject(error) : this.resolve({
|
|
1917
|
-
type: AnyToPromiseResponseTypes.DATA
|
|
1918
|
-
});
|
|
1919
|
-
};
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
*
|
|
1923
|
-
*/
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
async call(cb) {
|
|
1927
|
-
if (this.isDone()) {
|
|
1928
|
-
return this;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
try {
|
|
1932
|
-
this.handle(cb());
|
|
1933
|
-
} catch (er) {
|
|
1934
|
-
this.reject(er);
|
|
1935
|
-
}
|
|
1936
|
-
|
|
1937
|
-
return _classPrivateFieldLooseBase(this, _promise)[_promise];
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
reject(er) {
|
|
1941
|
-
if (this.isDone()) {
|
|
1942
|
-
return;
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
this.done(AnyToPromiseStatus.REJECTED);
|
|
1946
|
-
|
|
1947
|
-
_classPrivateFieldLooseBase(this, _rejects)[_rejects](er);
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
resolve(response = {}) {
|
|
1951
|
-
if (this.isDone()) {
|
|
1952
|
-
return;
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
this.done(AnyToPromiseStatus.RESOLVED);
|
|
1956
|
-
|
|
1957
|
-
_classPrivateFieldLooseBase(this, _resolves)[_resolves](_extends({}, response, {
|
|
1958
|
-
state: AnyToPromiseStatus.RESOLVED
|
|
1959
|
-
}));
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
destroy() {}
|
|
1963
|
-
|
|
1964
|
-
cancel() {
|
|
1965
|
-
if (this.isDone()) {
|
|
1966
|
-
return;
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
this.done(AnyToPromiseStatus.CANCELED);
|
|
1970
|
-
return _classPrivateFieldLooseBase(this, _resolves)[_resolves]({
|
|
1971
|
-
state: AnyToPromiseStatus.CANCELED
|
|
1972
|
-
});
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
done(status) {
|
|
1976
|
-
this.destroy();
|
|
1977
|
-
this.status = status;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
handle(process, additionalProps = {}) {
|
|
1981
|
-
if (this.isDone()) {
|
|
1982
|
-
return;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
if (process) {
|
|
1986
|
-
if (this.isCanceledResponse(process)) {
|
|
1987
|
-
// ABANDON
|
|
1988
|
-
return this.cancel();
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
if (isObservable(process)) {
|
|
1992
|
-
process = process.toPromise();
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
if (isResponse(process)) {
|
|
1996
|
-
return this.handle(process.data, _extends({}, additionalProps, {
|
|
1997
|
-
status: process.status,
|
|
1998
|
-
headers: process.headers
|
|
1999
|
-
}));
|
|
2000
|
-
}
|
|
2001
|
-
|
|
2002
|
-
if (isStream(process)) {
|
|
2003
|
-
return this.resolve(_extends({}, additionalProps, {
|
|
2004
|
-
type: AnyToPromiseResponseTypes.STREAM,
|
|
2005
|
-
data: process
|
|
2006
|
-
}));
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
if (isStream(process) || Buffer.isBuffer(process)) {
|
|
2010
|
-
return this.resolve(_extends({}, additionalProps, {
|
|
2011
|
-
type: AnyToPromiseResponseTypes.BUFFER,
|
|
2012
|
-
data: process
|
|
2013
|
-
}));
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
if (isPromise(process)) {
|
|
2017
|
-
return process.then(result => this.handle(result, additionalProps)).catch(error => {
|
|
2018
|
-
if (error.response && isResponse(error.response)) {
|
|
2019
|
-
return this.handle(error.response);
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
return this.reject(error);
|
|
2023
|
-
});
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
if (!_classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction]) {
|
|
2028
|
-
// no next function and empty response
|
|
2029
|
-
return this.resolve(_extends({}, additionalProps, {
|
|
2030
|
-
data: process,
|
|
2031
|
-
type: AnyToPromiseResponseTypes.DATA
|
|
2032
|
-
}));
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
isCanceledResponse(process) {
|
|
2037
|
-
return process === AnyToPromiseStatus.CANCELED;
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
|
-
class UnsupportedDecoratorType extends Error {
|
|
2043
|
-
constructor(decorator, args) {
|
|
2044
|
-
super(UnsupportedDecoratorType.buildMessage(decorator, args));
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
static buildMessage(decorator, args) {
|
|
2048
|
-
const [target, propertyKey, index] = args;
|
|
2049
|
-
const bindingType = decoratorTypeOf(args);
|
|
2050
|
-
const shortBinding = bindingType.split("/")[0];
|
|
2051
|
-
const param = shortBinding === "parameter" ? ".[" + index + "]" : "";
|
|
2052
|
-
const cstr = shortBinding === "parameter" ? ".constructor" : "";
|
|
2053
|
-
const method = propertyKey ? "." + propertyKey : cstr;
|
|
2054
|
-
const path = nameOf(classOf(target)) + method + param;
|
|
2055
|
-
return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
/**
|
|
2061
|
-
* The `@Deprecated()` decorators wraps the given method in such a way that it is marked as deprecated.
|
|
2062
|
-
*
|
|
2063
|
-
* ```typescript
|
|
2064
|
-
* provide Foo {
|
|
2065
|
-
*
|
|
2066
|
-
* @Deprecated("Foo.method: Use Foo.method2 instead")
|
|
2067
|
-
* public method() {
|
|
2068
|
-
*
|
|
2069
|
-
* }
|
|
2070
|
-
* ```
|
|
2071
|
-
*
|
|
2072
|
-
* When called, @Deprecated() will return a function that will emit a `DeprecationWarning` using the `process.on('warning')` event.
|
|
2073
|
-
* By default, this warning will be emitted and printed to `stderr` exactly once, the first time it is called. After the warning is emitted, the wrapped method is called.
|
|
2074
|
-
*
|
|
2075
|
-
* If either the `--no-deprecation` or `--no-warnings` command line flags are used, or if the `process.noDeprecation`
|
|
2076
|
-
* property is set to `true` prior to the first deprecation warning, the `@Deprecated()` decorators does nothing.
|
|
2077
|
-
*
|
|
2078
|
-
* If the `--trace-deprecation` or `--trace-warnings` command line flags are set, or the `process.traceDeprecation`
|
|
2079
|
-
* property is set to `true`, a warning and a stack trace are printed to stderr the first time the deprecated function is called.
|
|
2080
|
-
*
|
|
2081
|
-
* If the `--throw-deprecation` command line flag is set, or the `process.throwDeprecation` property is set to `true`,
|
|
2082
|
-
* then an exception will be thrown when the deprecated function is called.
|
|
2083
|
-
*
|
|
2084
|
-
* The `--throw-deprecation` command line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation`
|
|
2085
|
-
* and `process.traceDeprecation`.
|
|
2086
|
-
*
|
|
2087
|
-
* @param message
|
|
2088
|
-
* @returns {Function}
|
|
2089
|
-
* @decorator
|
|
2090
|
-
*/
|
|
2091
|
-
function Deprecated(message) {
|
|
2092
|
-
return (target, targetKey, descriptor) => {
|
|
2093
|
-
const originalMethod = descriptor.value;
|
|
2094
|
-
descriptor.value = require("util").deprecate(originalMethod, message);
|
|
2095
|
-
return descriptor;
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
/**
|
|
2100
|
-
* @module common/core
|
|
2101
|
-
*/
|
|
2102
|
-
/** */
|
|
2103
|
-
|
|
2104
|
-
function Configurable(value = true) {
|
|
2105
|
-
return (target, propertyKey) => {
|
|
2106
|
-
const descriptor = descriptorOf(target, propertyKey) || {
|
|
2107
|
-
writable: true,
|
|
2108
|
-
enumerable: true
|
|
2109
|
-
};
|
|
2110
|
-
descriptor.configurable = value;
|
|
2111
|
-
Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
|
|
2112
|
-
return descriptor;
|
|
2113
|
-
};
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
/**
|
|
2117
|
-
* @module common/core
|
|
2118
|
-
*/
|
|
2119
|
-
/** */
|
|
2120
|
-
|
|
2121
|
-
function Enumerable(value = true) {
|
|
2122
|
-
return (target, propertyKey) => {
|
|
2123
|
-
const descriptor = descriptorOf(target, propertyKey) || {
|
|
2124
|
-
writable: true,
|
|
2125
|
-
configurable: true
|
|
2126
|
-
};
|
|
2127
|
-
descriptor.enumerable = value;
|
|
2128
|
-
Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
|
|
2129
|
-
return descriptor;
|
|
2130
|
-
};
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
/**
|
|
2134
|
-
* @module common/core
|
|
2135
|
-
*/
|
|
2136
|
-
/** */
|
|
2137
|
-
|
|
2138
|
-
function Writable(value = true) {
|
|
2139
|
-
return (target, propertyKey) => {
|
|
2140
|
-
const descriptor = descriptorOf(target, propertyKey) || {
|
|
2141
|
-
configurable: true,
|
|
2142
|
-
enumerable: true
|
|
2143
|
-
};
|
|
2144
|
-
descriptor.writable = value;
|
|
2145
|
-
Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
|
|
2146
|
-
return descriptor;
|
|
2147
|
-
};
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
/**
|
|
2151
|
-
* @module common/core
|
|
2152
|
-
*/
|
|
2153
|
-
/** */
|
|
2154
|
-
|
|
2155
|
-
function Readonly() {
|
|
2156
|
-
return Writable(false);
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
/**
|
|
2160
|
-
* @module common/core
|
|
2161
|
-
*/
|
|
2162
|
-
/** */
|
|
2163
|
-
|
|
2164
|
-
function NotConfigurable() {
|
|
2165
|
-
return Configurable(false);
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
/**
|
|
2169
|
-
* @module common/core
|
|
2170
|
-
*/
|
|
2171
|
-
/** */
|
|
2172
|
-
|
|
2173
|
-
function NotEnumerable() {
|
|
2174
|
-
return Enumerable(false);
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
/**
|
|
2178
|
-
* Create a store correctly configured from the parameters given by the decorator.
|
|
2179
|
-
* The `fn` can return a decorator that will be initialized with the parameters (target, propertyKey, descriptor).
|
|
2180
|
-
* @param {(store: Store, parameters: DecoratorParameters) => void} fn
|
|
2181
|
-
* @returns {Function}
|
|
2182
|
-
*/
|
|
2183
|
-
|
|
2184
|
-
function StoreFn(fn) {
|
|
2185
|
-
return (...parameters) => {
|
|
2186
|
-
const store = Store.from(...parameters);
|
|
2187
|
-
const result = fn(store, parameters);
|
|
2188
|
-
|
|
2189
|
-
if (typeof result === "function") {
|
|
2190
|
-
result(...parameters);
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
return parameters[2];
|
|
2194
|
-
};
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
function StoreSet(key, value) {
|
|
2198
|
-
return StoreFn(store => {
|
|
2199
|
-
store.set(key, value);
|
|
2200
|
-
});
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
function StoreMerge(key, value) {
|
|
2204
|
-
return StoreFn(store => {
|
|
2205
|
-
store.merge(key, value);
|
|
2206
|
-
});
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
export { AnyToPromise, AnyToPromiseResponseTypes, AnyToPromiseStatus, CLASS_STORE, Configurable, DecoratorTypes, Deprecated, Entity, Enumerable, Env, EnvTypes, Hooks, METHOD_STORE, Metadata, NotConfigurable, NotEnumerable, PARAM_STORE, PROPERTY_STORE, Readonly, Store, StoreFn, StoreMerge, StoreSet, Type, UnsupportedDecoratorType, Writable, ancestorOf, ancestorsOf, catchAsyncError, catchError, classOf, cleanObject, constructorOf, decorateMethodsOf, decoratorArgs, decoratorTypeOf, deepClone, deepMerge, descriptorOf, getClass, getClassOrSymbol, getConstructor, getConstructorArgNames, getEnumerableKeys, getInheritedClass, getValue, inheritedDescriptorOf, isArray, isArrayOrArrayClass, isArrowFn, isBoolean, isBooleanOrBooleanClass, isClass, isClassObject, isCollection, isDate, isEmpty, isEnumerable, isFunction, isInheritedFrom, isNil, isNumber, isNumberOrNumberClass, isObject, isObservable, isPlainObject, isPrimitive, isPrimitiveClass, isPrimitiveOrPrimitiveClass, isPromise, isProtectedKey, isSerializable, isStream, isString, isStringOrStringClass, isSymbol, isSymbolOrSymbolClass, mergeReducerBuilder, methodsOf, nameOf, nameOfClass, nameOfSymbol, objectKeys, primitiveOf, prototypeOf, proxyDelegation, setValue, toMap, toStringConstructor, uniq, uniqBy, useDecorators, useMethodDecorator, useMethodDecorators };
|
|
2210
|
-
//# sourceMappingURL=index.modern.js.map
|