@effect-app/infra 4.0.0-beta.3 → 4.0.0-beta.300

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 (474) hide show
  1. package/CHANGELOG.md +2485 -0
  2. package/_check.sh +1 -1
  3. package/dist/CUPS.d.ts +29 -10
  4. package/dist/CUPS.d.ts.map +1 -1
  5. package/dist/CUPS.js +35 -14
  6. package/dist/ClusterCosmos.d.ts +64 -0
  7. package/dist/ClusterCosmos.d.ts.map +1 -0
  8. package/dist/ClusterCosmos.js +547 -0
  9. package/dist/ClusterServiceBus.d.ts +67 -0
  10. package/dist/ClusterServiceBus.d.ts.map +1 -0
  11. package/dist/ClusterServiceBus.js +82 -0
  12. package/dist/ContextProvider.d.ts +34 -0
  13. package/dist/ContextProvider.d.ts.map +1 -0
  14. package/dist/ContextProvider.js +40 -0
  15. package/dist/Emailer/Sendgrid.d.ts +110 -146
  16. package/dist/Emailer/Sendgrid.d.ts.map +1 -1
  17. package/dist/Emailer/Sendgrid.js +24 -19
  18. package/dist/Emailer/fake.d.ts +1 -1
  19. package/dist/Emailer/fake.d.ts.map +1 -1
  20. package/dist/Emailer/fake.js +4 -4
  21. package/dist/MainFiberSet.d.ts +12 -8
  22. package/dist/MainFiberSet.d.ts.map +1 -1
  23. package/dist/MainFiberSet.js +23 -7
  24. package/dist/QueueMaker/errors.d.ts +4 -2
  25. package/dist/QueueMaker/errors.d.ts.map +1 -1
  26. package/dist/QueueMaker/errors.js +4 -2
  27. package/dist/{adapters/SQL → SQL}/Model.d.ts +33 -47
  28. package/dist/SQL/Model.d.ts.map +1 -0
  29. package/dist/SQL/Model.js +469 -0
  30. package/dist/SQL.d.ts.map +1 -0
  31. package/dist/{adapters/SQL.js → SQL.js} +1 -1
  32. package/dist/Store/Cosmos/query.d.ts +14 -3
  33. package/dist/Store/Cosmos/query.d.ts.map +1 -1
  34. package/dist/Store/Cosmos/query.js +179 -41
  35. package/dist/Store/Cosmos.d.ts +2 -2
  36. package/dist/Store/Cosmos.d.ts.map +1 -1
  37. package/dist/Store/Cosmos.js +385 -254
  38. package/dist/Store/Disk.d.ts +4 -4
  39. package/dist/Store/Disk.d.ts.map +1 -1
  40. package/dist/Store/Disk.js +79 -39
  41. package/dist/Store/Memory.d.ts +5 -9
  42. package/dist/Store/Memory.d.ts.map +1 -1
  43. package/dist/Store/Memory.js +324 -67
  44. package/dist/Store/SQL/Pg.d.ts +4 -0
  45. package/dist/Store/SQL/Pg.d.ts.map +1 -0
  46. package/dist/Store/SQL/Pg.js +232 -0
  47. package/dist/Store/SQL/query.d.ts +49 -0
  48. package/dist/Store/SQL/query.d.ts.map +1 -0
  49. package/dist/Store/SQL/query.js +527 -0
  50. package/dist/Store/SQL.d.ts +21 -0
  51. package/dist/Store/SQL.d.ts.map +1 -0
  52. package/dist/Store/SQL.js +456 -0
  53. package/dist/Store/codeFilter.d.ts +4 -4
  54. package/dist/Store/codeFilter.d.ts.map +1 -1
  55. package/dist/Store/codeFilter.js +6 -4
  56. package/dist/Store/index.d.ts +6 -4
  57. package/dist/Store/index.d.ts.map +1 -1
  58. package/dist/Store/index.js +18 -5
  59. package/dist/Store/utils.d.ts +5 -2
  60. package/dist/Store/utils.d.ts.map +1 -1
  61. package/dist/Store/utils.js +9 -5
  62. package/dist/WorkflowEngineCosmos.d.ts +29 -0
  63. package/dist/WorkflowEngineCosmos.d.ts.map +1 -0
  64. package/dist/WorkflowEngineCosmos.js +542 -0
  65. package/dist/WorkflowEngineSqlite.d.ts +24 -0
  66. package/dist/WorkflowEngineSqlite.d.ts.map +1 -0
  67. package/dist/WorkflowEngineSqlite.js +550 -0
  68. package/dist/arbs.d.ts +1 -1
  69. package/dist/arbs.d.ts.map +1 -1
  70. package/dist/arbs.js +5 -3
  71. package/dist/codec.d.ts.map +1 -0
  72. package/dist/codec.js +5 -0
  73. package/dist/{adapters/cosmos-client.d.ts → cosmos-client.d.ts} +4 -2
  74. package/dist/cosmos-client.d.ts.map +1 -0
  75. package/dist/cosmos-client.js +11 -0
  76. package/dist/errorReporter.d.ts +6 -4
  77. package/dist/errorReporter.d.ts.map +1 -1
  78. package/dist/errorReporter.js +23 -27
  79. package/dist/fileUtil.d.ts +1 -1
  80. package/dist/fileUtil.d.ts.map +1 -1
  81. package/dist/fileUtil.js +4 -3
  82. package/dist/index.d.ts +2 -1
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +3 -2
  85. package/dist/internal/RequestContextMiddleware.d.ts +5 -0
  86. package/dist/internal/RequestContextMiddleware.d.ts.map +1 -0
  87. package/dist/internal/RequestContextMiddleware.js +45 -0
  88. package/dist/internal/auth.d.ts +53 -0
  89. package/dist/internal/auth.d.ts.map +1 -0
  90. package/dist/internal/auth.js +180 -0
  91. package/dist/internal/events.d.ts +11 -0
  92. package/dist/internal/events.d.ts.map +1 -0
  93. package/dist/internal/events.js +49 -0
  94. package/dist/internal/health.d.ts.map +1 -0
  95. package/dist/internal/health.js +5 -0
  96. package/dist/{api/layerUtils.d.ts → layerUtils.d.ts} +14 -6
  97. package/dist/layerUtils.d.ts.map +1 -0
  98. package/dist/layerUtils.js +17 -0
  99. package/dist/logger/jsonLogger.d.ts +1 -1
  100. package/dist/logger/jsonLogger.d.ts.map +1 -1
  101. package/dist/logger/jsonLogger.js +5 -3
  102. package/dist/logger/logFmtLogger.d.ts +1 -1
  103. package/dist/logger/logFmtLogger.d.ts.map +1 -1
  104. package/dist/logger/logFmtLogger.js +3 -3
  105. package/dist/logger/shared.d.ts +2 -2
  106. package/dist/logger/shared.d.ts.map +1 -1
  107. package/dist/logger/shared.js +5 -5
  108. package/dist/logger.d.ts +4 -4
  109. package/dist/logger.d.ts.map +1 -1
  110. package/dist/middlewares.d.ts.map +1 -0
  111. package/dist/{api/middlewares.js → middlewares.js} +1 -1
  112. package/dist/{adapters/mongo-client.d.ts → mongo-client.d.ts} +3 -2
  113. package/dist/mongo-client.d.ts.map +1 -0
  114. package/dist/mongo-client.js +15 -0
  115. package/dist/otel.d.ts +75 -0
  116. package/dist/otel.d.ts.map +1 -0
  117. package/dist/otel.js +65 -0
  118. package/dist/rateLimit.d.ts +11 -3
  119. package/dist/rateLimit.d.ts.map +1 -1
  120. package/dist/rateLimit.js +7 -12
  121. package/dist/{adapters/redis-client.d.ts → redis-client.d.ts} +6 -3
  122. package/dist/redis-client.d.ts.map +1 -0
  123. package/dist/redis-client.js +98 -0
  124. package/dist/{api/reportError.d.ts → reportError.d.ts} +1 -1
  125. package/dist/reportError.d.ts.map +1 -0
  126. package/dist/reportError.js +28 -0
  127. package/dist/{api/routing → routing}/middleware/RouterMiddleware.d.ts +4 -3
  128. package/dist/routing/middleware/RouterMiddleware.d.ts.map +1 -0
  129. package/dist/{api/routing → routing}/middleware/RouterMiddleware.js +1 -1
  130. package/dist/routing/middleware/middleware.d.ts +48 -0
  131. package/dist/routing/middleware/middleware.d.ts.map +1 -0
  132. package/dist/routing/middleware/middleware.js +152 -0
  133. package/dist/{api/routing → routing}/middleware.d.ts +0 -1
  134. package/dist/routing/middleware.d.ts.map +1 -0
  135. package/dist/{api/routing → routing}/middleware.js +1 -2
  136. package/dist/{api/routing → routing}/schema/jwt.d.ts +1 -1
  137. package/dist/routing/schema/jwt.d.ts.map +1 -0
  138. package/dist/routing/schema/jwt.js +13 -0
  139. package/dist/routing/tsort.d.ts.map +1 -0
  140. package/dist/routing/tsort.js +51 -0
  141. package/dist/{api/routing → routing}/utils.d.ts +3 -3
  142. package/dist/routing/utils.d.ts.map +1 -0
  143. package/dist/routing/utils.js +45 -0
  144. package/dist/routing.d.ts +182 -0
  145. package/dist/routing.d.ts.map +1 -0
  146. package/dist/routing.js +256 -0
  147. package/dist/test.d.ts +2 -2
  148. package/dist/test.d.ts.map +1 -1
  149. package/dist/test.js +2 -2
  150. package/dist/util.d.ts.map +1 -0
  151. package/dist/util.js +14 -0
  152. package/docs/cluster-storage.md +26 -0
  153. package/docs/workflow-engine.md +262 -0
  154. package/examples/query.ts +47 -39
  155. package/package.json +38 -352
  156. package/src/CUPS.ts +53 -14
  157. package/src/ClusterCosmos.ts +1118 -0
  158. package/src/ClusterServiceBus.ts +242 -0
  159. package/src/{api/ContextProvider.ts → ContextProvider.ts} +20 -17
  160. package/src/Emailer/Sendgrid.ts +83 -60
  161. package/src/Emailer/fake.ts +4 -4
  162. package/src/MainFiberSet.ts +32 -13
  163. package/src/QueueMaker/errors.ts +3 -1
  164. package/src/{adapters/SQL → SQL}/Model.ts +116 -110
  165. package/src/SQL.ts +1 -0
  166. package/src/Store/Cosmos/query.ts +218 -54
  167. package/src/Store/Cosmos.ts +529 -365
  168. package/src/Store/Disk.ts +112 -70
  169. package/src/Store/Memory.ts +366 -102
  170. package/src/Store/SQL/Pg.ts +363 -0
  171. package/src/Store/SQL/query.ts +603 -0
  172. package/src/Store/SQL.ts +746 -0
  173. package/src/Store/codeFilter.ts +8 -6
  174. package/src/Store/index.ts +25 -10
  175. package/src/Store/utils.ts +32 -25
  176. package/src/WorkflowEngineCosmos.ts +749 -0
  177. package/src/WorkflowEngineSqlite.ts +813 -0
  178. package/src/arbs.ts +5 -3
  179. package/src/{adapters/cosmos-client.ts → cosmos-client.ts} +5 -3
  180. package/src/errorReporter.ts +68 -78
  181. package/src/fileUtil.ts +3 -2
  182. package/src/index.ts +2 -1
  183. package/src/{api/internal → internal}/RequestContextMiddleware.ts +23 -6
  184. package/src/internal/auth.ts +272 -0
  185. package/src/{api/internal → internal}/events.ts +25 -15
  186. package/src/{api/layerUtils.ts → layerUtils.ts} +14 -10
  187. package/src/logger/jsonLogger.ts +5 -3
  188. package/src/logger/logFmtLogger.ts +3 -3
  189. package/src/logger/shared.ts +5 -4
  190. package/src/middlewares.ts +10 -0
  191. package/src/{adapters/mongo-client.ts → mongo-client.ts} +4 -2
  192. package/src/otel.ts +152 -0
  193. package/src/rateLimit.ts +34 -23
  194. package/src/{adapters/redis-client.ts → redis-client.ts} +7 -3
  195. package/src/{api/reportError.ts → reportError.ts} +3 -2
  196. package/src/{api/routing → routing}/middleware/RouterMiddleware.ts +5 -4
  197. package/src/routing/middleware/middleware.ts +196 -0
  198. package/src/routing/middleware.ts +4 -0
  199. package/src/{api/routing → routing}/schema/jwt.ts +4 -4
  200. package/src/{api/routing → routing}/utils.ts +2 -1
  201. package/src/routing.ts +823 -0
  202. package/src/test.ts +4 -4
  203. package/src/vitest.ts +1 -1
  204. package/test/auth.test.ts +101 -0
  205. package/test/cluster-cosmos.test.ts +612 -0
  206. package/test/cluster-servicebus.test.ts +180 -0
  207. package/test/cluster-sqlite.test.ts +205 -0
  208. package/test/contextProvider.test.ts +15 -12
  209. package/test/controller.test.ts +30 -32
  210. package/test/cosmos-query.test.ts +228 -0
  211. package/test/dist/auth.test.d.ts.map +1 -0
  212. package/test/dist/cluster-cosmos.test.d.ts.map +1 -0
  213. package/test/dist/cluster-servicebus.test.d.ts.map +1 -0
  214. package/test/dist/cluster-sqlite.test.d.ts.map +1 -0
  215. package/test/dist/contextProvider.test.d.ts.map +1 -1
  216. package/test/dist/controller.test.d.ts.map +1 -1
  217. package/test/dist/cosmos-query.test.d.ts.map +1 -0
  218. package/test/dist/fixtures.d.ts +29 -11
  219. package/test/dist/fixtures.d.ts.map +1 -1
  220. package/test/dist/fixtures.js +17 -10
  221. package/test/dist/query.test.d.ts.map +1 -1
  222. package/test/dist/rawQuery.test.d.ts.map +1 -1
  223. package/test/dist/repository-ext.test.d.ts.map +1 -0
  224. package/test/dist/requires.test.d.ts.map +1 -1
  225. package/test/dist/router-generator.test.d.ts.map +1 -0
  226. package/test/dist/routing-interruptibility.test.d.ts.map +1 -0
  227. package/test/dist/rpc-context-map-streaming.test.d.ts.map +1 -0
  228. package/test/dist/rpc-e2e-invalidation.test.d.ts.map +1 -0
  229. package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
  230. package/test/dist/rpc-stream-fullstack.test.d.ts.map +1 -0
  231. package/test/dist/sql-store.test.d.ts.map +1 -0
  232. package/test/dist/workflow-engine-cosmos.test.d.ts.map +1 -0
  233. package/test/dist/workflow-engine-sqlite.test.d.ts.map +1 -0
  234. package/test/fixtures.ts +16 -9
  235. package/test/layerUtils.test.ts +2 -2
  236. package/test/query.test.ts +1007 -43
  237. package/test/rawQuery.test.ts +340 -22
  238. package/test/repository-ext.test.ts +178 -0
  239. package/test/requires.test.ts +10 -5
  240. package/test/router-generator.test.ts +187 -0
  241. package/test/routing-interruptibility.test.ts +66 -0
  242. package/test/rpc-context-map-streaming.test.ts +262 -0
  243. package/test/rpc-e2e-invalidation.test.ts +418 -0
  244. package/test/rpc-multi-middleware.test.ts +86 -11
  245. package/test/rpc-stream-fullstack.test.ts +304 -0
  246. package/test/sql-store.test.ts +1711 -0
  247. package/test/validateSample.test.ts +26 -14
  248. package/test/workflow-engine-cosmos.test.ts +345 -0
  249. package/test/workflow-engine-sqlite.test.ts +297 -0
  250. package/tsconfig.examples.json +1 -1
  251. package/tsconfig.json +3 -1
  252. package/tsconfig.src.json +35 -35
  253. package/tsconfig.test.json +2 -2
  254. package/dist/Emailer/service.d.ts +0 -55
  255. package/dist/Emailer/service.d.ts.map +0 -1
  256. package/dist/Emailer/service.js +0 -6
  257. package/dist/Emailer.d.ts +0 -2
  258. package/dist/Emailer.d.ts.map +0 -1
  259. package/dist/Emailer.js +0 -2
  260. package/dist/Model/Repository/ext.d.ts +0 -41
  261. package/dist/Model/Repository/ext.d.ts.map +0 -1
  262. package/dist/Model/Repository/ext.js +0 -65
  263. package/dist/Model/Repository/internal/internal.d.ts +0 -59
  264. package/dist/Model/Repository/internal/internal.d.ts.map +0 -1
  265. package/dist/Model/Repository/internal/internal.js +0 -316
  266. package/dist/Model/Repository/legacy.d.ts +0 -19
  267. package/dist/Model/Repository/legacy.d.ts.map +0 -1
  268. package/dist/Model/Repository/legacy.js +0 -2
  269. package/dist/Model/Repository/makeRepo.d.ts +0 -49
  270. package/dist/Model/Repository/makeRepo.d.ts.map +0 -1
  271. package/dist/Model/Repository/makeRepo.js +0 -24
  272. package/dist/Model/Repository/service.d.ts +0 -89
  273. package/dist/Model/Repository/service.d.ts.map +0 -1
  274. package/dist/Model/Repository/service.js +0 -2
  275. package/dist/Model/Repository/validation.d.ts +0 -42
  276. package/dist/Model/Repository/validation.d.ts.map +0 -1
  277. package/dist/Model/Repository/validation.js +0 -32
  278. package/dist/Model/Repository.d.ts +0 -6
  279. package/dist/Model/Repository.d.ts.map +0 -1
  280. package/dist/Model/Repository.js +0 -6
  281. package/dist/Model/dsl.d.ts +0 -32
  282. package/dist/Model/dsl.d.ts.map +0 -1
  283. package/dist/Model/dsl.js +0 -44
  284. package/dist/Model/filter/filterApi.d.ts +0 -30
  285. package/dist/Model/filter/filterApi.d.ts.map +0 -1
  286. package/dist/Model/filter/filterApi.js +0 -2
  287. package/dist/Model/filter/types/errors.d.ts +0 -29
  288. package/dist/Model/filter/types/errors.d.ts.map +0 -1
  289. package/dist/Model/filter/types/errors.js +0 -2
  290. package/dist/Model/filter/types/fields.d.ts +0 -15
  291. package/dist/Model/filter/types/fields.d.ts.map +0 -1
  292. package/dist/Model/filter/types/fields.js +0 -2
  293. package/dist/Model/filter/types/path/common.d.ts +0 -316
  294. package/dist/Model/filter/types/path/common.d.ts.map +0 -1
  295. package/dist/Model/filter/types/path/common.js +0 -2
  296. package/dist/Model/filter/types/path/eager.d.ts +0 -95
  297. package/dist/Model/filter/types/path/eager.d.ts.map +0 -1
  298. package/dist/Model/filter/types/path/eager.js +0 -31
  299. package/dist/Model/filter/types/path/index.d.ts +0 -4
  300. package/dist/Model/filter/types/path/index.d.ts.map +0 -1
  301. package/dist/Model/filter/types/path/index.js +0 -3
  302. package/dist/Model/filter/types/utils.d.ts +0 -79
  303. package/dist/Model/filter/types/utils.d.ts.map +0 -1
  304. package/dist/Model/filter/types/utils.js +0 -2
  305. package/dist/Model/filter/types/validator.d.ts +0 -30
  306. package/dist/Model/filter/types/validator.d.ts.map +0 -1
  307. package/dist/Model/filter/types/validator.js +0 -2
  308. package/dist/Model/filter/types.d.ts +0 -5
  309. package/dist/Model/filter/types.d.ts.map +0 -1
  310. package/dist/Model/filter/types.js +0 -7
  311. package/dist/Model/query/dsl.d.ts +0 -248
  312. package/dist/Model/query/dsl.d.ts.map +0 -1
  313. package/dist/Model/query/dsl.js +0 -104
  314. package/dist/Model/query/new-kid-interpreter.d.ts +0 -28
  315. package/dist/Model/query/new-kid-interpreter.d.ts.map +0 -1
  316. package/dist/Model/query/new-kid-interpreter.js +0 -165
  317. package/dist/Model/query.d.ts +0 -15
  318. package/dist/Model/query.d.ts.map +0 -1
  319. package/dist/Model/query.js +0 -3
  320. package/dist/Model.d.ts +0 -4
  321. package/dist/Model.d.ts.map +0 -1
  322. package/dist/Model.js +0 -4
  323. package/dist/Operations.d.ts +0 -55
  324. package/dist/Operations.d.ts.map +0 -1
  325. package/dist/Operations.js +0 -102
  326. package/dist/OperationsRepo.d.ts +0 -41
  327. package/dist/OperationsRepo.d.ts.map +0 -1
  328. package/dist/OperationsRepo.js +0 -14
  329. package/dist/QueueMaker/SQLQueue.d.ts +0 -16
  330. package/dist/QueueMaker/SQLQueue.d.ts.map +0 -1
  331. package/dist/QueueMaker/SQLQueue.js +0 -130
  332. package/dist/QueueMaker/memQueue.d.ts +0 -11
  333. package/dist/QueueMaker/memQueue.d.ts.map +0 -1
  334. package/dist/QueueMaker/memQueue.js +0 -75
  335. package/dist/QueueMaker/sbqueue.d.ts +0 -12
  336. package/dist/QueueMaker/sbqueue.d.ts.map +0 -1
  337. package/dist/QueueMaker/sbqueue.js +0 -89
  338. package/dist/QueueMaker/service.d.ts +0 -11
  339. package/dist/QueueMaker/service.d.ts.map +0 -1
  340. package/dist/QueueMaker/service.js +0 -4
  341. package/dist/RequestContext.d.ts +0 -63
  342. package/dist/RequestContext.d.ts.map +0 -1
  343. package/dist/RequestContext.js +0 -49
  344. package/dist/RequestFiberSet.d.ts +0 -36
  345. package/dist/RequestFiberSet.d.ts.map +0 -1
  346. package/dist/RequestFiberSet.js +0 -78
  347. package/dist/Store/ContextMapContainer.d.ts +0 -14
  348. package/dist/Store/ContextMapContainer.d.ts.map +0 -1
  349. package/dist/Store/ContextMapContainer.js +0 -16
  350. package/dist/Store/service.d.ts +0 -108
  351. package/dist/Store/service.d.ts.map +0 -1
  352. package/dist/Store/service.js +0 -71
  353. package/dist/Store.d.ts +0 -2
  354. package/dist/Store.d.ts.map +0 -1
  355. package/dist/Store.js +0 -2
  356. package/dist/adapters/SQL/Model.d.ts.map +0 -1
  357. package/dist/adapters/SQL/Model.js +0 -470
  358. package/dist/adapters/SQL.d.ts.map +0 -1
  359. package/dist/adapters/ServiceBus.d.ts +0 -58
  360. package/dist/adapters/ServiceBus.d.ts.map +0 -1
  361. package/dist/adapters/ServiceBus.js +0 -99
  362. package/dist/adapters/cosmos-client.d.ts.map +0 -1
  363. package/dist/adapters/cosmos-client.js +0 -9
  364. package/dist/adapters/index.d.ts +0 -2
  365. package/dist/adapters/index.d.ts.map +0 -1
  366. package/dist/adapters/index.js +0 -2
  367. package/dist/adapters/logger.d.ts +0 -9
  368. package/dist/adapters/logger.d.ts.map +0 -1
  369. package/dist/adapters/logger.js +0 -3
  370. package/dist/adapters/memQueue.d.ts +0 -13
  371. package/dist/adapters/memQueue.d.ts.map +0 -1
  372. package/dist/adapters/memQueue.js +0 -20
  373. package/dist/adapters/mongo-client.d.ts.map +0 -1
  374. package/dist/adapters/mongo-client.js +0 -13
  375. package/dist/adapters/redis-client.d.ts.map +0 -1
  376. package/dist/adapters/redis-client.js +0 -94
  377. package/dist/api/ContextProvider.d.ts +0 -31
  378. package/dist/api/ContextProvider.d.ts.map +0 -1
  379. package/dist/api/ContextProvider.js +0 -38
  380. package/dist/api/codec.d.ts.map +0 -1
  381. package/dist/api/codec.js +0 -5
  382. package/dist/api/internal/RequestContextMiddleware.d.ts +0 -5
  383. package/dist/api/internal/RequestContextMiddleware.d.ts.map +0 -1
  384. package/dist/api/internal/RequestContextMiddleware.js +0 -35
  385. package/dist/api/internal/auth.d.ts +0 -15
  386. package/dist/api/internal/auth.d.ts.map +0 -1
  387. package/dist/api/internal/auth.js +0 -47
  388. package/dist/api/internal/events.d.ts +0 -9
  389. package/dist/api/internal/events.d.ts.map +0 -1
  390. package/dist/api/internal/events.js +0 -40
  391. package/dist/api/internal/health.d.ts.map +0 -1
  392. package/dist/api/internal/health.js +0 -5
  393. package/dist/api/layerUtils.d.ts.map +0 -1
  394. package/dist/api/layerUtils.js +0 -16
  395. package/dist/api/middlewares.d.ts.map +0 -1
  396. package/dist/api/reportError.d.ts.map +0 -1
  397. package/dist/api/reportError.js +0 -27
  398. package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +0 -1
  399. package/dist/api/routing/middleware/middleware.d.ts +0 -9
  400. package/dist/api/routing/middleware/middleware.d.ts.map +0 -1
  401. package/dist/api/routing/middleware/middleware.js +0 -92
  402. package/dist/api/routing/middleware.d.ts.map +0 -1
  403. package/dist/api/routing/schema/jwt.d.ts.map +0 -1
  404. package/dist/api/routing/schema/jwt.js +0 -12
  405. package/dist/api/routing/tsort.d.ts.map +0 -1
  406. package/dist/api/routing/tsort.js +0 -51
  407. package/dist/api/routing/utils.d.ts.map +0 -1
  408. package/dist/api/routing/utils.js +0 -44
  409. package/dist/api/routing.d.ts +0 -138
  410. package/dist/api/routing.d.ts.map +0 -1
  411. package/dist/api/routing.js +0 -166
  412. package/dist/api/setupRequest.d.ts +0 -12
  413. package/dist/api/setupRequest.d.ts.map +0 -1
  414. package/dist/api/setupRequest.js +0 -44
  415. package/dist/api/util.d.ts.map +0 -1
  416. package/dist/api/util.js +0 -14
  417. package/eslint.config.mjs +0 -24
  418. package/src/Emailer/service.ts +0 -52
  419. package/src/Emailer.ts +0 -1
  420. package/src/Model/Repository/ext.ts +0 -283
  421. package/src/Model/Repository/internal/internal.ts +0 -577
  422. package/src/Model/Repository/legacy.ts +0 -27
  423. package/src/Model/Repository/makeRepo.ts +0 -139
  424. package/src/Model/Repository/service.ts +0 -627
  425. package/src/Model/Repository/validation.ts +0 -31
  426. package/src/Model/Repository.ts +0 -5
  427. package/src/Model/dsl.ts +0 -128
  428. package/src/Model/filter/filterApi.ts +0 -60
  429. package/src/Model/filter/types/errors.ts +0 -47
  430. package/src/Model/filter/types/fields.ts +0 -50
  431. package/src/Model/filter/types/path/common.ts +0 -404
  432. package/src/Model/filter/types/path/eager.ts +0 -298
  433. package/src/Model/filter/types/path/index.ts +0 -4
  434. package/src/Model/filter/types/utils.ts +0 -128
  435. package/src/Model/filter/types/validator.ts +0 -46
  436. package/src/Model/filter/types.ts +0 -6
  437. package/src/Model/query/dsl.ts +0 -2110
  438. package/src/Model/query/new-kid-interpreter.ts +0 -210
  439. package/src/Model/query.ts +0 -13
  440. package/src/Model.ts +0 -3
  441. package/src/Operations.ts +0 -235
  442. package/src/OperationsRepo.ts +0 -16
  443. package/src/QueueMaker/SQLQueue.ts +0 -190
  444. package/src/QueueMaker/memQueue.ts +0 -131
  445. package/src/QueueMaker/sbqueue.ts +0 -134
  446. package/src/QueueMaker/service.ts +0 -17
  447. package/src/RequestContext.ts +0 -63
  448. package/src/RequestFiberSet.ts +0 -105
  449. package/src/Store/ContextMapContainer.ts +0 -20
  450. package/src/Store/index.test.ts.bak +0 -112
  451. package/src/Store/service.ts +0 -184
  452. package/src/Store.ts +0 -1
  453. package/src/adapters/SQL.ts +0 -1
  454. package/src/adapters/ServiceBus.ts +0 -209
  455. package/src/adapters/index.ts +0 -0
  456. package/src/adapters/logger.ts +0 -3
  457. package/src/adapters/memQueue.ts +0 -21
  458. package/src/api/internal/auth.ts +0 -68
  459. package/src/api/middlewares.ts +0 -10
  460. package/src/api/routing/middleware/middleware.ts +0 -128
  461. package/src/api/routing/middleware.ts +0 -6
  462. package/src/api/routing.ts +0 -597
  463. package/src/api/setupRequest.ts +0 -84
  464. package/tsconfig.json.bak +0 -12
  465. /package/dist/{adapters/SQL.d.ts → SQL.d.ts} +0 -0
  466. /package/dist/{api/codec.d.ts → codec.d.ts} +0 -0
  467. /package/dist/{api/internal → internal}/health.d.ts +0 -0
  468. /package/dist/{api/middlewares.d.ts → middlewares.d.ts} +0 -0
  469. /package/dist/{api/routing → routing}/tsort.d.ts +0 -0
  470. /package/dist/{api/util.d.ts → util.d.ts} +0 -0
  471. /package/src/{api/codec.ts → codec.ts} +0 -0
  472. /package/src/{api/internal → internal}/health.ts +0 -0
  473. /package/src/{api/routing → routing}/tsort.ts +0 -0
  474. /package/src/{api/util.ts → util.ts} +0 -0
