@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.
Files changed (415) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/decorators/configurable.js +14 -0
  3. package/lib/cjs/decorators/configurable.js.map +1 -0
  4. package/lib/cjs/decorators/deprecated.js +44 -0
  5. package/lib/cjs/decorators/deprecated.js.map +1 -0
  6. package/lib/cjs/decorators/enumerable.js +14 -0
  7. package/lib/cjs/decorators/enumerable.js.map +1 -0
  8. package/lib/cjs/decorators/notConfigurable.js +9 -0
  9. package/lib/cjs/decorators/notConfigurable.js.map +1 -0
  10. package/lib/cjs/decorators/notEnumerable.js +9 -0
  11. package/lib/cjs/decorators/notEnumerable.js.map +1 -0
  12. package/lib/cjs/decorators/readOnly.js +9 -0
  13. package/lib/cjs/decorators/readOnly.js.map +1 -0
  14. package/lib/cjs/decorators/storeFn.js +22 -0
  15. package/lib/cjs/decorators/storeFn.js.map +1 -0
  16. package/lib/cjs/decorators/storeMerge.js +11 -0
  17. package/lib/cjs/decorators/storeMerge.js.map +1 -0
  18. package/lib/cjs/decorators/storeSet.js +11 -0
  19. package/lib/cjs/decorators/storeSet.js.map +1 -0
  20. package/lib/cjs/decorators/writable.js +14 -0
  21. package/lib/cjs/decorators/writable.js.map +1 -0
  22. package/lib/cjs/domain/AnyToPromise.js +148 -0
  23. package/lib/cjs/domain/AnyToPromise.js.map +1 -0
  24. package/lib/cjs/domain/DecoratorTypes.js +15 -0
  25. package/lib/cjs/domain/DecoratorTypes.js.map +1 -0
  26. package/lib/cjs/domain/Env.js +19 -0
  27. package/lib/cjs/domain/Env.js.map +1 -0
  28. package/lib/cjs/domain/Hooks.js +89 -0
  29. package/lib/cjs/domain/Hooks.js.map +1 -0
  30. package/lib/cjs/domain/Metadata.js +508 -0
  31. package/lib/cjs/domain/Metadata.js.map +1 -0
  32. package/lib/cjs/domain/Store.js +157 -0
  33. package/lib/cjs/domain/Store.js.map +1 -0
  34. package/lib/cjs/domain/Type.js +7 -0
  35. package/lib/cjs/domain/Type.js.map +1 -0
  36. package/lib/cjs/errors/UnsupportedDecoratorType.js +23 -0
  37. package/lib/cjs/errors/UnsupportedDecoratorType.js.map +1 -0
  38. package/lib/cjs/index.js +85 -0
  39. package/lib/cjs/index.js.map +1 -0
  40. package/lib/cjs/interfaces/AnyDecorator.js +3 -0
  41. package/lib/cjs/interfaces/AnyDecorator.js.map +1 -0
  42. package/lib/cjs/interfaces/DecoratorParameters.js +3 -0
  43. package/lib/cjs/interfaces/DecoratorParameters.js.map +1 -0
  44. package/lib/cjs/interfaces/HashOf.js +3 -0
  45. package/lib/cjs/interfaces/HashOf.js.map +1 -0
  46. package/lib/cjs/interfaces/MetadataTypes.js +3 -0
  47. package/lib/cjs/interfaces/MetadataTypes.js.map +1 -0
  48. package/lib/cjs/interfaces/ValueOf.js +3 -0
  49. package/lib/cjs/interfaces/ValueOf.js.map +1 -0
  50. package/lib/cjs/package.json +3 -0
  51. package/lib/cjs/utils/catchError.js +22 -0
  52. package/lib/cjs/utils/catchError.js.map +1 -0
  53. package/lib/cjs/utils/decorators/decorateMethodsOf.js +24 -0
  54. package/lib/cjs/utils/decorators/decorateMethodsOf.js.map +1 -0
  55. package/lib/cjs/utils/decorators/decoratorArgs.js +9 -0
  56. package/lib/cjs/utils/decorators/decoratorArgs.js.map +1 -0
  57. package/lib/cjs/utils/decorators/decoratorTypeOf.js +23 -0
  58. package/lib/cjs/utils/decorators/decoratorTypeOf.js.map +1 -0
  59. package/lib/cjs/utils/decorators/inheritedDescriptorOf.js +15 -0
  60. package/lib/cjs/utils/decorators/inheritedDescriptorOf.js.map +1 -0
  61. package/lib/cjs/utils/decorators/useDecorators.js +14 -0
  62. package/lib/cjs/utils/decorators/useDecorators.js.map +1 -0
  63. package/lib/cjs/utils/decorators/useMethodDecorators.js +15 -0
  64. package/lib/cjs/utils/decorators/useMethodDecorators.js.map +1 -0
  65. package/lib/cjs/utils/http/getHostInfoFromPort.js +21 -0
  66. package/lib/cjs/utils/http/getHostInfoFromPort.js.map +1 -0
  67. package/lib/cjs/utils/imports/importPackage.js +39 -0
  68. package/lib/cjs/utils/imports/importPackage.js.map +1 -0
  69. package/lib/cjs/utils/objects/ancestorOf.js +12 -0
  70. package/lib/cjs/utils/objects/ancestorOf.js.map +1 -0
  71. package/lib/cjs/utils/objects/ancestorsOf.js +22 -0
  72. package/lib/cjs/utils/objects/ancestorsOf.js.map +1 -0
  73. package/lib/cjs/utils/objects/classOf.js +23 -0
  74. package/lib/cjs/utils/objects/classOf.js.map +1 -0
  75. package/lib/cjs/utils/objects/cleanObject.js +24 -0
  76. package/lib/cjs/utils/objects/cleanObject.js.map +1 -0
  77. package/lib/cjs/utils/objects/constructorOf.js +20 -0
  78. package/lib/cjs/utils/objects/constructorOf.js.map +1 -0
  79. package/lib/cjs/utils/objects/createInstance.js +9 -0
  80. package/lib/cjs/utils/objects/createInstance.js.map +1 -0
  81. package/lib/cjs/utils/objects/deepClone.js +63 -0
  82. package/lib/cjs/utils/objects/deepClone.js.map +1 -0
  83. package/lib/cjs/utils/objects/deepMerge.js +63 -0
  84. package/lib/cjs/utils/objects/deepMerge.js.map +1 -0
  85. package/lib/cjs/utils/objects/descriptorOf.js +19 -0
  86. package/lib/cjs/utils/objects/descriptorOf.js.map +1 -0
  87. package/lib/cjs/utils/objects/getClassOrSymbol.js +10 -0
  88. package/lib/cjs/utils/objects/getClassOrSymbol.js.map +1 -0
  89. package/lib/cjs/utils/objects/getConstructorArgNames.js +14 -0
  90. package/lib/cjs/utils/objects/getConstructorArgNames.js.map +1 -0
  91. package/lib/cjs/utils/objects/getEnumerableKeys.js +20 -0
  92. package/lib/cjs/utils/objects/getEnumerableKeys.js.map +1 -0
  93. package/lib/cjs/utils/objects/getValue.js +49 -0
  94. package/lib/cjs/utils/objects/getValue.js.map +1 -0
  95. package/lib/cjs/utils/objects/isArray.js +23 -0
  96. package/lib/cjs/utils/objects/isArray.js.map +1 -0
  97. package/lib/cjs/utils/objects/isArrowFn.js +9 -0
  98. package/lib/cjs/utils/objects/isArrowFn.js.map +1 -0
  99. package/lib/cjs/utils/objects/isBoolean.js +17 -0
  100. package/lib/cjs/utils/objects/isBoolean.js.map +1 -0
  101. package/lib/cjs/utils/objects/isBuffer.js +13 -0
  102. package/lib/cjs/utils/objects/isBuffer.js.map +1 -0
  103. package/lib/cjs/utils/objects/isClass.js +28 -0
  104. package/lib/cjs/utils/objects/isClass.js.map +1 -0
  105. package/lib/cjs/utils/objects/isCollection.js +22 -0
  106. package/lib/cjs/utils/objects/isCollection.js.map +1 -0
  107. package/lib/cjs/utils/objects/isDate.js +13 -0
  108. package/lib/cjs/utils/objects/isDate.js.map +1 -0
  109. package/lib/cjs/utils/objects/isEmpty.js +14 -0
  110. package/lib/cjs/utils/objects/isEmpty.js.map +1 -0
  111. package/lib/cjs/utils/objects/isEnumerable.js +22 -0
  112. package/lib/cjs/utils/objects/isEnumerable.js.map +1 -0
  113. package/lib/cjs/utils/objects/isFunction.js +8 -0
  114. package/lib/cjs/utils/objects/isFunction.js.map +1 -0
  115. package/lib/cjs/utils/objects/isInheritedFrom.js +26 -0
  116. package/lib/cjs/utils/objects/isInheritedFrom.js.map +1 -0
  117. package/lib/cjs/utils/objects/isNil.js +8 -0
  118. package/lib/cjs/utils/objects/isNil.js.map +1 -0
  119. package/lib/cjs/utils/objects/isNumber.js +17 -0
  120. package/lib/cjs/utils/objects/isNumber.js.map +1 -0
  121. package/lib/cjs/utils/objects/isObject.js +8 -0
  122. package/lib/cjs/utils/objects/isObject.js.map +1 -0
  123. package/lib/cjs/utils/objects/isObservable.js +8 -0
  124. package/lib/cjs/utils/objects/isObservable.js.map +1 -0
  125. package/lib/cjs/utils/objects/isPlainObject.js +18 -0
  126. package/lib/cjs/utils/objects/isPlainObject.js.map +1 -0
  127. package/lib/cjs/utils/objects/isPrimitive.js +30 -0
  128. package/lib/cjs/utils/objects/isPrimitive.js.map +1 -0
  129. package/lib/cjs/utils/objects/isPromise.js +16 -0
  130. package/lib/cjs/utils/objects/isPromise.js.map +1 -0
  131. package/lib/cjs/utils/objects/isProtectedKey.js +12 -0
  132. package/lib/cjs/utils/objects/isProtectedKey.js.map +1 -0
  133. package/lib/cjs/utils/objects/isSerializable.js +13 -0
  134. package/lib/cjs/utils/objects/isSerializable.js.map +1 -0
  135. package/lib/cjs/utils/objects/isStream.js +8 -0
  136. package/lib/cjs/utils/objects/isStream.js.map +1 -0
  137. package/lib/cjs/utils/objects/isString.js +16 -0
  138. package/lib/cjs/utils/objects/isString.js.map +1 -0
  139. package/lib/cjs/utils/objects/isSymbol.js +16 -0
  140. package/lib/cjs/utils/objects/isSymbol.js.map +1 -0
  141. package/lib/cjs/utils/objects/methodsOf.js +25 -0
  142. package/lib/cjs/utils/objects/methodsOf.js.map +1 -0
  143. package/lib/cjs/utils/objects/nameOf.js +32 -0
  144. package/lib/cjs/utils/objects/nameOf.js.map +1 -0
  145. package/lib/cjs/utils/objects/objectKeys.js +9 -0
  146. package/lib/cjs/utils/objects/objectKeys.js.map +1 -0
  147. package/lib/cjs/utils/objects/primitiveOf.js +20 -0
  148. package/lib/cjs/utils/objects/primitiveOf.js.map +1 -0
  149. package/lib/cjs/utils/objects/prototypeOf.js +14 -0
  150. package/lib/cjs/utils/objects/prototypeOf.js.map +1 -0
  151. package/lib/cjs/utils/objects/setValue.js +34 -0
  152. package/lib/cjs/utils/objects/setValue.js.map +1 -0
  153. package/lib/cjs/utils/objects/toMap.js +32 -0
  154. package/lib/cjs/utils/objects/toMap.js.map +1 -0
  155. package/lib/cjs/utils/objects/toStringConstructor.js +12 -0
  156. package/lib/cjs/utils/objects/toStringConstructor.js.map +1 -0
  157. package/lib/cjs/utils/proxyDelegation.js +54 -0
  158. package/lib/cjs/utils/proxyDelegation.js.map +1 -0
  159. package/lib/cjs/utils/uniq.js +16 -0
  160. package/lib/cjs/utils/uniq.js.map +1 -0
  161. package/lib/esm/decorators/configurable.js +10 -0
  162. package/lib/esm/decorators/configurable.js.map +1 -0
  163. package/lib/esm/decorators/deprecated.js +40 -0
  164. package/lib/esm/decorators/deprecated.js.map +1 -0
  165. package/lib/esm/decorators/enumerable.js +10 -0
  166. package/lib/esm/decorators/enumerable.js.map +1 -0
  167. package/lib/esm/decorators/notConfigurable.js +5 -0
  168. package/lib/esm/decorators/notConfigurable.js.map +1 -0
  169. package/lib/esm/decorators/notEnumerable.js +5 -0
  170. package/lib/esm/decorators/notEnumerable.js.map +1 -0
  171. package/lib/esm/decorators/readOnly.js +5 -0
  172. package/lib/esm/decorators/readOnly.js.map +1 -0
  173. package/lib/esm/decorators/storeFn.js +18 -0
  174. package/lib/esm/decorators/storeFn.js.map +1 -0
  175. package/lib/esm/decorators/storeMerge.js +7 -0
  176. package/lib/esm/decorators/storeMerge.js.map +1 -0
  177. package/lib/esm/decorators/storeSet.js +7 -0
  178. package/lib/esm/decorators/storeSet.js.map +1 -0
  179. package/lib/esm/decorators/writable.js +10 -0
  180. package/lib/esm/decorators/writable.js.map +1 -0
  181. package/lib/esm/domain/AnyToPromise.js +144 -0
  182. package/lib/esm/domain/AnyToPromise.js.map +1 -0
  183. package/lib/esm/domain/DecoratorTypes.js +12 -0
  184. package/lib/esm/domain/DecoratorTypes.js.map +1 -0
  185. package/lib/esm/domain/Env.js +16 -0
  186. package/lib/esm/domain/Env.js.map +1 -0
  187. package/lib/esm/domain/Hooks.js +85 -0
  188. package/lib/esm/domain/Hooks.js.map +1 -0
  189. package/lib/esm/domain/Metadata.js +504 -0
  190. package/lib/esm/domain/Metadata.js.map +1 -0
  191. package/lib/esm/domain/Store.js +153 -0
  192. package/lib/esm/domain/Store.js.map +1 -0
  193. package/lib/esm/domain/Type.js +4 -0
  194. package/lib/esm/domain/Type.js.map +1 -0
  195. package/lib/esm/errors/UnsupportedDecoratorType.js +19 -0
  196. package/lib/esm/errors/UnsupportedDecoratorType.js.map +1 -0
  197. package/lib/esm/index.js +82 -0
  198. package/lib/esm/index.js.map +1 -0
  199. package/lib/esm/interfaces/AnyDecorator.js +2 -0
  200. package/lib/esm/interfaces/AnyDecorator.js.map +1 -0
  201. package/lib/esm/interfaces/DecoratorParameters.js +2 -0
  202. package/lib/esm/interfaces/DecoratorParameters.js.map +1 -0
  203. package/lib/esm/interfaces/HashOf.js +2 -0
  204. package/lib/esm/interfaces/HashOf.js.map +1 -0
  205. package/lib/esm/interfaces/MetadataTypes.js +2 -0
  206. package/lib/esm/interfaces/MetadataTypes.js.map +1 -0
  207. package/lib/esm/interfaces/ValueOf.js +2 -0
  208. package/lib/esm/interfaces/ValueOf.js.map +1 -0
  209. package/lib/esm/package.json +3 -0
  210. package/lib/esm/utils/catchError.js +17 -0
  211. package/lib/esm/utils/catchError.js.map +1 -0
  212. package/lib/esm/utils/decorators/decorateMethodsOf.js +20 -0
  213. package/lib/esm/utils/decorators/decorateMethodsOf.js.map +1 -0
  214. package/lib/esm/utils/decorators/decoratorArgs.js +5 -0
  215. package/lib/esm/utils/decorators/decoratorArgs.js.map +1 -0
  216. package/lib/esm/utils/decorators/decoratorTypeOf.js +19 -0
  217. package/lib/esm/utils/decorators/decoratorTypeOf.js.map +1 -0
  218. package/lib/esm/utils/decorators/inheritedDescriptorOf.js +11 -0
  219. package/lib/esm/utils/decorators/inheritedDescriptorOf.js.map +1 -0
  220. package/lib/esm/utils/decorators/useDecorators.js +10 -0
  221. package/lib/esm/utils/decorators/useDecorators.js.map +1 -0
  222. package/lib/esm/utils/decorators/useMethodDecorators.js +10 -0
  223. package/lib/esm/utils/decorators/useMethodDecorators.js.map +1 -0
  224. package/lib/esm/utils/http/getHostInfoFromPort.js +17 -0
  225. package/lib/esm/utils/http/getHostInfoFromPort.js.map +1 -0
  226. package/lib/esm/utils/imports/importPackage.js +12 -0
  227. package/lib/esm/utils/imports/importPackage.js.map +1 -0
  228. package/lib/esm/utils/objects/ancestorOf.js +7 -0
  229. package/lib/esm/utils/objects/ancestorOf.js.map +1 -0
  230. package/lib/esm/utils/objects/ancestorsOf.js +18 -0
  231. package/lib/esm/utils/objects/ancestorsOf.js.map +1 -0
  232. package/lib/esm/utils/objects/classOf.js +18 -0
  233. package/lib/esm/utils/objects/classOf.js.map +1 -0
  234. package/lib/esm/utils/objects/cleanObject.js +20 -0
  235. package/lib/esm/utils/objects/cleanObject.js.map +1 -0
  236. package/lib/esm/utils/objects/constructorOf.js +15 -0
  237. package/lib/esm/utils/objects/constructorOf.js.map +1 -0
  238. package/lib/esm/utils/objects/createInstance.js +5 -0
  239. package/lib/esm/utils/objects/createInstance.js.map +1 -0
  240. package/lib/esm/utils/objects/deepClone.js +59 -0
  241. package/lib/esm/utils/objects/deepClone.js.map +1 -0
  242. package/lib/esm/utils/objects/deepMerge.js +58 -0
  243. package/lib/esm/utils/objects/deepMerge.js.map +1 -0
  244. package/lib/esm/utils/objects/descriptorOf.js +14 -0
  245. package/lib/esm/utils/objects/descriptorOf.js.map +1 -0
  246. package/lib/esm/utils/objects/getClassOrSymbol.js +6 -0
  247. package/lib/esm/utils/objects/getClassOrSymbol.js.map +1 -0
  248. package/lib/esm/utils/objects/getConstructorArgNames.js +10 -0
  249. package/lib/esm/utils/objects/getConstructorArgNames.js.map +1 -0
  250. package/lib/esm/utils/objects/getEnumerableKeys.js +16 -0
  251. package/lib/esm/utils/objects/getEnumerableKeys.js.map +1 -0
  252. package/lib/esm/utils/objects/getValue.js +45 -0
  253. package/lib/esm/utils/objects/getValue.js.map +1 -0
  254. package/lib/esm/utils/objects/isArray.js +18 -0
  255. package/lib/esm/utils/objects/isArray.js.map +1 -0
  256. package/lib/esm/utils/objects/isArrowFn.js +5 -0
  257. package/lib/esm/utils/objects/isArrowFn.js.map +1 -0
  258. package/lib/esm/utils/objects/isBoolean.js +12 -0
  259. package/lib/esm/utils/objects/isBoolean.js.map +1 -0
  260. package/lib/esm/utils/objects/isBuffer.js +9 -0
  261. package/lib/esm/utils/objects/isBuffer.js.map +1 -0
  262. package/lib/esm/utils/objects/isClass.js +24 -0
  263. package/lib/esm/utils/objects/isClass.js.map +1 -0
  264. package/lib/esm/utils/objects/isCollection.js +18 -0
  265. package/lib/esm/utils/objects/isCollection.js.map +1 -0
  266. package/lib/esm/utils/objects/isDate.js +9 -0
  267. package/lib/esm/utils/objects/isDate.js.map +1 -0
  268. package/lib/esm/utils/objects/isEmpty.js +10 -0
  269. package/lib/esm/utils/objects/isEmpty.js.map +1 -0
  270. package/lib/esm/utils/objects/isEnumerable.js +18 -0
  271. package/lib/esm/utils/objects/isEnumerable.js.map +1 -0
  272. package/lib/esm/utils/objects/isFunction.js +4 -0
  273. package/lib/esm/utils/objects/isFunction.js.map +1 -0
  274. package/lib/esm/utils/objects/isInheritedFrom.js +22 -0
  275. package/lib/esm/utils/objects/isInheritedFrom.js.map +1 -0
  276. package/lib/esm/utils/objects/isNil.js +4 -0
  277. package/lib/esm/utils/objects/isNil.js.map +1 -0
  278. package/lib/esm/utils/objects/isNumber.js +12 -0
  279. package/lib/esm/utils/objects/isNumber.js.map +1 -0
  280. package/lib/esm/utils/objects/isObject.js +4 -0
  281. package/lib/esm/utils/objects/isObject.js.map +1 -0
  282. package/lib/esm/utils/objects/isObservable.js +4 -0
  283. package/lib/esm/utils/objects/isObservable.js.map +1 -0
  284. package/lib/esm/utils/objects/isPlainObject.js +13 -0
  285. package/lib/esm/utils/objects/isPlainObject.js.map +1 -0
  286. package/lib/esm/utils/objects/isPrimitive.js +24 -0
  287. package/lib/esm/utils/objects/isPrimitive.js.map +1 -0
  288. package/lib/esm/utils/objects/isPromise.js +12 -0
  289. package/lib/esm/utils/objects/isPromise.js.map +1 -0
  290. package/lib/esm/utils/objects/isProtectedKey.js +8 -0
  291. package/lib/esm/utils/objects/isProtectedKey.js.map +1 -0
  292. package/lib/esm/utils/objects/isSerializable.js +9 -0
  293. package/lib/esm/utils/objects/isSerializable.js.map +1 -0
  294. package/lib/esm/utils/objects/isStream.js +4 -0
  295. package/lib/esm/utils/objects/isStream.js.map +1 -0
  296. package/lib/esm/utils/objects/isString.js +11 -0
  297. package/lib/esm/utils/objects/isString.js.map +1 -0
  298. package/lib/esm/utils/objects/isSymbol.js +11 -0
  299. package/lib/esm/utils/objects/isSymbol.js.map +1 -0
  300. package/lib/esm/utils/objects/methodsOf.js +21 -0
  301. package/lib/esm/utils/objects/methodsOf.js.map +1 -0
  302. package/lib/esm/utils/objects/nameOf.js +26 -0
  303. package/lib/esm/utils/objects/nameOf.js.map +1 -0
  304. package/lib/esm/utils/objects/objectKeys.js +5 -0
  305. package/lib/esm/utils/objects/objectKeys.js.map +1 -0
  306. package/lib/esm/utils/objects/primitiveOf.js +16 -0
  307. package/lib/esm/utils/objects/primitiveOf.js.map +1 -0
  308. package/lib/esm/utils/objects/prototypeOf.js +10 -0
  309. package/lib/esm/utils/objects/prototypeOf.js.map +1 -0
  310. package/lib/esm/utils/objects/setValue.js +30 -0
  311. package/lib/esm/utils/objects/setValue.js.map +1 -0
  312. package/lib/esm/utils/objects/toMap.js +28 -0
  313. package/lib/esm/utils/objects/toMap.js.map +1 -0
  314. package/lib/esm/utils/objects/toStringConstructor.js +8 -0
  315. package/lib/esm/utils/objects/toStringConstructor.js.map +1 -0
  316. package/lib/esm/utils/proxyDelegation.js +50 -0
  317. package/lib/esm/utils/proxyDelegation.js.map +1 -0
  318. package/lib/esm/utils/uniq.js +11 -0
  319. package/lib/esm/utils/uniq.js.map +1 -0
  320. package/lib/{decorators → types/decorators}/configurable.d.ts +0 -1
  321. package/lib/{decorators → types/decorators}/deprecated.d.ts +0 -0
  322. package/lib/{decorators → types/decorators}/enumerable.d.ts +0 -1
  323. package/lib/{decorators → types/decorators}/notConfigurable.d.ts +0 -1
  324. package/lib/{decorators → types/decorators}/notEnumerable.d.ts +0 -1
  325. package/lib/{decorators → types/decorators}/readOnly.d.ts +0 -1
  326. package/lib/{decorators → types/decorators}/storeFn.d.ts +0 -0
  327. package/lib/{decorators → types/decorators}/storeMerge.d.ts +0 -0
  328. package/lib/{decorators → types/decorators}/storeSet.d.ts +0 -0
  329. package/lib/{decorators → types/decorators}/writable.d.ts +0 -1
  330. package/lib/{domain → types/domain}/AnyToPromise.d.ts +0 -0
  331. package/lib/{domain → types/domain}/DecoratorTypes.d.ts +0 -0
  332. package/lib/{domain → types/domain}/Env.d.ts +0 -0
  333. package/lib/{domain → types/domain}/Hooks.d.ts +0 -0
  334. package/lib/{domain → types/domain}/Metadata.d.ts +0 -0
  335. package/lib/{domain → types/domain}/Store.d.ts +0 -0
  336. package/lib/{domain → types/domain}/Type.d.ts +0 -0
  337. package/lib/{errors → types/errors}/UnsupportedDecoratorType.d.ts +0 -0
  338. package/lib/types/index.d.ts +81 -0
  339. package/lib/{interfaces → types/interfaces}/AnyDecorator.d.ts +0 -0
  340. package/lib/{interfaces → types/interfaces}/DecoratorParameters.d.ts +0 -0
  341. package/lib/{interfaces → types/interfaces}/HashOf.d.ts +0 -0
  342. package/lib/{interfaces → types/interfaces}/MetadataTypes.d.ts +0 -0
  343. package/lib/{interfaces → types/interfaces}/ValueOf.d.ts +0 -0
  344. package/lib/{utils → types/utils}/catchError.d.ts +0 -0
  345. package/lib/{utils → types/utils}/decorators/decorateMethodsOf.d.ts +0 -0
  346. package/lib/{utils → types/utils}/decorators/decoratorArgs.d.ts +0 -0
  347. package/lib/{utils → types/utils}/decorators/decoratorTypeOf.d.ts +0 -0
  348. package/lib/{utils → types/utils}/decorators/inheritedDescriptorOf.d.ts +0 -0
  349. package/lib/{utils → types/utils}/decorators/useDecorators.d.ts +0 -0
  350. package/lib/{utils → types/utils}/decorators/useMethodDecorators.d.ts +0 -0
  351. package/lib/types/utils/http/getHostInfoFromPort.d.ts +6 -0
  352. package/lib/types/utils/imports/importPackage.d.ts +1 -0
  353. package/lib/{utils → types/utils}/objects/ancestorOf.d.ts +0 -0
  354. package/lib/{utils → types/utils}/objects/ancestorsOf.d.ts +0 -0
  355. package/lib/{utils → types/utils}/objects/classOf.d.ts +0 -0
  356. package/lib/{utils → types/utils}/objects/cleanObject.d.ts +0 -0
  357. package/lib/{utils → types/utils}/objects/constructorOf.d.ts +0 -0
  358. package/lib/{utils → types/utils}/objects/createInstance.d.ts +0 -0
  359. package/lib/types/utils/objects/deepClone.d.ts +6 -0
  360. package/lib/{utils → types/utils}/objects/deepMerge.d.ts +1 -1
  361. package/lib/{utils → types/utils}/objects/descriptorOf.d.ts +1 -0
  362. package/lib/{utils → types/utils}/objects/getClassOrSymbol.d.ts +0 -0
  363. package/lib/{utils → types/utils}/objects/getConstructorArgNames.d.ts +0 -0
  364. package/lib/{utils → types/utils}/objects/getEnumerableKeys.d.ts +0 -0
  365. package/lib/{utils → types/utils}/objects/getValue.d.ts +0 -0
  366. package/lib/{utils → types/utils}/objects/isArray.d.ts +0 -0
  367. package/lib/types/utils/objects/isArrowFn.d.ts +1 -0
  368. package/lib/{utils → types/utils}/objects/isBoolean.d.ts +0 -0
  369. package/lib/types/utils/objects/isBuffer.d.ts +7 -0
  370. package/lib/{utils → types/utils}/objects/isClass.d.ts +0 -0
  371. package/lib/{utils → types/utils}/objects/isCollection.d.ts +0 -0
  372. package/lib/{utils → types/utils}/objects/isDate.d.ts +0 -0
  373. package/lib/{utils → types/utils}/objects/isEmpty.d.ts +0 -0
  374. package/lib/{utils → types/utils}/objects/isEnumerable.d.ts +0 -0
  375. package/lib/{utils → types/utils}/objects/isFunction.d.ts +0 -0
  376. package/lib/{utils → types/utils}/objects/isInheritedFrom.d.ts +0 -0
  377. package/lib/{utils → types/utils}/objects/isNil.d.ts +0 -0
  378. package/lib/{utils → types/utils}/objects/isNumber.d.ts +0 -0
  379. package/lib/{utils → types/utils}/objects/isObject.d.ts +0 -0
  380. package/lib/{utils → types/utils}/objects/isObservable.d.ts +0 -0
  381. package/lib/{utils → types/utils}/objects/isPlainObject.d.ts +0 -0
  382. package/lib/{utils → types/utils}/objects/isPrimitive.d.ts +0 -0
  383. package/lib/{utils → types/utils}/objects/isPromise.d.ts +0 -0
  384. package/lib/{utils → types/utils}/objects/isProtectedKey.d.ts +0 -0
  385. package/lib/{utils → types/utils}/objects/isSerializable.d.ts +0 -0
  386. package/lib/{utils → types/utils}/objects/isStream.d.ts +0 -0
  387. package/lib/{utils → types/utils}/objects/isString.d.ts +0 -0
  388. package/lib/{utils → types/utils}/objects/isSymbol.d.ts +0 -0
  389. package/lib/types/utils/objects/methodsOf.d.ts +9 -0
  390. package/lib/{utils → types/utils}/objects/nameOf.d.ts +0 -0
  391. package/lib/{utils → types/utils}/objects/objectKeys.d.ts +0 -0
  392. package/lib/{utils → types/utils}/objects/primitiveOf.d.ts +0 -0
  393. package/lib/{utils → types/utils}/objects/prototypeOf.d.ts +0 -0
  394. package/lib/{utils → types/utils}/objects/setValue.d.ts +0 -0
  395. package/lib/{utils → types/utils}/objects/toMap.d.ts +0 -0
  396. package/lib/{utils → types/utils}/objects/toStringConstructor.d.ts +0 -0
  397. package/lib/{utils → types/utils}/proxyDelegation.d.ts +0 -0
  398. package/lib/{utils → types/utils}/uniq.d.ts +0 -0
  399. package/package.json +16 -12
  400. package/readme.md +1 -2
  401. package/tsconfig.compile.esm.json +12 -0
  402. package/lib/decorators/index.d.ts +0 -14
  403. package/lib/domain/Entity.d.ts +0 -97
  404. package/lib/domain/index.d.ts +0 -8
  405. package/lib/index.d.ts +0 -6
  406. package/lib/index.js +0 -2298
  407. package/lib/index.js.map +0 -1
  408. package/lib/index.modern.js +0 -2210
  409. package/lib/index.modern.js.map +0 -1
  410. package/lib/interfaces/index.d.ts +0 -4
  411. package/lib/utils/index.d.ts +0 -11
  412. package/lib/utils/objects/deepClone.d.ts +0 -5
  413. package/lib/utils/objects/index.d.ts +0 -42
  414. package/lib/utils/objects/isArrowFn.d.ts +0 -1
  415. package/lib/utils/objects/methodsOf.d.ts +0 -5
