@thisisagile/easy 17.25.1 → 17.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/dist/index.mjs +3476 -115
  2. package/dist/index.mjs.map +1 -1
  3. package/package.json +12 -4
  4. package/dist/chunk-2AB6ZQHC.mjs +0 -26
  5. package/dist/chunk-2AB6ZQHC.mjs.map +0 -1
  6. package/dist/chunk-4DJUHTQO.mjs +0 -55
  7. package/dist/chunk-4DJUHTQO.mjs.map +0 -1
  8. package/dist/chunk-4HWEQEHM.mjs +0 -20
  9. package/dist/chunk-4HWEQEHM.mjs.map +0 -1
  10. package/dist/chunk-4N72FQFX.mjs +0 -16
  11. package/dist/chunk-4N72FQFX.mjs.map +0 -1
  12. package/dist/chunk-4SWYJEN5.mjs +0 -82
  13. package/dist/chunk-4SWYJEN5.mjs.map +0 -1
  14. package/dist/chunk-4VZHB642.mjs +0 -37
  15. package/dist/chunk-4VZHB642.mjs.map +0 -1
  16. package/dist/chunk-ADJAEGCT.mjs +0 -21
  17. package/dist/chunk-ADJAEGCT.mjs.map +0 -1
  18. package/dist/chunk-AGTB4HMP.mjs +0 -11
  19. package/dist/chunk-AGTB4HMP.mjs.map +0 -1
  20. package/dist/chunk-BDA5LB4S.mjs +0 -29
  21. package/dist/chunk-BDA5LB4S.mjs.map +0 -1
  22. package/dist/chunk-BZOYP6X7.mjs +0 -134
  23. package/dist/chunk-BZOYP6X7.mjs.map +0 -1
  24. package/dist/chunk-CO2AFYVD.mjs +0 -43
  25. package/dist/chunk-CO2AFYVD.mjs.map +0 -1
  26. package/dist/chunk-D7UFAVDX.mjs +0 -54
  27. package/dist/chunk-D7UFAVDX.mjs.map +0 -1
  28. package/dist/chunk-DEFTEK45.mjs +0 -40
  29. package/dist/chunk-DEFTEK45.mjs.map +0 -1
  30. package/dist/chunk-DEJ7A5PY.mjs +0 -43
  31. package/dist/chunk-DEJ7A5PY.mjs.map +0 -1
  32. package/dist/chunk-DLA22ZCC.mjs +0 -20
  33. package/dist/chunk-DLA22ZCC.mjs.map +0 -1
  34. package/dist/chunk-DXQSIBC7.mjs +0 -13
  35. package/dist/chunk-DXQSIBC7.mjs.map +0 -1
  36. package/dist/chunk-ELDS3NWV.mjs +0 -23
  37. package/dist/chunk-ELDS3NWV.mjs.map +0 -1
  38. package/dist/chunk-ELUKCMQZ.mjs +0 -50
  39. package/dist/chunk-ELUKCMQZ.mjs.map +0 -1
  40. package/dist/chunk-FN7HN3YK.mjs +0 -58
  41. package/dist/chunk-FN7HN3YK.mjs.map +0 -1
  42. package/dist/chunk-GCY5A63A.mjs +0 -25
  43. package/dist/chunk-GCY5A63A.mjs.map +0 -1
  44. package/dist/chunk-GO66AIDJ.mjs +0 -76
  45. package/dist/chunk-GO66AIDJ.mjs.map +0 -1
  46. package/dist/chunk-GVTADDU5.mjs +0 -39
  47. package/dist/chunk-GVTADDU5.mjs.map +0 -1
  48. package/dist/chunk-GZIULZH2.mjs +0 -79
  49. package/dist/chunk-GZIULZH2.mjs.map +0 -1
  50. package/dist/chunk-HOVTNDHS.mjs +0 -297
  51. package/dist/chunk-HOVTNDHS.mjs.map +0 -1
  52. package/dist/chunk-HPM4L4MH.mjs +0 -20
  53. package/dist/chunk-HPM4L4MH.mjs.map +0 -1
  54. package/dist/chunk-HSOXY623.mjs +0 -53
  55. package/dist/chunk-HSOXY623.mjs.map +0 -1
  56. package/dist/chunk-IH4VU7UP.mjs +0 -31
  57. package/dist/chunk-IH4VU7UP.mjs.map +0 -1
  58. package/dist/chunk-JPWRHLXY.mjs +0 -51
  59. package/dist/chunk-JPWRHLXY.mjs.map +0 -1
  60. package/dist/chunk-L5KXXMUH.mjs +0 -46
  61. package/dist/chunk-L5KXXMUH.mjs.map +0 -1
  62. package/dist/chunk-L5ZI7SPN.mjs +0 -90
  63. package/dist/chunk-L5ZI7SPN.mjs.map +0 -1
  64. package/dist/chunk-LGLRWA42.mjs +0 -324
  65. package/dist/chunk-LGLRWA42.mjs.map +0 -1
  66. package/dist/chunk-LKTTPV6U.mjs +0 -70
  67. package/dist/chunk-LKTTPV6U.mjs.map +0 -1
  68. package/dist/chunk-LONFFS5R.mjs +0 -107
  69. package/dist/chunk-LONFFS5R.mjs.map +0 -1
  70. package/dist/chunk-LUHR6633.mjs +0 -54
  71. package/dist/chunk-LUHR6633.mjs.map +0 -1
  72. package/dist/chunk-MDXL65W4.mjs +0 -49
  73. package/dist/chunk-MDXL65W4.mjs.map +0 -1
  74. package/dist/chunk-N22QIDIK.mjs +0 -25
  75. package/dist/chunk-N22QIDIK.mjs.map +0 -1
  76. package/dist/chunk-NBYO2U6Q.mjs +0 -48
  77. package/dist/chunk-NBYO2U6Q.mjs.map +0 -1
  78. package/dist/chunk-NPCTXURR.mjs +0 -23
  79. package/dist/chunk-NPCTXURR.mjs.map +0 -1
  80. package/dist/chunk-OFGI5FLG.mjs +0 -11
  81. package/dist/chunk-OFGI5FLG.mjs.map +0 -1
  82. package/dist/chunk-OGLPG6DF.mjs +0 -18
  83. package/dist/chunk-OGLPG6DF.mjs.map +0 -1
  84. package/dist/chunk-OKPGJD64.mjs +0 -41
  85. package/dist/chunk-OKPGJD64.mjs.map +0 -1
  86. package/dist/chunk-OQNZEKWO.mjs +0 -24
  87. package/dist/chunk-OQNZEKWO.mjs.map +0 -1
  88. package/dist/chunk-OWLQ6U7M.mjs +0 -57
  89. package/dist/chunk-OWLQ6U7M.mjs.map +0 -1
  90. package/dist/chunk-P5MN5NGC.mjs +0 -24
  91. package/dist/chunk-P5MN5NGC.mjs.map +0 -1
  92. package/dist/chunk-PIRWVOO2.mjs +0 -7
  93. package/dist/chunk-PIRWVOO2.mjs.map +0 -1
  94. package/dist/chunk-PR6DFFCE.mjs +0 -94
  95. package/dist/chunk-PR6DFFCE.mjs.map +0 -1
  96. package/dist/chunk-QMASVXTD.mjs +0 -40
  97. package/dist/chunk-QMASVXTD.mjs.map +0 -1
  98. package/dist/chunk-QNNYTOR7.mjs +0 -142
  99. package/dist/chunk-QNNYTOR7.mjs.map +0 -1
  100. package/dist/chunk-RHOK5QZR.mjs +0 -175
  101. package/dist/chunk-RHOK5QZR.mjs.map +0 -1
  102. package/dist/chunk-RS7CT7BU.mjs +0 -20
  103. package/dist/chunk-RS7CT7BU.mjs.map +0 -1
  104. package/dist/chunk-RUFO75IB.mjs +0 -18
  105. package/dist/chunk-RUFO75IB.mjs.map +0 -1
  106. package/dist/chunk-RWGCMC6L.mjs +0 -164
  107. package/dist/chunk-RWGCMC6L.mjs.map +0 -1
  108. package/dist/chunk-SCVGZWV7.mjs +0 -35
  109. package/dist/chunk-SCVGZWV7.mjs.map +0 -1
  110. package/dist/chunk-SJ4YFZKO.mjs +0 -21
  111. package/dist/chunk-SJ4YFZKO.mjs.map +0 -1
  112. package/dist/chunk-SJGQU3OG.mjs +0 -15
  113. package/dist/chunk-SJGQU3OG.mjs.map +0 -1
  114. package/dist/chunk-SSROJBD5.mjs +0 -30
  115. package/dist/chunk-SSROJBD5.mjs.map +0 -1
  116. package/dist/chunk-SW2OCUH3.mjs +0 -10
  117. package/dist/chunk-SW2OCUH3.mjs.map +0 -1
  118. package/dist/chunk-TNZJKUDY.mjs +0 -45
  119. package/dist/chunk-TNZJKUDY.mjs.map +0 -1
  120. package/dist/chunk-UXADDXCJ.mjs +0 -68
  121. package/dist/chunk-UXADDXCJ.mjs.map +0 -1
  122. package/dist/chunk-UYDZZAEK.mjs +0 -11
  123. package/dist/chunk-UYDZZAEK.mjs.map +0 -1
  124. package/dist/chunk-VBZTERRM.mjs +0 -94
  125. package/dist/chunk-VBZTERRM.mjs.map +0 -1
  126. package/dist/chunk-WJZFE5NE.mjs +0 -17
  127. package/dist/chunk-WJZFE5NE.mjs.map +0 -1
  128. package/dist/chunk-WLTLSV2I.mjs +0 -20
  129. package/dist/chunk-WLTLSV2I.mjs.map +0 -1
  130. package/dist/chunk-WOSYMEQL.mjs +0 -60
  131. package/dist/chunk-WOSYMEQL.mjs.map +0 -1
  132. package/dist/chunk-WSBULPUZ.mjs +0 -30
  133. package/dist/chunk-WSBULPUZ.mjs.map +0 -1
  134. package/dist/chunk-WVTNXVBL.mjs +0 -56
  135. package/dist/chunk-WVTNXVBL.mjs.map +0 -1
  136. package/dist/chunk-ZHXKBOK2.mjs +0 -22
  137. package/dist/chunk-ZHXKBOK2.mjs.map +0 -1
  138. package/dist/chunk-ZPNFXK7Y.mjs +0 -36
  139. package/dist/chunk-ZPNFXK7Y.mjs.map +0 -1
  140. package/dist/data/Condition.mjs +0 -29
  141. package/dist/data/Condition.mjs.map +0 -1
  142. package/dist/data/DataProvider.mjs +0 -1
  143. package/dist/data/DataProvider.mjs.map +0 -1
  144. package/dist/data/Database.mjs +0 -23
  145. package/dist/data/Database.mjs.map +0 -1
  146. package/dist/data/Field.mjs +0 -47
  147. package/dist/data/Field.mjs.map +0 -1
  148. package/dist/data/InMemoryGateway.mjs +0 -70
  149. package/dist/data/InMemoryGateway.mjs.map +0 -1
  150. package/dist/data/Query.mjs +0 -1
  151. package/dist/data/Query.mjs.map +0 -1
  152. package/dist/data/QueryProvider.mjs +0 -1
  153. package/dist/data/QueryProvider.mjs.map +0 -1
  154. package/dist/domain/Audit.mjs +0 -36
  155. package/dist/domain/Audit.mjs.map +0 -1
  156. package/dist/domain/Child.mjs +0 -54
  157. package/dist/domain/Child.mjs.map +0 -1
  158. package/dist/domain/DateTime.mjs +0 -36
  159. package/dist/domain/DateTime.mjs.map +0 -1
  160. package/dist/domain/Entity.mjs +0 -71
  161. package/dist/domain/Entity.mjs.map +0 -1
  162. package/dist/domain/Repo.mjs +0 -96
  163. package/dist/domain/Repo.mjs.map +0 -1
  164. package/dist/domain/Struct.mjs +0 -33
  165. package/dist/domain/Struct.mjs.map +0 -1
  166. package/dist/domain/Typo.mjs +0 -114
  167. package/dist/domain/Typo.mjs.map +0 -1
  168. package/dist/http/CacheControl.mjs +0 -66
  169. package/dist/http/CacheControl.mjs.map +0 -1
  170. package/dist/http/ContentType.mjs +0 -21
  171. package/dist/http/ContentType.mjs.map +0 -1
  172. package/dist/http/HttpHeader.mjs +0 -8
  173. package/dist/http/HttpHeader.mjs.map +0 -1
  174. package/dist/http/HttpStatus.mjs +0 -25
  175. package/dist/http/HttpStatus.mjs.map +0 -1
  176. package/dist/http/HttpVerb.mjs +0 -21
  177. package/dist/http/HttpVerb.mjs.map +0 -1
  178. package/dist/http/LocalRequestStore.mjs +0 -29
  179. package/dist/http/LocalRequestStore.mjs.map +0 -1
  180. package/dist/http/Request.mjs +0 -1
  181. package/dist/http/Request.mjs.map +0 -1
  182. package/dist/http/RequestOptions.mjs +0 -30
  183. package/dist/http/RequestOptions.mjs.map +0 -1
  184. package/dist/http/RequestProvider.mjs +0 -1
  185. package/dist/http/RequestProvider.mjs.map +0 -1
  186. package/dist/http/Response.mjs +0 -13
  187. package/dist/http/Response.mjs.map +0 -1
  188. package/dist/http/RestResult.mjs +0 -34
  189. package/dist/http/RestResult.mjs.map +0 -1
  190. package/dist/http/toResponse.mjs +0 -33
  191. package/dist/http/toResponse.mjs.map +0 -1
  192. package/dist/process/App.mjs +0 -30
  193. package/dist/process/App.mjs.map +0 -1
  194. package/dist/process/Manage.mjs +0 -47
  195. package/dist/process/Manage.mjs.map +0 -1
  196. package/dist/process/Scope.mjs +0 -22
  197. package/dist/process/Scope.mjs.map +0 -1
  198. package/dist/process/Search.mjs +0 -31
  199. package/dist/process/Search.mjs.map +0 -1
  200. package/dist/process/UseCase.mjs +0 -53
  201. package/dist/process/UseCase.mjs.map +0 -1
  202. package/dist/resources/Req.mjs +0 -57
  203. package/dist/resources/Req.mjs.map +0 -1
  204. package/dist/security/Jwt.mjs +0 -77
  205. package/dist/security/Jwt.mjs.map +0 -1
  206. package/dist/services/Api.mjs +0 -44
  207. package/dist/services/Api.mjs.map +0 -1
  208. package/dist/services/ApiGateway.mjs +0 -45
  209. package/dist/services/ApiGateway.mjs.map +0 -1
  210. package/dist/services/AxiosProvider.mjs +0 -40
  211. package/dist/services/AxiosProvider.mjs.map +0 -1
  212. package/dist/services/MappedRouteGateway.mjs +0 -78
  213. package/dist/services/MappedRouteGateway.mjs.map +0 -1
  214. package/dist/services/RouteGateway.mjs +0 -46
  215. package/dist/services/RouteGateway.mjs.map +0 -1
  216. package/dist/services/ViewRouteGateway.mjs +0 -79
  217. package/dist/services/ViewRouteGateway.mjs.map +0 -1
  218. package/dist/sql/Clause.mjs +0 -24
  219. package/dist/sql/Clause.mjs.map +0 -1
  220. package/dist/sql/Column.mjs +0 -37
  221. package/dist/sql/Column.mjs.map +0 -1
  222. package/dist/sql/Count.mjs +0 -20
  223. package/dist/sql/Count.mjs.map +0 -1
  224. package/dist/sql/Delete.mjs +0 -19
  225. package/dist/sql/Delete.mjs.map +0 -1
  226. package/dist/sql/Insert.mjs +0 -21
  227. package/dist/sql/Insert.mjs.map +0 -1
  228. package/dist/sql/Join.mjs +0 -8
  229. package/dist/sql/Join.mjs.map +0 -1
  230. package/dist/sql/Select.mjs +0 -19
  231. package/dist/sql/Select.mjs.map +0 -1
  232. package/dist/sql/SqlQuery.mjs +0 -18
  233. package/dist/sql/SqlQuery.mjs.map +0 -1
  234. package/dist/sql/Table.mjs +0 -93
  235. package/dist/sql/Table.mjs.map +0 -1
  236. package/dist/sql/TableGateway.mjs +0 -72
  237. package/dist/sql/TableGateway.mjs.map +0 -1
  238. package/dist/sql/Update.mjs +0 -21
  239. package/dist/sql/Update.mjs.map +0 -1
  240. package/dist/types/AnyKey.mjs +0 -1
  241. package/dist/types/AnyKey.mjs.map +0 -1
  242. package/dist/types/Array.mjs +0 -16
  243. package/dist/types/Array.mjs.map +0 -1
  244. package/dist/types/Builder.mjs +0 -26
  245. package/dist/types/Builder.mjs.map +0 -1
  246. package/dist/types/Cache.mjs +0 -29
  247. package/dist/types/Cache.mjs.map +0 -1
  248. package/dist/types/CacheAge.mjs +0 -33
  249. package/dist/types/CacheAge.mjs.map +0 -1
  250. package/dist/types/Case.mjs +0 -29
  251. package/dist/types/Case.mjs.map +0 -1
  252. package/dist/types/Constructor.mjs +0 -23
  253. package/dist/types/Constructor.mjs.map +0 -1
  254. package/dist/types/Context.mjs +0 -28
  255. package/dist/types/Context.mjs.map +0 -1
  256. package/dist/types/Currency.mjs +0 -15
  257. package/dist/types/Currency.mjs.map +0 -1
  258. package/dist/types/Enum.mjs +0 -24
  259. package/dist/types/Enum.mjs.map +0 -1
  260. package/dist/types/Environment.mjs +0 -28
  261. package/dist/types/Environment.mjs.map +0 -1
  262. package/dist/types/ErrorOrigin.mjs +0 -1
  263. package/dist/types/ErrorOrigin.mjs.map +0 -1
  264. package/dist/types/Exception.mjs +0 -26
  265. package/dist/types/Exception.mjs.map +0 -1
  266. package/dist/types/Falsy.mjs +0 -10
  267. package/dist/types/Falsy.mjs.map +0 -1
  268. package/dist/types/Func.mjs +0 -8
  269. package/dist/types/Func.mjs.map +0 -1
  270. package/dist/types/Gateway.mjs +0 -24
  271. package/dist/types/Gateway.mjs.map +0 -1
  272. package/dist/types/Get.mjs +0 -13
  273. package/dist/types/Get.mjs.map +0 -1
  274. package/dist/types/Id.mjs +0 -13
  275. package/dist/types/Id.mjs.map +0 -1
  276. package/dist/types/IdName.mjs +0 -1
  277. package/dist/types/IdName.mjs.map +0 -1
  278. package/dist/types/Identity.mjs +0 -1
  279. package/dist/types/Identity.mjs.map +0 -1
  280. package/dist/types/Indexed.mjs +0 -15
  281. package/dist/types/Indexed.mjs.map +0 -1
  282. package/dist/types/Is.mjs +0 -42
  283. package/dist/types/Is.mjs.map +0 -1
  284. package/dist/types/IsA.mjs +0 -16
  285. package/dist/types/IsA.mjs.map +0 -1
  286. package/dist/types/IsDate.mjs +0 -14
  287. package/dist/types/IsDate.mjs.map +0 -1
  288. package/dist/types/IsEqual.mjs +0 -30
  289. package/dist/types/IsEqual.mjs.map +0 -1
  290. package/dist/types/Json.mjs +0 -29
  291. package/dist/types/Json.mjs.map +0 -1
  292. package/dist/types/List.mjs +0 -27
  293. package/dist/types/List.mjs.map +0 -1
  294. package/dist/types/Message.mjs +0 -11
  295. package/dist/types/Message.mjs.map +0 -1
  296. package/dist/types/Meta.mjs +0 -19
  297. package/dist/types/Meta.mjs.map +0 -1
  298. package/dist/types/Nullish.mjs +0 -8
  299. package/dist/types/Nullish.mjs.map +0 -1
  300. package/dist/types/Number.mjs +0 -30
  301. package/dist/types/Number.mjs.map +0 -1
  302. package/dist/types/Object.mjs +0 -24
  303. package/dist/types/Object.mjs.map +0 -1
  304. package/dist/types/PageList.mjs +0 -40
  305. package/dist/types/PageList.mjs.map +0 -1
  306. package/dist/types/Parser.mjs +0 -80
  307. package/dist/types/Parser.mjs.map +0 -1
  308. package/dist/types/Primitive.mjs +0 -9
  309. package/dist/types/Primitive.mjs.map +0 -1
  310. package/dist/types/Repository.mjs +0 -24
  311. package/dist/types/Repository.mjs.map +0 -1
  312. package/dist/types/Result.mjs +0 -23
  313. package/dist/types/Result.mjs.map +0 -1
  314. package/dist/types/Results.mjs +0 -26
  315. package/dist/types/Results.mjs.map +0 -1
  316. package/dist/types/Sort.mjs +0 -10
  317. package/dist/types/Sort.mjs.map +0 -1
  318. package/dist/types/Tag.mjs +0 -26
  319. package/dist/types/Tag.mjs.map +0 -1
  320. package/dist/types/Template.mjs +0 -21
  321. package/dist/types/Template.mjs.map +0 -1
  322. package/dist/types/Text.mjs +0 -21
  323. package/dist/types/Text.mjs.map +0 -1
  324. package/dist/types/ToText.mjs +0 -23
  325. package/dist/types/ToText.mjs.map +0 -1
  326. package/dist/types/Try.mjs +0 -31
  327. package/dist/types/Try.mjs.map +0 -1
  328. package/dist/types/TypeGuard.mjs +0 -1
  329. package/dist/types/TypeGuard.mjs.map +0 -1
  330. package/dist/types/Types.mjs +0 -1
  331. package/dist/types/Types.mjs.map +0 -1
  332. package/dist/types/Uri.mjs +0 -119
  333. package/dist/types/Uri.mjs.map +0 -1
  334. package/dist/types/Uuid.mjs +0 -16
  335. package/dist/types/Uuid.mjs.map +0 -1
  336. package/dist/types/Validatable.mjs +0 -13
  337. package/dist/types/Validatable.mjs.map +0 -1
  338. package/dist/types/Value.mjs +0 -14
  339. package/dist/types/Value.mjs.map +0 -1
  340. package/dist/utils/Base64.mjs +0 -12
  341. package/dist/utils/Base64.mjs.map +0 -1
  342. package/dist/utils/Convert.mjs +0 -14
  343. package/dist/utils/Convert.mjs.map +0 -1
  344. package/dist/utils/If.mjs +0 -25
  345. package/dist/utils/If.mjs.map +0 -1
  346. package/dist/utils/Loading.mjs +0 -11
  347. package/dist/utils/Loading.mjs.map +0 -1
  348. package/dist/utils/Log.mjs +0 -21
  349. package/dist/utils/Log.mjs.map +0 -1
  350. package/dist/utils/Mapper.mjs +0 -28
  351. package/dist/utils/Mapper.mjs.map +0 -1
  352. package/dist/utils/Promise.mjs +0 -35
  353. package/dist/utils/Promise.mjs.map +0 -1
  354. package/dist/utils/Property.mjs +0 -13
  355. package/dist/utils/Property.mjs.map +0 -1
  356. package/dist/utils/Seconds.mjs +0 -18
  357. package/dist/utils/Seconds.mjs.map +0 -1
  358. package/dist/utils/Sentence.mjs +0 -71
  359. package/dist/utils/Sentence.mjs.map +0 -1
  360. package/dist/utils/State.mjs +0 -12
  361. package/dist/utils/State.mjs.map +0 -1
  362. package/dist/utils/Traverse.mjs +0 -12
  363. package/dist/utils/Traverse.mjs.map +0 -1
  364. package/dist/utils/View.mjs +0 -41
  365. package/dist/utils/View.mjs.map +0 -1
  366. package/dist/utils/Wait.mjs +0 -17
  367. package/dist/utils/Wait.mjs.map +0 -1
  368. package/dist/validation/Contraints.mjs +0 -65
  369. package/dist/validation/Contraints.mjs.map +0 -1
  370. package/dist/validation/Validate.mjs +0 -35
  371. package/dist/validation/Validate.mjs.map +0 -1
  372. package/dist/validation/When.mjs +0 -31
  373. package/dist/validation/When.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,116 +1,3477 @@