@@ -1,597 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
3
- /* eslint-disable @typescript-eslint/no-empty-object-type */
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- import { Config, Effect, Layer, type NonEmptyReadonlyArray, Predicate, S, type Scope } from "effect-app"
6
- import { type HttpHeaders } from "effect-app/http"
7
- import { type GetEffectContext, type GetEffectError, type RpcContextMap } from "effect-app/rpc/RpcContextMap"
8
- import { type TypeTestId } from "effect-app/TypeTest"
9
- import { typedKeysOf, typedValuesOf } from "effect-app/utils"
10
- import { type Yieldable } from "effect/Effect"
11
- import { Rpc, RpcGroup, type RpcSerialization, RpcServer } from "effect/unstable/rpc"
12
- import { type LayerUtils } from "./layerUtils.js"
13
- import { type RouterMiddleware } from "./routing/middleware.js"
14
-
15
- export * from "./routing/middleware.js"
16
-
17
- // it's the result of extending S.Req setting success, config
18
- // it's a schema plus some metadata
19
- export type AnyRequestModule = S.Top & {
20
- _tag: string // unique identifier for the request module
21
- config: any // ?
22
- success: S.Top // validates the success response
23
- error: S.Top // validates the failure response
24
- }
25
-
26
- // builder pattern for adding actions to a router until all actions are added
27
- export interface AddAction<Actions extends AnyRequestModule, Accum extends Record<string, any> = {}> {
28
- accum: Accum
29
- add<A extends Handler<Actions, any, any>>(
30
- a: A
31
- ): A extends Handler<infer M extends AnyRequestModule, any, any> ? Exclude<Actions, M> extends never ?
32
- & Accum
33
- & { [K in M["_tag"]]: A }
34
- :
35
- & AddAction<
36
- Exclude<Actions, M>,
37
- & Accum
38
- & { [K in M["_tag"]]: A }
39
- >
40
- & Accum
41
- & { [K in M["_tag"]]: A }
42
- : never
43
- }
44
-
45
- // note:
46
- // "d" stands for decoded i.e. the Type
47
- // "raw" stands for encoded i.e. the Encoded
48
- namespace RequestTypes {
49
- export const DECODED = "d" as const
50
- export type DECODED = typeof DECODED
51
- export const RAW = "raw" as const
52
- export type RAW = typeof RAW
53
- }
54
- type RequestType = typeof RequestTypes[keyof typeof RequestTypes]
55
-
56
- type GetSuccess<T> = T extends { success: S.Top } ? T["success"] : typeof S.Void
57
- type GetFailure<T extends { error?: S.Top }> = T["error"] extends never ? typeof S.Never : T["error"]
58
-
59
- type GetSuccessShape<Action extends { success?: S.Top }, RT extends RequestType> = {
60
- d: S.Schema.Type<GetSuccess<Action>>
61
- raw: S.Codec.Encoded<GetSuccess<Action>>
62
- }[RT]
63
-
64
- interface HandlerBase<Action extends AnyRequestModule, RT extends RequestType, A, E, R> {
65
- new(): {}
66
- _tag: RT
67
- stack: string
68
- handler: (req: S.Schema.Type<Action>, headers: HttpHeaders.Headers) => Effect.Effect<A, E, R>
69
- }
70
-
71
- export interface Handler<Action extends AnyRequestModule, RT extends RequestType, R> extends
72
- HandlerBase<
73
- Action,
74
- RT,
75
- GetSuccessShape<Action, RT>,
76
- S.Schema.Type<GetFailure<Action>> | S.SchemaError,
77
- R
78
- >
79
- {}
80
-
81
- type AnyHandler<Action extends AnyRequestModule> = Handler<
82
- Action,
83
- RequestType,
84
- any // R
85
- >
86
-
87
- // a Resource is typically the whole module with all the exported sh*t
88
- // this helper retrieves only the entities (classes) which are built by extending S.Req
89
- type FilterRequestModules<T> = {
90
- [K in keyof T as T[K] extends AnyRequestModule ? K : never]: T[K]
91
- }
92
-
93
- type RpcRouteR<
94
- T extends [any, (req: any, headers: HttpHeaders.Headers) => Effect.Effect<any, any, any>]
95
- > = T extends [
96
- any,
97
- (...args: any[]) => Effect.Effect<any, any, infer R>
98
- ] ? R
99
- : never
100
-
101
- type Match<
102
- Resource extends Record<string, any>,
103
- RequestContextMap extends Record<string, any>,
104
- RT extends RequestType,
105
- Key extends keyof Resource
106
- > = {
107
- // note: the defaults of = never prevent the whole router to error (??)
108
- <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
109
- f: Effect.Effect<A, E, R2>
110
- ): Handler<
111
- Resource[Key],
112
- RT,
113
- Exclude<
114
- Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
115
- Scope.Scope
116
- >
117
- >
118
-
119
- <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
120
- f: (req: S.Schema.Type<Resource[Key]>) => Effect.Effect<A, E, R2>
121
- ): Handler<
122
- Resource[Key],
123
- RT,
124
- Exclude<
125
- Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
126
- Scope.Scope
127
- >
128
- >
129
- }
130
-
131
- export type RouteMatcher<
132
- RequestContextMap extends Record<string, any>,
133
- Resource extends Record<string, any>
134
- > = {
135
- // use Resource as Key over using Keys, so that the Go To on X.Action remain in tact in Controllers files
136
- /**
137
- * Requires the Type shape
138
- */
139
- [Key in keyof FilterRequestModules<Resource>]:
140
- & Match<Resource, RequestContextMap, RequestTypes.DECODED, Key>
141
- & {
142
- success: Resource[Key]["success"]
143
- successRaw: S.Codec<S.Codec.Encoded<Resource[Key]["success"]>>
144
- error: Resource[Key]["error"]
145
- /**
146
- * Requires the Encoded shape (e.g directly undecoded from DB, so that we don't do multiple Decode/Encode)
147
- */
148
- raw: Match<Resource, RequestContextMap, RequestTypes.RAW, Key>
149
- }
150
- }
151
-
152
- export const skipOnProd = Effect
153
- .gen(function*() {
154
- const env = yield* Config.string("env")
155
- return env !== "prod"
156
- })
157
- .pipe(Effect.orDie)
158
-
159
- export const makeRouter = <
160
- Self,
161
- RequestContextMap extends Record<string, RpcContextMap.Any>,
162
- MakeMiddlewareE,
163
- MakeMiddlewareR,
164
- ContextProviderA,
165
- ContextProviderE,
166
- ContextProviderR,
167
- RequestContextId
168
- >(
169
- middleware: RouterMiddleware<
170
- Self,
171
- RequestContextMap,
172
- MakeMiddlewareE,
173
- MakeMiddlewareR,
174
- ContextProviderA,
175
- ContextProviderE,
176
- ContextProviderR,
177
- RequestContextId
178
- >
179
- ) => {
180
- /**
181
- * Create a Router for specified resource
182
- * if `check` is provided, the router will only be created if the effect succeeds with true
183
- */
184
- function matchFor<
185
- const ModuleName extends string,
186
- const Resource extends Record<string, any>
187
- >(
188
- rsc: Resource & { meta: { moduleName: ModuleName } },
189
- options?: { check?: Effect.Effect<boolean> }
190
- ) {
191
- type HandlerWithInputGen<
192
- Action extends AnyRequestModule,
193
- RT extends RequestType
194
- > = (
195
- req: S.Schema.Type<Action>
196
- ) => Generator<
197
- Yieldable<any,
198
- any,
199
- S.Schema.Type<GetFailure<Action>> | S.SchemaError,
200
- // the actual implementation of the handler may just require the dynamic context provided by the middleware
201
- // and the per request context provided by the context provider
202
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
203
- >,
204
- GetSuccessShape<Action, RT>,
205
- never
206
- >
207
-
208
- type HandlerWithInputEff<
209
- Action extends AnyRequestModule,
210
- RT extends RequestType
211
- > = (
212
- req: S.Schema.Type<Action>
213
- ) => Effect.Effect<
214
- GetSuccessShape<Action, RT>,
215
- S.Schema.Type<GetFailure<Action>> | S.SchemaError,
216
- // the actual implementation of the handler may just require the dynamic context provided by the middleware
217
- // and the per request context provided by the context provider
218
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
219
- >
220
-
221
- type HandlerEff<
222
- Action extends AnyRequestModule,
223
- RT extends RequestType
224
- > = Effect.Effect<
225
- GetSuccessShape<Action, RT>,
226
- S.Schema.Type<GetFailure<Action>> | S.SchemaError,
227
- // the actual implementation of the handler may just require the dynamic context provided by the middleware
228
- // and the per request context provided by the context provider
229
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
230
- >
231
-
232
- type Handlers<Action extends AnyRequestModule, RT extends RequestType> =
233
- | HandlerWithInputGen<Action, RT>
234
- | HandlerWithInputEff<Action, RT>
235
- | HandlerEff<Action, RT>
236
-
237
- type HandlersDecoded<Action extends AnyRequestModule> = Handlers<Action, RequestTypes.DECODED>
238
-
239
- type HandlersRaw<Action extends AnyRequestModule> =
240
- | { raw: HandlerWithInputGen<Action, RequestTypes.RAW> }
241
- | { raw: HandlerWithInputEff<Action, RequestTypes.RAW> }
242
- | { raw: HandlerEff<Action, RequestTypes.RAW> }
243
-
244
- type AnyHandlers<Action extends AnyRequestModule> = HandlersRaw<Action> | HandlersDecoded<Action>
245
-
246
- const { meta } = rsc
247
-
248
- type RequestModules = FilterRequestModules<Resource>
249
- const requestModules = typedKeysOf(rsc).reduce((acc, cur) => {
250
- if (Predicate.isObject(rsc[cur]) && rsc[cur]["success"]) {
251
- acc[cur as keyof RequestModules] = rsc[cur] as RequestModules[keyof RequestModules]
252
- }
253
- return acc
254
- }, {} as RequestModules)
255
-
256
- const routeMatcher = typedKeysOf(requestModules).reduce(
257
- (prev, cur) => {
258
- ;(prev as any)[cur] = Object.assign((handlerImpl: any) => {
259
- // handlerImpl is the actual handler implementation
260
- if (handlerImpl[Symbol.toStringTag] === "GeneratorFunction") handlerImpl = Effect.fnUntraced(handlerImpl)
261
- const stack = new Error().stack?.split("\n").slice(2).join("\n")
262
- return Effect.isEffect(handlerImpl)
263
- ? class {
264
- static request = rsc[cur]
265
- static stack = stack
266
- static _tag = RequestTypes.DECODED
267
- static handler = () => handlerImpl
268
- }
269
- : class {
270
- static request = rsc[cur]
271
- static stack = stack
272
- static _tag = RequestTypes.DECODED
273
- static handler = handlerImpl
274
- }
275
- }, {
276
- success: rsc[cur].success,
277
- successRaw: S.toEncoded(rsc[cur].success),
278
- error: rsc[cur].error,
279
- raw: // "Raw" variations are for when you don't want to decode just to encode it again on the response
280
- // e.g for direct projection from DB
281
- // but more importantly, to skip Effectful decoders, like to resolve relationships from the database or remote client.
282
- (handlerImpl: any) => {
283
- if (handlerImpl[Symbol.toStringTag] === "GeneratorFunction") handlerImpl = Effect.fnUntraced(handlerImpl)
284
- const stack = new Error().stack?.split("\n").slice(2).join("\n")
285
- return Effect.isEffect(handlerImpl)
286
- ? class {
287
- static request = rsc[cur]
288
- static stack = stack
289
- static _tag = RequestTypes.RAW
290
- static handler = () => handlerImpl
291
- }
292
- : class {
293
- static request = rsc[cur]
294
- static stack = stack
295
- static _tag = RequestTypes.RAW
296
- static handler = handlerImpl
297
- }
298
- }
299
- })
300
- return prev
301
- },
302
- {} as RouteMatcher<RequestContextMap, Resource>
303
- )
304
-
305
- const router3: <
306
- const Impl extends {
307
- [K in keyof FilterRequestModules<Resource>]: AnyHandlers<Resource[K]>
308
- }
309
- >(
310
- impl: Impl
311
- ) => {
312
- [K in keyof Impl & keyof FilterRequestModules<Resource>]: Handler<
313
- FilterRequestModules<Resource>[K],
314
- Impl[K] extends { raw: any } ? RequestTypes.RAW : RequestTypes.DECODED,
315
- Exclude<
316
- Exclude<
317
- // retrieves context R from the actual implementation of the handler
318
- Impl[K] extends { raw: any }
319
- ? Impl[K]["raw"] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
320
- : Impl[K]["raw"] extends Effect.Effect<any, any, infer R> ? R
321
- : Impl[K]["raw"] extends (...args: any[]) => Generator<
322
- Yieldable<any,any, any, infer R>,
323
- any,
324
- any
325
- > ? R
326
- : never
327
- : Impl[K] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
328
- : Impl[K] extends Effect.Effect<any, any, infer R> ? R
329
- : Impl[K] extends (...args: any[]) => Generator<
330
- Yieldable<any,any, any, infer R>,
331
- any,
332
- any
333
- > ? R
334
- : never,
335
- | GetEffectContext<RequestContextMap, Resource[K]["config"]>
336
- | ContextProviderA
337
- >,
338
- Scope.Scope
339
- >
340
- >
341
- } = (impl: Record<keyof RequestModules, any>) =>
342
- typedKeysOf(impl).reduce((acc, cur) => {
343
- acc[cur] = "raw" in impl[cur] ? routeMatcher[cur].raw(impl[cur].raw) : routeMatcher[cur](impl[cur])
344
- return acc
345
- }, {} as any)
346
-
347
- const makeRoutes = <
348
- MakeE,
349
- MakeR,
350
- THandlers extends {
351
- // important to keep them separate via | for type checking!!
352
- [K in keyof RequestModules]: AnyHandler<Resource[K]>
353
- },
354
- MakeDependencies extends NonEmptyReadonlyArray<Layer.Any> | never[]
355
- >(
356
- dependencies: MakeDependencies,
357
- make: (
358
- match: any
359
- ) =>
360
- | Effect.Effect<THandlers, MakeE, MakeR>
361
- | Generator<Yieldable<any, any, MakeE, MakeR>, THandlers, any>
362
- ) => {
363
- const dependenciesL = (dependencies ? Layer.mergeAll(...dependencies as any) : Layer.empty) as Layer.Layer<
364
- LayerUtils.GetLayersSuccess<MakeDependencies>,
365
- LayerUtils.GetLayersError<MakeDependencies>,
366
- LayerUtils.GetLayersContext<MakeDependencies>
367
- >
368
-
369
- const layer = Effect
370
- .gen(function*() {
371
- const finalMake = ((make as any)[Symbol.toStringTag] === "GeneratorFunction"
372
- ? Effect.fnUntraced(make as any)(router3) as any
373
- : make(router3) as any) as Effect.Effect<THandlers, MakeE, MakeR>
374
-
375
- const controllers = yield* finalMake
376
-
377
- // return make.pipe(Effect.map((c) => controllers(c, dependencies)))
378
- const mapped = typedKeysOf(requestModules).reduce((acc, cur) => {
379
- const handler = controllers[cur as keyof typeof controllers]
380
- const resource = rsc[cur]
381
-
382
- acc[cur] = [
383
- handler._tag === RequestTypes.RAW
384
- ? class extends (resource as any) {
385
- static success = S.toEncoded(resource.success)
386
- } as any
387
- : resource,
388
- (payload: any, headers: any) =>
389
- (handler.handler(payload, headers) as Effect.Effect<unknown, unknown, unknown>).pipe(
390
- Effect.withSpan(`Request.${meta.moduleName}.${resource._tag}`, {}, {
391
- captureStackTrace: () => handler.stack // capturing the handler stack is the main reason why we are doing the span here
392
- })
393
- )
394
- ] as const
395
- return acc
396
- }, {} as any) as {
397
- [K in keyof RequestModules]: [
398
- Resource[K],
399
- (
400
- req: any,
401
- headers: HttpHeaders.Headers
402
- ) => Effect.Effect<
403
- Effect.Success<ReturnType<THandlers[K]["handler"]>>,
404
- | Effect.Error<ReturnType<THandlers[K]["handler"]>>
405
- | GetEffectError<RequestContextMap, Resource[K]["config"]>,
406
- Exclude<
407
- Effect.Services<ReturnType<THandlers[K]["handler"]>>,
408
- ContextProviderA | GetEffectContext<RequestContextMap, Resource[K]["config"]>
409
- >
410
- >
411
- ]
412
- }
413
-
414
- const rpcs = RpcGroup
415
- .make(
416
- ...typedValuesOf(mapped).map(([resource]) => {
417
- return Rpc
418
- .make(resource._tag, { payload: resource, success: resource.success, error: resource.error })
419
- .annotate(middleware.requestContext, resource.config ?? {})
420
- })
421
- )
422
- .prefix(`${meta.moduleName}.`)
423
- .middleware(middleware as any)
424
-
425
- const rpc = rpcs
426
- .toLayer(Effect.gen(function*() {
427
- return typedValuesOf(mapped).reduce((acc, [resource, handler]) => {
428
- acc[`${meta.moduleName}.${resource._tag}`] = handler
429
- return acc
430
- }, {} as Record<string, any>) as any // TODO
431
- })) as unknown as Layer.Layer<
432
- { [K in keyof RequestModules]: Rpc.Handler<K> },
433
- MakeE,
434
- RpcRouteR<typeof mapped[keyof typeof mapped]>
435
- >
436
-
437
- return RpcServer
438
- .layerHttp({
439
- spanPrefix: "RpcServer." + meta.moduleName,
440
- group: rpcs,
441
- path: ("/rpc/" + meta.moduleName) as `/${typeof meta.moduleName}`,
442
- protocol: "http"
443
- })
444
- .pipe(Layer.provide(rpc))
445
- })
446
- .pipe(Layer.unwrap)
447
-
448
- const routes = layer.pipe(
449
- Layer.provide([
450
- dependenciesL,
451
- middleware.Default
452
- ])
453
- )
454
-
455
- const check = options?.check
456
- return check
457
- ? Effect
458
- .gen(function*() {
459
- if (!(yield* check)) {
460
- yield* Effect.logWarning(`Skipping router for module ${meta.moduleName}`)
461
- return Layer.empty
462
- }
463
- return routes
464
- })
465
- .pipe(Layer.unwrap)
466
- : routes
467
- }
468
-
469
- const effect: {
470
- // Multiple times duplicated the "good" overload, so that errors will only mention the last overload when failing
471
- <
472
- const Make extends {
473
- dependencies?: ReadonlyArray<Layer.Any>
474
- effect: (match: typeof router3) => Generator<
475
- Yieldable<
476
- any,
477
- any,
478
- any,
479
- any
480
- >,
481
- { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> },
482
- any
483
- >
484
- /** @deprecated */
485
- readonly ಠ_ಠ: never
486
- }
487
- >(
488
- make: Make
489
- ):
490
- & Layer.Layer<
491
- never,
492
- | MakeErrors<Make>
493
- | MakeDepsE<Make>
494
- | Layer.Error<typeof middleware.Default>,
495
- | MakeDepsIn<Make>
496
- | Layer.Services<typeof middleware.Default>
497
- | Exclude<
498
- MakeContext<Make>,
499
- MakeDepsOut<Make>
500
- >
501
- | RpcSerialization.RpcSerialization
502
- >
503
- & {
504
- // just for type testing purposes
505
- [TypeTestId]: Make
506
- }
507
- <
508
- const Make extends {
509
- dependencies?: ReadonlyArray<Layer.Any>
510
- // v4: generators yield Yieldable with asEffect()
511
- effect: (match: typeof router3) => Generator<
512
- Yieldable<any, any, any, any>,
513
- { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> },
514
- any
515
- >
516
- }
517
- >(
518
- make: Make
519
- ):
520
- & Layer.Layer<
521
- never,
522
- | MakeErrors<Make>
523
- | MakeDepsE<Make>
524
- | Layer.Error<typeof middleware.Default>,
525
- | MakeDepsIn<Make>
526
- | Layer.Services<typeof middleware.Default>
527
- | Exclude<
528
- MakeContext<Make>,
529
- MakeDepsOut<Make>
530
- >
531
- | RpcSerialization.RpcSerialization
532
- >
533
- & {
534
- // just for type testing purposes
535
- readonly [TypeTestId]: Make
536
- }
537
- } =
538
- ((make: { dependencies: any; effect: any }) =>
539
- Object.assign(makeRoutes(make.dependencies, make.effect), { make })) as any
540
-
541
- return effect
542
- }
543
-
544
- function matchAll<
545
- T extends {
546
- [key: string]: Layer.Layer<never, any, any>
547
- }
548
- >(
549
- handlers: T
550
- ) {
551
- const routers = typedValuesOf(handlers)
552
-
553
- return Layer.mergeAll(...routers as [any]) as unknown as Layer.Layer<
554
- never,
555
- Layer.Error<typeof handlers[keyof typeof handlers]>,
556
- Layer.Services<typeof handlers[keyof typeof handlers]>
557
- >
558
- }
559
-
560
- return {
561
- matchAll,
562
- Router: matchFor
563
- }
564
- }
565
-
566
- export type MakeDeps<Make> = Make extends { readonly dependencies: ReadonlyArray<Layer.Any> }
567
- ? Make["dependencies"][number]
568
- : never
569
-
570
- export type MakeErrors<Make> = /*Make extends { readonly effect: (_: any) => Effect.Effect<any, infer E, any> } ? E
571
- : Make extends { readonly effect: (_: any) => Effect.Effect<any, never, any> } ? never
572
- : */
573
- // v4: generators yield Yieldable with asEffect()
574
- Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, never, any>, any, any> } ? never
575
- : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, infer E, any>, any, any> } ? E
576
- : never
577
-
578
- export type MakeContext<Make> = /*Make extends { readonly effect: (_: any) => Effect.Effect<any, any, infer R> } ? R
579
- : Make extends { readonly effect: (_: any) => Effect.Effect<any, any, never> } ? never
580
- : */
581
- // v4: generators yield Yieldable with asEffect()
582
- Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any, never>, any, any> } ? never
583
- : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any, infer R>, any, any> } ? R
584
- : never
585
-
586
- export type MakeHandlers<Make, _Handlers extends Record<string, any>> = /*Make extends
587
- { readonly effect: (_: any) => Effect.Effect<{ [K in keyof Handlers]: AnyHandler<Handlers[K]> }, any, any> }
588
- ? Effect.Success<ReturnType<Make["effect"]>>
589
- : */
590
- Make extends { readonly effect: (_: any) => Generator<any, infer S, any> } ? S
591
- : never
592
-
593
- export type MakeDepsE<Make> = Layer.Error<MakeDeps<Make>>
594
-
595
- export type MakeDepsIn<Make> = Layer.Services<MakeDeps<Make>>
596
-
597
- export type MakeDepsOut<Make> = Layer.Success<MakeDeps<Make>>
@@ -1,84 +0,0 @@
1
- import { Effect, Layer, Tracer } from "effect-app"
2
- import { NonEmptyString255 } from "effect-app/Schema"
3
- import { LocaleRef, RequestContext, spanAttributes } from "../RequestContext.js"
4
- import { ContextMapContainer } from "../Store/ContextMapContainer.js"
5
- import { storeId } from "../Store/Memory.js"
6
-
7
- export const getRequestContext = Effect
8
- .all({
9
- span: Effect.currentSpan.pipe(Effect.orDie),
10
- locale: LocaleRef.asEffect(),
11
- namespace: storeId.asEffect()
12
- })
13
- .pipe(
14
- Effect.map(({ locale, namespace, span }) =>
15
- new RequestContext({
16
- span: Tracer.externalSpan(span),
17
- locale,
18
- namespace,
19
- name: NonEmptyString255(span.name)
20
- })
21
- )
22
- )
23
-
24
- export const getRC = Effect.all({
25
- locale: LocaleRef.asEffect(),
26
- namespace: storeId.asEffect()
27
- })
28
-
29
- const withRequestSpan = (name = "request", options?: Tracer.SpanOptions) => <R, E, A>(f: Effect.Effect<A, E, R>) =>
30
- Effect.andThen(
31
- getRC,
32
- (ctx) =>
33
- f.pipe(
34
- Effect.withSpan(name, {
35
- ...options,
36
- attributes: { ...spanAttributes({ ...ctx, name: NonEmptyString255(name) }), ...options?.attributes }
37
- }, {
38
- captureStackTrace: options?.captureStackTrace ?? false
39
- }),
40
- // TODO: false
41
- // request context info is picked up directly in the logger for annotations.
42
- Effect.withLogSpan(name)
43
- )
44
- )
45
-
46
- export const setupRequestContextFromCurrent =
47
- (name = "request", options?: Tracer.SpanOptions) => <R, E, A>(self: Effect.Effect<A, E, R>) =>
48
- self
49
- .pipe(
50
- withRequestSpan(name, options),
51
- Effect.provide(ContextMapContainer.layer)
52
- )
53
-
54
- // TODO: consider integrating Effect.withParentSpan
55
- export function setupRequestContext<R, E, A>(self: Effect.Effect<A, E, R>, requestContext: RequestContext) {
56
- const layer = Layer.mergeAll(
57
- ContextMapContainer.layer,
58
- Layer.succeed(LocaleRef, requestContext.locale),
59
- Layer.succeed(storeId, requestContext.namespace)
60
- )
61
- return self
62
- .pipe(
63
- withRequestSpan(requestContext.name),
64
- Effect.provide(layer)
65
- )
66
- }
67
-
68
- export function setupRequestContextWithCustomSpan<R, E, A>(
69
- self: Effect.Effect<A, E, R>,
70
- requestContext: RequestContext,
71
- name: string,
72
- options?: Tracer.SpanOptions
73
- ) {
74
- const layer = Layer.mergeAll(
75
- ContextMapContainer.layer,
76
- Layer.succeed(LocaleRef, requestContext.locale),
77
- Layer.succeed(storeId, requestContext.namespace)
78
- )
79
- return self
80
- .pipe(
81
- withRequestSpan(name, options),
82
- Effect.provide(layer)
83
- )
84
- }
package/tsconfig.json.bak DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {},
3
- "extends": "../../tsconfig.base.json",
4
- "references": [
5
- {
6
- "path": "./tsconfig.src.json"
7
- },
8
- {
9
- "path": "./tsconfig.test.json"
10
- }
11
- ],
12
- }
File without changes
File without changes
File without changes
File without changes