@tsed/core 6.87.1 → 6.89.0

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