@webiny/stdlib 0.0.1

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 (302) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/README.md +60 -0
  5. package/dist/browser/features/LocalStorageCache/LocalStorageCache.d.ts +26 -0
  6. package/dist/browser/features/LocalStorageCache/LocalStorageCache.d.ts.map +1 -0
  7. package/dist/browser/features/LocalStorageCache/LocalStorageCache.js +159 -0
  8. package/dist/browser/features/LocalStorageCache/LocalStorageCache.js.map +1 -0
  9. package/dist/browser/features/LocalStorageCache/errors.d.ts +26 -0
  10. package/dist/browser/features/LocalStorageCache/errors.d.ts.map +1 -0
  11. package/dist/browser/features/LocalStorageCache/errors.js +23 -0
  12. package/dist/browser/features/LocalStorageCache/errors.js.map +1 -0
  13. package/dist/browser/features/LocalStorageCache/feature.d.ts +6 -0
  14. package/dist/browser/features/LocalStorageCache/feature.d.ts.map +1 -0
  15. package/dist/browser/features/LocalStorageCache/feature.js +10 -0
  16. package/dist/browser/features/LocalStorageCache/feature.js.map +1 -0
  17. package/dist/browser/features/LocalStorageCache/index.d.ts +4 -0
  18. package/dist/browser/features/LocalStorageCache/index.d.ts.map +1 -0
  19. package/dist/browser/features/LocalStorageCache/index.js +4 -0
  20. package/dist/browser/features/LocalStorageCache/index.js.map +1 -0
  21. package/dist/browser/index.d.ts +2 -0
  22. package/dist/browser/index.d.ts.map +1 -0
  23. package/dist/browser/index.js +2 -0
  24. package/dist/browser/index.js.map +1 -0
  25. package/dist/common/core/BaseError.d.ts +13 -0
  26. package/dist/common/core/BaseError.d.ts.map +1 -0
  27. package/dist/common/core/BaseError.js +8 -0
  28. package/dist/common/core/BaseError.js.map +1 -0
  29. package/dist/common/core/Result.d.ts +103 -0
  30. package/dist/common/core/Result.d.ts.map +1 -0
  31. package/dist/common/core/Result.js +127 -0
  32. package/dist/common/core/Result.js.map +1 -0
  33. package/dist/common/core/ResultAsync.d.ts +17 -0
  34. package/dist/common/core/ResultAsync.d.ts.map +1 -0
  35. package/dist/common/core/ResultAsync.js +62 -0
  36. package/dist/common/core/ResultAsync.js.map +1 -0
  37. package/dist/common/core/createAbstraction.d.ts +4 -0
  38. package/dist/common/core/createAbstraction.d.ts.map +1 -0
  39. package/dist/common/core/createAbstraction.js +5 -0
  40. package/dist/common/core/createAbstraction.js.map +1 -0
  41. package/dist/common/core/createFeature.d.ts +10 -0
  42. package/dist/common/core/createFeature.d.ts.map +1 -0
  43. package/dist/common/core/createFeature.js +9 -0
  44. package/dist/common/core/createFeature.js.map +1 -0
  45. package/dist/common/core/index.d.ts +7 -0
  46. package/dist/common/core/index.d.ts.map +1 -0
  47. package/dist/common/core/index.js +6 -0
  48. package/dist/common/core/index.js.map +1 -0
  49. package/dist/common/features/Cache/AsyncMemoryCache.d.ts +23 -0
  50. package/dist/common/features/Cache/AsyncMemoryCache.d.ts.map +1 -0
  51. package/dist/common/features/Cache/AsyncMemoryCache.js +90 -0
  52. package/dist/common/features/Cache/AsyncMemoryCache.js.map +1 -0
  53. package/dist/common/features/Cache/AsyncMemoryCacheFeature.d.ts +6 -0
  54. package/dist/common/features/Cache/AsyncMemoryCacheFeature.d.ts.map +1 -0
  55. package/dist/common/features/Cache/AsyncMemoryCacheFeature.js +10 -0
  56. package/dist/common/features/Cache/AsyncMemoryCacheFeature.js.map +1 -0
  57. package/dist/common/features/Cache/MemoryCache.d.ts +23 -0
  58. package/dist/common/features/Cache/MemoryCache.d.ts.map +1 -0
  59. package/dist/common/features/Cache/MemoryCache.js +75 -0
  60. package/dist/common/features/Cache/MemoryCache.js.map +1 -0
  61. package/dist/common/features/Cache/MemoryCacheFeature.d.ts +6 -0
  62. package/dist/common/features/Cache/MemoryCacheFeature.d.ts.map +1 -0
  63. package/dist/common/features/Cache/MemoryCacheFeature.js +10 -0
  64. package/dist/common/features/Cache/MemoryCacheFeature.js.map +1 -0
  65. package/dist/common/features/Cache/abstractions/AsyncCache.d.ts +39 -0
  66. package/dist/common/features/Cache/abstractions/AsyncCache.d.ts.map +1 -0
  67. package/dist/common/features/Cache/abstractions/AsyncCache.js +3 -0
  68. package/dist/common/features/Cache/abstractions/AsyncCache.js.map +1 -0
  69. package/dist/common/features/Cache/abstractions/Cache.d.ts +39 -0
  70. package/dist/common/features/Cache/abstractions/Cache.d.ts.map +1 -0
  71. package/dist/common/features/Cache/abstractions/Cache.js +3 -0
  72. package/dist/common/features/Cache/abstractions/Cache.js.map +1 -0
  73. package/dist/common/features/Cache/abstractions/CacheError.d.ts +5 -0
  74. package/dist/common/features/Cache/abstractions/CacheError.d.ts.map +1 -0
  75. package/dist/common/features/Cache/abstractions/CacheError.js +5 -0
  76. package/dist/common/features/Cache/abstractions/CacheError.js.map +1 -0
  77. package/dist/common/features/Cache/abstractions/index.d.ts +4 -0
  78. package/dist/common/features/Cache/abstractions/index.d.ts.map +1 -0
  79. package/dist/common/features/Cache/abstractions/index.js +4 -0
  80. package/dist/common/features/Cache/abstractions/index.js.map +1 -0
  81. package/dist/common/features/Cache/index.d.ts +8 -0
  82. package/dist/common/features/Cache/index.d.ts.map +1 -0
  83. package/dist/common/features/Cache/index.js +6 -0
  84. package/dist/common/features/Cache/index.js.map +1 -0
  85. package/dist/common/features/Logger/ConsoleLogger.d.ts +28 -0
  86. package/dist/common/features/Logger/ConsoleLogger.d.ts.map +1 -0
  87. package/dist/common/features/Logger/ConsoleLogger.js +84 -0
  88. package/dist/common/features/Logger/ConsoleLogger.js.map +1 -0
  89. package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.d.ts +27 -0
  90. package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.d.ts.map +1 -0
  91. package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.js +3 -0
  92. package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.js.map +1 -0
  93. package/dist/common/features/Logger/abstractions/Logger.d.ts +20 -0
  94. package/dist/common/features/Logger/abstractions/Logger.d.ts.map +1 -0
  95. package/dist/common/features/Logger/abstractions/Logger.js +3 -0
  96. package/dist/common/features/Logger/abstractions/Logger.js.map +1 -0
  97. package/dist/common/features/Logger/abstractions/index.d.ts +3 -0
  98. package/dist/common/features/Logger/abstractions/index.d.ts.map +1 -0
  99. package/dist/common/features/Logger/abstractions/index.js +3 -0
  100. package/dist/common/features/Logger/abstractions/index.js.map +1 -0
  101. package/dist/common/features/Logger/feature.d.ts +9 -0
  102. package/dist/common/features/Logger/feature.d.ts.map +1 -0
  103. package/dist/common/features/Logger/feature.js +13 -0
  104. package/dist/common/features/Logger/feature.js.map +1 -0
  105. package/dist/common/features/Logger/index.d.ts +5 -0
  106. package/dist/common/features/Logger/index.d.ts.map +1 -0
  107. package/dist/common/features/Logger/index.js +5 -0
  108. package/dist/common/features/Logger/index.js.map +1 -0
  109. package/dist/common/index.d.ts +11 -0
  110. package/dist/common/index.d.ts.map +1 -0
  111. package/dist/common/index.js +9 -0
  112. package/dist/common/index.js.map +1 -0
  113. package/dist/common/utils/boolean.d.ts +7 -0
  114. package/dist/common/utils/boolean.d.ts.map +1 -0
  115. package/dist/common/utils/boolean.js +22 -0
  116. package/dist/common/utils/boolean.js.map +1 -0
  117. package/dist/common/utils/dotProp.d.ts +23 -0
  118. package/dist/common/utils/dotProp.d.ts.map +1 -0
  119. package/dist/common/utils/dotProp.js +45 -0
  120. package/dist/common/utils/dotProp.js.map +1 -0
  121. package/dist/index.d.ts +2 -0
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +2 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/node/features/DirectoryTool/DirectoryTool.d.ts +24 -0
  126. package/dist/node/features/DirectoryTool/DirectoryTool.d.ts.map +1 -0
  127. package/dist/node/features/DirectoryTool/DirectoryTool.js +83 -0
  128. package/dist/node/features/DirectoryTool/DirectoryTool.js.map +1 -0
  129. package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.d.ts +32 -0
  130. package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.d.ts.map +1 -0
  131. package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.js +3 -0
  132. package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.js.map +1 -0
  133. package/dist/node/features/DirectoryTool/abstractions/index.d.ts +2 -0
  134. package/dist/node/features/DirectoryTool/abstractions/index.d.ts.map +1 -0
  135. package/dist/node/features/DirectoryTool/abstractions/index.js +2 -0
  136. package/dist/node/features/DirectoryTool/abstractions/index.js.map +1 -0
  137. package/dist/node/features/DirectoryTool/feature.d.ts +5 -0
  138. package/dist/node/features/DirectoryTool/feature.d.ts.map +1 -0
  139. package/dist/node/features/DirectoryTool/feature.js +9 -0
  140. package/dist/node/features/DirectoryTool/feature.js.map +1 -0
  141. package/dist/node/features/DirectoryTool/index.d.ts +4 -0
  142. package/dist/node/features/DirectoryTool/index.d.ts.map +1 -0
  143. package/dist/node/features/DirectoryTool/index.js +4 -0
  144. package/dist/node/features/DirectoryTool/index.js.map +1 -0
  145. package/dist/node/features/FileTool/FileTool.d.ts +26 -0
  146. package/dist/node/features/FileTool/FileTool.d.ts.map +1 -0
  147. package/dist/node/features/FileTool/FileTool.js +71 -0
  148. package/dist/node/features/FileTool/FileTool.js.map +1 -0
  149. package/dist/node/features/FileTool/abstractions/FileTool.d.ts +15 -0
  150. package/dist/node/features/FileTool/abstractions/FileTool.d.ts.map +1 -0
  151. package/dist/node/features/FileTool/abstractions/FileTool.js +3 -0
  152. package/dist/node/features/FileTool/abstractions/FileTool.js.map +1 -0
  153. package/dist/node/features/FileTool/abstractions/index.d.ts +2 -0
  154. package/dist/node/features/FileTool/abstractions/index.d.ts.map +1 -0
  155. package/dist/node/features/FileTool/abstractions/index.js +2 -0
  156. package/dist/node/features/FileTool/abstractions/index.js.map +1 -0
  157. package/dist/node/features/FileTool/feature.d.ts +5 -0
  158. package/dist/node/features/FileTool/feature.d.ts.map +1 -0
  159. package/dist/node/features/FileTool/feature.js +9 -0
  160. package/dist/node/features/FileTool/feature.js.map +1 -0
  161. package/dist/node/features/FileTool/index.d.ts +4 -0
  162. package/dist/node/features/FileTool/index.d.ts.map +1 -0
  163. package/dist/node/features/FileTool/index.js +4 -0
  164. package/dist/node/features/FileTool/index.js.map +1 -0
  165. package/dist/node/features/JsonFileTool/JsonFileTool.d.ts +19 -0
  166. package/dist/node/features/JsonFileTool/JsonFileTool.d.ts.map +1 -0
  167. package/dist/node/features/JsonFileTool/JsonFileTool.js +43 -0
  168. package/dist/node/features/JsonFileTool/JsonFileTool.js.map +1 -0
  169. package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.d.ts +17 -0
  170. package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.d.ts.map +1 -0
  171. package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.js +3 -0
  172. package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.js.map +1 -0
  173. package/dist/node/features/JsonFileTool/abstractions/index.d.ts +2 -0
  174. package/dist/node/features/JsonFileTool/abstractions/index.d.ts.map +1 -0
  175. package/dist/node/features/JsonFileTool/abstractions/index.js +2 -0
  176. package/dist/node/features/JsonFileTool/abstractions/index.js.map +1 -0
  177. package/dist/node/features/JsonFileTool/feature.d.ts +5 -0
  178. package/dist/node/features/JsonFileTool/feature.d.ts.map +1 -0
  179. package/dist/node/features/JsonFileTool/feature.js +9 -0
  180. package/dist/node/features/JsonFileTool/feature.js.map +1 -0
  181. package/dist/node/features/JsonFileTool/index.d.ts +4 -0
  182. package/dist/node/features/JsonFileTool/index.d.ts.map +1 -0
  183. package/dist/node/features/JsonFileTool/index.js +4 -0
  184. package/dist/node/features/JsonFileTool/index.js.map +1 -0
  185. package/dist/node/features/NdJsonReaderTool/LineAccumulator.d.ts +13 -0
  186. package/dist/node/features/NdJsonReaderTool/LineAccumulator.d.ts.map +1 -0
  187. package/dist/node/features/NdJsonReaderTool/LineAccumulator.js +68 -0
  188. package/dist/node/features/NdJsonReaderTool/LineAccumulator.js.map +1 -0
  189. package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.d.ts +22 -0
  190. package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.d.ts.map +1 -0
  191. package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.js +73 -0
  192. package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.js.map +1 -0
  193. package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.d.ts +41 -0
  194. package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.d.ts.map +1 -0
  195. package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.js +3 -0
  196. package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.js.map +1 -0
  197. package/dist/node/features/NdJsonReaderTool/abstractions/index.d.ts +2 -0
  198. package/dist/node/features/NdJsonReaderTool/abstractions/index.d.ts.map +1 -0
  199. package/dist/node/features/NdJsonReaderTool/abstractions/index.js +2 -0
  200. package/dist/node/features/NdJsonReaderTool/abstractions/index.js.map +1 -0
  201. package/dist/node/features/NdJsonReaderTool/feature.d.ts +5 -0
  202. package/dist/node/features/NdJsonReaderTool/feature.d.ts.map +1 -0
  203. package/dist/node/features/NdJsonReaderTool/feature.js +9 -0
  204. package/dist/node/features/NdJsonReaderTool/feature.js.map +1 -0
  205. package/dist/node/features/NdJsonReaderTool/index.d.ts +4 -0
  206. package/dist/node/features/NdJsonReaderTool/index.d.ts.map +1 -0
  207. package/dist/node/features/NdJsonReaderTool/index.js +4 -0
  208. package/dist/node/features/NdJsonReaderTool/index.js.map +1 -0
  209. package/dist/node/features/PackageJsonFileTool/PackageJsonFile.d.ts +67 -0
  210. package/dist/node/features/PackageJsonFileTool/PackageJsonFile.d.ts.map +1 -0
  211. package/dist/node/features/PackageJsonFileTool/PackageJsonFile.js +91 -0
  212. package/dist/node/features/PackageJsonFileTool/PackageJsonFile.js.map +1 -0
  213. package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.d.ts +23 -0
  214. package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.d.ts.map +1 -0
  215. package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.js +75 -0
  216. package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.js.map +1 -0
  217. package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.d.ts +40 -0
  218. package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.d.ts.map +1 -0
  219. package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.js +3 -0
  220. package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.js.map +1 -0
  221. package/dist/node/features/PackageJsonFileTool/abstractions/index.d.ts +2 -0
  222. package/dist/node/features/PackageJsonFileTool/abstractions/index.d.ts.map +1 -0
  223. package/dist/node/features/PackageJsonFileTool/abstractions/index.js +2 -0
  224. package/dist/node/features/PackageJsonFileTool/abstractions/index.js.map +1 -0
  225. package/dist/node/features/PackageJsonFileTool/feature.d.ts +5 -0
  226. package/dist/node/features/PackageJsonFileTool/feature.d.ts.map +1 -0
  227. package/dist/node/features/PackageJsonFileTool/feature.js +9 -0
  228. package/dist/node/features/PackageJsonFileTool/feature.js.map +1 -0
  229. package/dist/node/features/PackageJsonFileTool/index.d.ts +5 -0
  230. package/dist/node/features/PackageJsonFileTool/index.d.ts.map +1 -0
  231. package/dist/node/features/PackageJsonFileTool/index.js +5 -0
  232. package/dist/node/features/PackageJsonFileTool/index.js.map +1 -0
  233. package/dist/node/features/PathTool/PathTool.d.ts +14 -0
  234. package/dist/node/features/PathTool/PathTool.d.ts.map +1 -0
  235. package/dist/node/features/PathTool/PathTool.js +38 -0
  236. package/dist/node/features/PathTool/PathTool.js.map +1 -0
  237. package/dist/node/features/PathTool/abstractions/PathTool.d.ts +23 -0
  238. package/dist/node/features/PathTool/abstractions/PathTool.d.ts.map +1 -0
  239. package/dist/node/features/PathTool/abstractions/PathTool.js +3 -0
  240. package/dist/node/features/PathTool/abstractions/PathTool.js.map +1 -0
  241. package/dist/node/features/PathTool/abstractions/index.d.ts +2 -0
  242. package/dist/node/features/PathTool/abstractions/index.d.ts.map +1 -0
  243. package/dist/node/features/PathTool/abstractions/index.js +2 -0
  244. package/dist/node/features/PathTool/abstractions/index.js.map +1 -0
  245. package/dist/node/features/PathTool/errors.d.ts +12 -0
  246. package/dist/node/features/PathTool/errors.d.ts.map +1 -0
  247. package/dist/node/features/PathTool/errors.js +9 -0
  248. package/dist/node/features/PathTool/errors.js.map +1 -0
  249. package/dist/node/features/PathTool/feature.d.ts +5 -0
  250. package/dist/node/features/PathTool/feature.d.ts.map +1 -0
  251. package/dist/node/features/PathTool/feature.js +9 -0
  252. package/dist/node/features/PathTool/feature.js.map +1 -0
  253. package/dist/node/features/PathTool/index.d.ts +5 -0
  254. package/dist/node/features/PathTool/index.d.ts.map +1 -0
  255. package/dist/node/features/PathTool/index.js +5 -0
  256. package/dist/node/features/PathTool/index.js.map +1 -0
  257. package/dist/node/features/PinoLogger/PinoLogger.d.ts +27 -0
  258. package/dist/node/features/PinoLogger/PinoLogger.d.ts.map +1 -0
  259. package/dist/node/features/PinoLogger/PinoLogger.js +152 -0
  260. package/dist/node/features/PinoLogger/PinoLogger.js.map +1 -0
  261. package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.d.ts +24 -0
  262. package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.d.ts.map +1 -0
  263. package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.js +3 -0
  264. package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.js.map +1 -0
  265. package/dist/node/features/PinoLogger/abstractions/index.d.ts +2 -0
  266. package/dist/node/features/PinoLogger/abstractions/index.d.ts.map +1 -0
  267. package/dist/node/features/PinoLogger/abstractions/index.js +2 -0
  268. package/dist/node/features/PinoLogger/abstractions/index.js.map +1 -0
  269. package/dist/node/features/PinoLogger/feature.d.ts +9 -0
  270. package/dist/node/features/PinoLogger/feature.d.ts.map +1 -0
  271. package/dist/node/features/PinoLogger/feature.js +13 -0
  272. package/dist/node/features/PinoLogger/feature.js.map +1 -0
  273. package/dist/node/features/PinoLogger/index.d.ts +4 -0
  274. package/dist/node/features/PinoLogger/index.d.ts.map +1 -0
  275. package/dist/node/features/PinoLogger/index.js +4 -0
  276. package/dist/node/features/PinoLogger/index.js.map +1 -0
  277. package/dist/node/features/ReadStreamFactory/ReadStreamFactory.d.ts +11 -0
  278. package/dist/node/features/ReadStreamFactory/ReadStreamFactory.d.ts.map +1 -0
  279. package/dist/node/features/ReadStreamFactory/ReadStreamFactory.js +27 -0
  280. package/dist/node/features/ReadStreamFactory/ReadStreamFactory.js.map +1 -0
  281. package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.d.ts +21 -0
  282. package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.d.ts.map +1 -0
  283. package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.js +3 -0
  284. package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.js.map +1 -0
  285. package/dist/node/features/ReadStreamFactory/abstractions/index.d.ts +2 -0
  286. package/dist/node/features/ReadStreamFactory/abstractions/index.d.ts.map +1 -0
  287. package/dist/node/features/ReadStreamFactory/abstractions/index.js +2 -0
  288. package/dist/node/features/ReadStreamFactory/abstractions/index.js.map +1 -0
  289. package/dist/node/features/ReadStreamFactory/feature.d.ts +5 -0
  290. package/dist/node/features/ReadStreamFactory/feature.d.ts.map +1 -0
  291. package/dist/node/features/ReadStreamFactory/feature.js +9 -0
  292. package/dist/node/features/ReadStreamFactory/feature.js.map +1 -0
  293. package/dist/node/features/ReadStreamFactory/index.d.ts +4 -0
  294. package/dist/node/features/ReadStreamFactory/index.d.ts.map +1 -0
  295. package/dist/node/features/ReadStreamFactory/index.js +4 -0
  296. package/dist/node/features/ReadStreamFactory/index.js.map +1 -0
  297. package/dist/node/index.d.ts +9 -0
  298. package/dist/node/index.d.ts.map +1 -0
  299. package/dist/node/index.js +9 -0
  300. package/dist/node/index.js.map +1 -0
  301. package/dist/package.json +58 -0
  302. package/package.json +61 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Result.d.ts","sourceRoot":"","sources":["../../../src/common/core/Result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IACtC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEnC,OAAO,eAIN;IAED;;;;;;OAMG;IACH,OAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAChD,OAAc,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAKxC;;;;;OAKG;IACH,OAAc,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEhD;IAED;;;;;OAKG;IACI,IAAI,IAAI,IAAI,IAAI;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEjE;IAED;;;;;OAKG;IACI,MAAM,IAAI,IAAI,IAAI;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnE;IAED;;;;;OAKG;IACH,IAAW,KAAK,IAAI,MAAM,CAOzB;IAED;;;;;OAKG;IACH,IAAW,KAAK,IAAI,MAAM,CAMzB;IAED;;;;;;OAMG;IACI,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAMzD;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM9D;IAED;;;;;;;;OAQG;IACI,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAM7E;IAED;;;;;;OAMG;IACI,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE;QAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;QAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;KAAE,GAAG,CAAC,CAMrF;CACJ;AAED,yBAAiB,MAAM,CAAC;IACpB,KAAY,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IACpF,KAAY,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC;CACxF"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * A container type that represents either a successful result (`ok`) or a failure (`fail`).
