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