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