3
+ * Inspired by functional programming constructs like `Either` or `Result` in other languages.
4
+ *
5
+ * @template TValue - The type of the success value.
6
+ * @template TError - The type of the error value.
7
+ */
8
+ export class Result {
9
+ _isOk;
10
+ _value;
11
+ _error;
12
+ constructor(isOk, value, error) {
13
+ this._isOk = isOk;
14
+ this._value = value;
15
+ this._error = error;
16
+ }
17
+ static ok(value) {
18
+ return new Result(true, value);
19
+ }
20
+ /**
21
+ * Creates a failed `Result` containing the provided error.
22
+ *
23
+ * @param error - The error to wrap in a failed result.
24
+ * @returns A `Result` instance with the error.
25
+ */
26
+ static fail(error) {
27
+ return new Result(false, undefined, error);
28
+ }
29
+ /**
30
+ * Checks whether the result is successful.
31
+ *
32
+ * @returns `true` if the result is `ok`, otherwise `false`.
33
+ * Acts as a type guard to narrow the type to a successful result.
34
+ */
35
+ isOk() {
36
+ return this._isOk;
37
+ }
38
+ /**
39
+ * Checks whether the result is a failure.
40
+ *
41
+ * @returns `true` if the result is `fail`, otherwise `false`.
42
+ * Acts as a type guard to narrow the type to a failed result.
43
+ */
44
+ isFail() {
45
+ return !this._isOk;
46
+ }
47
+ /**
48
+ * Gets the value inside a successful result.
49
+ *
50
+ * @throws If the result is a failure.
51
+ * @returns The success value.
52
+ */
53
+ get value() {
54
+ if (!this._isOk) {
55
+ console.error(this.error);
56
+ throw new Error("Tried to get value from a failed Result.");
57
+ }
58
+ return this._value;
59
+ }
60
+ /**
61
+ * Gets the error inside a failed result.
62
+ *
63
+ * @throws If the result is successful.
64
+ * @returns The error value.
65
+ */
66
+ get error() {
67
+ if (this._isOk) {
68
+ throw new Error("Tried to get error from a successful Result.");
69
+ }
70
+ return this._error;
71
+ }
72
+ /**
73
+ * Transforms the success value using the provided mapping function.
74
+ *
75
+ * @template U - The type of the new success value.
76
+ * @param fn - Function to apply to the value if the result is successful.
77
+ * @returns A new `Result` containing the mapped value, or the original error if failed.
78
+ */
79
+ map(fn) {
80
+ if (this.isOk()) {
81
+ return Result.ok(fn(this._value));
82
+ }
83
+ return Result.fail(this._error);
84
+ }
85
+ /**
86
+ * Transforms the error value using the provided mapping function.
87
+ *
88
+ * @template F - The type of the new error.
89
+ * @param fn - Function to apply to the error if the result is a failure.
90
+ * @returns A new `Result` containing the original value or the mapped error.
91
+ */
92
+ mapError(fn) {
93
+ if (this.isFail()) {
94
+ return Result.fail(fn(this._error));
95
+ }
96
+ return Result.ok(this._value);
97
+ }
98
+ /**
99
+ * Chains another `Result`-producing function onto this result.
100
+ * If this result is successful, the function is applied to the value.
101
+ * If this result is a failure, the original error is returned.
102
+ *
103
+ * @template U - The type of the next success value.
104
+ * @param fn - A function that takes the current value and returns another `Result`.
105
+ * @returns A new `Result` from applying the function or the original failure.
106
+ */
107
+ flatMap(fn) {
108
+ if (this.isOk()) {
109
+ return fn(this._value);
110
+ }
111
+ return Result.fail(this._error);
112
+ }
113
+ /**
114
+ * Pattern-matches the result to handle both success and failure cases.
115
+ *
116
+ * @template U - The return type of both match functions.
117
+ * @param handlers - An object containing `ok` and `fail` handlers.
118
+ * @returns The return value from the corresponding handler.
119
+ */
120
+ match(handlers) {
121
+ if (this.isOk()) {
122
+ return handlers.ok(this._value);
123
+ }
124
+ return handlers.fail(this._error);
125
+ }
126
+ }
127
+ //# sourceMappingURL=Result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Result.js","sourceRoot":"","sources":["../../../src/common/core/Result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IACI,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAAU;IAEnC,YAAoB,IAAa,EAAE,KAAc,EAAE,KAAc;QAC7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAWM,MAAM,CAAC,EAAE,CAAI,KAAS;QACzB,OAAO,IAAI,MAAM,CAAkB,IAAI,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,IAAI,CAAI,KAAQ;QAC1B,OAAO,IAAI,MAAM,CAAW,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACI,MAAM;QACT,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,IA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AI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC;IAChD,CAAC;CACJ"}
@@ -0,0 +1,17 @@
1
+ import { Result } from "./Result.js";
2
+ export declare class ResultAsync<TValue, TError = never> {
3
+ private readonly promise;
4
+ constructor(promise: Promise<Result<TValue, TError>>);
5
+ static from<T, E>(fn: () => Promise<Result<T, E>>): ResultAsync<T, E>;
6
+ static ok<T>(value: T): ResultAsync<T, never>;
7
+ static fail<E>(error: E): ResultAsync<never, E>;
8
+ unwrap(): Promise<Result<TValue, TError>>;
9
+ mapAsync<U>(fn: (value: TValue) => U | Promise<U>): ResultAsync<U, TError>;
10
+ mapErrorAsync<F>(fn: (error: TError) => F | Promise<F>): ResultAsync<TValue, F>;
11
+ flatMapAsync<U>(fn: (value: TValue) => ResultAsync<U, TError>): ResultAsync<U, TError>;
12
+ match<U>(handlers: {
13
+ ok: (value: TValue) => U;
14
+ fail: (error: TError) => U;
15
+ }): Promise<U>;
16
+ }
17
+ //# sourceMappingURL=ResultAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultAsync.d.ts","sourceRoot":"","sources":["../../../src/common/core/ResultAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAI;IAGzE,OAAc,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAE3E;IAGD,OAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,CAEnD;IAGD,OAAc,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAErD;IAGY,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAErD;IAGM,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAUhF;IAGM,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAUrF;IAGM,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAU5F;IAGY,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE;QAC5B,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;QACzB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;KAC9B,GAAG,OAAO,CAAC,CAAC,CAAC,CAQb;CACJ"}
@@ -0,0 +1,62 @@
1
+ import { Result } from "./Result.js";
2
+ export class ResultAsync {
3
+ promise;
4
+ constructor(promise) {
5
+ this.promise = promise;
6
+ }
7
+ // Wrap a function returning a Promise<Result<T, E>>.
8
+ static from(fn) {
9
+ return new ResultAsync(fn());
10
+ }
11
+ // Wrap a successful value.
12
+ static ok(value) {
13
+ return new ResultAsync(Promise.resolve(Result.ok(value)));
14
+ }
15
+ // Wrap a failure.
16
+ static fail(error) {
17
+ return new ResultAsync(Promise.resolve(Result.fail(error)));
18
+ }
19
+ // Await the wrapped result.
20
+ async unwrap() {
21
+ return this.promise;
22
+ }
23
+ // Transform the success value.
24
+ mapAsync(fn) {
25
+ const newPromise = this.promise.then(async (res) => {
26
+ if (res.isOk()) {
27
+ return Result.ok(await fn(res.value));
28
+ }
29
+ return Result.fail(res.error);
30
+ });
31
+ return new ResultAsync(newPromise);
32
+ }
33
+ // Transform the error value.
34
+ mapErrorAsync(fn) {
35
+ const newPromise = this.promise.then(async (res) => {
36
+ if (res.isFail()) {
37
+ return Result.fail(await fn(res.error));
38
+ }
39
+ return Result.ok(res.value);
40
+ });
41
+ return new ResultAsync(newPromise);
42
+ }
43
+ // Chain another async Result.
44
+ flatMapAsync(fn) {
45
+ const newPromise = this.promise.then(async (res) => {
46
+ if (res.isFail()) {
47
+ return Result.fail(res.error);
48
+ }
49
+ return await fn(res.value).unwrap();
50
+ });
51
+ return new ResultAsync(newPromise);
52
+ }
53
+ // Match success/failure (like sync Result).
54
+ async match(handlers) {
55
+ const result = await this.unwrap();
56
+ if (result.isOk()) {
57
+ return handlers.ok(result.value);
58
+ }
59
+ return handlers.fail(result.error);
60
+ }
61
+ }
62
+ //# sourceMappingURL=ResultAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultAsync.js","sourceRoot":"","sources":["../../../src/common/core/ResultAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,WAAW;IACS,OAAO;IAApC,YAA6B,OAAwC;uBAAxC,OAAO;IAAoC,CAAC;IAEzE,qDAAqD;IAC9C,MAAM,CAAC,IAAI,CAAO,EAA+B;QACpD,OAAO,IAAI,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,2BAA2B;IACpB,MAAM,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C,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,8BAA8B;IACvB,YAAY,CAAI,EAA6C;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;YAC7C,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;gBACf,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;YAED,OAAO,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,4CAA4C;IACrC,KAAK,CAAC,KAAK,CAAI,QAGrB;QACG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QAEnC,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAChB,OAAO,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ export type { Abstraction };
3
+ export declare function createAbstraction<T>(name: string): Abstraction<T>;
4
+ //# sourceMappingURL=createAbstraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAbstraction.d.ts","sourceRoot":"","sources":["../../../src/common/core/createAbstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAEjE"}
@@ -0,0 +1,5 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ export function createAbstraction(name) {
3
+ return new Abstraction(name);
4
+ }
5
+ //# sourceMappingURL=createAbstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAbstraction.js","sourceRoot":"","sources":["../../../src/common/core/createAbstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,MAAM,UAAU,iBAAiB,CAAI,IAAY;IAC7C,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Container } from "@webiny/di";
2
+ export type FeatureDefinition<TRegister = void> = [TRegister] extends [void] ? {
3
+ name: string;
4
+ register(container: Container): void;
5
+ } : {
6
+ name: string;
7
+ register(container: Container, context: TRegister): void;
8
+ };
9
+ export declare function createFeature<TRegister = void>(def: FeatureDefinition<TRegister>): FeatureDefinition<TRegister>;
10
+ //# sourceMappingURL=createFeature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFeature.d.ts","sourceRoot":"","sources":["../../../src/common/core/createFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,MAAM,iBAAiB,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,GACtE;IACI,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACxC,GACD;IACI,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;CAC5D,CAAC;AAER,wBAAgB,aAAa,CAAC,SAAS,GAAG,IAAI,EAC1C,GAAG,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAClC,iBAAiB,CAAC,SAAS,CAAC,CAS9B"}
@@ -0,0 +1,9 @@
1
+ export function createFeature(def) {
2
+ const feature = {
3
+ name: def.name,
4
+ register: def.register
5
+ };
6
+ Reflect.defineMetadata("wby:isFeature", true, feature);
7
+ return feature;
8
+ }
9
+ //# sourceMappingURL=createFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFeature.js","sourceRoot":"","sources":["../../../src/common/core/createFeature.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,aAAa,CACzB,GAAiC;IAEjC,MAAM,OAAO,GAAG;QACZ,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;KACzB,CAAC;IAEF,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAEvD,OAAO,OAAuC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { BaseError } from "./BaseError.js";
2
+ export type { ErrorInput } from "./BaseError.js";
3
+ export { createAbstraction } from "./createAbstraction.js";
4
+ export { createFeature } from "./createFeature.js";
5
+ export { Result } from "./Result.js";
6
+ export { ResultAsync } from "./ResultAsync.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { BaseError } from "./BaseError.js";
2
+ export { createAbstraction } from "./createAbstraction.js";
3
+ export { createFeature } from "./createFeature.js";
4
+ export { Result } from "./Result.js";
5
+ export { ResultAsync } from "./ResultAsync.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { ResultAsync } from "../../core/index.js";
2
+ import { AsyncCache as AsyncCacheAbstraction } from "./abstractions/AsyncCache.js";
3
+ import type { CacheError } from "./abstractions/CacheError.js";
4
+ declare class AsyncMemoryCacheImpl implements AsyncCacheAbstraction.Interface {
5
+ private store;
6
+ private prefix;
7
+ constructor();
8
+ private static fromStore;
9
+ private prefixedKey;
10
+ get<T>(key: string): ResultAsync<T | null, CacheError>;
11
+ set<T>(key: string, value: T): ResultAsync<void, CacheError>;
12
+ remove(key: string): ResultAsync<void, CacheError>;
13
+ has(key: string): ResultAsync<boolean, CacheError>;
14
+ clear(): ResultAsync<void, CacheError>;
15
+ keys(): ResultAsync<string[], CacheError>;
16
+ getOrSet<T>(key: string, factory: () => T | Promise<T>): ResultAsync<T, CacheError>;
17
+ byPrefix(prefix: string): AsyncCacheAbstraction.Interface;
18
+ }
19
+ export declare const AsyncMemoryCache: typeof AsyncMemoryCacheImpl & {
20
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/AsyncCache.js").IAsyncCache>;
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=AsyncMemoryCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncMemoryCache.d.ts","sourceRoot":"","sources":["../../../../src/common/features/Cache/AsyncMemoryCache.ts"],"names":[],"mappings":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AsyncCache as AsyncCacheAbstraction } from "./abstractions/AsyncCache.js";
3
+ class AsyncMemoryCacheImpl {
4
+ store = new Map();
5
+ prefix = "";
6
+ constructor() { }
7
+ static fromStore(store, prefix) {
8
+ const instance = new AsyncMemoryCacheImpl();
9
+ instance.store = store;
10
+ instance.prefix = prefix;
11
+ return instance;
12
+ }
13
+ prefixedKey(key) {
14
+ return this.prefix ? `${this.prefix}.${key}` : key;
15
+ }
16
+ get(key) {
17
+ return ResultAsync.from(async () => {
18
+ const raw = this.store.get(this.prefixedKey(key));
19
+ if (raw === undefined) {
20
+ return Result.ok(null);
21
+ }
22
+ return Result.ok(JSON.parse(raw));
23
+ });
24
+ }
25
+ set(key, value) {
26
+ return ResultAsync.from(async () => {
27
+ this.store.set(this.prefixedKey(key), JSON.stringify(value));
28
+ return Result.ok();
29
+ });
30
+ }
31
+ remove(key) {
32
+ return ResultAsync.from(async () => {
33
+ this.store.delete(this.prefixedKey(key));
34
+ return Result.ok();
35
+ });
36
+ }
37
+ has(key) {
38
+ return ResultAsync.from(async () => {
39
+ return Result.ok(this.store.has(this.prefixedKey(key)));
40
+ });
41
+ }
42
+ clear() {
43
+ return ResultAsync.from(async () => {
44
+ if (this.prefix) {
45
+ const scopePrefix = `${this.prefix}.`;
46
+ for (const key of [...this.store.keys()]) {
47
+ if (key.startsWith(scopePrefix)) {
48
+ this.store.delete(key);
49
+ }
50
+ }
51
+ }
52
+ else {
53
+ this.store.clear();
54
+ }
55
+ return Result.ok();
56
+ });
57
+ }
58
+ keys() {
59
+ return ResultAsync.from(async () => {
60
+ if (this.prefix) {
61
+ const scopePrefix = `${this.prefix}.`;
62
+ return Result.ok([...this.store.keys()]
63
+ .filter(k => k.startsWith(scopePrefix))
64
+ .map(k => k.slice(scopePrefix.length)));
65
+ }
66
+ return Result.ok([...this.store.keys()]);
67
+ });
68
+ }
69
+ getOrSet(key, factory) {
70
+ return ResultAsync.from(async () => {
71
+ const prefixed = this.prefixedKey(key);
72
+ const stored = this.store.get(prefixed);
73
+ if (stored) {
74
+ return Result.ok(JSON.parse(stored));
75
+ }
76
+ const value = await factory();
77
+ this.store.set(prefixed, JSON.stringify(value));
78
+ return Result.ok(value);
79
+ });
80
+ }
81
+ byPrefix(prefix) {
82
+ const combined = this.prefix ? `${this.prefix}.${prefix}` : prefix;
83
+ return AsyncMemoryCacheImpl.fromStore(this.store, combined);
84
+ }
85
+ }
86
+ export const AsyncMemoryCache = AsyncCacheAbstraction.createImplementation({
87
+ implementation: AsyncMemoryCacheImpl,
88
+ dependencies: []
89
+ });
90
+ //# sourceMappingURL=AsyncMemoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncMemoryCache.js","sourceRoot":"","sources":["../../../../src/common/features/Cache/AsyncMemoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,UAAU,IAAI,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGnF,MAAM,oBAAoB;IACd,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IACvC,MAAM,GAAW,EAAE,CAAC;IAE5B,gBAAsB,CAAC;IAEf,MAAM,CAAC,SAAS,CAAC,KAA0B,EAAE,MAAc;QAC/D,MAAM,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC5C,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,WAAW,CAAC,GAAW;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACvD,CAAC;IAEM,GAAG,CAAI,GAAW;QACrB,OAAO,WAAW,CAAC,IAAI,CAAuB,KAAK,IAAI,EAAE;YACrD,MAAM,GAAG,GAAG,IAA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,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAM,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,QAAQ,CAAC,MAAc;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACnE,OAAO,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChE,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;IACvE,cAAc,EAAE,oBAAoB;IACpC,YAAY,EAAE,EAAE;CACnB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Registers AsyncMemoryCache as the AsyncCache implementation. */
2
+ export declare const AsyncMemoryCacheFeature: {
3
+ name: string;
4
+ register(container: import("@webiny/di").Container): void;
5
+ };
6
+ //# sourceMappingURL=AsyncMemoryCacheFeature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncMemoryCacheFeature.d.ts","sourceRoot":"","sources":["../../../../src/common/features/Cache/AsyncMemoryCacheFeature.ts"],"names":[],"mappings":"AAGA,mEAAmE;AACnE,eAAO,MAAM,uBAAuB;;;CAKlC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { createFeature } from "../../core/index.js";
2
+ import { AsyncMemoryCache } from "./AsyncMemoryCache.js";
3
+ /** Registers AsyncMemoryCache as the AsyncCache implementation. */
4
+ export const AsyncMemoryCacheFeature = createFeature({
5
+ name: "Core/AsyncMemoryCacheFeature",
6
+ register(container) {
7
+ container.register(AsyncMemoryCache).inSingletonScope();
8
+ }
9
+ });
10
+ //# sourceMappingURL=AsyncMemoryCacheFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncMemoryCacheFeature.js","sourceRoot":"","sources":["../../../../src/common/features/Cache/AsyncMemoryCacheFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;IACjD,IAAI,EAAE,8BAA8B;IACpC,QAAQ,CAAC,SAAS;QACd,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC5D,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Result } from "../../core/index.js";
2
+ import { Cache as CacheAbstraction } from "./abstractions/Cache.js";
3
+ import type { CacheError } from "./abstractions/CacheError.js";
4
+ declare class MemoryCacheImpl implements CacheAbstraction.Interface {
5
+ private store;
6
+ private prefix;
7
+ constructor();
8
+ private static fromStore;
9
+ private prefixedKey;
10
+ get<T>(key: string): Result<T | null, CacheError>;
11
+ set<T>(key: string, value: T): Result<void, CacheError>;
12
+ remove(key: string): Result<void, CacheError>;
13
+ has(key: string): Result<boolean, CacheError>;
14
+ clear(): Result<void, CacheError>;
15
+ keys(): Result<string[], CacheError>;
16
+ getOrSet<T>(key: string, factory: () => T): Result<T, CacheError>;
17
+ byPrefix(prefix: string): CacheAbstraction.Interface;
18
+ }
19
+ export declare const MemoryCache: typeof MemoryCacheImpl & {
20
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/Cache.js").ICache>;
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=MemoryCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryCache.d.ts","sourceRoot":"","sources":["../../../../src/common/features/Cache/MemoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,cAAM,eAAgB,YAAW,gBAAgB,CAAC,SAAS;IACvD,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,MAAM,CAAc;IAE5B,cAAuB;IAEvB,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB,OAAO,CAAC,WAAW;IAIZ,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAMvD;IAEM,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAG7D;IAEM,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAGnD;IAEM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAEnD;IAEM,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAYvC;IAEM,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAU1C;IAEM,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAQvE;IAEM,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAG1D;CACJ;AAED,eAAO,MAAM,WAAW;;CAGtB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { Result } from "../../core/index.js";
2
+ import { Cache as CacheAbstraction } from "./abstractions/Cache.js";
3
+ class MemoryCacheImpl {
4
+ store = new Map();
5
+ prefix = "";
6
+ constructor() { }
7
+ static fromStore(store, prefix) {
8
+ const instance = new MemoryCacheImpl();
9
+ instance.store = store;
10
+ instance.prefix = prefix;
11
+ return instance;
12
+ }
13
+ prefixedKey(key) {
14
+ return this.prefix ? `${this.prefix}.${key}` : key;
15
+ }
16
+ get(key) {
17
+ const raw = this.store.get(this.prefixedKey(key));
18
+ if (raw === undefined) {
19
+ return Result.ok(null);
20
+ }
21
+ return Result.ok(JSON.parse(raw));
22
+ }
23
+ set(key, value) {
24
+ this.store.set(this.prefixedKey(key), JSON.stringify(value));
25
+ return Result.ok();
26
+ }
27
+ remove(key) {
28
+ this.store.delete(this.prefixedKey(key));
29
+ return Result.ok();
30
+ }
31
+ has(key) {
32
+ return Result.ok(this.store.has(this.prefixedKey(key)));
33
+ }
34
+ clear() {
35
+ if (this.prefix) {
36
+ const scopePrefix = `${this.prefix}.`;
37
+ for (const key of [...this.store.keys()]) {
38
+ if (key.startsWith(scopePrefix)) {
39
+ this.store.delete(key);
40
+ }
41
+ }
42
+ }
43
+ else {
44
+ this.store.clear();
45
+ }
46
+ return Result.ok();
47
+ }
48
+ keys() {
49
+ if (this.prefix) {
50
+ const scopePrefix = `${this.prefix}.`;
51
+ return Result.ok([...this.store.keys()]
52
+ .filter(k => k.startsWith(scopePrefix))
53
+ .map(k => k.slice(scopePrefix.length)));
54
+ }
55
+ return Result.ok([...this.store.keys()]);
56
+ }
57
+ getOrSet(key, factory) {
58
+ const prefixed = this.prefixedKey(key);
59
+ if (this.store.has(prefixed)) {
60
+ return Result.ok(JSON.parse(this.store.get(prefixed)));
61
+ }
62
+ const value = factory();
63
+ this.store.set(prefixed, JSON.stringify(value));
64
+ return Result.ok(value);
65
+ }
66
+ byPrefix(prefix) {
67
+ const combined = this.prefix ? `${this.prefix}.${prefix}` : prefix;
68
+ return MemoryCacheImpl.fromStore(this.store, combined);
69
+ }
70
+ }
71
+ export const MemoryCache = CacheAbstraction.createImplementation({
72
+ implementation: MemoryCacheImpl,
73
+ dependencies: []
74
+ });
75
+ //# sourceMappingURL=MemoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryCache.js","sourceRoot":"","sources":["../../../../src/common/features/Cache/MemoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,MAAM,eAAe;IACT,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IACvC,MAAM,GAAW,EAAE,CAAC;IAE5B,gBAAsB,CAAC;IAEf,MAAM,CAAC,SAAS,CAAC,KAA0B,EAAE,MAAc;QAC/D,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACvC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,WAAW,CAAC,GAAW;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACvD,CAAC;IAEM,GAAG,CAAI,GAAW;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3B,CAA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;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC,oBAAoB,CAAC;IAC7D,cAAc,EAAE,eAAe;IAC/B,YAAY,EAAE,EAAE;CACnB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Registers MemoryCache as the Cache implementation. */
2
+ export declare const MemoryCacheFeature: {
3
+ name: string;
4
+ register(container: import("@webiny/di").Container): void;
5
+ };
6
+ //# sourceMappingURL=MemoryCacheFeature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryCacheFeature.d.ts","sourceRoot":"","sources":["../../../../src/common/features/Cache/MemoryCacheFeature.ts"],"names":[],"mappings":"AAGA,yDAAyD;AACzD,eAAO,MAAM,kBAAkB;;;CAK7B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { createFeature } from "../../core/index.js";
2
+ import { MemoryCache } from "./MemoryCache.js";
3
+ /** Registers MemoryCache as the Cache implementation. */
4
+ export const MemoryCacheFeature = createFeature({
5
+ name: "Core/MemoryCacheFeature",
6
+ register(container) {
7
+ container.register(MemoryCache).inSingletonScope();
8
+ }
9
+ });
10
+ //# sourceMappingURL=MemoryCacheFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryCacheFeature.js","sourceRoot":"","sources":["../../../../src/common/features/Cache/MemoryCacheFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;IAC5C,IAAI,EAAE,yBAAyB;IAC/B,QAAQ,CAAC,SAAS;QACd,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACvD,CAAC;CACJ,CAAC,CAAC"}