@tsed/core 7.0.0-alpha.1 → 7.0.0-beta.3

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