1
- export * from "./data/Condition";
2
- export * from "./data/InMemoryGateway";
3
- export * from "./data/Database";
4
- export * from "./data/DataProvider";
5
- export * from "./data/Field";
6
- export * from "./data/Query";
7
- export * from "./data/QueryProvider";
8
- export * from "./domain/Audit";
9
- export * from "./domain/Child";
10
- export * from "./domain/DateTime";
11
- export * from "./domain/Entity";
12
- export * from "./domain/Struct";
13
- export * from "./domain/Repo";
14
- export * from "./domain/Typo";
15
- export * from "./http/CacheControl";
16
- export * from "./http/ContentType";
17
- export * from "./http/HttpHeader";
18
- export * from "./http/HttpStatus";
19
- export * from "./http/HttpVerb";
20
- export * from "./http/Request";
21
- export * from "./http/RequestOptions";
22
- export * from "./http/RequestProvider";
23
- export * from "./http/Response";
24
- export * from "./http/RestResult";
25
- export * from "./http/toResponse";
26
- export * from "./process/App";
27
- export * from "./process/Manage";
28
- export * from "./process/Scope";
29
- export * from "./process/Search";
30
- export * from "./process/UseCase";
31
- export * from "./resources/Req";
32
- export * from "./security/Jwt";
33
- export * from "./services/Api";
34
- export * from "./services/ApiGateway";
35
- export * from "./services/AxiosProvider";
36
- export * from "./services/MappedRouteGateway";
37
- export * from "./services/RouteGateway";
38
- export * from "./services/ViewRouteGateway";
39
- export * from "./sql/Clause";
40
- export * from "./sql/Column";
41
- export * from "./sql/Delete";
42
- export * from "./sql/Insert";
43
- export * from "./sql/Join";
44
- export * from "./sql/SqlQuery";
45
- export * from "./sql/Select";
46
- export * from "./sql/Table";
47
- export * from "./sql/TableGateway";
48
- export * from "./sql/Update";
49
- export * from "./types/AnyKey";
50
- export * from "./types/Array";
51
- export * from "./types/Builder";
52
- export * from "./types/Cache";
53
- export * from "./types/CacheAge";
54
- export * from "./types/Case";
55
- export * from "./types/Constructor";
56
- export * from "./types/Context";
57
- export * from "./types/Currency";
58
- export * from "./types/Enum";
59
- export * from "./types/Environment";
60
- export * from "./types/ErrorOrigin";
61
- export * from "./types/Exception";
62
- export * from "./types/Falsy";
63
- export * from "./types/Func";
64
- export * from "./types/Gateway";
65
- export * from "./types/Get";
66
- export * from "./types/Id";
67
- export * from "./types/Identity";
68
- export * from "./types/IdName";
69
- export * from "./types/Indexed";
70
- export * from "./types/Is";
71
- export * from "./types/IsA";
72
- export * from "./types/IsDate";
73
- export * from "./types/IsEqual";
74
- export * from "./types/Json";
75
- export * from "./types/List";
76
- export * from "./types/Message";
77
- export * from "./types/Meta";
78
- export * from "./types/Nullish";
79
- export * from "./types/Number";
80
- export * from "./types/Object";
81
- export * from "./types/PageList";
82
- export * from "./types/Parser";
83
- export * from "./types/Primitive";
84
- export * from "./types/Repository";
85
- export * from "./types/Result";
86
- export * from "./types/Results";
87
- export * from "./types/Sort";
88
- export * from "./types/Tag";
89
- export * from "./types/Template";
90
- export * from "./types/Text";
91
- export * from "./types/Try";
92
- export * from "./types/TypeGuard";
93
- export * from "./types/Types";
94
- export * from "./types/Uri";
95
- export * from "./types/Uuid";
96
- export * from "./types/Validatable";
97
- export * from "./types/Value";
98
- export * from "./utils/Base64";
99
- export * from "./utils/Convert";
100
- export * from "./utils/If";
101
- export * from "./utils/Loading";
102
- export * from "./utils/Log";
103
- export * from "./utils/Mapper";
104
- export * from "./utils/Promise";
105
- export * from "./utils/Property";
106
- export * from "./utils/Seconds";
107
- export * from "./utils/State";
108
- export * from "./utils/Sentence";
109
- export * from "./utils/Traverse";
110
- export * from "./utils/View";
111
- export * from "./utils/Wait";
112
- export * from "./validation/Contraints";
113
- export * from "./validation/Validate";
114
- export * from "./validation/When";
115
- export * from "./types/ToText";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+
13
+ // src/types/Is.ts
14
+ var isDefined = (o) => o !== void 0 && o !== null;
15
+ var isUndefined = (v) => v === void 0 || v === null;
16
+ var isEmpty = (o) => o === "" || o === null || o === void 0 || isArray(o) && o.length === 0;
17
+ var isNotEmpty = (o) => o !== "" && o !== null && o !== void 0 && (!isArray(o) || o.length > 0);
18
+ var isString = (o) => o instanceof String || typeof o === "string";
19
+ var isIsoDateString = (o) => isString(o) && /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)$/.test(o);
20
+ var isBoolean = (o) => isDefined(o) && typeof o === "boolean";
21
+ var isTrue = (o) => isFunction(o) ? isTrue(o()) : isBoolean(o) ? o : !!o;
22
+ var isNumber = (o) => isDefined(o) && typeof o === "number" && !Number.isNaN(o);
23
+ var isObject = (o) => o != null && typeof o === "object" && !isArray(o);
24
+ var isEmptyObject = (o) => isObject(o) && Object.getOwnPropertyNames(o).length === 0;
25
+ var isFunction = (o) => isDefined(o) && typeof o === "function";
26
+ var isArray = (o) => isDefined(o) && o instanceof Array;
27
+ var isIn = (o, values2) => isArray(values2) && values2.some((v) => v === o);
28
+ var isIntersecting = (o, values2) => isArray(o) && isArray(values2) && o.some((ov) => isIn(ov, values2));
29
+ var isError = (e) => isDefined(e) && e instanceof Error;
30
+ var isNotPresent = (...os) => os.some(
31
+ (o) => o === null || o === void 0 || o === "" || o instanceof Array && o.length === 0 || typeof o === "object" && Object.getOwnPropertyNames(o).length === 0
32
+ );
33
+ var isPresent = (...os) => !isNotPresent(...os);
34
+
35
+ // src/types/Primitive.ts
36
+ var isPrimitive = (v) => {
37
+ return v === null || v === void 0 || isIn(typeof v, ["string", "number", "bigint", "boolean", "symbol"]);
38
+ };
39
+
40
+ // src/types/Func.ts
41
+ var isFunc = (o) => !!o && typeof o === "function";
42
+
43
+ // src/types/Constructor.ts
44
+ var isConstructor = (c) => (isDefined(c) && isFunc(c) && c.prototype && c.prototype.constructor) === c;
45
+ var isInstance = (ctor, o) => isFunction(ctor) && o instanceof ctor;
46
+ var ofConstruct = (c, ...args) => isConstructor(c) ? new c(...args) : isFunc(c) ? c(...args) : c;
47
+ var toName = (subject, postfix = "") => subject?.constructor?.name?.replace(postfix, "").toLowerCase() ?? "";
48
+ var isPromise = (value) => {
49
+ return value instanceof Promise;
50
+ };
51
+ var on = (t, f) => {
52
+ const result = f(t);
53
+ return isPromise(result) ? result.then(() => t) : t;
54
+ };
55
+ var use = (t, f) => f(t);
56
+ var ifA = (c, t, alt) => !isPrimitive(t) && t instanceof c ? t : alt ? ifA(c, alt) : void 0;
57
+
58
+ // src/types/IsA.ts
59
+ var isA = (t, ...properties) => !isPrimitive(t) && properties.every((p) => p.toString() in t);
60
+ var isAn = isA;
61
+ var isIdentity = (by) => use(by, (b) => isObject(b) && isDefined(b.id));
62
+
63
+ // src/types/Get.ts
64
+ var ofGet = (g, ...args) => isFunc(g) ? g(...args) : g;
65
+ var ifGet = (pred, valid2, invalid) => ofGet(pred) ? ofGet(valid2) : ofGet(invalid);
66
+ var ofProperty = (t, p) => isFunc(p) ? p(t) : t[p];
67
+
68
+ // src/types/Array.ts
69
+ var toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
70
+ var toObject = (key, ...items) => toArray(...items).reduce((o, i) => {
71
+ o[i[key]] = i;
72
+ return o;
73
+ }, {});
74
+ var array = {
75
+ merge: (first = [], second = [], firstKey = "id", secondKey = "id") => first.map((f) => ({
76
+ ...f,
77
+ ...second.find((s) => isDefined(s[secondKey]) && isDefined(f[firstKey]) && s[secondKey] === f[firstKey])
78
+ })),
79
+ switch: (items = [], item) => use([...items], (res) => {
80
+ on(res.indexOf(item), (i) => i !== -1 ? res.splice(i, 1) : res.push(item));
81
+ return res;
82
+ }),
83
+ splitIn: (items = [], length = 2) => {
84
+ const res = Array.from({ length }, () => []);
85
+ items.forEach((i, index) => res[index % length].push(i));
86
+ return res;
87
+ },
88
+ chunk: (items = [], length = 2) => {
89
+ const chunks = Math.ceil(items.length / length);
90
+ const res = Array.from({ length: chunks }, () => []);
91
+ items.forEach((i, index) => res[Math.floor(index / chunks)].push(i));
92
+ return res;
93
+ }
94
+ };
95
+
96
+ // src/types/Text.ts
97
+ var isText = (t) => isDefined(t) && isFunc(t.toString);
98
+ var asString = (t, alt = "") => (isText(t) ? t : ofGet(alt)).toString();
99
+ var replaceAll = (origin, search, replace = "") => asString(origin).split(asString(search)).join(asString(replace));
100
+ var toWords = (input) => {
101
+ return asString(input).replace(/(\p{Lower})(\p{Upper})/gu, "$1 $2").replace(/(\p{Upper})(\p{Upper}\p{Lower})/gu, "$1 $2").split(/[_\W]+/g).filter(Boolean);
102
+ };
103
+ var kebab = (s = "") => toWords(s).join("-").toLowerCase();
104
+ var capitalize = (s = "") => s.charAt(0).toUpperCase() + s.slice(1);
105
+
106
+ // src/utils/Traverse.ts
107
+ var traverse = (subject, property = "") => {
108
+ subject ??= {};
109
+ const props = property.split(".");
110
+ const p = props.shift();
111
+ return props.length === 0 ? subject[p] : traverse(subject[p], props.join("."));
112
+ };
113
+ var traverseSet = (subject, property, value) => {
114
+ const props = property.split(".");
115
+ const p = props.shift();
116
+ return {
117
+ ...subject,
118
+ [p]: props.length === 0 ? value : traverseSet(subject[p], props.join("."), value)
119
+ };
120
+ };
121
+ var accumulate = (items, ...keys2) => items.map((t, i, arr) => {
122
+ const acc = keys2.reduce(
123
+ (acc2, v) => traverseSet(acc2, v, i === 0 ? traverse(t, v) : traverse(arr[i - 1], v) + traverse(t, v)),
124
+ t
125
+ );
126
+ arr[i] = acc;
127
+ return acc;
128
+ });
129
+
130
+ // src/types/List.ts
131
+ var List = class extends Array {
132
+ get ids() {
133
+ return this.mapDefined((i) => i.id);
134
+ }
135
+ get indexed() {
136
+ return this.map((v, index) => ({ ...v, index }));
137
+ }
138
+ isSubSetOf(...items) {
139
+ return this.diff(items).length === 0;
140
+ }
141
+ isSuperSetOf(...items) {
142
+ return this.length > items.length && toList(...items).isSubSetOf(...this);
143
+ }
144
+ isIntersectingWith(...items) {
145
+ return this.intersect(items).length > 0;
146
+ }
147
+ isDisjointWith(...items) {
148
+ return !this.isIntersectingWith(...items);
149
+ }
150
+ areEqual(...items) {
151
+ return this.isSubSetOf(...items) && toList(...items).isSubSetOf(...this);
152
+ }
153
+ asc(p) {
154
+ return this.sort((e1, e2) => ofProperty(e1, p) > ofProperty(e2, p) ? 1 : -1);
155
+ }
156
+ desc(p) {
157
+ return this.sort((e1, e2) => ofProperty(e1, p) < ofProperty(e2, p) ? 1 : -1);
158
+ }
159
+ first(p, params) {
160
+ return p ? this.find(p, params) : this[0];
161
+ }
162
+ firstValue(f, alt) {
163
+ return ifDefined(
164
+ this.first((t) => !!f(t)),
165
+ f,
166
+ (v) => ofGet(alt, v)
167
+ );
168
+ }
169
+ isFirst(value) {
170
+ return value === this.first();
171
+ }
172
+ next(p, params) {
173
+ return p ? this[this.findIndex(p, params) + 1] : this[0];
174
+ }
175
+ prev(p, params) {
176
+ return p ? this[this.findIndex(p, params) - 1] : this[0];
177
+ }
178
+ last(p, params) {
179
+ return p ? this.filter(p, params).last() : this[this.length - 1];
180
+ }
181
+ isLast(value) {
182
+ return value === this.last();
183
+ }
184
+ overlaps(...items) {
185
+ return toList(...items).some((i) => this.some((t) => i === t));
186
+ }
187
+ diff(others) {
188
+ return this.filter((i) => !others.includes(i));
189
+ }
190
+ diffByKey(others, key) {
191
+ return this.filter((i) => !others.some((o) => o[key] === i[key]));
192
+ }
193
+ symmetricDiff(others) {
194
+ return this.diff(others).concat(toList(...others).diff(this));
195
+ }
196
+ symmetricDiffByKey(others, key) {
197
+ return this.diffByKey(others, key).concat(toList(...others).diffByKey(this, key));
198
+ }
199
+ intersect(others) {
200
+ return this.filter((i) => others.includes(i));
201
+ }
202
+ intersectByKey(others, key) {
203
+ return this.filter((i) => others.some((o) => o[key] === i[key]));
204
+ }
205
+ intersectBy(others, f) {
206
+ return this.filter((i) => others.some((o) => f(i, o)));
207
+ }
208
+ accumulate(...keys2) {
209
+ return this.map((d, i, arr) => {
210
+ const acc = keys2.reduce((acc2, v) => {
211
+ acc2[v] = i === 0 ? d[v] : arr[i - 1][v] + d[v];
212
+ return acc2;
213
+ }, d);
214
+ arr[i] = acc;
215
+ return acc;
216
+ });
217
+ }
218
+ toJSON() {
219
+ return this.reduce((a, i) => {
220
+ a.push(JSON.parse(JSON.stringify(i ?? {})));
221
+ return a;
222
+ }, new Array());
223
+ }
224
+ map(f, params) {
225
+ return toList(super.map(f, params));
226
+ }
227
+ flatMap(f, params) {
228
+ return toList(super.flatMap(f, params));
229
+ }
230
+ mapDefined(f, params) {
231
+ return this.map(f, params).defined();
232
+ }
233
+ mapAsync(f) {
234
+ return Promise.all(super.map((e) => f(e))).then((a) => toList(a));
235
+ }
236
+ mapSerial(f) {
237
+ return super.reduce((p, item) => p.then((results) => on(results, async (r) => r.push(await f(item)))), Promise.resolve(toList()));
238
+ }
239
+ distinct() {
240
+ return this.filter((i, index) => this.indexOf(i) === index);
241
+ }
242
+ distinctByKey(key) {
243
+ const seen = /* @__PURE__ */ new Set();
244
+ return this.filter((item) => !seen.has(item[key]) && seen.add(item[key]));
245
+ }
246
+ distinctByValue() {
247
+ const seen = /* @__PURE__ */ new Set();
248
+ return this.filter((item) => !seen.has(JSON.stringify(item)) && seen.add(JSON.stringify(item)));
249
+ }
250
+ filter(p, params) {
251
+ return toList(super.filter(p, params));
252
+ }
253
+ sum(p) {
254
+ return this.reduce((sum, i) => sum + p(i), 0);
255
+ }
256
+ max(p) {
257
+ return typeof p === "function" ? this.sort((e1, e2) => p(e1) < p(e2) ? 1 : -1).first() : this.desc(p).first();
258
+ }
259
+ min(p) {
260
+ return typeof p === "function" ? this.sort((e1, e2) => p(e1) > p(e2) ? 1 : -1).first() : this.asc(p).first();
261
+ }
262
+ byId(id) {
263
+ return this.first((i) => asString(i.id) === asString(id));
264
+ }
265
+ byKey(key, value) {
266
+ return this.first((i) => i[key] == value);
267
+ }
268
+ add(...items) {
269
+ super.push(...toArray(...items));
270
+ return this;
271
+ }
272
+ concat(...items) {
273
+ return toList(super.concat(...items));
274
+ }
275
+ reverse() {
276
+ return toList(super.reverse());
277
+ }
278
+ splice(start, deleteCount, ...items) {
279
+ return toList(super.splice(start, deleteCount, ...items));
280
+ }
281
+ remove(item) {
282
+ const index = this.indexOf(item);
283
+ if (index > -1) {
284
+ this.splice(index, 1);
285
+ }
286
+ return this;
287
+ }
288
+ replace(key, item) {
289
+ const index = this.findIndex((i) => i[key] === item?.[key]);
290
+ ifTrue(index != -1, () => this.splice(index, 1, item));
291
+ return this;
292
+ }
293
+ switch(item) {
294
+ return this.includes(item) ? this.remove(item) : this.add(item);
295
+ }
296
+ switchOn(item, on2) {
297
+ return use(
298
+ typeof on2 === "function" ? this.find(on2) : use(traverse(item, on2), (v) => this.find((i) => traverse(i, on2) === v)),
299
+ (i) => i ? this.remove(i) : this.add(item)
300
+ );
301
+ }
302
+ defined() {
303
+ return this.reduce((l, v) => isDefined(v) ? l.add(v) : l, toList());
304
+ }
305
+ toObject(key, options = {}) {
306
+ return this.reduce((o, i) => {
307
+ o[i[key]] = i;
308
+ if (options.deleteKey)
309
+ delete o[i[key]][key];
310
+ return o;
311
+ }, {});
312
+ }
313
+ toObjectList(key) {
314
+ return this.reduce(
315
+ (a, t) => {
316
+ const k = t[key];
317
+ a[k] = a[k] ?? toList();
318
+ a[k].push(t);
319
+ return a;
320
+ },
321
+ {}
322
+ );
323
+ }
324
+ orElse(...alt) {
325
+ return !isEmpty(this) ? this : !isEmpty(...alt) ? toList(...alt) : void 0;
326
+ }
327
+ weave(insertFrom, interval) {
328
+ for (let i = interval, n = 0; i <= this.length && n < insertFrom.length; i += interval + 1) {
329
+ this.splice(i, 0, insertFrom[n++]);
330
+ }
331
+ return this;
332
+ }
333
+ slice(start, end) {
334
+ return toList(super.slice(start, end));
335
+ }
336
+ none(p) {
337
+ return !this.some(p);
338
+ }
339
+ chunk(chunkSize) {
340
+ return this.reduce((acc, _, index) => index % chunkSize === 0 ? on(acc, (a) => a.push(this.slice(index, index + chunkSize))) : acc, toList());
341
+ }
342
+ //we needed to add U because of a Typescript issue with generics
343
+ update(p, val) {
344
+ return this.map((v, i, a) => p(v, i, a) ? ofGet(val, v, i, a) : v);
345
+ }
346
+ updateFirst(p, val) {
347
+ const index = this.findIndex(p);
348
+ return this.update((t, i) => p(t, i, this) && i == index, val);
349
+ }
350
+ updateFirstById(id, val) {
351
+ return this.updateFirst((i) => asString(i?.id) === asString(id), val);
352
+ }
353
+ updateById(id, val) {
354
+ return this.update((i) => asString(i?.id) === asString(id), val);
355
+ }
356
+ };
357
+ var toList = (...items) => new List().add(...items);
358
+ var isList = (l) => isDefined(l) && isArray(l) && isA(l, "first", "last", "asc", "desc");
359
+ var asList = (c, items = []) => toList(toArray(items).map((i) => new c(i)));
360
+ var maxValue = (l, key) => l.desc(key).first()?.[key];
361
+ var minValue = (l, key) => l.asc(key).first()?.[key];
362
+
363
+ // src/utils/If.ts
364
+ function ifTrue(o, f, alt) {
365
+ return isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
366
+ }
367
+ function ifFalse(o, f, alt) {
368
+ return !isTrue(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
369
+ }
370
+ function ifDefined(o, f, alt) {
371
+ return isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt);
372
+ }
373
+ function ifNotEmpty(o, f = (o2) => o2, alt) {
374
+ return isNotEmpty(o) ? ofConstruct(f, o) : ofConstruct(alt, o);
375
+ }
376
+ function ifEither(os, f = (o) => o, alt) {
377
+ return use(
378
+ toList(os).first((o) => isPresent(o)),
379
+ (o) => isDefined(o) ? ofConstruct(f, o) : ofConstruct(alt, o)
380
+ );
381
+ }
382
+
383
+ // src/types/Object.ts
384
+ function entries(subject) {
385
+ return ifDefined(
386
+ subject,
387
+ () => toList([...Object.entries(subject), ...Object.entries(Object.getPrototypeOf(subject))]),
388
+ () => toList()
389
+ );
390
+ }
391
+ function values(subject) {
392
+ return toList([...Object.values(subject), ...Object.values(Object.getPrototypeOf(subject))]);
393
+ }
394
+ function keys(subject) {
395
+ return toList([...Object.keys(subject), ...Object.keys(Object.getPrototypeOf(subject))]);
396
+ }
397
+ function extractKeys(obj, keys2) {
398
+ return keys2.filter((k) => k in obj).reduce(
399
+ (acc, key) => {
400
+ acc.keys[key] = obj[key];
401
+ delete acc[key];
402
+ return acc;
403
+ },
404
+ { keys: {}, ...obj }
405
+ );
406
+ }
407
+
408
+ // src/types/Json.ts
409
+ var isJson = (subject) => isA(subject, "toJSON");
410
+ var json = {
411
+ parse: (subject) => JSON.parse(JSON.stringify(subject ?? {})),
412
+ merge: (...subjects) => json.parse(subjects.map((s) => asJson(s, (s2) => json.parse(s2))).reduce((js, j) => ({ ...js, ...j }), {})),
413
+ delete: (subject, key) => {
414
+ ifDefined(subject, () => delete subject[key]);
415
+ return subject;
416
+ },
417
+ set: (subject, key = "", value) => isEmpty(key) ? subject : value !== void 0 ? { ...subject, ...{ [key]: value } } : json.delete(subject, key),
418
+ omit: (subject, ...keys2) => keys2.reduce((js, k) => json.delete(js, k), json.parse(subject)),
419
+ pick: (subject, ...keys2) => keys2.reduce((js, k) => json.set(js, k, subject[k]), {}),
420
+ defaults: (options = {}, defaults = {}) => json.merge(defaults, options),
421
+ isSubset: (subject, subset) => !entries(subset).some(([k, v]) => subject[k] !== v),
422
+ split: (t, keys2, prop = "extracted") => {
423
+ const extracted = {};
424
+ const rest2 = { ...t };
425
+ keys2.forEach((key) => {
426
+ if (key in t) {
427
+ ifDefined(t[key], (v) => extracted[key] = v);
428
+ delete rest2[key];
429
+ }
430
+ });
431
+ return { [prop]: extracted, ...rest2 };
432
+ }
433
+ };
434
+ var toJson = json.merge;
435
+ var asJson = (j, alt = {}) => isJson(j) ? j.toJSON() : isObject(j) ? j : ofGet(alt, j);
436
+ var Any = class {
437
+ constructor(value) {
438
+ this.value = value;
439
+ }
440
+ merge = (...subjects) => any(json.merge(this.value, ...subjects));
441
+ delete = (key) => any(json.delete(this.value, key));
442
+ omit = (...keys2) => any(json.omit(this.value, ...keys2));
443
+ set = (key, value) => any(json.set(this.value, key, value));
444
+ toJSON() {
445
+ return this.value;
446
+ }
447
+ };
448
+ var takeFirstKey = (j, alt = "") => entries(asJson(j)).first(([, v]) => isDefined(v))?.[0] ?? alt;
449
+ var any = (value) => new Any(value);
450
+
451
+ // src/utils/Convert.ts
452
+ var Convert = class {
453
+ constructor(from, to) {
454
+ this.from = from;
455
+ this.to = to;
456
+ }
457
+ };
458
+ var convert = {
459
+ default: new Convert(
460
+ (a) => a,
461
+ (a) => a
462
+ ),
463
+ ignore: new Convert(
464
+ () => void 0,
465
+ () => void 0
466
+ ),
467
+ toBool: {
468
+ fromNumber: new Convert(
469
+ (b) => b ? 1 : 0,
470
+ (n) => n !== 0
471
+ ),
472
+ fromString: new Convert(
473
+ (b) => b ? "true" : "false",
474
+ (s) => s === "true"
475
+ )
476
+ },
477
+ toDate: {
478
+ fromString: new Convert(
479
+ (s) => new Date(s).toISOString(),
480
+ (s) => s
481
+ )
482
+ },
483
+ toNumber: {
484
+ fromString: new Convert(
485
+ (n) => asString(n),
486
+ (s) => parseInt(s)
487
+ )
488
+ }
489
+ };
490
+
491
+ // src/data/Condition.ts
492
+ var Condition = class {
493
+ constructor(key, operator, value) {
494
+ this.key = key;
495
+ this.operator = operator;
496
+ this.value = value;
497
+ }
498
+ and = (...others) => new LogicalCondition("and", [this, ...others]);
499
+ or = (...others) => new LogicalCondition("or", [this, ...others]);
500
+ toJSON() {
501
+ return { [this.key]: { [`$${this.operator}`]: json.parse(this.value) } };
502
+ }
503
+ };
504
+ var LogicalCondition = class {
505
+ constructor(operator, conditions) {
506
+ this.operator = operator;
507
+ this.conditions = conditions;
508
+ }
509
+ toJSON() {
510
+ return { [`$${this.operator}`]: this.conditions.map((c) => c.toJSON()) };
511
+ }
512
+ };
513
+ var SortCondition = class extends Condition {
514
+ constructor(key, value) {
515
+ super(key, "", value);
516
+ this.key = key;
517
+ this.value = value;
518
+ }
519
+ toJSON() {
520
+ return { [this.key]: this.value };
521
+ }
522
+ };
523
+ var toCondition = (field, operator, value, conv = convert.default) => new Condition(field, operator, conv.from(value));
524
+ var isSortCondition = (s) => isDefined(s) && s instanceof SortCondition;
525
+
526
+ // src/types/Meta.ts
527
+ import "reflect-metadata";
528
+ var ClassMeta = class {
529
+ constructor(subject, data = (subject.prototype ?? subject).constructor) {
530
+ this.subject = subject;
531
+ this.data = data;
532
+ }
533
+ get = (key) => Reflect.getMetadata(key, this.data);
534
+ set = (key, value) => {
535
+ Reflect.defineMetadata(key, value, this.data);
536
+ return value;
537
+ };
538
+ entries = () => entries(this.subject);
539
+ parse = (f, options = {}) => {
540
+ const { initial = {}, skipUndefined = false } = options;
541
+ return this.entries().reduce((a, [k, val]) => use(f(val), (v) => isDefined(v) || !skipUndefined ? on(a, (a2) => a2[k] = v) : a), initial);
542
+ };
543
+ properties = (key) => toList([...Object.getOwnPropertyNames(this.subject), ...Object.getOwnPropertyNames(Object.getPrototypeOf(this.subject))]).map((p) => this.property(p)).filter((p) => key ? p.get(key) : p);
544
+ keys = (key) => this.properties().map((p) => p.get(key)).reduce((list, u) => u ? list.add(u) : list, toList());
545
+ values = () => values(this.subject);
546
+ property = (property) => new PropertyMeta(this.subject, property);
547
+ };
548
+ var PropertyMeta = class {
549
+ constructor(subject, property, data = Reflect.getMetadata(property, subject)) {
550
+ this.subject = subject;
551
+ this.property = property;
552
+ this.data = data;
553
+ }
554
+ get value() {
555
+ return this.subject[this.property];
556
+ }
557
+ get = (key) => isDefined(this.data) && isDefined(this.data[key]) ? this.data[key] : void 0;
558
+ set = (key, value) => {
559
+ Reflect.defineMetadata(this.property, { ...this.data, [key]: value }, this.subject);
560
+ return value;
561
+ };
562
+ };
563
+ var meta = (subject) => new ClassMeta(subject ?? {});
564
+
565
+ // src/types/Enum.ts
566
+ var isEnumConstructor = (c) => isFunction(c) && c.isEnum;
567
+ var Enum = class {
568
+ constructor(name, id = name.toLowerCase(), code = id.toString()) {
569
+ this.name = name;
570
+ this.id = id;
571
+ this.code = code;
572
+ }
573
+ static isEnum = true;
574
+ get isValid() {
575
+ return isDefined(this.id);
576
+ }
577
+ static all() {
578
+ return meta(this.allTuple()).values();
579
+ }
580
+ static filter(p, params) {
581
+ return this.all().filter(p, params);
582
+ }
583
+ static first(p, params) {
584
+ return this.all().first(p, params);
585
+ }
586
+ static byIds(ids = []) {
587
+ return toList(ids).mapDefined((id) => this.byId(id)).distinct();
588
+ }
589
+ static byId(id, alt) {
590
+ return this.allTuple()[id] ?? ofGet(alt);
591
+ }
592
+ static allTuple() {
593
+ return meta(this).get(`all-${this.name}`) ?? meta(this).set(`all-${this.name}`, meta(this).values().filter(isEnum).toObject("id"));
594
+ }
595
+ equals(other) {
596
+ return this.id === (isEnum(other) ? other.id : other);
597
+ }
598
+ isIn(...items) {
599
+ return items.some((i) => this.equals(i));
600
+ }
601
+ toJSON() {
602
+ return this.id;
603
+ }
604
+ toString() {
605
+ return this.id.toString();
606
+ }
607
+ };
608
+ var isEnum = (e) => isDefined(e) && e instanceof Enum && isAn(e, "name", "id", "code");
609
+
610
+ // src/types/Template.ts
611
+ var Template = class {
612
+ constructor(template2, subject = {}, options = {}) {
613
+ this.template = template2;
614
+ this.subject = subject;
615
+ this.options = options;
616
+ }
617
+ toString = () => {
618
+ return entries(this.options).reduce((t, [k]) => this.option(t, k), this.object()).replace(" ", " ");
619
+ };
620
+ props = (tmpl, key, result = toList()) => {
621
+ const i1 = tmpl.indexOf(`{${key}`);
622
+ if (i1 < 0) {
623
+ return result;
624
+ }
625
+ const i2 = tmpl.indexOf("}", i1);
626
+ return this.props(tmpl.slice(i2 + 1), key, result.add(tmpl.substring(i1 + 1, i2)));
627
+ };
628
+ object = () => {
629
+ return this.props(this.template, "this").reduce((t, p) => t.replace(`{${p}}`, textValue(this.subject, p.replace("this.", ""))), this.template);
630
+ };
631
+ option = (tmpl, prop) => {
632
+ return this.props(tmpl, prop).reduce((t, p) => t.replace(`{${p}}`, textValue(this.options, p)), tmpl);
633
+ };
634
+ };
635
+ function template(tmpl, subject, options = {}) {
636
+ return new Template(asString(tmpl), subject, {
637
+ type: toName(subject),
638
+ subject: text(JSON.stringify(subject)),
639
+ ...options
640
+ });
641
+ }
642
+
643
+ // src/types/ToText.ts
644
+ var ToText = class {
645
+ constructor(subject) {
646
+ this.subject = subject;
647
+ }
648
+ get cap() {
649
+ return this.map((s) => capitalize(s?.toLowerCase()));
650
+ }
651
+ get capFirst() {
652
+ return this.map((s) => capitalize(s));
653
+ }
654
+ get title() {
655
+ return this.map(
656
+ (s) => s.split(" ").map((w) => text(w).cap).join(" ")
657
+ );
658
+ }
659
+ get pascal() {
660
+ return this.title.replace(" ", "");
661
+ }
662
+ get lower() {
663
+ return this.map((s) => s.toLowerCase());
664
+ }
665
+ get upper() {
666
+ return this.map((s) => s.toUpperCase());
667
+ }
668
+ get camel() {
669
+ return this.title.trim.map((s) => `${s.charAt(0).toLowerCase()}${s.slice(1)}`);
670
+ }
671
+ get kebab() {
672
+ return this.lower.replace(" ", "-");
673
+ }
674
+ get strictKebab() {
675
+ return this.map((s) => s.replace(/[^a-z\d]+/gi, " ").trim()).kebab;
676
+ }
677
+ get slug() {
678
+ return this.map(
679
+ (s) => s.replace(/ß/g, "ss").normalize("NFKD").replace(/[\u0300-\u036F]/g, "").toLowerCase().replace(/[^a-z\d]+/g, "-").replace(/(^-)|(-$)/g, "")
680
+ );
681
+ }
682
+ get snake() {
683
+ return this.upper.replace(" ", "_");
684
+ }
685
+ get plural() {
686
+ return this.ifLike("") ?? this.add("s");
687
+ }
688
+ get space() {
689
+ return this.map((s) => s.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]/g, " "));
690
+ }
691
+ get sentence() {
692
+ return this.isEmpty ? this : this.map((s) => `${s.charAt(0).toUpperCase()}${s.slice(1)}.`);
693
+ }
694
+ get initials() {
695
+ return this.map(
696
+ (s) => s.split(" ").map((w) => w[0]).join("")
697
+ );
698
+ }
699
+ get trim() {
700
+ return this.map((s) => s.replace(/[- ,_#]/g, ""));
701
+ }
702
+ get trimSentence() {
703
+ return this.map(
704
+ (s) => s.replace(/[\u200B-\u200D\uFEFF]/g, "").replace(/[\s\u00A0]+/g, " ").replace(/\s+([.,;:!?])/g, "$1").trim()
705
+ );
706
+ }
707
+ get isEmpty() {
708
+ return isEmpty(this.toString());
709
+ }
710
+ parse = (subject, options = {}) => text(template(this.subject, subject, { type: toName(subject), ...options }));
711
+ is = (...others) => others.some((o) => this.toString() === text(o).toString());
712
+ equals = this.is;
713
+ isLike = (...others) => others.some((o) => this.trim.lower.is(text(o).trim.lower));
714
+ ifLike = (...others) => this.isLike(...others) ? this : void 0;
715
+ endsWith = (end) => this.subject.endsWith(asString(end));
716
+ startsWith = (end) => this.subject.startsWith(asString(end));
717
+ first = (n) => this.map((s) => s.substring(0, n));
718
+ last = (n) => this.map((s) => s.substring(s.length - n));
719
+ map = (func) => text(ofGet(func, this.subject));
720
+ replace = (search, replace) => this.map((s) => replaceAll(s, search, replace));
721
+ add = (add, separator = "") => this.map((s) => isNotEmpty(add) ? `${s}${separator}${text(add)}` : s);
722
+ with = (separator, ...other) => this.map(
723
+ (s) => toList(s).add(...other.map((u) => text(u).toString())).filter((s2) => isNotEmpty(s2)).join(separator)
724
+ );
725
+ split = (separator = " ") => toList(this.subject.split(separator));
726
+ toString() {
727
+ return this.subject;
728
+ }
729
+ toJSON() {
730
+ return this.subject;
731
+ }
732
+ };
733
+ function text(subject, alt = "") {
734
+ const sub = subject ? asString(subject) : alt;
735
+ return new ToText(sub !== "[object Object]" ? sub : "");
736
+ }
737
+ function textValue(subject, prop) {
738
+ const p = prop.split(".");
739
+ const root = subject?.[p[0]];
740
+ const initial = typeof root === "object" && root !== null ? root : text(root);
741
+ return p.splice(1).reduce((t, s) => t?.[s], initial)?.toString() ?? "";
742
+ }
743
+
744
+ // src/types/Exception.ts
745
+ var Exception = class _Exception extends Enum {
746
+ constructor(message, id, reason) {
747
+ super(message, id ?? text(message).pascal.toString());
748
+ this.message = message;
749
+ this.reason = reason;
750
+ }
751
+ static AlreadyExists = new _Exception("Subject already exists");
752
+ static DoesNotExist = new _Exception("Does not exist");
753
+ static IsMissingId = new _Exception("Subject is missing an id");
754
+ static IsNotImplemented = new _Exception("Is not implemented");
755
+ static IsNotValid = new _Exception("Is not valid");
756
+ static Unknown = new _Exception("Unknown error");
757
+ static CouldNotExecute = (target) => new _Exception(`Could not execute ${target}.`, "CouldNotExecute");
758
+ static CouldNotValidate = (target) => new _Exception(`Could not validate ${target}.`, "CouldNotValidate");
759
+ static EnvironmentVariableNotFound = (variable) => new _Exception(`Environment variable ${text(variable).upper} could not be found.`, "EnvironmentVariableNotFound");
760
+ because = (reason) => new _Exception(this.message, this.id, reason);
761
+ };
762
+ var isException = (e, t) => e instanceof Exception && (isDefined(t) ? e.equals(asString(t)) : true);
763
+ var isDoesNotExist = (e) => e instanceof Exception && Exception.DoesNotExist.equals(e);
764
+
765
+ // src/utils/Promise.ts
766
+ var resolve = (subject) => Promise.resolve(subject);
767
+ var reject = (e) => Promise.reject(e);
768
+ var tuple = {
769
+ 2: (first, second) => Promise.all([first, second]),
770
+ 3: (first, second, third) => Promise.all([first, second, third]),
771
+ 4: (first, second, third, forth) => Promise.all([first, second, third, forth]),
772
+ 5: (first, second, third, forth, fifth) => Promise.all([first, second, third, forth, fifth]),
773
+ all: (first, second) => Promise.all([first, Promise.all(second)]),
774
+ spread: (first, ...second) => Promise.all([first, Promise.all(toArray(second))]),
775
+ list: (list) => Promise.all([...list]).then(toList),
776
+ settled: (list) => Promise.allSettled([...list]).then((rs) => ({
777
+ fulfilled: toList(...rs.filter((r) => r.status === "fulfilled").map((r) => r.value)),
778
+ rejected: toList(...rs.filter((r) => r.status === "rejected").map((r) => asString(r.reason)))
779
+ })),
780
+ object: (obj) => use(keys(obj), (ks) => tuple.list(values(obj)).then((vs) => vs.reduce((acc, v, i) => on(acc, (a) => a[ks[i]] = v), {})))
781
+ };
782
+ var tuple2 = tuple[2];
783
+ var tuple3 = tuple[3];
784
+ var tuple4 = tuple[4];
785
+ var tuple5 = tuple[5];
786
+ var tupleO = tuple.object;
787
+ var settled = tuple.settled;
788
+
789
+ // src/types/Gateway.ts
790
+ var Gateway = class {
791
+ all(options) {
792
+ return reject(Exception.IsNotImplemented);
793
+ }
794
+ byId(id, options) {
795
+ return reject(Exception.IsNotImplemented);
796
+ }
797
+ by(_key, _value, _options) {
798
+ return reject(Exception.IsNotImplemented);
799
+ }
800
+ byIds(..._ids) {
801
+ return reject(Exception.IsNotImplemented);
802
+ }
803
+ search(q, options) {
804
+ return reject(Exception.IsNotImplemented);
805
+ }
806
+ filter(options) {
807
+ return reject(Exception.IsNotImplemented);
808
+ }
809
+ exists(id, options) {
810
+ return reject(Exception.IsNotImplemented);
811
+ }
812
+ add(item, options) {
813
+ return reject(Exception.IsNotImplemented);
814
+ }
815
+ update(item, options) {
816
+ return reject(Exception.IsNotImplemented);
817
+ }
818
+ remove(id, options) {
819
+ return reject(Exception.IsNotImplemented);
820
+ }
821
+ };
822
+
823
+ // src/validation/When.ts
824
+ var When = class _When {
825
+ constructor(subject, valid2 = true, results) {
826
+ this.subject = subject;
827
+ this.valid = valid2;
828
+ this.results = results;
829
+ }
830
+ get not() {
831
+ return this.clone(!this.valid);
832
+ }
833
+ get and() {
834
+ return this.clone(this.valid);
835
+ }
836
+ get isDefined() {
837
+ return this.clone(this.valid === isDefined(this.subject));
838
+ }
839
+ get isEmpty() {
840
+ return this.clone(this.valid === isEmpty(this.subject));
841
+ }
842
+ get isTrue() {
843
+ return this.clone(this.valid === !!this.subject);
844
+ }
845
+ get isValid() {
846
+ this.results = validate(this.subject);
847
+ return this.clone(this.valid === this.results.isValid);
848
+ }
849
+ isInstance = (c) => this.clone(this.valid === this.subject instanceof c);
850
+ with = (pred) => this.clone(this.valid === ofGet(pred, this.subject));
851
+ contains = (property) => this.clone(this.valid === isDefined(ofGet(property, this.subject)));
852
+ in = (...items) => this.clone(this.valid === isIn(this.subject, toArray(...items)));
853
+ is = (item) => this.clone(this.valid === (this.subject === item));
854
+ reject = (error) => !this.valid ? resolve(this.subject) : reject(ofGet(error, this.subject) ?? this.results ?? Exception.Unknown);
855
+ recover = (f) => resolve(!this.valid ? this.subject : f(this.subject));
856
+ clone = (result = true) => new _When(this.subject, result, this.results);
857
+ };
858
+ var when = (subject) => new When(subject);
859
+
860
+ // src/types/Context.ts
861
+ var DotEnvContext = class {
862
+ domain = process.env.DOMAIN ?? "easy";
863
+ name = process.env.ENVIRONMENT_NAME ?? "";
864
+ host = process.env.HOST ?? "";
865
+ port = Number.parseInt(process.env.PORT ?? "8080");
866
+ app = process.env.APP ?? "";
867
+ get = (key, alt) => {
868
+ const k = text(key).map((k2) => k2.replace(/([a-z])([A-Z])/g, "$1 $2")).snake.toString();
869
+ return process.env[k] ?? alt;
870
+ };
871
+ };
872
+ var BaseRequestContext = class {
873
+ state = {};
874
+ get token() {
875
+ return this.get("token");
876
+ }
877
+ set token(token) {
878
+ this.set("token", token);
879
+ }
880
+ get identity() {
881
+ return this.token;
882
+ }
883
+ get jwt() {
884
+ return this.get("jwt");
885
+ }
886
+ set jwt(jwt) {
887
+ this.set("jwt", jwt);
888
+ }
889
+ get correlationId() {
890
+ return this.get("correlationId");
891
+ }
892
+ set correlationId(id) {
893
+ this.set("correlationId", id);
894
+ }
895
+ get lastError() {
896
+ return this.get("lastError");
897
+ }
898
+ set lastError(error) {
899
+ this.set("lastError", error);
900
+ }
901
+ get(key) {
902
+ return this.state[key];
903
+ }
904
+ set(key, value) {
905
+ return this.state[key] = value;
906
+ }
907
+ create = (f) => f();
908
+ wrap = (f) => f();
909
+ };
910
+ var BaseContext = class extends BaseRequestContext {
911
+ };
912
+ var Context = class {
913
+ constructor(state = {}) {
914
+ this.state = state;
915
+ this.state = {
916
+ ...{
917
+ env: new DotEnvContext(),
918
+ request: new BaseRequestContext(),
919
+ other: {}
920
+ },
921
+ ...this.state
922
+ };
923
+ }
924
+ get env() {
925
+ return this.state.env;
926
+ }
927
+ set env(env) {
928
+ this.state.env = env;
929
+ }
930
+ get request() {
931
+ return this.state.request;
932
+ }
933
+ set request(request) {
934
+ this.state.request = request;
935
+ }
936
+ get other() {
937
+ return this.state.other;
938
+ }
939
+ };
940
+ var ctx = new Context();
941
+
942
+ // src/types/Result.ts
943
+ var toResult = (message, location, domain = ctx.env.domain) => ({
944
+ message: message.toString(),
945
+ location: location?.toString(),
946
+ domain: domain?.toString()
947
+ });
948
+ var isResult = (r) => isA(r, "message");
949
+
950
+ // src/types/Results.ts
951
+ var parse = (...rs) => toArray(...rs).map((r) => isResult(r) ? r : toResult(r));
952
+ var Results = class {
953
+ results;
954
+ constructor(...rs) {
955
+ this.results = parse(...rs);
956
+ }
957
+ get length() {
958
+ return this.results.length;
959
+ }
960
+ get isValid() {
961
+ return this.results.length === 0;
962
+ }
963
+ add = (...rs) => toResults(...this.results, ...parse(...rs));
964
+ };
965
+ var toResults = (...r) => new Results(...r);
966
+ var isResults = (r) => isDefined(r) && r instanceof Results;
967
+
968
+ // src/types/Value.ts
969
+ var Value = class {
970
+ constructor(value) {
971
+ this.value = value;
972
+ this.value = value;
973
+ }
974
+ get isValid() {
975
+ return isDefined(this.value);
976
+ }
977
+ toJSON() {
978
+ return this.value;
979
+ }
980
+ toString() {
981
+ return asString(this.value);
982
+ }
983
+ };
984
+ var isValue = (v) => v instanceof Value;
985
+
986
+ // src/types/Validatable.ts
987
+ var isValidatable = (v) => isA(v, "isValid");
988
+
989
+ // src/validation/Validate.ts
990
+ var asResults = (subject, template2, options = {}) => toResults(toResult(text(template2).parse(subject, options), toName(subject)));
991
+ var validators = (subject) => meta(subject).keys("constraint").reduce((list, vs) => list.add(vs), toList());
992
+ var runValidator = (v, subject) => {
993
+ try {
994
+ const actual = isFunction(subject[v.property]) ? subject[v.property]() : subject[v.property];
995
+ const constraint2 = v.constraint(actual);
996
+ return isResults(constraint2) ? constraint2 : !constraint2 ? asResults(subject, v.text, {
997
+ ...v,
998
+ actual
999
+ }) : toResults();
1000
+ } catch (e) {
1001
+ return asResults(subject, asString(e));
1002
+ }
1003
+ };
1004
+ var constraints = (subject) => validators(subject).map((vs) => runValidator(vs, subject)).reduce((rs, r) => rs.add(...r.results), toResults());
1005
+ var validate = (subject) => choose(subject).is.not.defined(
1006
+ (s) => s,
1007
+ () => toResults("Subject is not defined.")
1008
+ ).type(isEnum, (e) => e.isValid ? toResults() : asResults(e, "This is not a valid {type}.")).type(isValue, (v) => v.isValid ? toResults() : asResults(v, "This is not a valid {type}.")).type(isArray, (a) => a.map((i) => validate(i)).reduce((rs, r) => rs.add(...r.results), toResults())).type(isValidatable, (v) => constraints(v)).else(toResults());
1009
+ var validateReject = (subject) => when(subject).not.isValid.reject();
1010
+ var isValid = (t) => validate(t).isValid;
1011
+
1012
+ // src/types/Try.ts
1013
+ var Try = class _Try {
1014
+ is = {
1015
+ defined: (prop) => this.filter((v) => isDefined(prop ? prop(v) : v)),
1016
+ empty: (prop) => this.filter((v) => isEmpty(prop ? prop(v) : v)),
1017
+ valid: (prop) => this.filter((v) => validate(prop ? prop(v) : v).isValid),
1018
+ true: (prop) => this.filter((v) => isTrue(prop ? prop(v) : v)),
1019
+ false: (prop) => this.filter((v) => !isTrue(prop ? prop(v) : v)),
1020
+ not: {
1021
+ defined: (prop) => this.filter((v) => !isDefined(prop ? prop(v) : v)),
1022
+ empty: (prop) => this.filter((v) => !isEmpty(prop ? prop(v) : v)),
1023
+ valid: (prop) => this.filter((v) => !validate(prop ? prop(v) : v).isValid)
1024
+ }
1025
+ };
1026
+ if = this.is;
1027
+ static of = (c, ...args) => {
1028
+ try {
1029
+ const out = ofGet(c, ...args);
1030
+ return new Success(out instanceof _Try ? out.value : out);
1031
+ } catch (e) {
1032
+ return new Failure(e);
1033
+ }
1034
+ };
1035
+ };
1036
+ var Success = class extends Try {
1037
+ constructor(value) {
1038
+ super();
1039
+ this.value = value;
1040
+ }
1041
+ get error() {
1042
+ throw new Error("No error found");
1043
+ }
1044
+ get isValid() {
1045
+ return true;
1046
+ }
1047
+ map(f) {
1048
+ return tryTo(f, this.value);
1049
+ }
1050
+ recover(f) {
1051
+ return this;
1052
+ }
1053
+ recoverFrom(type, f) {
1054
+ return this;
1055
+ }
1056
+ accept(f) {
1057
+ return tryTo(() => {
1058
+ f(this.value);
1059
+ return this;
1060
+ });
1061
+ }
1062
+ filter(predicate) {
1063
+ return tryTo(() => {
1064
+ if (predicate(this.value))
1065
+ return this;
1066
+ throw new Error(`Applying filter(${predicate.toString()}) failed.`);
1067
+ });
1068
+ }
1069
+ or(value) {
1070
+ return this.value;
1071
+ }
1072
+ orElse(value) {
1073
+ return this.value;
1074
+ }
1075
+ orThrow(_error) {
1076
+ return this.value;
1077
+ }
1078
+ };
1079
+ var Failure = class _Failure extends Try {
1080
+ constructor(error) {
1081
+ super();
1082
+ this.error = error;
1083
+ }
1084
+ get value() {
1085
+ throw this.error;
1086
+ }
1087
+ get isValid() {
1088
+ return false;
1089
+ }
1090
+ map(f) {
1091
+ return new _Failure(this.error);
1092
+ }
1093
+ recover(f) {
1094
+ return tryTo(f, this.error);
1095
+ }
1096
+ recoverFrom(type, f) {
1097
+ return tryTo(() => this.error instanceof type ? this.recover(f) : this);
1098
+ }
1099
+ accept(f) {
1100
+ return this;
1101
+ }
1102
+ filter(predicate) {
1103
+ return this;
1104
+ }
1105
+ or(value) {
1106
+ return ofGet(value);
1107
+ }
1108
+ orElse(value) {
1109
+ return ofGet(value);
1110
+ }
1111
+ orThrow(error) {
1112
+ throw ofConstruct(error);
1113
+ }
1114
+ };
1115
+ var tryTo = (c, ...args) => Try.of(c, ...args);
1116
+
1117
+ // src/types/Case.ts
1118
+ var CaseBuilder = class {
1119
+ constructor(v) {
1120
+ this.v = v;
1121
+ }
1122
+ is = {
1123
+ defined: (prop, out) => new Case(this.v).case(isDefined(prop(this.v)), out),
1124
+ empty: (prop, out) => new Case(this.v).case(isEmpty(prop(this.v)), out),
1125
+ valid: (prop, out) => new Case(this.v).case(validate(prop(this.v)).isValid, out),
1126
+ in: (prop, out) => new Case(this.v).case(ofGet(prop, this.v).includes(this.v), out),
1127
+ not: {
1128
+ defined: (prop, out) => new Case(this.v).case(!isDefined(prop(this.v)), out),
1129
+ empty: (prop, out) => new Case(this.v).case(!isEmpty(prop(this.v)), out),
1130
+ valid: (prop, out) => new Case(this.v).case(!validate(prop(this.v)).isValid, out),
1131
+ in: (prop, out) => new Case(this.v).case(!ofGet(prop, this.v).includes(this.v), out)
1132
+ }
1133
+ };
1134
+ if = this.is;
1135
+ case(pred, out) {
1136
+ return new Case(this.v).case(pred, out);
1137
+ }
1138
+ type(guard, out) {
1139
+ return new Case(this.v).type(guard, out);
1140
+ }
1141
+ equals(value, out) {
1142
+ return new Case(this.v).equals(value, out);
1143
+ }
1144
+ };
1145
+ var Case = class _Case {
1146
+ constructor(value, outcome) {
1147
+ this.value = value;
1148
+ this.outcome = outcome;
1149
+ }
1150
+ is = {
1151
+ defined: (prop, out) => new _Case(this.value).case(isDefined(prop(this.value)), out),
1152
+ empty: (prop, out) => new _Case(this.value).case(isEmpty(prop(this.value)), out),
1153
+ valid: (prop, out) => new _Case(this.value).case(validate(prop(this.value)).isValid, out),
1154
+ in: (prop, out) => new _Case(this.value).case(ofGet(prop, this.value).includes(this.value), out),
1155
+ not: {
1156
+ defined: (prop, out) => new _Case(this.value).case(!isDefined(prop(this.value)), out),
1157
+ empty: (prop, out) => new _Case(this.value).case(!isEmpty(prop(this.value)), out),
1158
+ valid: (prop, out) => new _Case(this.value).case(!validate(prop(this.value)).isValid, out),
1159
+ in: (prop, out) => new _Case(this.value).case(!ofGet(prop, this.value).includes(this.value), out)
1160
+ }
1161
+ };
1162
+ if = this.is;
1163
+ case(pred, out) {
1164
+ return tryTo(pred, this.value).is.true().map(() => ofGet(out, this.value)).map((res) => new Found(this.value, res)).or(this);
1165
+ }
1166
+ type(guard, out) {
1167
+ return tryTo(guard, this.value).is.true().map(() => out(this.value)).map((res) => new Found(this.value, res)).or(this);
1168
+ }
1169
+ equals(value, out) {
1170
+ return this.case(this.value === value, out);
1171
+ }
1172
+ else(alt) {
1173
+ return ofGet(alt, this.value);
1174
+ }
1175
+ };
1176
+ var Found = class extends Case {
1177
+ constructor(value, outcome) {
1178
+ super(value, outcome);
1179
+ this.value = value;
1180
+ this.outcome = outcome;
1181
+ }
1182
+ is = {
1183
+ defined: (_prop, _out) => this,
1184
+ empty: (_prop, _out) => this,
1185
+ valid: (_prop, _out) => this,
1186
+ in: (_prop, _out) => this,
1187
+ not: {
1188
+ defined: (_prop, _out) => this,
1189
+ empty: (_prop, _out) => this,
1190
+ valid: (_prop, _out) => this,
1191
+ in: (_prop, _out) => this
1192
+ }
1193
+ };
1194
+ if = this.is;
1195
+ case(pred, out) {
1196
+ return this;
1197
+ }
1198
+ type(guard, out) {
1199
+ return this;
1200
+ }
1201
+ equals(value, out) {
1202
+ return this;
1203
+ }
1204
+ else(alt) {
1205
+ return this.outcome;
1206
+ }
1207
+ };
1208
+ var choose = (value) => new CaseBuilder(value);
1209
+
1210
+ // src/types/PageList.ts
1211
+ var toFilter = (field, value) => toShortFilter(field, field, value);
1212
+ var toShortFilter = (field, shortField, value) => ({
1213
+ field,
1214
+ shortField,
1215
+ values: [{ value }]
1216
+ });
1217
+ var PageList = class extends List {
1218
+ _options;
1219
+ get options() {
1220
+ return this._options;
1221
+ }
1222
+ get take() {
1223
+ return this._options?.take ?? 250;
1224
+ }
1225
+ get skip() {
1226
+ return this._options?.skip ?? 0;
1227
+ }
1228
+ get total() {
1229
+ return this._options?.total;
1230
+ }
1231
+ get sorts() {
1232
+ return this._options?.sorts;
1233
+ }
1234
+ get filters() {
1235
+ return this._options?.filters;
1236
+ }
1237
+ get meta() {
1238
+ return {
1239
+ take: this.take,
1240
+ skip: this.skip,
1241
+ total: this.total,
1242
+ sorts: this.sorts,
1243
+ filters: this.filters
1244
+ };
1245
+ }
1246
+ get ids() {
1247
+ return this.mapDefined((i) => i.id);
1248
+ }
1249
+ asc(p) {
1250
+ return toPageList(super.asc(p), this);
1251
+ }
1252
+ desc(p) {
1253
+ return toPageList(super.desc(p), this);
1254
+ }
1255
+ diff(others) {
1256
+ return toPageList(super.diff(others), this);
1257
+ }
1258
+ diffByKey(others, key) {
1259
+ return toPageList(super.diffByKey(others, key), this);
1260
+ }
1261
+ symmetricDiff(others) {
1262
+ return toPageList(super.symmetricDiff(others), this);
1263
+ }
1264
+ symmetricDiffByKey(others, key) {
1265
+ return toPageList(super.symmetricDiffByKey(others, key), this);
1266
+ }
1267
+ intersect(others) {
1268
+ return toPageList(super.intersect(others), this);
1269
+ }
1270
+ intersectByKey(others, key) {
1271
+ return toPageList(super.intersectByKey(others, key), this);
1272
+ }
1273
+ map(f, params) {
1274
+ const items = super.map(f, params);
1275
+ return toPageList(items, this);
1276
+ }
1277
+ flatMap(f, params) {
1278
+ return toPageList(super.flatMap(f, params), this);
1279
+ }
1280
+ mapDefined(f, params) {
1281
+ return toPageList(super.mapDefined(f, params), this);
1282
+ }
1283
+ mapAsync(f) {
1284
+ return super.mapAsync(f).then((r) => toPageList(r, this));
1285
+ }
1286
+ areEqual(...items) {
1287
+ return this.isSubSetOf(...items) && toList(...items).isSubSetOf(...this);
1288
+ }
1289
+ distinct() {
1290
+ return toPageList(super.distinct(), this);
1291
+ }
1292
+ distinctByKey(key) {
1293
+ return toPageList(super.distinctByKey(key), this);
1294
+ }
1295
+ distinctByValue() {
1296
+ return toPageList(super.distinctByValue(), this);
1297
+ }
1298
+ filter(p, params) {
1299
+ return toPageList(super.filter(p, params), this);
1300
+ }
1301
+ accumulate(...keys2) {
1302
+ return toPageList(super.accumulate(...keys2), this);
1303
+ }
1304
+ concat(...items) {
1305
+ return toPageList(super.concat(...items), this);
1306
+ }
1307
+ reverse() {
1308
+ return toPageList(super.reverse(), this);
1309
+ }
1310
+ splice(start, deleteCount, ...items) {
1311
+ return toPageList(super.splice(start, deleteCount, ...items), this);
1312
+ }
1313
+ remove(item) {
1314
+ return toPageList(super.remove(item), this);
1315
+ }
1316
+ replace(key, item) {
1317
+ return toPageList(super.replace(key, item), this);
1318
+ }
1319
+ switch(item) {
1320
+ return toPageList(super.switch(item), this);
1321
+ }
1322
+ defined() {
1323
+ return toPageList(super.defined(), this);
1324
+ }
1325
+ orElse(...alt) {
1326
+ return toPageList(super.orElse(...alt), this);
1327
+ }
1328
+ slice(start, end) {
1329
+ return toPageList(super.slice(start, end), this);
1330
+ }
1331
+ //we needed to add U because of a Typescript issue with generics
1332
+ update(p, val) {
1333
+ return toPageList(super.update(p, val), this);
1334
+ }
1335
+ updateFirst(p, val) {
1336
+ return toPageList(super.updateFirst(p, val), this);
1337
+ }
1338
+ updateFirstById(id, val) {
1339
+ return toPageList(super.updateFirstById(id, val), this);
1340
+ }
1341
+ updateById(id, val) {
1342
+ return toPageList(super.updateById(id, val), this);
1343
+ }
1344
+ setPageOptions(options) {
1345
+ this._options = options;
1346
+ return this;
1347
+ }
1348
+ };
1349
+ var isPageList = (l) => isList(l) && isA(l, "total");
1350
+ var toPageList = (items = [], options) => {
1351
+ return choose(items).case(
1352
+ (i) => i.length === 1 && isNumber(i[0]),
1353
+ (i) => new PageList().add(...i)
1354
+ ).else((i) => new PageList(...i)).setPageOptions(isPageList(options) ? options.options : options);
1355
+ };
1356
+ var asPageList = (c, items = toPageList()) => items.map((i) => ofConstruct(c, i));
1357
+
1358
+ // src/data/InMemoryGateway.ts
1359
+ var InMemoryGateway = class extends Gateway {
1360
+ constructor(data) {
1361
+ super();
1362
+ this.data = data;
1363
+ }
1364
+ all(options) {
1365
+ return this.data.then((d) => toPageList(d, d));
1366
+ }
1367
+ byId(id) {
1368
+ return this.data.then((d) => d.byId(id)).then((d) => d ? { ...d } : void 0);
1369
+ }
1370
+ by = (key, value) => {
1371
+ return this.data.then((d) => d.filter((i) => i[key] === value));
1372
+ };
1373
+ exists(id) {
1374
+ return this.byId(id).then((d) => isDefined(d));
1375
+ }
1376
+ add(item) {
1377
+ return when(item).not.contains((i) => i.id).reject(Exception.IsMissingId).then((i) => this.exists(i.id)).then((ex) => when(ex).isTrue.reject(Exception.AlreadyExists)).then(() => this.data.then((d) => d.add(item))).then(() => ({ ...item }));
1378
+ }
1379
+ remove(id) {
1380
+ return this.data.then(
1381
+ (d) => when(d.findIndex((i) => i.id === id)).with((i) => i < 0).reject(Exception.DoesNotExist).then((i) => d.splice(i, 1))
1382
+ ).then(() => true);
1383
+ }
1384
+ update(item) {
1385
+ return when(item).not.contains((i) => i.id).reject(Exception.IsMissingId).then((i) => this.remove(i.id).then(() => this.add(i)));
1386
+ }
1387
+ };
1388
+
1389
+ // src/data/Database.ts
1390
+ var DefaultProvider = class {
1391
+ };
1392
+ var Database = class _Database extends Enum {
1393
+ constructor(name, provider, options) {
1394
+ super(name);
1395
+ this.provider = provider;
1396
+ this.options = options;
1397
+ }
1398
+ static Default = new _Database("Default", DefaultProvider);
1399
+ provide = () => ofConstruct(this.provider, this);
1400
+ };
1401
+
1402
+ // src/utils/Property.ts
1403
+ var Property = class {
1404
+ constructor(property, options) {
1405
+ this.property = property;
1406
+ this.options = options;
1407
+ this.options = { ...options, convert: options?.convert ?? convert.default };
1408
+ }
1409
+ in = (source = {}) => this.options?.convert?.to(source[this.property] ?? ofGet(this.options?.dflt));
1410
+ out = (source = {}, key = "") => this.options?.convert?.from(source[key]);
1411
+ toString() {
1412
+ return this.property;
1413
+ }
1414
+ };
1415
+
1416
+ // src/data/Field.ts
1417
+ var Field = class extends Property {
1418
+ is = (value) => this.condition("eq", value);
1419
+ isNot = (value) => this.condition("ne", value);
1420
+ isIn = (...value) => this.condition("in", toArray(value));
1421
+ notIn = (...value) => this.condition("nin", toArray(value));
1422
+ exists = (does) => this.condition("exists", does);
1423
+ greater = (value) => this.condition("gt", value);
1424
+ greaterEqual = (value) => this.condition("gte", value);
1425
+ less = (value) => this.condition("lt", value);
1426
+ lessEqual = (value) => this.condition("lte", value);
1427
+ asc = () => new SortCondition(this.property, 1);
1428
+ desc = () => new SortCondition(this.property, -1);
1429
+ condition = (operator, value) => toCondition(this.property, operator, value, this.options?.convert);
1430
+ };
1431
+ var isField = (f) => isDefined(f) && f instanceof Field;
1432
+
1433
+ // src/domain/Struct.ts
1434
+ var Struct = class {
1435
+ constructor(state = {}) {
1436
+ this.state = state;
1437
+ }
1438
+ get isValid() {
1439
+ return validate(this).isValid;
1440
+ }
1441
+ toJSON() {
1442
+ return json.delete(json.parse({ ...this }), "state");
1443
+ }
1444
+ toString() {
1445
+ return this.constructor.name;
1446
+ }
1447
+ update(_add) {
1448
+ return this;
1449
+ }
1450
+ merge(a) {
1451
+ return json.merge(this, a);
1452
+ }
1453
+ };
1454
+ function isStruct(s) {
1455
+ return isDefined(s) && s instanceof Struct;
1456
+ }
1457
+
1458
+ // src/domain/DateTime.ts
1459
+ import { DateTime as LuxonDateTime, Settings } from "luxon";
1460
+
1461
+ // src/types/IsDate.ts
1462
+ var isDate = (o) => o instanceof Date && !isNaN(o.getTime());
1463
+ var days = {
1464
+ add: (date, days2) => {
1465
+ date.setDate(date.getDate() + days2);
1466
+ return date;
1467
+ },
1468
+ today: () => /* @__PURE__ */ new Date(),
1469
+ yesterday: () => days.add(days.today(), -1),
1470
+ tomorrow: () => days.add(days.today(), 1)
1471
+ };
1472
+ var inPast = (o) => isDate(o) && o <= days.today();
1473
+ var inFuture = (o) => isDate(o) && o > days.today();
1474
+
1475
+ // src/utils/Seconds.ts
1476
+ var seconds = {
1477
+ toDuration: (s) => {
1478
+ const seconds2 = s % 60;
1479
+ const minutes = Math.floor(s / 60) % 60;
1480
+ const hours = Math.floor(s / 3600) % 24;
1481
+ const days2 = Math.floor(s / 86400);
1482
+ return { days: days2, hours, minutes, seconds: seconds2 };
1483
+ },
1484
+ toText: (s) => {
1485
+ const { days: days2, hours, minutes, seconds: secs } = seconds.toDuration(s);
1486
+ return toList(ifTrue(days2, `${days2}d`), ifTrue(hours, `${hours}h`), ifTrue(minutes, `${minutes}m`), ifTrue(days2 + hours + minutes === 0, `${secs}s`)).mapDefined((s2) => s2).join(" ");
1487
+ }
1488
+ };
1489
+
1490
+ // src/domain/DateTime.ts
1491
+ Settings.defaultZone = "utc";
1492
+ var DateTime = class _DateTime extends Value {
1493
+ luxon;
1494
+ constructor(value, format) {
1495
+ const luxon = choose(value).type(isString, (v) => format ? LuxonDateTime.fromFormat(v, format, { setZone: true }) : LuxonDateTime.fromISO(v, { setZone: true })).type(isNumber, (v) => LuxonDateTime.fromMillis(v)).type(isDate, (v) => LuxonDateTime.fromJSDate(v)).type(isDateTime, (v) => v.luxon).else(value instanceof LuxonDateTime ? value : LuxonDateTime.fromISO(void 0));
1496
+ super(luxon.toISO() ?? void 0);
1497
+ this.luxon = luxon;
1498
+ }
1499
+ static get now() {
1500
+ return new _DateTime(LuxonDateTime.utc());
1501
+ }
1502
+ get isValid() {
1503
+ return isDefined(this.value) && this.utc.isValid;
1504
+ }
1505
+ /**
1506
+ * @deprecated Deprecated in favor for DateTime.from as that also accepts locales and another DateTime
1507
+ */
1508
+ get fromNow() {
1509
+ return this.from();
1510
+ }
1511
+ get inAmsterdam() {
1512
+ return this.withZone("Europe/Amsterdam");
1513
+ }
1514
+ get inNewYork() {
1515
+ return this.withZone("America/New_York");
1516
+ }
1517
+ get inLondon() {
1518
+ return this.withZone("Europe/London");
1519
+ }
1520
+ get inWarsaw() {
1521
+ return this.withZone("Europe/Warsaw");
1522
+ }
1523
+ get utc() {
1524
+ return this.luxon.setZone("utc");
1525
+ }
1526
+ from(dateOrLocale, maybeLocale) {
1527
+ return use(
1528
+ (isString(dateOrLocale) ? dateOrLocale : maybeLocale) ?? "en",
1529
+ (locale) => ifDefined(
1530
+ isA(dateOrLocale) ? dateOrLocale : void 0,
1531
+ (d) => this.utc.setLocale(locale).toRelative({ base: d.utc }),
1532
+ () => this.utc.setLocale(locale).toRelative()
1533
+ )
1534
+ ) ?? "";
1535
+ }
1536
+ isAfter(dt2) {
1537
+ return this.utc > dt2.utc;
1538
+ }
1539
+ isBefore(dt2) {
1540
+ return this.utc < dt2.utc;
1541
+ }
1542
+ equals(dt2) {
1543
+ return this.utc.hasSame(dt2.utc, "millisecond");
1544
+ }
1545
+ add(n, unit = "day") {
1546
+ return new _DateTime(this.luxon.plus(isNumber(n) ? { [unit]: n } : n));
1547
+ }
1548
+ subtract(n, unit = "day") {
1549
+ return new _DateTime(this.luxon.minus(isNumber(n) ? { [unit]: n } : n));
1550
+ }
1551
+ diff(other, unit = "day", opts) {
1552
+ return Math[opts?.rounding ?? "floor"](this.utc.diff(other.utc).as(unit));
1553
+ }
1554
+ startOf(unit = "day") {
1555
+ return new _DateTime(this.luxon.startOf(unit));
1556
+ }
1557
+ endOf(unit = "day") {
1558
+ return new _DateTime(this.luxon.endOf(unit));
1559
+ }
1560
+ isWeekend() {
1561
+ return this.luxon.isWeekend;
1562
+ }
1563
+ withZone(zone) {
1564
+ return new _DateTime(this.luxon.setZone(zone));
1565
+ }
1566
+ toString() {
1567
+ return this.value ?? "";
1568
+ }
1569
+ toJSON() {
1570
+ return this.utc.toISO();
1571
+ }
1572
+ toFormat(format) {
1573
+ return this.luxon.toFormat(format);
1574
+ }
1575
+ toLocale(locale = "nl-NL", format = "D") {
1576
+ return this.luxon.setLocale(locale).toFormat(format);
1577
+ }
1578
+ toFull(locale) {
1579
+ return this.toLocale(locale, "DDD");
1580
+ }
1581
+ toDate() {
1582
+ return this.isValid ? this.utc.toJSDate() : void 0;
1583
+ }
1584
+ toEpoch() {
1585
+ return this.luxon.toMillis();
1586
+ }
1587
+ ago(end = _DateTime.now) {
1588
+ return seconds.toText(end.diff(this, "second"));
1589
+ }
1590
+ withClock(clock) {
1591
+ return tryTo(() => [this.toDate(), clock.toDate()]).map(([td, cd]) => new Date(td.getFullYear(), td.getMonth(), td.getDate(), cd.getHours(), cd.getMinutes(), cd.getSeconds())).map((d) => new _DateTime(d)).value;
1592
+ }
1593
+ };
1594
+ var isDateTime = (dt2) => isDefined(dt2) && dt2 instanceof DateTime;
1595
+ var dt = (dt2) => new DateTime(dt2);
1596
+
1597
+ // src/validation/Contraints.ts
1598
+ var constraint = (c, message) => (subject, property) => {
1599
+ const cs = meta(subject).property(property).get("constraint") ?? toList();
1600
+ meta(subject).property(property).set("constraint", cs.add({ property, constraint: c, text: message }));
1601
+ };
1602
+ var defined = (message) => constraint((v) => isDefined(v), message ?? "Property {property} must be defined.");
1603
+ var required = (message) => constraint((v) => isNotEmpty(v), message ?? "Property {property} is required, and may not be empty.");
1604
+ var notEmpty = (message) => constraint((v) => isNotEmpty(v), message ?? "Property {property} may not be empty.");
1605
+ var valid = () => constraint((v) => validate(v), "");
1606
+ var optional = () => constraint((v) => !isDefined(v) || validate(v), "");
1607
+ var includes = (sub, message) => constraint((s) => isDefined(s) && isString(s) && s.includes(sub), message ?? `Value {actual} must include '${sub}'.`);
1608
+ var inList = (values2, message) => constraint((v) => isDefined(v) && isIn(v, values2), message ?? "Value {actual} must appear in list.");
1609
+ var inOptionalList = (values2, message) => constraint((v) => !isDefined(v) || isIn(v, values2), message ?? "Value {actual} must appear in list.");
1610
+ var gt = (limit, message) => constraint((v) => v > limit, message ?? `Value {actual} must be larger than '${limit}'.`);
1611
+ var gte = (limit, message) => constraint((v) => v >= limit, message ?? `Value {actual} must be larger than or equal to ${limit}.`);
1612
+ var lt = (limit, message) => constraint((v) => v < limit, message ?? `Value {actual} must be smaller than ${limit}.`);
1613
+ var lte = (limit, message) => constraint((v) => v <= limit, message ?? `Value {actual} must be smaller than or equal to ${limit}.`);
1614
+ var past = (message) => constraint((v) => inPast(v), message ?? "Value {actual} must lay in the past.");
1615
+ var future = (message) => constraint((v) => inFuture(v), message ?? "Value {actual} must lay in the future.");
1616
+ var minLength = (length, message) => constraint(
1617
+ (v) => tryTo(() => v).is.defined().map((v2) => text(v2).toString().length >= length).orElse(true),
1618
+ message ?? `Value {actual} must be at least '${length}' characters long.`
1619
+ );
1620
+ var maxLength = (length, message) => constraint(
1621
+ (v) => tryTo(() => v).is.defined().map((v2) => text(v2).toString().length <= length).orElse(true),
1622
+ message ?? `Value {actual} cannot be longer than '${length}' characters.`
1623
+ );
1624
+ var rule = (message) => constraint((v) => isFunction(v) ? v() : isBoolean(v) ? v : false, message ?? `Value {actual} must be true`);
1625
+
1626
+ // src/domain/Audit.ts
1627
+ var Audit = class extends Struct {
1628
+ by = { id: this.state.by?.id, user: this.state.by?.user };
1629
+ when = new DateTime(this.state.when);
1630
+ constructor(json3) {
1631
+ super(
1632
+ choose(json3).is.defined(
1633
+ (j) => j,
1634
+ (j) => j
1635
+ ).else({
1636
+ by: isIdentity(ctx.request?.identity) ? ctx.request?.identity : { id: 0, user: "easy" },
1637
+ when: DateTime.now.toJSON()
1638
+ })
1639
+ );
1640
+ }
1641
+ };
1642
+ __decorateClass([
1643
+ required()
1644
+ ], Audit.prototype, "by", 2);
1645
+ __decorateClass([
1646
+ valid()
1647
+ ], Audit.prototype, "when", 2);
1648
+
1649
+ // src/types/Uuid.ts
1650
+ import { v4 as uuid } from "uuid";
1651
+ var toUuid = () => uuid();
1652
+ var isValidUuid = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i);
1653
+ var isUuid = (id) => isString(id) && isValidUuid.test(id);
1654
+ var includeUuid = new RegExp(/\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i);
1655
+ var includesUuid = (value) => includeUuid.test(asString(value));
1656
+
1657
+ // src/types/Id.ts
1658
+ var toId = () => toUuid();
1659
+
1660
+ // src/domain/Child.ts
1661
+ var Child = class extends Struct {
1662
+ id = this.state.id ?? toId();
1663
+ merge(a) {
1664
+ return json.merge(this, a, { id: this.id });
1665
+ }
1666
+ };
1667
+ __decorateClass([
1668
+ required()
1669
+ ], Child.prototype, "id", 2);
1670
+
1671
+ // src/domain/Entity.ts
1672
+ var Entity = class extends Struct {
1673
+ id = this.state.id ?? toId();
1674
+ created = new Audit(this.state.created);
1675
+ lastModified = new Audit(this.state.lastModified);
1676
+ merge(a) {
1677
+ return json.merge(this, a, {
1678
+ id: this.id,
1679
+ created: this.created,
1680
+ lastModified: new Audit()
1681
+ });
1682
+ }
1683
+ };
1684
+ __decorateClass([
1685
+ required()
1686
+ ], Entity.prototype, "id", 2);
1687
+ __decorateClass([
1688
+ required()
1689
+ ], Entity.prototype, "created", 2);
1690
+ __decorateClass([
1691
+ required()
1692
+ ], Entity.prototype, "lastModified", 2);
1693
+
1694
+ // src/types/Repository.ts
1695
+ var Repository = class {
1696
+ all(options) {
1697
+ return reject(Exception.IsNotImplemented);
1698
+ }
1699
+ byId(id) {
1700
+ return reject(Exception.IsNotImplemented);
1701
+ }
1702
+ byIds(...ids) {
1703
+ return reject(Exception.IsNotImplemented);
1704
+ }
1705
+ byKey(key, options) {
1706
+ return reject(Exception.IsNotImplemented);
1707
+ }
1708
+ by(key, value, options) {
1709
+ return reject(Exception.IsNotImplemented);
1710
+ }
1711
+ search(q, options) {
1712
+ return reject(Exception.IsNotImplemented);
1713
+ }
1714
+ filter(options) {
1715
+ return reject(Exception.IsNotImplemented);
1716
+ }
1717
+ exists(id) {
1718
+ return reject(Exception.IsNotImplemented);
1719
+ }
1720
+ add(t) {
1721
+ return reject(Exception.IsNotImplemented);
1722
+ }
1723
+ update(id, json3) {
1724
+ return reject(Exception.IsNotImplemented);
1725
+ }
1726
+ remove(id) {
1727
+ return reject(Exception.IsNotImplemented);
1728
+ }
1729
+ upsert(id, item) {
1730
+ return reject(Exception.IsNotImplemented);
1731
+ }
1732
+ };
1733
+
1734
+ // src/domain/Repo.ts
1735
+ var Repo = class extends Repository {
1736
+ constructor(ctor, gateway) {
1737
+ super();
1738
+ this.ctor = ctor;
1739
+ this.gateway = gateway;
1740
+ }
1741
+ create = (item) => isValidatable(item) ? item : new this.ctor(item);
1742
+ all(options) {
1743
+ return this.gateway.all(options).then((js) => js.map((i) => new this.ctor(i)));
1744
+ }
1745
+ byId(id) {
1746
+ return this.gateway.byId(id).then((j) => when(j).not.isDefined.reject(Exception.DoesNotExist)).then((j) => new this.ctor(j));
1747
+ }
1748
+ byIds(...ids) {
1749
+ return this.gateway.byIds(...ids).then((j) => asList(this.ctor, j));
1750
+ }
1751
+ byKey(key, options) {
1752
+ return this.gateway.by("key", key, options).then((js) => js.map((i) => new this.ctor(i)));
1753
+ }
1754
+ by(key, value, options) {
1755
+ return this.gateway.by(key.toString(), value, options).then((js) => js.map((i) => new this.ctor(i)));
1756
+ }
1757
+ search(q, options) {
1758
+ return this.gateway.search(q, options).then((js) => js.map((i) => new this.ctor(i)));
1759
+ }
1760
+ filter(options) {
1761
+ return this.gateway.filter(options).then((js) => js.map((i) => new this.ctor(i)));
1762
+ }
1763
+ exists(id) {
1764
+ return this.gateway.exists(id);
1765
+ }
1766
+ add(t) {
1767
+ return this.extend(this.create(t), "add").then((i) => when(i).not.isValid.reject()).then((i) => this.validate(i, "add")).then((i) => this.gateway.add(toJson(i))).then((j) => new this.ctor(j));
1768
+ }
1769
+ update(id, json3) {
1770
+ return this.gateway.byId(id).then((j) => when(j).not.isDefined.reject(Exception.DoesNotExist)).then((j) => new this.ctor(j).update(json3)).then((i) => this.extend(i, "update")).then((i) => when(i).not.isValid.reject()).then((i) => this.validate(i, "update")).then((i) => this.gateway.update(toJson(i))).then((j) => new this.ctor(j));
1771
+ }
1772
+ remove(id) {
1773
+ return this.gateway.remove(id);
1774
+ }
1775
+ extend(item, _action) {
1776
+ return resolve(item);
1777
+ }
1778
+ validate(item, _action) {
1779
+ return resolve(item);
1780
+ }
1781
+ upsert(id, item) {
1782
+ return this.update(id, item).catch((e) => Exception.DoesNotExist.equals(e) ? this.add(item) : reject(e));
1783
+ }
1784
+ };
1785
+
1786
+ // src/domain/Typo.ts
1787
+ var Typo = class extends Repository {
1788
+ constructor(view2, gateway) {
1789
+ super();
1790
+ this.view = view2;
1791
+ this.gateway = gateway;
1792
+ }
1793
+ create = (j) => this.view.from(j);
1794
+ all(options) {
1795
+ return this.gateway.all(options).then((js) => js.map(this.create));
1796
+ }
1797
+ byId(id) {
1798
+ return this.gateway.byId(id).then((j) => when(j).not.isDefined.reject(Exception.DoesNotExist)).then((j) => this.create(j));
1799
+ }
1800
+ byIds(...ids) {
1801
+ return this.gateway.byIds(...ids).then((js) => js.map(this.create));
1802
+ }
1803
+ byKey(key, options) {
1804
+ return this.gateway.by("key", key, options).then((js) => js.map(this.create));
1805
+ }
1806
+ by(key, value, options) {
1807
+ return this.gateway.by(key.toString(), value, options).then((js) => js.map(this.create));
1808
+ }
1809
+ search(q, options) {
1810
+ return this.gateway.search(q, options).then((js) => js.map(this.create));
1811
+ }
1812
+ filter(options) {
1813
+ return this.gateway.filter(options).then((js) => js.map((j) => this.create(j)));
1814
+ }
1815
+ exists(id) {
1816
+ return this.gateway.exists(id);
1817
+ }
1818
+ };
1819
+ var Agent = class extends Repository {
1820
+ constructor(gateway) {
1821
+ super();
1822
+ this.gateway = gateway;
1823
+ }
1824
+ all(options) {
1825
+ return this.gateway.all(options);
1826
+ }
1827
+ byId(id) {
1828
+ return this.gateway.byId(id);
1829
+ }
1830
+ byIds(...ids) {
1831
+ return this.gateway.byIds(...ids);
1832
+ }
1833
+ byKey(key, options) {
1834
+ return this.gateway.by("key", key, options);
1835
+ }
1836
+ by(key, value, options) {
1837
+ return this.gateway.by(key.toString(), value, options);
1838
+ }
1839
+ search(q, options) {
1840
+ return this.gateway.search(q, options);
1841
+ }
1842
+ filter(options) {
1843
+ return this.gateway.filter(options);
1844
+ }
1845
+ exists(id) {
1846
+ return this.gateway.exists(id);
1847
+ }
1848
+ add(t) {
1849
+ return this.gateway.add(toJson(t));
1850
+ }
1851
+ update(id, t) {
1852
+ return this.gateway.update({ ...toJson(t), id });
1853
+ }
1854
+ upsert(id, t) {
1855
+ return this.gateway.upsert({ ...toJson(t), id });
1856
+ }
1857
+ remove(id) {
1858
+ return this.gateway.remove(id);
1859
+ }
1860
+ };
1861
+
1862
+ // src/types/Number.ts
1863
+ var asNumber = (n, alt) => tryTo(() => asString(n)).map((s) => parseInt(s)).filter((n2) => isNumber(n2)).or(ofGet(alt) ?? NaN);
1864
+
1865
+ // src/types/CacheAge.ts
1866
+ var ageNumber = (s) => asNumber(s.replace(/[a-z]/g, ""));
1867
+ var cacheAge = {
1868
+ toMilliseconds: (ca) => choose(asString(ca)).case(
1869
+ (c) => c.endsWith("ms"),
1870
+ (c) => ageNumber(c)
1871
+ ).case(
1872
+ (c) => c.endsWith("s"),
1873
+ (c) => ageNumber(c) * 1e3
1874
+ ).case(
1875
+ (c) => c.endsWith("m"),
1876
+ (c) => ageNumber(c) * 60 * 1e3
1877
+ ).case(
1878
+ (c) => c.endsWith("h"),
1879
+ (c) => ageNumber(c) * 3600 * 1e3
1880
+ ).case(
1881
+ (c) => c.endsWith("d"),
1882
+ (c) => ageNumber(c) * 24 * 3600 * 1e3
1883
+ ).else(ca),
1884
+ toSeconds: (ca) => choose(asString(ca)).case(
1885
+ (c) => c.endsWith("ms"),
1886
+ (c) => ageNumber(c) / 1e3
1887
+ ).case(
1888
+ (c) => c.endsWith("s"),
1889
+ (c) => ageNumber(c)
1890
+ ).case(
1891
+ (c) => c.endsWith("m"),
1892
+ (c) => ageNumber(c) * 60
1893
+ ).case(
1894
+ (c) => c.endsWith("h"),
1895
+ (c) => ageNumber(c) * 3600
1896
+ ).case(
1897
+ (c) => c.endsWith("d"),
1898
+ (c) => ageNumber(c) * 24 * 3600
1899
+ ).else(ca)
1900
+ };
1901
+ var isCacheAge = (ca) => isString(ca) || isNumber(ca);
1902
+
1903
+ // src/http/CacheControl.ts
1904
+ var CacheControl = class _CacheControl {
1905
+ constructor(enabled = true, directives = {}) {
1906
+ this.enabled = enabled;
1907
+ this.directives = directives;
1908
+ }
1909
+ name = "Cache-Control";
1910
+ static disabled = () => new _CacheControl(false);
1911
+ static OneSecond = () => new _CacheControl().maxAge(1).staleWhileRevalidate(1);
1912
+ static fiveSeconds = () => new _CacheControl().maxAge(5).staleWhileRevalidate(5);
1913
+ static tenSeconds = () => new _CacheControl().maxAge(10).staleWhileRevalidate(10);
1914
+ static thirtySeconds = () => new _CacheControl().maxAge(30).staleWhileRevalidate(30);
1915
+ static sixtySeconds = () => new _CacheControl().maxAge(60).staleWhileRevalidate(60);
1916
+ static custom = (maxAge, staleWhileRevalidate) => new _CacheControl().maxAge(maxAge).staleWhileRevalidate(staleWhileRevalidate);
1917
+ maxAge = (ca) => on(this, (t) => t.directives["max-age"] = ca);
1918
+ sharedMaxAge = (ca) => on(this, (t) => t.directives["s-maxage"] = ca);
1919
+ noCache = (a) => on(this, (t) => t.directives["no-cache"] = a);
1920
+ mustRevalidate = (a) => on(this, (t) => t.directives["must-revalidate"] = a);
1921
+ private = (a) => on(this, (t) => t.directives["private"] = a);
1922
+ public = (a) => on(this, (t) => t.directives["public"] = a);
1923
+ immutable = (a) => on(this, (t) => t.directives["immutable"] = a);
1924
+ staleWhileRevalidate = (ca) => on(this, (t) => t.directives["stale-while-revalidate"] = ca);
1925
+ value = () => this.toString();
1926
+ toString() {
1927
+ return entries(this.directives).mapDefined(([k, v]) => ifDefined(v, isCacheAge(v) ? `${k}=${cacheAge.toSeconds(v)}` : k)).join(",");
1928
+ }
1929
+ };
1930
+
1931
+ // src/http/ContentType.ts
1932
+ import formUrlEncoded from "form-urlencoded";
1933
+ var ContentType = class _ContentType extends Enum {
1934
+ constructor(name, type, encoder = (b) => asString(b)) {
1935
+ super(name, type);
1936
+ this.type = type;
1937
+ this.encoder = encoder;
1938
+ }
1939
+ static Form = new _ContentType("form", "application/x-www-form-urlencoded", (b) => formUrlEncoded(b));
1940
+ static Json = new _ContentType("json", "application/json", (b) => b);
1941
+ static RawJson = new _ContentType("rawJson", "application/json", (b) => b);
1942
+ static Stream = new _ContentType("stream", "application/octet-stream");
1943
+ static Text = new _ContentType("text", "text/plain");
1944
+ static Xml = new _ContentType("xml", "application/xml");
1945
+ encode = (body) => ofGet(this.encoder, body);
1946
+ };
1947
+
1948
+ // src/http/HttpHeader.ts
1949
+ var HttpHeader = {
1950
+ ContentType: "Content-Type",
1951
+ Correlation: "X-Correlation-Id"
1952
+ };
1953
+
1954
+ // src/http/HttpStatus.ts
1955
+ var HttpStatus = class _HttpStatus extends Enum {
1956
+ static Continue = new _HttpStatus("Continue", 100);
1957
+ static SwitchingProtocols = new _HttpStatus("Switching protocols", 101);
1958
+ static Processing = new _HttpStatus("Processing", 102);
1959
+ static EarlyHints = new _HttpStatus("Early hints", 103);
1960
+ static Ok = new _HttpStatus("Ok", 200);
1961
+ static Created = new _HttpStatus("Created", 201);
1962
+ static Accepted = new _HttpStatus("Accepted", 202);
1963
+ static NonAuthoritativeInformation = new _HttpStatus("Non-authoritative information", 203);
1964
+ static NoContent = new _HttpStatus("No content", 204);
1965
+ static ResetContent = new _HttpStatus("Reset content", 205);
1966
+ static PartialContent = new _HttpStatus("Partial content", 206);
1967
+ static MultiStatus = new _HttpStatus("Multi-status", 207);
1968
+ static AlreadyReported = new _HttpStatus("Already reported", 208);
1969
+ static ImUsed = new _HttpStatus("IM used", 226);
1970
+ static MultipleChoices = new _HttpStatus("Multiple Choices", 300);
1971
+ static MovedPermanently = new _HttpStatus("Moved Permanently", 301);
1972
+ static Found = new _HttpStatus("Found", 302);
1973
+ static SeeOther = new _HttpStatus("See other", 303);
1974
+ static NotModified = new _HttpStatus("Not modified", 304);
1975
+ static UseProxy = new _HttpStatus("Use proxy", 305);
1976
+ static SwitchProxy = new _HttpStatus("Switch proxy", 306);
1977
+ static TemporaryRedirect = new _HttpStatus("Temporary redirect", 307);
1978
+ static PermanentRedirect = new _HttpStatus("Permanent redirect", 308);
1979
+ static BadRequest = new _HttpStatus("Bad request", 400);
1980
+ static NotAuthorized = new _HttpStatus("Not authorized", 401);
1981
+ static PaymentRequired = new _HttpStatus("Payment required", 402);
1982
+ static Forbidden = new _HttpStatus("Forbidden", 403);
1983
+ static NotFound = new _HttpStatus("Not found", 404);
1984
+ static MethodNotAllowed = new _HttpStatus("Method not allowed", 405);
1985
+ static NotAcceptable = new _HttpStatus("Not acceptable", 406);
1986
+ static ProxyAuthenticationRequired = new _HttpStatus("Proxy authentication required", 407);
1987
+ static RequestTimeout = new _HttpStatus("Request timeout", 408);
1988
+ static Conflict = new _HttpStatus("Conflict", 409);
1989
+ static Gone = new _HttpStatus("Gone", 410);
1990
+ static LengthRequired = new _HttpStatus("Length required", 411);
1991
+ static PreconditionFailed = new _HttpStatus("Precondition failed", 412);
1992
+ static PayloadTooLarge = new _HttpStatus("Payload too large", 413);
1993
+ static UriTooLong = new _HttpStatus("URI too long", 414);
1994
+ static UnsupportedMediaType = new _HttpStatus("Unsupported media type", 415);
1995
+ static RangeNotSatisfiable = new _HttpStatus("Range not satisfiable", 416);
1996
+ static ExpectationFailed = new _HttpStatus("Expectation failed", 417);
1997
+ static ImATeapot = new _HttpStatus("I'm a teapot", 418);
1998
+ static MisdirectedRequest = new _HttpStatus("Misdirected request", 421);
1999
+ static UnprocessableEntity = new _HttpStatus("Unprocessable entity", 422);
2000
+ static Locked = new _HttpStatus("Locked", 423);
2001
+ static FailedDependency = new _HttpStatus("Failed dependency", 424);
2002
+ static TooEarly = new _HttpStatus("Too early", 425);
2003
+ static UpgradeRequired = new _HttpStatus("Upgrade required", 426);
2004
+ static PreconditionRequired = new _HttpStatus("Precondition required", 428);
2005
+ static TooManyRequests = new _HttpStatus("Too many requests", 429);
2006
+ static RequestHeaderFieldsTooLarge = new _HttpStatus("Request header fields too large", 431);
2007
+ static UnavailableForLegalReasons = new _HttpStatus("Unavailable for legal reasons", 451);
2008
+ static InternalServerError = new _HttpStatus("Internal server error", 500);
2009
+ static NotImplemented = new _HttpStatus("Not implemented", 501);
2010
+ static BadGateway = new _HttpStatus("Bad gateway", 502);
2011
+ static ServiceUnavailable = new _HttpStatus("Service unavailable", 503);
2012
+ static GatewayTimeout = new _HttpStatus("Gateway timeout", 504);
2013
+ static HTTPVersionNotSupported = new _HttpStatus("Http version not supported", 505);
2014
+ static VariantAlsoNegotiates = new _HttpStatus("Variant also negotiates", 506);
2015
+ static InsufficientStorage = new _HttpStatus("Insufficient storage", 507);
2016
+ static LoopDetected = new _HttpStatus("Loop detected", 508);
2017
+ static NotExtended = new _HttpStatus("Not extended", 510);
2018
+ static NetworkAuthenticationRequired = new _HttpStatus("Network authentication required", 511);
2019
+ get isError() {
2020
+ return this.isClientError || this.isServerError;
2021
+ }
2022
+ get isClientError() {
2023
+ return this.id >= 400 && this.id < 500;
2024
+ }
2025
+ get isServerError() {
2026
+ return this.id >= 500 && this.id < 600;
2027
+ }
2028
+ get status() {
2029
+ return this.id;
2030
+ }
2031
+ };
2032
+ var isHttpStatus = (s) => isAn(s, "id", "status");
2033
+ var toHttpStatus = (s) => isHttpStatus(s) ? s : HttpStatus.byId(s);
2034
+
2035
+ // src/http/HttpVerb.ts
2036
+ var HttpVerb = class _HttpVerb extends Enum {
2037
+ static Get = new _HttpVerb("Get");
2038
+ static Put = new _HttpVerb("Put");
2039
+ static Patch = new _HttpVerb("Patch");
2040
+ static Post = new _HttpVerb("Post");
2041
+ static Delete = new _HttpVerb("Delete");
2042
+ constructor(name) {
2043
+ super(name, name.toLowerCase(), name.toUpperCase());
2044
+ }
2045
+ };
2046
+
2047
+ // src/http/RequestOptions.ts
2048
+ var toPageOptions = (options) => options instanceof RequestOptions ? options.pageOptions : options;
2049
+ var RequestOptions = class _RequestOptions extends Enum {
2050
+ constructor(type = ContentType.Json, headers = {}, pageOptions) {
2051
+ super(type.name);
2052
+ this.type = type;
2053
+ this.headers = headers;
2054
+ this.pageOptions = pageOptions;
2055
+ this.headers["Content-Type"] = type.id;
2056
+ this.headers[HttpHeader.Correlation] = ctx.request.correlationId ?? toUuid();
2057
+ }
2058
+ requestOptions = {};
2059
+ static get Form() {
2060
+ return new _RequestOptions(ContentType.Form);
2061
+ }
2062
+ static get Json() {
2063
+ return new _RequestOptions(ContentType.Json);
2064
+ }
2065
+ static get Stream() {
2066
+ return new _RequestOptions(ContentType.Stream);
2067
+ }
2068
+ static get Text() {
2069
+ return new _RequestOptions(ContentType.Text);
2070
+ }
2071
+ static get Xml() {
2072
+ return new _RequestOptions(ContentType.Xml);
2073
+ }
2074
+ page = (options) => {
2075
+ this.pageOptions = options;
2076
+ return this;
2077
+ };
2078
+ authorization = (auth) => this.setHeader("Authorization", auth);
2079
+ apiKey = (apiKey) => this.setHeader("apiKey", apiKey);
2080
+ setHeader = (key, value) => on(this, (t) => t.headers[asString(key)] = value);
2081
+ setHeaderUnlessPresent = (key, value) => value ? this.setHeader(key, this.headers[key] ?? value) : this;
2082
+ accept = (type) => this.setHeader("Accept", type.id);
2083
+ bearer = (jwt) => {
2084
+ return isNotEmpty(jwt) ? this.authorization(`Bearer ${jwt}`) : this;
2085
+ };
2086
+ basic = (username, password) => {
2087
+ const basicAuth = Buffer.from(`${username}:${password}`, "utf8").toString("base64");
2088
+ return this.authorization(`Basic ${basicAuth}`);
2089
+ };
2090
+ maxRedirects = (max) => {
2091
+ this.requestOptions.maxRedirects = max;
2092
+ return this;
2093
+ };
2094
+ validateStatus = (validate2) => {
2095
+ this.requestOptions.validateStatus = validate2;
2096
+ return this;
2097
+ };
2098
+ timeout = (t) => {
2099
+ this.requestOptions.timeout = t;
2100
+ return this;
2101
+ };
2102
+ };
2103
+ var isRequestOptions = (o) => isDefined(o) && o instanceof RequestOptions;
2104
+
2105
+ // src/http/Response.ts
2106
+ var isResponse = (r) => isA(r, "status", "body");
2107
+
2108
+ // src/http/RestResult.ts
2109
+ var hasErrors = (a) => isDefined(a?.error?.errors);
2110
+ var hasItems = (a) => isDefined(a?.data.items);
2111
+ var rest = {
2112
+ toData: (status, items = [], totalItems, meta2) => ({
2113
+ data: {
2114
+ code: status.status,
2115
+ items: toList(items),
2116
+ itemCount: items.length,
2117
+ totalItems,
2118
+ meta: meta2
2119
+ }
2120
+ }),
2121
+ toError: (status, errors = [toResult(status.name)]) => ({
2122
+ error: {
2123
+ code: status.status,
2124
+ message: status.name ?? errors[0].message ?? "Unknown",
2125
+ errors: toList(errors),
2126
+ errorCount: errors.length
2127
+ }
2128
+ }),
2129
+ to: (payload, status) => choose(payload).is.not.defined((p) => p, void 0).type(isHttpStatus, (h) => rest.toError(h ?? status ?? HttpStatus.InternalServerError, [toResult(h.name)])).type(isResult, (r) => rest.toError(status ?? HttpStatus.BadRequest, [r])).type(isError, (e) => rest.toError(status ?? HttpStatus.BadRequest, [e])).type(isResults, (r) => rest.toError(status ?? HttpStatus.BadRequest, r.results)).type(isResponse, (r) => rest.toError(status ?? HttpStatus.byId(r.body.error?.code), r.body.error?.errors)).type(hasErrors, (e) => rest.toError(status ?? HttpStatus.byId(e.error.code, HttpStatus.BadRequest), e.error.errors)).type(hasItems, (d) => rest.toData(status ?? HttpStatus.byId(d.data.code, HttpStatus.Ok), d.data.items, d.data.totalItems, d.data.meta)).else((p) => rest.toData(status ?? HttpStatus.Ok, toList(p)))
2130
+ };
2131
+ var isRestResult = (r) => isDefined(r) && (isDefined(r.data) || isDefined(r.error));
2132
+
2133
+ // src/http/toResponse.ts
2134
+ function toResponse(status, body, headers) {
2135
+ return {
2136
+ status: toHttpStatus(status),
2137
+ headers,
2138
+ body: rest.to(body)
2139
+ };
2140
+ }
2141
+
2142
+ // src/process/Scope.ts
2143
+ var Scope = class _Scope extends Enum {
2144
+ constructor(name, id = text(name).kebab, subs = toList()) {
2145
+ super(name, id.toString());
2146
+ this.name = name;
2147
+ this.subs = subs;
2148
+ }
2149
+ for(item) {
2150
+ return new _Scope(`${this.name} ${isString(item) ? text(item).title : item.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`));
2151
+ }
2152
+ combines(...scopes) {
2153
+ this.subs.add(scopes);
2154
+ return this;
2155
+ }
2156
+ expand() {
2157
+ return this.subs.flatMap((s) => s.expand()).add(this).distinct();
2158
+ }
2159
+ };
2160
+
2161
+ // src/process/App.ts
2162
+ var App = class _App extends Scope {
2163
+ constructor(name) {
2164
+ super(name);
2165
+ }
2166
+ static Main = new _App("Main");
2167
+ };
2168
+
2169
+ // src/process/Search.ts
2170
+ var Search = class {
2171
+ constructor(repo) {
2172
+ this.repo = repo;
2173
+ }
2174
+ all(options) {
2175
+ return this.repo.all(options);
2176
+ }
2177
+ byId(id) {
2178
+ return this.repo.byId(id);
2179
+ }
2180
+ byIds(...ids) {
2181
+ return this.repo.byIds(...ids);
2182
+ }
2183
+ byKey(key, options) {
2184
+ return this.repo.byKey(key, options);
2185
+ }
2186
+ query({ query, skip, take }) {
2187
+ return this.search(query, { skip, take });
2188
+ }
2189
+ search(query, options) {
2190
+ return choose(query).is.not.empty(
2191
+ (q) => q,
2192
+ (q) => this.repo.search(q, options)
2193
+ ).else(() => resolve(toPageList()));
2194
+ }
2195
+ filter(options) {
2196
+ return this.repo.filter(options);
2197
+ }
2198
+ exists(id) {
2199
+ return this.repo.exists(id);
2200
+ }
2201
+ };
2202
+
2203
+ // src/process/Manage.ts
2204
+ var Manage = class extends Search {
2205
+ add(json3) {
2206
+ return this.repo.add(json3);
2207
+ }
2208
+ update(id, json3) {
2209
+ return this.repo.update(id, json3);
2210
+ }
2211
+ upsert(id, json3) {
2212
+ return this.repo.upsert(id, json3);
2213
+ }
2214
+ remove(id) {
2215
+ return this.repo.remove(id);
2216
+ }
2217
+ };
2218
+
2219
+ // src/process/UseCase.ts
2220
+ var UseCase = class _UseCase extends Enum {
2221
+ constructor(app, name, id = text(name).kebab, scopes = toList()) {
2222
+ super(name, id.toString());
2223
+ this.app = app;
2224
+ this.scopes = scopes;
2225
+ }
2226
+ static byScopes(...s) {
2227
+ return this.filter((u) => u.scopes.some((us) => isIn(us, s)));
2228
+ }
2229
+ with(...s) {
2230
+ this.scopes.add(
2231
+ ...toList(s).flatMap((s2) => s2.expand()).distinct()
2232
+ );
2233
+ return this;
2234
+ }
2235
+ for(item) {
2236
+ return new _UseCase(this.app, `${this.name} ${isString(item) ? item : item?.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`)).with(
2237
+ ...this.scopes.map((s) => s?.for(item))
2238
+ );
2239
+ }
2240
+ };
2241
+
2242
+ // src/resources/Req.ts
2243
+ var Req = class {
2244
+ constructor(path = {}, query = {}, body, headers) {
2245
+ this.path = path;
2246
+ this.query = query;
2247
+ this.body = body;
2248
+ this.headers = headers;
2249
+ this.skip = ifDefined(query.skip, (s) => asNumber(s));
2250
+ this.take = ifDefined(query.take, (t) => asNumber(t));
2251
+ }
2252
+ skip;
2253
+ take;
2254
+ get id() {
2255
+ return this.get("id");
2256
+ }
2257
+ get q() {
2258
+ return this.get("q");
2259
+ }
2260
+ get = (key) => this.path[key.toString()] ?? this.query[key.toString()];
2261
+ };
2262
+ function toReq(req) {
2263
+ return new Req(req.params, req.query, req.body, req.headers);
2264
+ }
2265
+
2266
+ // ../../node_modules/jwt-decode/build/esm/index.js
2267
+ var InvalidTokenError = class extends Error {
2268
+ };
2269
+ InvalidTokenError.prototype.name = "InvalidTokenError";
2270
+ function b64DecodeUnicode(str) {
2271
+ return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
2272
+ let code = p.charCodeAt(0).toString(16).toUpperCase();
2273
+ if (code.length < 2) {
2274
+ code = "0" + code;
2275
+ }
2276
+ return "%" + code;
2277
+ }));
2278
+ }
2279
+ function base64UrlDecode(str) {
2280
+ let output = str.replace(/-/g, "+").replace(/_/g, "/");
2281
+ switch (output.length % 4) {
2282
+ case 0:
2283
+ break;
2284
+ case 2:
2285
+ output += "==";
2286
+ break;
2287
+ case 3:
2288
+ output += "=";
2289
+ break;
2290
+ default:
2291
+ throw new Error("base64 string is not of the correct length");
2292
+ }
2293
+ try {
2294
+ return b64DecodeUnicode(output);
2295
+ } catch (err) {
2296
+ return atob(output);
2297
+ }
2298
+ }
2299
+ function jwtDecode(token, options) {
2300
+ if (typeof token !== "string") {
2301
+ throw new InvalidTokenError("Invalid token specified: must be a string");
2302
+ }
2303
+ options || (options = {});
2304
+ const pos = options.header === true ? 0 : 1;
2305
+ const part = token.split(".")[pos];
2306
+ if (typeof part !== "string") {
2307
+ throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
2308
+ }
2309
+ let decoded;
2310
+ try {
2311
+ decoded = base64UrlDecode(part);
2312
+ } catch (e) {
2313
+ throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
2314
+ }
2315
+ try {
2316
+ return JSON.parse(decoded);
2317
+ } catch (e) {
2318
+ throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
2319
+ }
2320
+ }
2321
+
2322
+ // src/security/Jwt.ts
2323
+ var Jwt = class _Jwt extends Value {
2324
+ static of = (a) => new _Jwt(a.jwt);
2325
+ decode = () => jwtDecode(this.value);
2326
+ toJSON() {
2327
+ return { jwt: this.value };
2328
+ }
2329
+ };
2330
+
2331
+ // src/services/AxiosProvider.ts
2332
+ import axios from "axios";
2333
+ var isResponse2 = (a) => isDefined(a?.response);
2334
+ var isRequest = (a) => isDefined(a?.request);
2335
+ var asResponse = (uri2, verb, error) => choose(error).type(
2336
+ isResponse2,
2337
+ (r) => toResponse(r.response.status, isRestResult(r.response.data) ? r.response.data : toResult(r.response.statusText, uri2.path, uri2), r.response.headers)
2338
+ ).type(isRequest, (r) => toResponse(r.request.status, toResult(r.request.message, uri2.path, uri2))).else((e) => toResponse(HttpStatus.InternalServerError, toResult(e.message, uri2.path, uri2)));
2339
+ var AxiosProvider = class {
2340
+ constructor(ai = axios) {
2341
+ this.ai = ai;
2342
+ }
2343
+ execute = ({ uri: uri2, verb, body, transform = (r) => r, transformError = (r) => r, options = RequestOptions.Json }) => this.ai.request({
2344
+ url: uri2.toString(),
2345
+ method: verb.toString(),
2346
+ headers: uri2.isInternal && isEmpty(options.headers.Authorization) ? options.bearer(ctx.request.jwt).headers : options.headers,
2347
+ data: options.type.encode(body),
2348
+ maxRedirects: options.requestOptions.maxRedirects,
2349
+ ...options.requestOptions.timeout && { timeout: cacheAge.toMilliseconds(options?.requestOptions.timeout) },
2350
+ ...options.requestOptions.validateStatus && { validateStatus: options.requestOptions.validateStatus }
2351
+ }).then((r) => toResponse(r.status, transform(r.data), r.headers)).catch((e) => Promise.reject(asResponse(uri2, verb, transformError(e))));
2352
+ };
2353
+
2354
+ // src/services/Api.ts
2355
+ var Api = class {
2356
+ constructor(provider = new AxiosProvider(), store) {
2357
+ this.provider = provider;
2358
+ this.store = store;
2359
+ }
2360
+ get(uri2, options, transform, transformError = (r) => r) {
2361
+ return this.execute({
2362
+ uri: uri2.skip(toPageOptions(options)?.skip).take(toPageOptions(options)?.take),
2363
+ verb: HttpVerb.Get,
2364
+ transform,
2365
+ transformError,
2366
+ options: this.options(HttpVerb.Get, options)
2367
+ });
2368
+ }
2369
+ post(uri2, body, options = RequestOptions.Json, transform, transformError = (r) => r) {
2370
+ return this.execute({
2371
+ uri: uri2,
2372
+ verb: HttpVerb.Post,
2373
+ body,
2374
+ transform,
2375
+ transformError,
2376
+ options: this.options(HttpVerb.Post, options)
2377
+ });
2378
+ }
2379
+ put(uri2, body, options = RequestOptions.Json, transform, transformError = (r) => r) {
2380
+ return this.execute({
2381
+ uri: uri2,
2382
+ verb: HttpVerb.Put,
2383
+ body,
2384
+ transform,
2385
+ transformError,
2386
+ options: this.options(HttpVerb.Put, options)
2387
+ });
2388
+ }
2389
+ patch(uri2, body, options = RequestOptions.Json, transform, transformError = (r) => r) {
2390
+ return this.execute({
2391
+ uri: uri2,
2392
+ verb: HttpVerb.Patch,
2393
+ body,
2394
+ transform,
2395
+ transformError,
2396
+ options: this.options(HttpVerb.Patch, options)
2397
+ });
2398
+ }
2399
+ delete(uri2, options = RequestOptions.Json, transform, transformError = (r) => r) {
2400
+ return this.execute({
2401
+ uri: uri2,
2402
+ verb: HttpVerb.Delete,
2403
+ transform,
2404
+ transformError,
2405
+ options: this.options(HttpVerb.Delete, options)
2406
+ });
2407
+ }
2408
+ options(verb, options) {
2409
+ return options instanceof RequestOptions ? options : RequestOptions.Json;
2410
+ }
2411
+ execute(req) {
2412
+ return this.store ? this.store.execute(req, () => this.provider.execute(req)) : this.provider.execute(req);
2413
+ }
2414
+ };
2415
+ var api = new Api();
2416
+
2417
+ // src/services/ApiGateway.ts
2418
+ var ApiGateway = class extends Gateway {
2419
+ constructor(api2 = new Api()) {
2420
+ super();
2421
+ this.api = api2;
2422
+ }
2423
+ get(uri2, options) {
2424
+ return this.api.get(uri2, options).then((r) => use(r.body.data, (d) => toPageList(d?.items, { total: d?.totalItems, ...d?.meta })));
2425
+ }
2426
+ getOne(uri2, options) {
2427
+ return this.get(uri2, options).then((r) => r.first());
2428
+ }
2429
+ post(uri2, item, options) {
2430
+ return this.api.post(uri2, item, options).then((r) => r.body.data?.items.first() ?? {});
2431
+ }
2432
+ postSearch(uri2, options) {
2433
+ return this.api.post(uri2, options).then((r) => use(r.body.data, (d) => toPageList(d?.items, { total: d?.totalItems, ...d?.meta })));
2434
+ }
2435
+ patch(uri2, item, options) {
2436
+ return this.api.patch(uri2, item, options).then((r) => r.body.data?.items.first() ?? {});
2437
+ }
2438
+ put(uri2, item, options) {
2439
+ return this.api.put(uri2, item, options).then((r) => r.body.data?.items.first() ?? {});
2440
+ }
2441
+ delete(uri2, options) {
2442
+ return this.api.delete(uri2, options).then(() => true);
2443
+ }
2444
+ };
2445
+
2446
+ // src/services/RouteGateway.ts
2447
+ var RouteGateway = class extends ApiGateway {
2448
+ constructor(route, routeId, api2 = new Api()) {
2449
+ super(api2);
2450
+ this.route = route;
2451
+ this.routeId = routeId;
2452
+ this.api = api2;
2453
+ }
2454
+ all(options) {
2455
+ return this.get(this.route().expand(options ?? {}), options);
2456
+ }
2457
+ byId(id) {
2458
+ return this.getOne(this.routeId().id(id));
2459
+ }
2460
+ byIds(...ids) {
2461
+ return this.get(this.route().ids(toArray(...ids)));
2462
+ }
2463
+ search(q, options) {
2464
+ return this.get(this.route().expand({ ...options, q }));
2465
+ }
2466
+ exists(id) {
2467
+ return this.byId(id).then((r) => isDefined(r)).catch((r) => HttpStatus.NotFound.equals(r.status) ? false : Promise.reject(r));
2468
+ }
2469
+ add(item) {
2470
+ return this.post(this.route(), item);
2471
+ }
2472
+ filter(options) {
2473
+ return this.postSearch(this.route().expand(options ?? {}));
2474
+ }
2475
+ update(item) {
2476
+ return this.patch(this.routeId().id(item.id), item);
2477
+ }
2478
+ upsert(item) {
2479
+ return this.put(this.routeId().id(item.id), item);
2480
+ }
2481
+ remove(id) {
2482
+ return this.delete(this.routeId().id(id));
2483
+ }
2484
+ };
2485
+
2486
+ // src/utils/State.ts
2487
+ var State = class {
2488
+ constructor(state = {}) {
2489
+ this.state = state;
2490
+ }
2491
+ get = (key, alt) => this.state[key] ?? (this.state[key] = ofConstruct(alt));
2492
+ set = (key, value) => this.get(key, value);
2493
+ };
2494
+
2495
+ // src/utils/Mapper.ts
2496
+ var isMapping = (m) => isA(m, "in", "out");
2497
+ var Mapper = class extends State {
2498
+ constructor(options = { startFrom: "scratch" }, property = "") {
2499
+ super();
2500
+ this.options = options;
2501
+ this.property = property;
2502
+ }
2503
+ map = mappings;
2504
+ // All properties that are a mapping
2505
+ get properties() {
2506
+ return this.get(
2507
+ "props",
2508
+ () => meta(this).entries().filter(([, v]) => isMapping(v))
2509
+ );
2510
+ }
2511
+ // All names of properties (in target) that have a Mapping
2512
+ get keys() {
2513
+ return this.get("keys", () => this.properties.map(([k]) => k));
2514
+ }
2515
+ // All names of properties (in source) that are named in a Mapping
2516
+ get columns() {
2517
+ return this.get("columns", () => this.properties.mapDefined(([, p]) => ifNotEmpty(p.property, p.property))).distinct();
2518
+ }
2519
+ // All names of properties (in source) that are NOT properties in target
2520
+ get droppedIn() {
2521
+ return this.get("droppedIn", () => this.columns.filter((c) => !this.keys.some((k) => k === c)));
2522
+ }
2523
+ // All names op properties (in target) that are NOT properties in source
2524
+ get droppedOut() {
2525
+ return this.get("droppedOut", () => this.properties.filter(([, p]) => !this.keys.some((k) => k === p.property)).map(([k]) => k));
2526
+ }
2527
+ in(from = {}) {
2528
+ return json.omit(
2529
+ this.properties.reduce((a, [k, p]) => json.merge(a, { [k]: p.in({ ...a, ...from }) }), this.options.startFrom === "source" ? from : {}),
2530
+ ...this.droppedIn
2531
+ );
2532
+ }
2533
+ out(to = {}) {
2534
+ return json.omit(
2535
+ this.properties.reduce(
2536
+ (a, [k, p]) => json.merge(a, isEmpty(p.property) ? p.out(to, k) : { [p.property ?? ""]: p.out({ ...a, ...to }, k) }),
2537
+ this.options.startFrom === "source" ? to : {}
2538
+ ),
2539
+ ...this.droppedOut
2540
+ );
2541
+ }
2542
+ toString() {
2543
+ return this.constructor.name;
2544
+ }
2545
+ };
2546
+ var mappings = {
2547
+ item: (property, options) => new Property(property, options),
2548
+ ignore: (property = "") => ({
2549
+ property,
2550
+ in: () => void 0,
2551
+ out: () => void 0
2552
+ }),
2553
+ skipIn: (property) => ({
2554
+ property,
2555
+ in: () => void 0,
2556
+ out: (source = {}) => source[property]
2557
+ }),
2558
+ skipOut: (property) => ({
2559
+ property,
2560
+ in: (source = {}) => source[property],
2561
+ out: () => void 0
2562
+ }),
2563
+ func: (property, funcIn, funcOut) => ({
2564
+ property,
2565
+ in: (source = {}) => ofGet(funcIn, source),
2566
+ out: (source = {}) => ofGet(funcOut, source)
2567
+ }),
2568
+ add: (funcIn) => ({
2569
+ property: "",
2570
+ in: (source = {}) => ofGet(funcIn, source),
2571
+ out: () => void 0
2572
+ }),
2573
+ map: (mapper, property = "") => ({
2574
+ property,
2575
+ in: (source = {}) => ofConstruct(mapper).in(isEmpty(property) ? source : source[property]),
2576
+ out: (source = {}, key = "") => ofConstruct(mapper).out(isEmpty(key) ? source : source[key])
2577
+ }),
2578
+ propsToList: (...maps) => ({
2579
+ property: "",
2580
+ in: (source = {}) => toList(maps.map((m) => ofConstruct(m).in(source))).toJSON(),
2581
+ out: (source = {}, key = "") => maps.reduce((a, m, i) => {
2582
+ const res = toList(source[key])[i];
2583
+ const out = m.out(res);
2584
+ return { ...a, [m.property]: out ?? {} };
2585
+ }, {})
2586
+ }),
2587
+ list: (mapper, property) => ({
2588
+ property,
2589
+ in: (source = {}) => toList(source[property]).map((v) => mapper.in(v)).toJSON(),
2590
+ out: (source = {}, key = "") => toList(isEmpty(key) ? source : source[key]).map((v) => mapper.out(v)).toJSON()
2591
+ })
2592
+ };
2593
+
2594
+ // src/services/MappedRouteGateway.ts
2595
+ var MappedRouteGateway = class extends RouteGateway {
2596
+ constructor(route, routeId, map = new Mapper(), api2 = new Api()) {
2597
+ super(route, routeId, api2);
2598
+ this.route = route;
2599
+ this.routeId = routeId;
2600
+ this.map = map;
2601
+ this.api = api2;
2602
+ }
2603
+ get(uri2, options) {
2604
+ return super.get(uri2, options).then((is) => is.map((i) => this.map.in(i)));
2605
+ }
2606
+ getOne(uri2, options) {
2607
+ return super.get(uri2, options).then((is) => is.first()).then((i) => this.map.in(i));
2608
+ }
2609
+ add(item) {
2610
+ return super.add(this.map.out(item));
2611
+ }
2612
+ update(item) {
2613
+ return super.update(this.map.out(item));
2614
+ }
2615
+ };
2616
+
2617
+ // src/types/IsEqual.ts
2618
+ var isEqualArray = (one, another) => choose([one, another]).case(([o, a]) => !isArray(o) || !isArray(a), false).case(([o, a]) => o?.length !== a?.length, false).else(([o, a]) => !o.some((v, i) => !isEqual(v, a[i])));
2619
+ var isEqualObject = (one, another) => choose([Object.keys(one), Object.keys(another)]).case(([keysO, keysA]) => keysO.length !== keysA.length, false).case(([keysO, keysA]) => keysO.some((k) => !keysA.includes(k)), false).case(([keysO]) => keysO.some((k) => !isEqual(one[k], another[k])), false).else(true);
2620
+ var isEqual = (one, another) => choose([one, another]).case(([o, a]) => o === a, true).case(
2621
+ ([o, a]) => isArray(o) || isArray(a),
2622
+ ([o, a]) => isEqualArray(o, a)
2623
+ ).case(
2624
+ ([o, a]) => o == null || a == null || !isObject(o) && !isObject(a),
2625
+ ([o, a]) => o !== o && a !== a
2626
+ ).else(([o, a]) => isEqualObject(o, a));
2627
+
2628
+ // src/utils/View.ts
2629
+ var ignore = Symbol("view.ignore");
2630
+ var keep = Symbol("view.keep");
2631
+ var json2 = Symbol("view.json");
2632
+ var spread = "view.spread";
2633
+ var toViewer = (key, value) => choose(value).is.not.defined((v) => v, { key, f: () => void 0 }).type(isBoolean, (b) => ({ key, f: () => b })).equals(ignore, { key, f: () => void 0 }).equals(keep, { key, f: (a) => traverse(a, key) }).equals(json2, { key, f: (a) => asJson(traverse(a, key)) }).type(isString, (s) => ({ key, f: (a) => traverse(a, s) })).type(isEnumConstructor, (c) => ({
2634
+ key,
2635
+ f: (a, key2) => use(traverse(a, key2), (v) => isArray(v) ? c.byIds(v) : c.byId(v))
2636
+ })).type(isConstructor, (c) => ({
2637
+ key,
2638
+ f: (a, key2) => use(traverse(a, key2), (v) => isArray(v) ? v.map((i) => optional2(c, i)) : optional2(c, v))
2639
+ })).type(isSimpleView, (f) => ({ key, f: (a) => ifDefined(traverse(a, key), (v) => f.from(v)) })).type(isFunction, (f) => ({ key, f })).else((v) => ({ key, f: () => v }));
2640
+ var optional2 = (c, v) => ifDefined(
2641
+ v,
2642
+ (i) => new c(i),
2643
+ () => v
2644
+ );
2645
+ var toViewers = (views2) => meta(views2).entries().map(([k, v]) => toViewer(k, v));
2646
+ var View = class _View {
2647
+ constructor(views2 = {}, startsFrom = "scratch", viewers = toViewers(views2)) {
2648
+ this.views = views2;
2649
+ this.startsFrom = startsFrom;
2650
+ this.viewers = viewers;
2651
+ }
2652
+ get fromSource() {
2653
+ return new _View(this.views, "source", this.viewers);
2654
+ }
2655
+ from(source) {
2656
+ if (isPageList(source))
2657
+ return toPageList(
2658
+ source.map((s) => this.reduce(s)),
2659
+ source.options
2660
+ );
2661
+ if (isArray(source))
2662
+ return source.map((s) => this.reduce(s));
2663
+ return this.reduce(source);
2664
+ }
2665
+ same = (one, another) => isEqual(this.from(one), this.from(another));
2666
+ reduce = (source) => use(
2667
+ asJson(source),
2668
+ (src) => this.viewers.reduce(
2669
+ (acc, v) => v.key === spread ? { ...acc, ...asJson(v.f(src, v.key)) } : json.set(acc, v.key, v.f(src, v.key)),
2670
+ this.startsFrom === "scratch" ? {} : src
2671
+ )
2672
+ );
2673
+ };
2674
+ var isSimpleView = (a) => a instanceof View;
2675
+ var view = (views2) => new View(views2);
2676
+ var views = {
2677
+ ignore,
2678
+ keep,
2679
+ json: json2,
2680
+ spread,
2681
+ skip: ignore,
2682
+ value: (value) => () => value,
2683
+ or: {
2684
+ key: (altKey) => (a, key) => traverse(a, key) ?? traverse(a, altKey),
2685
+ value: (altValue) => (a, key) => traverse(a, key) ?? altValue,
2686
+ func: (altFunc) => (a, key) => traverse(a, key) ?? altFunc(a, key)
2687
+ }
2688
+ };
2689
+
2690
+ // src/services/ViewRouteGateway.ts
2691
+ var ViewRouteGateway = class extends RouteGateway {
2692
+ constructor(route, routeId, views2 = {
2693
+ in: view({}).fromSource,
2694
+ out: view({}).fromSource
2695
+ }, api2 = new Api()) {
2696
+ super(route, routeId, api2);
2697
+ this.route = route;
2698
+ this.routeId = routeId;
2699
+ this.views = views2;
2700
+ this.api = api2;
2701
+ }
2702
+ get(uri2, options) {
2703
+ return super.get(uri2, options).then((is) => is.map((i) => this.views.in.from(i)));
2704
+ }
2705
+ getOne(uri2, options) {
2706
+ return super.get(uri2, options).then((is) => is.first()).then((i) => this.views.in.from(i));
2707
+ }
2708
+ add(item) {
2709
+ return super.add(this.views.out.from(item));
2710
+ }
2711
+ update(item) {
2712
+ return super.update(this.views.out.from(item));
2713
+ }
2714
+ };
2715
+
2716
+ // src/sql/Clause.ts
2717
+ var quote = (a) => isNumber(a) || isBoolean(a) || isClause(a) ? a.toString() : `'${a}'`;
2718
+ var Clause = class {
2719
+ constructor(first, operator, second) {
2720
+ this.first = first;
2721
+ this.operator = operator;
2722
+ this.second = second;
2723
+ }
2724
+ and = (other) => new ParathesizedClause(this, "AND", other);
2725
+ or = (other) => new ParathesizedClause(this, "OR", other);
2726
+ toString() {
2727
+ return `${this.first} ${this.operator} ${quote(this.second)}`;
2728
+ }
2729
+ };
2730
+ var ParathesizedClause = class extends Clause {
2731
+ toString() {
2732
+ return `(${this.first} ${this.operator} ${quote(this.second)})`;
2733
+ }
2734
+ };
2735
+ var toClause = (first, operator, second, conv = convert.default) => new Clause(first, operator, conv.from(second));
2736
+ var isClause = (c) => isA(c, "and", "or");
2737
+
2738
+ // src/sql/Column.ts
2739
+ var Column = class extends Property {
2740
+ constructor(owner, property, options) {
2741
+ super(property, options);
2742
+ this.owner = owner;
2743
+ }
2744
+ get count() {
2745
+ return this.function("COUNT");
2746
+ }
2747
+ get max() {
2748
+ return this.function("MAX");
2749
+ }
2750
+ get min() {
2751
+ return this.function("MIN");
2752
+ }
2753
+ get sum() {
2754
+ return this.function("SUM");
2755
+ }
2756
+ get average() {
2757
+ return this.function("AVG");
2758
+ }
2759
+ get length() {
2760
+ return this.function("LEN");
2761
+ }
2762
+ get asc() {
2763
+ return this.format("$col ASC");
2764
+ }
2765
+ get desc() {
2766
+ return this.format("$col DESC");
2767
+ }
2768
+ in = (source = {}) => tryTo(source).map((s) => s[this.property] ?? ofGet(this.options?.dflt)).map((v) => this.options?.convert?.to(v)).orElse();
2769
+ out = (source = {}, key = "") => tryTo(source).map((s) => this.options?.convert?.from(s[key])).orElse();
2770
+ function = (func) => this.format(`${func}($name)`);
2771
+ format = (pattern) => new PatternColumn(this, pattern);
2772
+ is = (value) => this.clause("=", value);
2773
+ not = (value) => this.clause("<>", value);
2774
+ like = (value) => this.clause("LIKE", `%${value}%`);
2775
+ startsLike = (value) => this.clause("LIKE", `${value}%`);
2776
+ endsLike = (value) => this.clause("LIKE", `%${value}`);
2777
+ unlike = (value) => this.clause("NOT LIKE", `%${value}%`);
2778
+ less = (value) => this.clause("<", value);
2779
+ lessEqual = (value) => this.clause("<=", value);
2780
+ greater = (value) => this.clause(">", value);
2781
+ greaterEqual = (value) => this.clause(">=", value);
2782
+ as = (as) => this.format(`$col AS ${as}`);
2783
+ toString() {
2784
+ return `${this.owner}.${this.property}`;
2785
+ }
2786
+ clause = (operator, value) => toClause(this, operator, value, this?.options?.convert);
2787
+ };
2788
+ var PatternColumn = class extends Column {
2789
+ constructor(col, pattern) {
2790
+ super(col.owner, col.property);
2791
+ this.col = col;
2792
+ this.pattern = pattern;
2793
+ }
2794
+ toString() {
2795
+ return this.pattern.replace("$col", this.col.toString()).replace("$table", this.col.owner.toString).replace("$name", this.col.property);
2796
+ }
2797
+ };
2798
+ var OrderColumn = class extends PatternColumn {
2799
+ };
2800
+
2801
+ // src/sql/SqlQuery.ts
2802
+ var SqlQuery = class {
2803
+ constructor(table, clauses = toList()) {
2804
+ this.table = table;
2805
+ this.clauses = clauses;
2806
+ }
2807
+ where = (...clauses) => {
2808
+ this.clauses.add(clauses);
2809
+ return this;
2810
+ };
2811
+ };
2812
+
2813
+ // src/sql/Delete.ts
2814
+ var Delete = class extends SqlQuery {
2815
+ toString() {
2816
+ return `DELETE FROM ${this.table}` + ifGet(this.clauses.length, ` WHERE ${this.clauses.join(" AND ")};`, ";");
2817
+ }
2818
+ };
2819
+
2820
+ // src/sql/Insert.ts
2821
+ var Insert = class extends SqlQuery {
2822
+ constructor(table, fields) {
2823
+ super(table);
2824
+ this.table = table;
2825
+ this.fields = fields;
2826
+ }
2827
+ toString() {
2828
+ return `INSERT INTO ${this.table} (${Object.keys(this.fields).join(", ")}) OUTPUT INSERTED.* VALUES (${Object.values(this.fields).map((v) => quote(v)).join(", ")});`;
2829
+ }
2830
+ };
2831
+
2832
+ // src/sql/Join.ts
2833
+ var Join = class {
2834
+ constructor(first, second, c, c2) {
2835
+ this.first = first;
2836
+ this.second = second;
2837
+ this.c = c;
2838
+ this.c2 = c2;
2839
+ this.db = this.first.db;
2840
+ }
2841
+ db;
2842
+ on(c, c2) {
2843
+ this.c = c;
2844
+ this.c2 = c2;
2845
+ return this;
2846
+ }
2847
+ toString() {
2848
+ return `${this.first} JOIN ${this.second} ON ${this.c} = ${this.c2}`;
2849
+ }
2850
+ };
2851
+
2852
+ // src/sql/Select.ts
2853
+ var Select = class extends SqlQuery {
2854
+ constructor(table, columns = toList()) {
2855
+ super(table);
2856
+ this.columns = columns;
2857
+ }
2858
+ ordered = toList();
2859
+ grouped = toList();
2860
+ _top = 0;
2861
+ _limit = 0;
2862
+ _offset = 0;
2863
+ from(t) {
2864
+ this.table = t ?? this.table;
2865
+ return this;
2866
+ }
2867
+ orderBy = (...ordered) => {
2868
+ this.ordered.add(ordered);
2869
+ return this;
2870
+ };
2871
+ groupBy(...grouped) {
2872
+ this.grouped.add(grouped);
2873
+ return this;
2874
+ }
2875
+ top(t) {
2876
+ this._top = t;
2877
+ return this;
2878
+ }
2879
+ limit(l) {
2880
+ this._limit = l;
2881
+ return this;
2882
+ }
2883
+ offset(o) {
2884
+ this._offset = o;
2885
+ return this;
2886
+ }
2887
+ toString() {
2888
+ return `SELECT ` + ifGet(this._top, `TOP ${this._top} `, "") + ifGet(this.columns.length, this.columns.join(", "), "*") + ` FROM ${this.table}` + ifGet(this.clauses.length, ` WHERE ${this.clauses.join(" AND ")}`, "") + ifGet(this.grouped.length, ` GROUP BY ${this.grouped.join(", ")}`, "") + ifGet(this.ordered.length, ` ORDERED BY ${this.ordered.join(", ")}`, "") + ifGet(this._limit, ` LIMIT ${this._limit}`, "") + ifGet(this._offset, ` OFFSET ${this._offset};`, ";");
2889
+ }
2890
+ };
2891
+
2892
+ // src/sql/Update.ts
2893
+ var Update = class extends SqlQuery {
2894
+ constructor(table, fields) {
2895
+ super(table);
2896
+ this.table = table;
2897
+ this.fields = fields;
2898
+ }
2899
+ toString() {
2900
+ return `UPDATE ${this.table} SET ${Object.entries(this.fields).map(([k, v]) => toClause(k, "=", v)).join(", ")} OUTPUT INSERTED.*` + ifGet(this.clauses.length, ` WHERE ${this.clauses.join(" AND ")};`, ";");
2901
+ }
2902
+ };
2903
+
2904
+ // src/sql/Count.ts
2905
+ var Count = class extends Select {
2906
+ toString() {
2907
+ return `SELECT COUNT(*)` + ifGet(this._top, ` TOP ${this._top}`, "") + ` FROM ${this.table}` + ifGet(this.clauses.length, ` WHERE ${this.clauses.join(" AND ")}`, "") + ifGet(this.grouped.length, ` GROUP BY ${this.grouped.join(", ")}`, "") + ";";
2908
+ }
2909
+ };
2910
+
2911
+ // src/sql/Table.ts
2912
+ var Table = class extends Mapper {
2913
+ map = {
2914
+ ...mappings,
2915
+ column: (name, options) => new Column(this, name, options)
2916
+ };
2917
+ id = this.map.column("", { dflt: toUuid });
2918
+ constructor(options = { startFrom: "source" }) {
2919
+ super(options);
2920
+ }
2921
+ get db() {
2922
+ return Database.Default;
2923
+ }
2924
+ get count() {
2925
+ return new Count(this);
2926
+ }
2927
+ /**
2928
+ * @deprecated Deprecated since version 6.2. Please use map.column instead.
2929
+ */
2930
+ prop = (name, options) => this.map.column(name, options);
2931
+ select = (...columns) => new Select(this, toList(columns));
2932
+ insert = (fields) => new Insert(this, this.out(fields));
2933
+ update = (fields) => new Update(this, this.out(fields));
2934
+ delete = () => new Delete(this, toList());
2935
+ join = (t) => new Join(this, t);
2936
+ };
2937
+
2938
+ // src/sql/TableGateway.ts
2939
+ var TableGateway = class extends Gateway {
2940
+ constructor(table, provider = table.db.provide()) {
2941
+ super();
2942
+ this.table = table;
2943
+ this.provider = provider;
2944
+ }
2945
+ provide = ({ provider } = {}) => provider ?? this.provider;
2946
+ all(options) {
2947
+ return this.provide(options).query(this.table.select()).then(
2948
+ (js) => toPageList(
2949
+ js.map((j) => this.table.in(j)),
2950
+ options
2951
+ )
2952
+ );
2953
+ }
2954
+ byId(id, options) {
2955
+ return this.provide(options).query(this.table.select().where(this.table.id.is(id))).then((js) => js.first()).then((j) => ifDefined(j, this.table.in(j)));
2956
+ }
2957
+ exists(id, options) {
2958
+ return this.byId(id).then((j) => isDefined(j));
2959
+ }
2960
+ add(item, options) {
2961
+ return this.provide(options).query(this.table.insert(item)).then((js) => when(js.first()).not.isDefined.reject(`Could not add items with id ${item.id}`)).then((j) => this.table.in(j));
2962
+ }
2963
+ remove(id, options) {
2964
+ return this.provide(options).command(this.table.delete().where(this.table.id.is(id))).then(() => true);
2965
+ }
2966
+ update(item, options) {
2967
+ return this.provide(options).query(this.table.update(item).where(this.table.id.is(item.id))).then((js) => when(js.first()).not.isDefined.reject(`Could not update item with id ${item.id}`)).then((j) => this.table.in(j));
2968
+ }
2969
+ };
2970
+
2971
+ // src/types/Builder.ts
2972
+ var builder = class _builder {
2973
+ static state = {};
2974
+ static singleton = (ctr, ...args) => _builder.state[asString(ctr)] ?? (_builder.state[asString(ctr)] = new ctr(...args));
2975
+ static reset = () => {
2976
+ _builder.state = {};
2977
+ };
2978
+ };
2979
+ var build = {
2980
+ singleton: (ctr, ...args) => builder.singleton(ctr, ...args),
2981
+ reset: () => builder.reset()
2982
+ };
2983
+ var singleton = (ctr, ...args) => build.singleton(ctr, ...args);
2984
+
2985
+ // src/types/Cache.ts
2986
+ var toCacheOptions = (co) => ({
2987
+ expiresIn: co.expiresIn ?? "5m",
2988
+ store: co.store
2989
+ });
2990
+ var cache = (options) => (subject) => {
2991
+ meta(subject).set("cache", toCacheOptions(options));
2992
+ };
2993
+
2994
+ // src/types/Currency.ts
2995
+ var isCurrency = (c) => isA(c, "id", "name", "digits", "code");
2996
+
2997
+ // src/types/Environment.ts
2998
+ var Environment = class _Environment extends Enum {
2999
+ static Dev = new _Environment("Development", "dev");
3000
+ static Tst = new _Environment("Test", "tst");
3001
+ static Acc = new _Environment("Acceptance", "acc");
3002
+ static Prd = new _Environment("Production", "prd");
3003
+ };
3004
+
3005
+ // src/types/Falsy.ts
3006
+ var isFalsy = (v) => !v;
3007
+ var isTruthy = (v) => !isFalsy(v);
3008
+
3009
+ // src/types/Indexed.ts
3010
+ var isIndexed = (u) => isA(u, "index");
3011
+
3012
+ // src/types/Message.ts
3013
+ var ofMessage = (g, ...params) => isFunc(g) ? g(...params) : g;
3014
+
3015
+ // src/types/Nullish.ts
3016
+ var isNullish = (v) => v == null;
3017
+
3018
+ // src/types/Parser.ts
3019
+ var Parser = class {
3020
+ constructor(value, valid2 = true) {
3021
+ this.value = value;
3022
+ this.valid = valid2;
3023
+ }
3024
+ if = {
3025
+ equals: (pred) => this.evaluate(isTrue, pred),
3026
+ empty: (pred) => this.evaluate(isEmpty, pred),
3027
+ defined: (pred) => this.evaluate(isDefined, pred),
3028
+ valid: (pred) => this.evaluate(isValid, pred),
3029
+ in: (...items) => this.evaluate(() => isIn(this.value, toArray(...items))),
3030
+ is: {
3031
+ object: (pred) => this.evaluate(isObject, pred),
3032
+ string: (pred) => this.evaluate(isString, pred),
3033
+ instance: (c, pred) => this.evaluate(() => this.value instanceof c, pred)
3034
+ },
3035
+ not: {
3036
+ empty: (pred) => this.evaluateNot(isEmpty, pred),
3037
+ defined: (pred) => this.evaluateNot(isDefined, pred),
3038
+ valid: (pred) => this.evaluateNot(isValid, pred),
3039
+ isObject: (pred) => this.evaluateNot(isObject, pred),
3040
+ in: (...items) => this.evaluate(() => !isIn(this.value, toArray(...items))),
3041
+ is: {
3042
+ object: (pred) => this.evaluateNot(isObject, pred),
3043
+ string: (pred) => this.evaluateNot(isString, pred),
3044
+ instance: (c, pred) => this.evaluate(() => !(this.value instanceof c), pred)
3045
+ }
3046
+ }
3047
+ };
3048
+ evaluate(meta2, pred) {
3049
+ return on(this, (t) => t.valid = ofGet(meta2, pred ? ofGet(pred, this.value) : this.value));
3050
+ }
3051
+ evaluateNot(meta2, pred) {
3052
+ return on(this, (t) => t.valid = !ofGet(meta2, pred ? ofGet(pred, this.value) : this.value));
3053
+ }
3054
+ };
3055
+
3056
+ // src/types/Sort.ts
3057
+ var asc = 1;
3058
+ var desc = -1;
3059
+
3060
+ // src/types/Tag.ts
3061
+ var tag = (name) => (subject, property) => {
3062
+ meta(subject).property(property).set(name, property);
3063
+ };
3064
+ var searchable = () => tag(searchable.name);
3065
+
3066
+ // src/types/Uri.ts
3067
+ var toSegment = (key, {
3068
+ segment,
3069
+ query
3070
+ } = {}) => ({
3071
+ key,
3072
+ segment,
3073
+ query,
3074
+ toString: () => asString(key)
3075
+ });
3076
+ var uri = {
3077
+ host: (key) => toSegment(key, { segment: key ?? ctx.env.host ?? "$host" }),
3078
+ resource: (resource) => toSegment(toName(resource, "Uri"), { segment: toName(resource, "Uri") }),
3079
+ segment: (key) => toSegment(key, { segment: key }),
3080
+ path: (key) => toSegment(key, { segment: `:${key}` }),
3081
+ query: (key) => toSegment(key, {
3082
+ query: (value) => tryTo(value).is.defined().map((v) => encodeURIComponent(asString(v))).map((v) => `${key}=${v}`).orElse("") ?? ""
3083
+ }),
3084
+ boolean: (key) => toSegment(key, { query: (value) => isTrue(value) ? `${key}` : "" })
3085
+ };
3086
+ var toRoute = (...segments) => toList(segments).mapDefined((s) => s.segment).join("/");
3087
+ var EasyUri = class _EasyUri {
3088
+ constructor(segments = []) {
3089
+ this.segments = segments;
3090
+ }
3091
+ static id = uri.path("id");
3092
+ static ids = uri.query("ids");
3093
+ static query = uri.query("q");
3094
+ static sort = uri.query("s");
3095
+ static skip = uri.query("skip");
3096
+ static take = uri.query("take");
3097
+ host = uri.host();
3098
+ resource = uri.resource(this);
3099
+ state = {};
3100
+ get path() {
3101
+ return toRoute(uri.segment(""), this.resource, ...this.segments);
3102
+ }
3103
+ get complete() {
3104
+ return toRoute(this.host, this.resource, ...this.segments);
3105
+ }
3106
+ get isInternal() {
3107
+ return toRoute(this.host) === (ctx.env.host ?? "$host");
3108
+ }
3109
+ get props() {
3110
+ return meta(this.state).values();
3111
+ }
3112
+ route = (resource = this.resource.key) => toRoute(uri.segment(""), uri.segment(resource?.toLowerCase()), ...this.segments);
3113
+ set = (segment, value) => {
3114
+ tryTo(value).is.defined().accept((value2) => this.state[segment.key ?? ""] = { segment, value: value2 });
3115
+ return this;
3116
+ };
3117
+ toString() {
3118
+ return tryTo(() => this.props).map((ps) => ps.filter((p) => p.segment?.segment)).map((ps) => ps.reduce((r, p) => r.replace(asString(p.segment.segment), asString(p.value)), this.complete)).map((route) => ({
3119
+ route,
3120
+ query: this.props.mapDefined((p) => p.segment?.query ? p.segment?.query(p.value) : void 0)?.join("&")
3121
+ })).map(({ route, query }) => isNotEmpty(query) ? `${route}?${query}` : route).value;
3122
+ }
3123
+ id = (id) => this.set(_EasyUri.id, id);
3124
+ ids = (ids) => this.set(_EasyUri.ids, toArray(ids).join(","));
3125
+ query = (q) => this.set(_EasyUri.query, q);
3126
+ sort = (s) => this.set(_EasyUri.sort, asString(s));
3127
+ skip = (index) => this.set(_EasyUri.skip, index);
3128
+ take = (items) => this.set(_EasyUri.take, items);
3129
+ expand(props) {
3130
+ return entries(props).filter(([_, v]) => isNotEmpty(v)).reduce((u, [k, v]) => isBoolean(v) ? u.set(uri.boolean(k), v) : u.set(uri.query(k), toArray(v).join(",")), this);
3131
+ }
3132
+ };
3133
+ var clipUri = (uri2) => tryTo(() => asString(uri2)).map((uri3) => uri3.replace(/^(https?:\/\/)?(www\.)?/, "")).map((uri3) => uri3.replace(/\/$/, "")).value;
3134
+
3135
+ // src/utils/Base64.ts
3136
+ var base64 = {
3137
+ decode: (data) => Buffer.from(data, "base64").toString("utf-8"),
3138
+ encode: (data) => Buffer.from(data, "utf-8").toString("base64"),
3139
+ toJson: (data) => JSON.parse(base64.decode(data))
3140
+ };
3141
+
3142
+ // src/utils/Loading.ts
3143
+ var isLoading = (...targets) => isNotPresent(...targets);
3144
+
3145
+ // src/utils/Log.ts
3146
+ function log(labelOrT, t) {
3147
+ if (t) {
3148
+ console.log(labelOrT, t);
3149
+ return t;
3150
+ } else {
3151
+ console.log(labelOrT);
3152
+ return labelOrT;
3153
+ }
3154
+ }
3155
+ function dir(t) {
3156
+ console.dir(t, { depth: 200 });
3157
+ return t;
3158
+ }
3159
+
3160
+ // src/utils/Sentence.ts
3161
+ var Sentence = class {
3162
+ constructor(word, pre, sentence = (pre?.sentence ?? []).concat(word)) {
3163
+ this.sentence = sentence;
3164
+ }
3165
+ toString() {
3166
+ return text(this.sentence.join(" ")).sentence.toString();
3167
+ }
3168
+ };
3169
+ var Topic = class extends Sentence {
3170
+ it = new Sentence("it", this);
3171
+ anything = new Sentence("anything", this);
3172
+ id = (id) => new Sentence(`id '${id}'`, this);
3173
+ your = (subject) => new Sentence(`your ${subject ?? "item"}`, this);
3174
+ a = (subject) => new Sentence(subject ? `a ${subject}` : "an item", this);
3175
+ an = (subject) => new Sentence(`an ${subject ?? "item"}`, this);
3176
+ any = (subjects) => new Sentence(`any ${subjects ?? "items"}`, this);
3177
+ };
3178
+ var Verb = class extends Sentence {
3179
+ add = new Topic("add", this);
3180
+ check = new Topic("check", this);
3181
+ fetch = new Topic("fetch", this);
3182
+ find = new Topic("find", this);
3183
+ like = new Topic("like", this);
3184
+ process = new Topic("process", this);
3185
+ remove = new Topic("remove", this);
3186
+ translate = new Topic("translate", this);
3187
+ update = new Topic("update", this);
3188
+ validate = new Topic("validate", this);
3189
+ };
3190
+ var Not = class extends Verb {
3191
+ };
3192
+ var SupportVerb = class extends Verb {
3193
+ not = new Not("not", this);
3194
+ };
3195
+ var We = class extends Sentence {
3196
+ could = new SupportVerb("could", this);
3197
+ did = new SupportVerb("did", this);
3198
+ added = new Topic("added", this);
3199
+ checked = new Topic("checked", this);
3200
+ fetched = new Topic("fetched", this);
3201
+ found = new Topic("found", this);
3202
+ liked = new Topic("liked", this);
3203
+ processed = new Topic("processed", this);
3204
+ removed = new Topic("removed", this);
3205
+ translated = new Topic("translated", this);
3206
+ updated = new Topic("updated", this);
3207
+ validated = new Topic("validated", this);
3208
+ };
3209
+ var we = new We("we");
3210
+
3211
+ // src/utils/Wait.ts
3212
+ var Wait = class {
3213
+ static wait(ms = 0) {
3214
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
3215
+ }
3216
+ static seconds(s = 0) {
3217
+ return this.wait(s * 1e3);
3218
+ }
3219
+ };
3220
+ var wait = (millis) => Wait.wait(millis);
3221
+ export {
3222
+ Agent,
3223
+ Api,
3224
+ ApiGateway,
3225
+ App,
3226
+ Audit,
3227
+ AxiosProvider,
3228
+ BaseContext,
3229
+ BaseRequestContext,
3230
+ CacheControl,
3231
+ Child,
3232
+ Clause,
3233
+ Column,
3234
+ Condition,
3235
+ ContentType,
3236
+ Context,
3237
+ Convert,
3238
+ Database,
3239
+ DateTime,
3240
+ DefaultProvider,
3241
+ Delete,
3242
+ DotEnvContext,
3243
+ EasyUri,
3244
+ Entity,
3245
+ Enum,
3246
+ Environment,
3247
+ Exception,
3248
+ Field,
3249
+ Gateway,
3250
+ HttpHeader,
3251
+ HttpStatus,
3252
+ HttpVerb,
3253
+ InMemoryGateway,
3254
+ Insert,
3255
+ Join,
3256
+ Jwt,
3257
+ List,
3258
+ LogicalCondition,
3259
+ Manage,
3260
+ MappedRouteGateway,
3261
+ Mapper,
3262
+ OrderColumn,
3263
+ PageList,
3264
+ ParathesizedClause,
3265
+ Parser,
3266
+ PatternColumn,
3267
+ Property,
3268
+ Repo,
3269
+ Repository,
3270
+ Req,
3271
+ RequestOptions,
3272
+ Results,
3273
+ RouteGateway,
3274
+ Scope,
3275
+ Search,
3276
+ Select,
3277
+ Sentence,
3278
+ SortCondition,
3279
+ SqlQuery,
3280
+ State,
3281
+ Struct,
3282
+ Table,
3283
+ TableGateway,
3284
+ Template,
3285
+ ToText,
3286
+ Try,
3287
+ Typo,
3288
+ Update,
3289
+ UseCase,
3290
+ Value,
3291
+ View,
3292
+ ViewRouteGateway,
3293
+ Wait,
3294
+ When,
3295
+ accumulate,
3296
+ any,
3297
+ api,
3298
+ array,
3299
+ asJson,
3300
+ asList,
3301
+ asNumber,
3302
+ asPageList,
3303
+ asResults,
3304
+ asString,
3305
+ asc,
3306
+ base64,
3307
+ build,
3308
+ cache,
3309
+ cacheAge,
3310
+ capitalize,
3311
+ choose,
3312
+ clipUri,
3313
+ constraint,
3314
+ convert,
3315
+ ctx,
3316
+ days,
3317
+ defined,
3318
+ desc,
3319
+ dir,
3320
+ dt,
3321
+ entries,
3322
+ extractKeys,
3323
+ future,
3324
+ gt,
3325
+ gte,
3326
+ ifA,
3327
+ ifDefined,
3328
+ ifEither,
3329
+ ifFalse,
3330
+ ifGet,
3331
+ ifNotEmpty,
3332
+ ifTrue,
3333
+ inFuture,
3334
+ inList,
3335
+ inOptionalList,
3336
+ inPast,
3337
+ includes,
3338
+ includesUuid,
3339
+ isA,
3340
+ isAn,
3341
+ isArray,
3342
+ isBoolean,
3343
+ isCacheAge,
3344
+ isClause,
3345
+ isConstructor,
3346
+ isCurrency,
3347
+ isDate,
3348
+ isDateTime,
3349
+ isDefined,
3350
+ isDoesNotExist,
3351
+ isEmpty,
3352
+ isEmptyObject,
3353
+ isEnum,
3354
+ isEnumConstructor,
3355
+ isEqual,
3356
+ isError,
3357
+ isException,
3358
+ isFalsy,
3359
+ isField,
3360
+ isFunc,
3361
+ isFunction,
3362
+ isHttpStatus,
3363
+ isIdentity,
3364
+ isIn,
3365
+ isIndexed,
3366
+ isInstance,
3367
+ isIntersecting,
3368
+ isIsoDateString,
3369
+ isJson,
3370
+ isList,
3371
+ isLoading,
3372
+ isMapping,
3373
+ isNotEmpty,
3374
+ isNotPresent,
3375
+ isNullish,
3376
+ isNumber,
3377
+ isObject,
3378
+ isPageList,
3379
+ isPresent,
3380
+ isPrimitive,
3381
+ isRequestOptions,
3382
+ isResponse,
3383
+ isRestResult,
3384
+ isResult,
3385
+ isResults,
3386
+ isSimpleView,
3387
+ isSortCondition,
3388
+ isString,
3389
+ isStruct,
3390
+ isText,
3391
+ isTrue,
3392
+ isTruthy,
3393
+ isUndefined,
3394
+ isUuid,
3395
+ isValid,
3396
+ isValidatable,
3397
+ isValue,
3398
+ json,
3399
+ kebab,
3400
+ keys,
3401
+ log,
3402
+ lt,
3403
+ lte,
3404
+ mappings,
3405
+ maxLength,
3406
+ maxValue,
3407
+ meta,
3408
+ minLength,
3409
+ minValue,
3410
+ notEmpty,
3411
+ ofConstruct,
3412
+ ofGet,
3413
+ ofMessage,
3414
+ ofProperty,
3415
+ on,
3416
+ optional,
3417
+ past,
3418
+ quote,
3419
+ reject,
3420
+ replaceAll,
3421
+ required,
3422
+ resolve,
3423
+ rest,
3424
+ rule,
3425
+ searchable,
3426
+ seconds,
3427
+ settled,
3428
+ singleton,
3429
+ tag,
3430
+ takeFirstKey,
3431
+ template,
3432
+ text,
3433
+ textValue,
3434
+ toArray,
3435
+ toCacheOptions,
3436
+ toClause,
3437
+ toCondition,
3438
+ toFilter,
3439
+ toHttpStatus,
3440
+ toId,
3441
+ toJson,
3442
+ toList,
3443
+ toName,
3444
+ toObject,
3445
+ toPageList,
3446
+ toPageOptions,
3447
+ toReq,
3448
+ toResponse,
3449
+ toResult,
3450
+ toResults,
3451
+ toSegment,
3452
+ toShortFilter,
3453
+ toUuid,
3454
+ toViewer,
3455
+ toWords,
3456
+ traverse,
3457
+ traverseSet,
3458
+ tryTo,
3459
+ tuple,
3460
+ tuple2,
3461
+ tuple3,
3462
+ tuple4,
3463
+ tuple5,
3464
+ tupleO,
3465
+ uri,
3466
+ use,
3467
+ valid,
3468
+ validate,
3469
+ validateReject,
3470
+ values,
3471
+ view,
3472
+ views,
3473
+ wait,
3474
+ we,
3475
+ when
3476
+ };
116
3477
  //# sourceMappingURL=index.mjs.map