package/lib/index.js DELETED
@@ -1,2298 +0,0 @@
1
- require('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
- exports.DecoratorTypes = void 0;
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
- })(exports.DecoratorTypes || (exports.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 exports.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 exports.DecoratorTypes.PARAM_CTOR:
1088
- case exports.DecoratorTypes.PARAM_STC:
1089
- case exports.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 exports.DecoratorTypes.PROP:
1099
- case exports.DecoratorTypes.PROP_STC:
1100
- return storeGet(PROPERTY_STORE, target, propertyKey);
1101
-
1102
- case exports.DecoratorTypes.METHOD:
1103
- case exports.DecoratorTypes.METHOD_STC:
1104
- return storeGet(METHOD_STORE, target, propertyKey);
1105
-
1106
- case exports.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
- return input.reduce((map, value, index) => {
1586
- const ids = [].concat(identity(value, index));
1587
- ids.forEach(id => map.set(id, value));
1588
- return map;
1589
- }, new Map());
1590
- }
1591
-
1592
- const identity = createIdentityFn(keyOrFn);
1593
- return Object.entries(input).reduce((map, [key, value]) => {
1594
- return map.set(identity(value, key), value);
1595
- }, new Map());
1596
- }
1597
-
1598
- class Entity {
1599
- constructor({
1600
- target,
1601
- propertyKey,
1602
- descriptor,
1603
- index
1604
- }) {
1605
- this._target = target;
1606
- this.propertyKey = propertyKey;
1607
- this.propertyName = String(propertyKey);
1608
- this.descriptor = descriptor;
1609
- this.index = index;
1610
- this.decoratorType = decoratorTypeOf([target, propertyKey, descriptor || index]);
1611
- this.token = target && classOf(target);
1612
- }
1613
- /**
1614
- * Reference to the class
1615
- */
1616
-
1617
-
1618
- get target() {
1619
- return this._target;
1620
- }
1621
- /**
1622
- * Return the class name of the entity.
1623
- * @returns {string}
1624
- */
1625
-
1626
-
1627
- get targetName() {
1628
- return nameOf(this.token);
1629
- }
1630
- /**
1631
- *
1632
- * @returns {Type<any>}
1633
- */
1634
-
1635
-
1636
- get type() {
1637
- return this._type;
1638
- }
1639
- /**
1640
- * Get original type without transformation
1641
- * @param value
1642
- */
1643
-
1644
-
1645
- set type(value) {
1646
- this._type = value;
1647
- }
1648
- /**
1649
- * Return the itemSchema target type. if the type is a function used for recursive model, the function will be called to
1650
- * get the right type.
1651
- */
1652
-
1653
-
1654
- get computedType() {
1655
- return this._type;
1656
- }
1657
- /**
1658
- *
1659
- * @returns {boolean}
1660
- */
1661
-
1662
-
1663
- get isCollection() {
1664
- return !!this.collectionType;
1665
- }
1666
- /**
1667
- *
1668
- * @returns {boolean}
1669
- */
1670
-
1671
-
1672
- get isArray() {
1673
- return isArrayOrArrayClass(this.collectionType);
1674
- }
1675
- /**
1676
- *
1677
- * @returns {boolean}
1678
- */
1679
-
1680
-
1681
- get isPrimitive() {
1682
- return isPrimitiveOrPrimitiveClass(this._type);
1683
- }
1684
- /**
1685
- *
1686
- * @returns {boolean}
1687
- */
1688
-
1689
-
1690
- get isDate() {
1691
- return isDate(this.computedType);
1692
- }
1693
- /**
1694
- *
1695
- * @returns {boolean}
1696
- */
1697
-
1698
-
1699
- get isObject() {
1700
- return isObject(this.computedType);
1701
- }
1702
- /**
1703
- *
1704
- */
1705
-
1706
-
1707
- get isClass() {
1708
- return isClass(this.computedType);
1709
- }
1710
-
1711
- }
1712
-
1713
- /**
1714
- *
1715
- */
1716
- exports.Env = void 0;
1717
-
1718
- (function (Env) {
1719
- Env["PROD"] = "production";
1720
- Env["DEV"] = "development";
1721
- Env["TEST"] = "test";
1722
- })(exports.Env || (exports.Env = {}));
1723
- /**
1724
- * Fallback
1725
- * @type {Env}
1726
- */
1727
- // tslint:disable-next-line: variable-name
1728
-
1729
-
1730
- const EnvTypes = exports.Env;
1731
-
1732
- class Hooks {
1733
- constructor() {
1734
- this.listeners = new Map();
1735
- }
1736
- /**
1737
- * Listen a hook event
1738
- * @param event
1739
- * @param cb
1740
- */
1741
-
1742
-
1743
- on(event, cb) {
1744
- if (!this.listeners.has(event)) {
1745
- this.listeners.set(event, []);
1746
- }
1747
-
1748
- this.listeners.get(event).push(cb);
1749
- return this;
1750
- }
1751
- /**
1752
- * Remove a listener attached to an event
1753
- * @param event
1754
- * @param cb
1755
- */
1756
-
1757
-
1758
- off(event, cb) {
1759
- if (this.listeners.has(event)) {
1760
- this.listeners.set(event, this.listeners.get(event).filter(item => item === cb));
1761
- }
1762
-
1763
- return this;
1764
- }
1765
- /**
1766
- * Trigger an event and call listener.
1767
- * @param event
1768
- * @param args
1769
- * @param callThis
1770
- */
1771
-
1772
-
1773
- emit(event, args = [], callThis = null) {
1774
- if (this.listeners.has(event)) {
1775
- for (const cb of this.listeners.get(event)) {
1776
- cb.call(callThis, ...args);
1777
- }
1778
- }
1779
- }
1780
- /**
1781
- * Trigger an event, listener alter given value and return it.
1782
- * @param event
1783
- * @param value
1784
- * @param args
1785
- * @param callThis
1786
- */
1787
-
1788
-
1789
- alter(event, value, args = [], callThis = null) {
1790
- if (this.listeners.has(event)) {
1791
- for (const cb of this.listeners.get(event)) {
1792
- value = cb.call(callThis, value, ...args);
1793
- }
1794
- }
1795
-
1796
- return value;
1797
- }
1798
- /**
1799
- * Trigger an event and call async listener.
1800
- * @param event
1801
- * @param args
1802
- * @param callThis
1803
- */
1804
-
1805
-
1806
- async asyncEmit(event, args = [], callThis = null) {
1807
- if (this.listeners.has(event)) {
1808
- for (const cb of this.listeners.get(event)) {
1809
- await cb.call(callThis, ...args);
1810
- }
1811
- }
1812
- }
1813
- /**
1814
- * Trigger an event, async listener alter given value and return it.
1815
- * @param event
1816
- * @param value
1817
- * @param args
1818
- * @param callThis
1819
- */
1820
-
1821
-
1822
- async asyncAlter(event, value, args = [], callThis = null) {
1823
- if (this.listeners.has(event)) {
1824
- for (const cb of this.listeners.get(event)) {
1825
- value = await cb.call(callThis, value, ...args);
1826
- }
1827
- }
1828
-
1829
- return value;
1830
- }
1831
-
1832
- }
1833
-
1834
- const Type = Function; // @ts-ignore
1835
-
1836
- global.Type = Type;
1837
-
1838
- /**
1839
- * @ignore
1840
- */
1841
-
1842
- function isResponse(obj) {
1843
- return obj.data && obj.headers && obj.status && obj.statusText;
1844
- }
1845
- /**
1846
- * @ignore
1847
- */
1848
-
1849
-
1850
- exports.AnyToPromiseStatus = void 0;
1851
-
1852
- (function (AnyToPromiseStatus) {
1853
- AnyToPromiseStatus["PENDING"] = "PENDING";
1854
- AnyToPromiseStatus["CANCELED"] = "CANCELED";
1855
- AnyToPromiseStatus["RESOLVED"] = "RESOLVED";
1856
- AnyToPromiseStatus["REJECTED"] = "REJECTED";
1857
- })(exports.AnyToPromiseStatus || (exports.AnyToPromiseStatus = {}));
1858
-
1859
- exports.AnyToPromiseResponseTypes = void 0;
1860
-
1861
- (function (AnyToPromiseResponseTypes) {
1862
- AnyToPromiseResponseTypes["STREAM"] = "STREAM";
1863
- AnyToPromiseResponseTypes["BUFFER"] = "BUFFER";
1864
- AnyToPromiseResponseTypes["DATA"] = "DATA";
1865
- })(exports.AnyToPromiseResponseTypes || (exports.AnyToPromiseResponseTypes = {}));
1866
-
1867
- var _resolves = /*#__PURE__*/_classPrivateFieldLooseKey("resolves");
1868
-
1869
- var _rejects = /*#__PURE__*/_classPrivateFieldLooseKey("rejects");
1870
-
1871
- var _hasNextFunction = /*#__PURE__*/_classPrivateFieldLooseKey("hasNextFunction");
1872
-
1873
- var _promise = /*#__PURE__*/_classPrivateFieldLooseKey("promise");
1874
-
1875
- class AnyToPromise {
1876
- constructor({
1877
- hasNextFunction = false
1878
- } = {}) {
1879
- Object.defineProperty(this, _resolves, {
1880
- writable: true,
1881
- value: void 0
1882
- });
1883
- Object.defineProperty(this, _rejects, {
1884
- writable: true,
1885
- value: void 0
1886
- });
1887
- Object.defineProperty(this, _hasNextFunction, {
1888
- writable: true,
1889
- value: void 0
1890
- });
1891
- Object.defineProperty(this, _promise, {
1892
- writable: true,
1893
- value: void 0
1894
- });
1895
- this.status = exports.AnyToPromiseStatus.PENDING;
1896
- _classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = false;
1897
- _classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = hasNextFunction;
1898
- _classPrivateFieldLooseBase(this, _promise)[_promise] = new Promise((resolve, reject) => {
1899
- _classPrivateFieldLooseBase(this, _resolves)[_resolves] = resolve;
1900
- _classPrivateFieldLooseBase(this, _rejects)[_rejects] = reject;
1901
- });
1902
- }
1903
-
1904
- isDone() {
1905
- return this.status !== exports.AnyToPromiseStatus.PENDING;
1906
- }
1907
-
1908
- get next() {
1909
- _classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction] = true;
1910
- return error => {
1911
- if (this.isDone()) {
1912
- return;
1913
- }
1914
-
1915
- return error ? this.reject(error) : this.resolve({
1916
- type: exports.AnyToPromiseResponseTypes.DATA
1917
- });
1918
- };
1919
- }
1920
- /**
1921
- *
1922
- */
1923
-
1924
-
1925
- async call(cb) {
1926
- if (this.isDone()) {
1927
- return this;
1928
- }
1929
-
1930
- try {
1931
- this.handle(cb());
1932
- } catch (er) {
1933
- this.reject(er);
1934
- }
1935
-
1936
- return _classPrivateFieldLooseBase(this, _promise)[_promise];
1937
- }
1938
-
1939
- reject(er) {
1940
- if (this.isDone()) {
1941
- return;
1942
- }
1943
-
1944
- this.done(exports.AnyToPromiseStatus.REJECTED);
1945
-
1946
- _classPrivateFieldLooseBase(this, _rejects)[_rejects](er);
1947
- }
1948
-
1949
- resolve(response = {}) {
1950
- if (this.isDone()) {
1951
- return;
1952
- }
1953
-
1954
- this.done(exports.AnyToPromiseStatus.RESOLVED);
1955
-
1956
- _classPrivateFieldLooseBase(this, _resolves)[_resolves](_extends({}, response, {
1957
- state: exports.AnyToPromiseStatus.RESOLVED
1958
- }));
1959
- }
1960
-
1961
- destroy() {}
1962
-
1963
- cancel() {
1964
- if (this.isDone()) {
1965
- return;
1966
- }
1967
-
1968
- this.done(exports.AnyToPromiseStatus.CANCELED);
1969
- return _classPrivateFieldLooseBase(this, _resolves)[_resolves]({
1970
- state: exports.AnyToPromiseStatus.CANCELED
1971
- });
1972
- }
1973
-
1974
- done(status) {
1975
- this.destroy();
1976
- this.status = status;
1977
- }
1978
-
1979
- handle(process, additionalProps = {}) {
1980
- if (this.isDone()) {
1981
- return;
1982
- }
1983
-
1984
- if (process) {
1985
- if (this.isCanceledResponse(process)) {
1986
- // ABANDON
1987
- return this.cancel();
1988
- }
1989
-
1990
- if (isObservable(process)) {
1991
- process = process.toPromise();
1992
- }
1993
-
1994
- if (isResponse(process)) {
1995
- return this.handle(process.data, _extends({}, additionalProps, {
1996
- status: process.status,
1997
- headers: process.headers
1998
- }));
1999
- }
2000
-
2001
- if (isStream(process)) {
2002
- return this.resolve(_extends({}, additionalProps, {
2003
- type: exports.AnyToPromiseResponseTypes.STREAM,
2004
- data: process
2005
- }));
2006
- }
2007
-
2008
- if (isStream(process) || Buffer.isBuffer(process)) {
2009
- return this.resolve(_extends({}, additionalProps, {
2010
- type: exports.AnyToPromiseResponseTypes.BUFFER,
2011
- data: process
2012
- }));
2013
- }
2014
-
2015
- if (isPromise(process)) {
2016
- return process.then(result => this.handle(result, additionalProps)).catch(error => {
2017
- if (error.response && isResponse(error.response)) {
2018
- return this.handle(error.response);
2019
- }
2020
-
2021
- return this.reject(error);
2022
- });
2023
- }
2024
- }
2025
-
2026
- if (!_classPrivateFieldLooseBase(this, _hasNextFunction)[_hasNextFunction]) {
2027
- // no next function and empty response
2028
- return this.resolve(_extends({}, additionalProps, {
2029
- data: process,
2030
- type: exports.AnyToPromiseResponseTypes.DATA
2031
- }));
2032
- }
2033
- }
2034
-
2035
- isCanceledResponse(process) {
2036
- return process === exports.AnyToPromiseStatus.CANCELED;
2037
- }
2038
-
2039
- }
2040
-
2041
- class UnsupportedDecoratorType extends Error {
2042
- constructor(decorator, args) {
2043
- super(UnsupportedDecoratorType.buildMessage(decorator, args));
2044
- }
2045
-
2046
- static buildMessage(decorator, args) {
2047
- const [target, propertyKey, index] = args;
2048
- const bindingType = decoratorTypeOf(args);
2049
- const shortBinding = bindingType.split("/")[0];
2050
- const param = shortBinding === "parameter" ? ".[" + index + "]" : "";
2051
- const cstr = shortBinding === "parameter" ? ".constructor" : "";
2052
- const method = propertyKey ? "." + propertyKey : cstr;
2053
- const path = nameOf(classOf(target)) + method + param;
2054
- return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;
2055
- }
2056
-
2057
- }
2058
-
2059
- /**
2060
- * The `@Deprecated()` decorators wraps the given method in such a way that it is marked as deprecated.
2061
- *
2062
- * ```typescript
2063
- * provide Foo {
2064
- *
2065
- * @Deprecated("Foo.method: Use Foo.method2 instead")
2066
- * public method() {
2067
- *
2068
- * }
2069
- * ```
2070
- *
2071
- * When called, @Deprecated() will return a function that will emit a `DeprecationWarning` using the `process.on('warning')` event.
2072
- * 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.
2073
- *
2074
- * If either the `--no-deprecation` or `--no-warnings` command line flags are used, or if the `process.noDeprecation`
2075
- * property is set to `true` prior to the first deprecation warning, the `@Deprecated()` decorators does nothing.
2076
- *
2077
- * If the `--trace-deprecation` or `--trace-warnings` command line flags are set, or the `process.traceDeprecation`
2078
- * property is set to `true`, a warning and a stack trace are printed to stderr the first time the deprecated function is called.
2079
- *
2080
- * If the `--throw-deprecation` command line flag is set, or the `process.throwDeprecation` property is set to `true`,
2081
- * then an exception will be thrown when the deprecated function is called.
2082
- *
2083
- * The `--throw-deprecation` command line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation`
2084
- * and `process.traceDeprecation`.
2085
- *
2086
- * @param message
2087
- * @returns {Function}
2088
- * @decorator
2089
- */
2090
- function Deprecated(message) {
2091
- return (target, targetKey, descriptor) => {
2092
- const originalMethod = descriptor.value;
2093
- descriptor.value = require("util").deprecate(originalMethod, message);
2094
- return descriptor;
2095
- };
2096
- }
2097
-
2098
- /**
2099
- * @module common/core
2100
- */
2101
- /** */
2102
-
2103
- function Configurable(value = true) {
2104
- return (target, propertyKey) => {
2105
- const descriptor = descriptorOf(target, propertyKey) || {
2106
- writable: true,
2107
- enumerable: true
2108
- };
2109
- descriptor.configurable = value;
2110
- Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
2111
- return descriptor;
2112
- };
2113
- }
2114
-
2115
- /**
2116
- * @module common/core
2117
- */
2118
- /** */
2119
-
2120
- function Enumerable(value = true) {
2121
- return (target, propertyKey) => {
2122
- const descriptor = descriptorOf(target, propertyKey) || {
2123
- writable: true,
2124
- configurable: true
2125
- };
2126
- descriptor.enumerable = value;
2127
- Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
2128
- return descriptor;
2129
- };
2130
- }
2131
-
2132
- /**
2133
- * @module common/core
2134
- */
2135
- /** */
2136
-
2137
- function Writable(value = true) {
2138
- return (target, propertyKey) => {
2139
- const descriptor = descriptorOf(target, propertyKey) || {
2140
- configurable: true,
2141
- enumerable: true
2142
- };
2143
- descriptor.writable = value;
2144
- Object.defineProperty(target && target.prototype || target, propertyKey, descriptor);
2145
- return descriptor;
2146
- };
2147
- }
2148
-
2149
- /**
2150
- * @module common/core
2151
- */
2152
- /** */
2153
-
2154
- function Readonly() {
2155
- return Writable(false);
2156
- }
2157
-
2158
- /**
2159
- * @module common/core
2160
- */
2161
- /** */
2162
-
2163
- function NotConfigurable() {
2164
- return Configurable(false);
2165
- }
2166
-
2167
- /**
2168
- * @module common/core
2169
- */
2170
- /** */
2171
-
2172
- function NotEnumerable() {
2173
- return Enumerable(false);
2174
- }
2175
-
2176
- /**
2177
- * Create a store correctly configured from the parameters given by the decorator.
2178
- * The `fn` can return a decorator that will be initialized with the parameters (target, propertyKey, descriptor).
2179
- * @param {(store: Store, parameters: DecoratorParameters) => void} fn
2180
- * @returns {Function}
2181
- */
2182
-
2183
- function StoreFn(fn) {
2184
- return (...parameters) => {
2185
- const store = Store.from(...parameters);
2186
- const result = fn(store, parameters);
2187
-
2188
- if (typeof result === "function") {
2189
- result(...parameters);
2190
- }
2191
-
2192
- return parameters[2];
2193
- };
2194
- }
2195
-
2196
- function StoreSet(key, value) {
2197
- return StoreFn(store => {
2198
- store.set(key, value);
2199
- });
2200
- }
2201
-
2202
- function StoreMerge(key, value) {
2203
- return StoreFn(store => {
2204
- store.merge(key, value);
2205
- });
2206
- }
2207
-
2208
- exports.AnyToPromise = AnyToPromise;
2209
- exports.CLASS_STORE = CLASS_STORE;
2210
- exports.Configurable = Configurable;
2211
- exports.Deprecated = Deprecated;
2212
- exports.Entity = Entity;
2213
- exports.Enumerable = Enumerable;
2214
- exports.EnvTypes = EnvTypes;
2215
- exports.Hooks = Hooks;
2216
- exports.METHOD_STORE = METHOD_STORE;
2217
- exports.Metadata = Metadata;
2218
- exports.NotConfigurable = NotConfigurable;
2219
- exports.NotEnumerable = NotEnumerable;
2220
- exports.PARAM_STORE = PARAM_STORE;
2221
- exports.PROPERTY_STORE = PROPERTY_STORE;
2222
- exports.Readonly = Readonly;
2223
- exports.Store = Store;
2224
- exports.StoreFn = StoreFn;
2225
- exports.StoreMerge = StoreMerge;
2226
- exports.StoreSet = StoreSet;
2227
- exports.Type = Type;
2228
- exports.UnsupportedDecoratorType = UnsupportedDecoratorType;
2229
- exports.Writable = Writable;
2230
- exports.ancestorOf = ancestorOf;
2231
- exports.ancestorsOf = ancestorsOf;
2232
- exports.catchAsyncError = catchAsyncError;
2233
- exports.catchError = catchError;
2234
- exports.classOf = classOf;
2235
- exports.cleanObject = cleanObject;
2236
- exports.constructorOf = constructorOf;
2237
- exports.decorateMethodsOf = decorateMethodsOf;
2238
- exports.decoratorArgs = decoratorArgs;
2239
- exports.decoratorTypeOf = decoratorTypeOf;
2240
- exports.deepClone = deepClone;
2241
- exports.deepMerge = deepMerge;
2242
- exports.descriptorOf = descriptorOf;
2243
- exports.getClass = getClass;
2244
- exports.getClassOrSymbol = getClassOrSymbol;
2245
- exports.getConstructor = getConstructor;
2246
- exports.getConstructorArgNames = getConstructorArgNames;
2247
- exports.getEnumerableKeys = getEnumerableKeys;
2248
- exports.getInheritedClass = getInheritedClass;
2249
- exports.getValue = getValue;
2250
- exports.inheritedDescriptorOf = inheritedDescriptorOf;
2251
- exports.isArray = isArray;
2252
- exports.isArrayOrArrayClass = isArrayOrArrayClass;
2253
- exports.isArrowFn = isArrowFn;
2254
- exports.isBoolean = isBoolean;
2255
- exports.isBooleanOrBooleanClass = isBooleanOrBooleanClass;
2256
- exports.isClass = isClass;
2257
- exports.isClassObject = isClassObject;
2258
- exports.isCollection = isCollection;
2259
- exports.isDate = isDate;
2260
- exports.isEmpty = isEmpty;
2261
- exports.isEnumerable = isEnumerable;
2262
- exports.isFunction = isFunction;
2263
- exports.isInheritedFrom = isInheritedFrom;
2264
- exports.isNil = isNil;
2265
- exports.isNumber = isNumber;
2266
- exports.isNumberOrNumberClass = isNumberOrNumberClass;
2267
- exports.isObject = isObject;
2268
- exports.isObservable = isObservable;
2269
- exports.isPlainObject = isPlainObject;
2270
- exports.isPrimitive = isPrimitive;
2271
- exports.isPrimitiveClass = isPrimitiveClass;
2272
- exports.isPrimitiveOrPrimitiveClass = isPrimitiveOrPrimitiveClass;
2273
- exports.isPromise = isPromise;
2274
- exports.isProtectedKey = isProtectedKey;
2275
- exports.isSerializable = isSerializable;
2276
- exports.isStream = isStream;
2277
- exports.isString = isString;
2278
- exports.isStringOrStringClass = isStringOrStringClass;
2279
- exports.isSymbol = isSymbol;
2280
- exports.isSymbolOrSymbolClass = isSymbolOrSymbolClass;
2281
- exports.mergeReducerBuilder = mergeReducerBuilder;
2282
- exports.methodsOf = methodsOf;
2283
- exports.nameOf = nameOf;
2284
- exports.nameOfClass = nameOfClass;
2285
- exports.nameOfSymbol = nameOfSymbol;
2286
- exports.objectKeys = objectKeys;
2287
- exports.primitiveOf = primitiveOf;
2288
- exports.prototypeOf = prototypeOf;
2289
- exports.proxyDelegation = proxyDelegation;
2290
- exports.setValue = setValue;
2291
- exports.toMap = toMap;
2292
- exports.toStringConstructor = toStringConstructor;
2293
- exports.uniq = uniq;
2294
- exports.uniqBy = uniqBy;
2295
- exports.useDecorators = useDecorators;
2296
- exports.useMethodDecorator = useMethodDecorator;
2297
- exports.useMethodDecorators = useMethodDecorators;
2298
- //# sourceMappingURL=index.js.map