@effect-app/infra 4.0.0-beta.248 → 4.0.0-beta.249

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 (377) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/ContextProvider.d.ts +34 -0
  3. package/dist/ContextProvider.d.ts.map +1 -0
  4. package/dist/ContextProvider.js +40 -0
  5. package/dist/Emailer/Sendgrid.d.ts +109 -145
  6. package/dist/Emailer/Sendgrid.d.ts.map +1 -1
  7. package/dist/Emailer/Sendgrid.js +4 -3
  8. package/dist/Emailer/fake.d.ts +2 -2
  9. package/dist/Emailer/fake.d.ts.map +1 -1
  10. package/dist/Emailer/fake.js +2 -2
  11. package/dist/QueueMaker/SQLQueue.d.ts +2 -2
  12. package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
  13. package/dist/QueueMaker/SQLQueue.js +4 -4
  14. package/dist/QueueMaker/memQueue.d.ts +2 -2
  15. package/dist/QueueMaker/memQueue.d.ts.map +1 -1
  16. package/dist/QueueMaker/memQueue.js +4 -4
  17. package/dist/QueueMaker/sbqueue.d.ts +2 -2
  18. package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
  19. package/dist/QueueMaker/sbqueue.js +4 -4
  20. package/dist/RequestFiberSet.js +2 -2
  21. package/dist/{adapters/SQL → SQL}/Model.d.ts +2 -2
  22. package/dist/SQL/Model.d.ts.map +1 -0
  23. package/dist/SQL/Model.js +469 -0
  24. package/dist/{adapters/SQL.d.ts → SQL.d.ts} +1 -1
  25. package/dist/SQL.d.ts.map +1 -0
  26. package/dist/{adapters/SQL.js → SQL.js} +1 -1
  27. package/dist/{adapters/ServiceBus.d.ts → ServiceBus.d.ts} +1 -1
  28. package/dist/ServiceBus.d.ts.map +1 -0
  29. package/dist/ServiceBus.js +108 -0
  30. package/dist/Store/ContextMapContainer.d.ts +2 -2
  31. package/dist/Store/ContextMapContainer.d.ts.map +1 -1
  32. package/dist/Store/ContextMapContainer.js +2 -2
  33. package/dist/Store/Cosmos/query.d.ts +4 -4
  34. package/dist/Store/Cosmos/query.d.ts.map +1 -1
  35. package/dist/Store/Cosmos/query.js +1 -1
  36. package/dist/Store/Cosmos.d.ts +2 -2
  37. package/dist/Store/Cosmos.d.ts.map +1 -1
  38. package/dist/Store/Cosmos.js +3 -3
  39. package/dist/Store/Disk.d.ts +3 -3
  40. package/dist/Store/Disk.d.ts.map +1 -1
  41. package/dist/Store/Disk.js +2 -2
  42. package/dist/Store/Memory.d.ts +3 -3
  43. package/dist/Store/Memory.d.ts.map +1 -1
  44. package/dist/Store/Memory.js +2 -2
  45. package/dist/Store/SQL/Pg.d.ts +2 -2
  46. package/dist/Store/SQL/Pg.d.ts.map +1 -1
  47. package/dist/Store/SQL/Pg.js +2 -2
  48. package/dist/Store/SQL/query.d.ts +3 -3
  49. package/dist/Store/SQL/query.d.ts.map +1 -1
  50. package/dist/Store/SQL/query.js +1 -1
  51. package/dist/Store/SQL.d.ts +3 -3
  52. package/dist/Store/SQL.d.ts.map +1 -1
  53. package/dist/Store/SQL.js +2 -2
  54. package/dist/Store/codeFilter.d.ts +4 -4
  55. package/dist/Store/codeFilter.d.ts.map +1 -1
  56. package/dist/Store/codeFilter.js +1 -1
  57. package/dist/Store/index.d.ts +3 -4
  58. package/dist/Store/index.d.ts.map +1 -1
  59. package/dist/Store/index.js +2 -3
  60. package/dist/Store/utils.d.ts +2 -2
  61. package/dist/Store/utils.d.ts.map +1 -1
  62. package/dist/Store/utils.js +1 -1
  63. package/dist/{api/codec.d.ts → codec.d.ts} +1 -1
  64. package/dist/codec.d.ts.map +1 -0
  65. package/dist/codec.js +5 -0
  66. package/dist/{adapters/cosmos-client.d.ts → cosmos-client.d.ts} +1 -1
  67. package/dist/cosmos-client.d.ts.map +1 -0
  68. package/dist/cosmos-client.js +11 -0
  69. package/dist/errorReporter.d.ts +1 -1
  70. package/dist/errorReporter.d.ts.map +1 -1
  71. package/dist/errorReporter.js +2 -2
  72. package/dist/index.d.ts +3 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +3 -2
  75. package/dist/{api/internal → internal}/RequestContextMiddleware.d.ts +2 -2
  76. package/dist/internal/RequestContextMiddleware.d.ts.map +1 -0
  77. package/dist/internal/RequestContextMiddleware.js +46 -0
  78. package/dist/{api/internal → internal}/auth.d.ts +1 -1
  79. package/dist/internal/auth.d.ts.map +1 -0
  80. package/dist/internal/auth.js +180 -0
  81. package/dist/{api/internal → internal}/events.d.ts +1 -1
  82. package/dist/internal/events.d.ts.map +1 -0
  83. package/dist/internal/events.js +49 -0
  84. package/dist/{api/internal → internal}/health.d.ts +1 -1
  85. package/dist/internal/health.d.ts.map +1 -0
  86. package/dist/internal/health.js +5 -0
  87. package/dist/layerUtils.d.ts +32 -0
  88. package/dist/layerUtils.d.ts.map +1 -0
  89. package/dist/layerUtils.js +17 -0
  90. package/dist/logger/jsonLogger.d.ts +1 -1
  91. package/dist/logger/jsonLogger.d.ts.map +1 -1
  92. package/dist/logger/jsonLogger.js +2 -2
  93. package/dist/logger/logFmtLogger.d.ts +1 -1
  94. package/dist/logger/logFmtLogger.d.ts.map +1 -1
  95. package/dist/logger/logFmtLogger.js +2 -2
  96. package/dist/logger/shared.d.ts +2 -2
  97. package/dist/logger/shared.d.ts.map +1 -1
  98. package/dist/logger/shared.js +2 -2
  99. package/dist/{adapters/memQueue.d.ts → memQueue.d.ts} +1 -1
  100. package/dist/memQueue.d.ts.map +1 -0
  101. package/dist/memQueue.js +21 -0
  102. package/dist/{api/middlewares.d.ts → middlewares.d.ts} +1 -1
  103. package/dist/middlewares.d.ts.map +1 -0
  104. package/dist/{api/middlewares.js → middlewares.js} +1 -1
  105. package/dist/{adapters/mongo-client.d.ts → mongo-client.d.ts} +1 -1
  106. package/dist/mongo-client.d.ts.map +1 -0
  107. package/dist/mongo-client.js +15 -0
  108. package/dist/{adapters/redis-client.d.ts → redis-client.d.ts} +1 -1
  109. package/dist/redis-client.d.ts.map +1 -0
  110. package/dist/redis-client.js +98 -0
  111. package/dist/reportError.d.ts +4 -0
  112. package/dist/reportError.d.ts.map +1 -0
  113. package/dist/reportError.js +28 -0
  114. package/dist/{api/routing → routing}/middleware/RouterMiddleware.d.ts +1 -1
  115. package/dist/routing/middleware/RouterMiddleware.d.ts.map +1 -0
  116. package/dist/{api/routing → routing}/middleware/RouterMiddleware.js +1 -1
  117. package/dist/{api/routing → routing}/middleware/middleware.d.ts +2 -2
  118. package/dist/routing/middleware/middleware.d.ts.map +1 -0
  119. package/dist/routing/middleware/middleware.js +128 -0
  120. package/dist/{api/routing → routing}/middleware.d.ts +1 -1
  121. package/dist/routing/middleware.d.ts.map +1 -0
  122. package/dist/{api/routing → routing}/middleware.js +1 -1
  123. package/dist/{api/routing → routing}/schema/jwt.d.ts +1 -1
  124. package/dist/routing/schema/jwt.d.ts.map +1 -0
  125. package/dist/routing/schema/jwt.js +13 -0
  126. package/dist/routing/tsort.d.ts +8 -0
  127. package/dist/routing/tsort.d.ts.map +1 -0
  128. package/dist/routing/tsort.js +51 -0
  129. package/dist/{api/routing → routing}/utils.d.ts +1 -1
  130. package/dist/routing/utils.d.ts.map +1 -0
  131. package/dist/routing/utils.js +45 -0
  132. package/dist/routing.d.ts +184 -0
  133. package/dist/routing.d.ts.map +1 -0
  134. package/dist/{api/routing.js → routing.js} +1 -1
  135. package/dist/{api/setupRequest.d.ts → setupRequest.d.ts} +2 -2
  136. package/dist/setupRequest.d.ts.map +1 -0
  137. package/dist/setupRequest.js +70 -0
  138. package/dist/{api/util.d.ts → util.d.ts} +1 -1
  139. package/dist/util.d.ts.map +1 -0
  140. package/dist/util.js +14 -0
  141. package/examples/query.ts +2 -2
  142. package/package.json +84 -200
  143. package/src/Emailer/Sendgrid.ts +20 -5
  144. package/src/Emailer/fake.ts +1 -1
  145. package/src/QueueMaker/SQLQueue.ts +3 -3
  146. package/src/QueueMaker/memQueue.ts +3 -3
  147. package/src/QueueMaker/sbqueue.ts +3 -3
  148. package/src/RequestFiberSet.ts +1 -1
  149. package/src/{adapters/SQL → SQL}/Model.ts +1 -1
  150. package/src/{adapters/ServiceBus.ts → ServiceBus.ts} +1 -1
  151. package/src/Store/ContextMapContainer.ts +1 -1
  152. package/src/Store/Cosmos/query.ts +3 -3
  153. package/src/Store/Cosmos.ts +4 -4
  154. package/src/Store/Disk.ts +2 -2
  155. package/src/Store/Memory.ts +4 -4
  156. package/src/Store/SQL/Pg.ts +3 -3
  157. package/src/Store/SQL/query.ts +2 -2
  158. package/src/Store/SQL.ts +3 -3
  159. package/src/Store/codeFilter.ts +3 -3
  160. package/src/Store/index.ts +2 -4
  161. package/src/Store/utils.ts +1 -1
  162. package/src/errorReporter.ts +1 -1
  163. package/src/index.ts +2 -1
  164. package/src/{api/internal → internal}/RequestContextMiddleware.ts +3 -3
  165. package/src/{api/internal → internal}/events.ts +2 -2
  166. package/src/{api/layerUtils.ts → layerUtils.ts} +1 -1
  167. package/src/logger/jsonLogger.ts +1 -1
  168. package/src/logger/logFmtLogger.ts +1 -1
  169. package/src/logger/shared.ts +1 -1
  170. package/src/{adapters/redis-client.ts → redis-client.ts} +1 -1
  171. package/src/{api/reportError.ts → reportError.ts} +1 -1
  172. package/src/{api/routing → routing}/middleware/middleware.ts +4 -4
  173. package/src/{api/setupRequest.ts → setupRequest.ts} +3 -3
  174. package/test/auth.test.ts +1 -1
  175. package/test/contextProvider.test.ts +1 -1
  176. package/test/controller.test.ts +3 -3
  177. package/test/cosmos-query.test.ts +1 -1
  178. package/test/dist/controller.test.d.ts.map +1 -1
  179. package/test/dist/query.test.d.ts.map +1 -1
  180. package/test/dist/rawQuery.test.d.ts.map +1 -1
  181. package/test/layerUtils.test.ts +1 -1
  182. package/test/query.test.ts +4 -4
  183. package/test/rawQuery.test.ts +4 -4
  184. package/test/repository-ext.test.ts +3 -3
  185. package/test/router-generator.test.ts +3 -3
  186. package/test/routing-interruptibility.test.ts +2 -2
  187. package/test/rpc-context-map-streaming.test.ts +3 -3
  188. package/test/rpc-e2e-invalidation.test.ts +2 -2
  189. package/test/rpc-multi-middleware.test.ts +1 -1
  190. package/test/rpc-stream-fullstack.test.ts +2 -2
  191. package/test/validateSample.test.ts +3 -3
  192. package/dist/Emailer/service.d.ts +0 -64
  193. package/dist/Emailer/service.d.ts.map +0 -1
  194. package/dist/Emailer/service.js +0 -7
  195. package/dist/Emailer.d.ts +0 -2
  196. package/dist/Emailer.d.ts.map +0 -1
  197. package/dist/Emailer.js +0 -2
  198. package/dist/Model/Repository/Registry.d.ts +0 -21
  199. package/dist/Model/Repository/Registry.d.ts.map +0 -1
  200. package/dist/Model/Repository/Registry.js +0 -18
  201. package/dist/Model/Repository/ext.d.ts +0 -60
  202. package/dist/Model/Repository/ext.d.ts.map +0 -1
  203. package/dist/Model/Repository/ext.js +0 -122
  204. package/dist/Model/Repository/internal/internal.d.ts +0 -62
  205. package/dist/Model/Repository/internal/internal.d.ts.map +0 -1
  206. package/dist/Model/Repository/internal/internal.js +0 -398
  207. package/dist/Model/Repository/legacy.d.ts +0 -21
  208. package/dist/Model/Repository/legacy.d.ts.map +0 -1
  209. package/dist/Model/Repository/legacy.js +0 -2
  210. package/dist/Model/Repository/makeRepo.d.ts +0 -53
  211. package/dist/Model/Repository/makeRepo.d.ts.map +0 -1
  212. package/dist/Model/Repository/makeRepo.js +0 -27
  213. package/dist/Model/Repository/service.d.ts +0 -97
  214. package/dist/Model/Repository/service.d.ts.map +0 -1
  215. package/dist/Model/Repository/service.js +0 -2
  216. package/dist/Model/Repository/validation.d.ts +0 -71
  217. package/dist/Model/Repository/validation.d.ts.map +0 -1
  218. package/dist/Model/Repository/validation.js +0 -32
  219. package/dist/Model/Repository.d.ts +0 -7
  220. package/dist/Model/Repository.d.ts.map +0 -1
  221. package/dist/Model/Repository.js +0 -7
  222. package/dist/Model/dsl.d.ts +0 -33
  223. package/dist/Model/dsl.d.ts.map +0 -1
  224. package/dist/Model/dsl.js +0 -43
  225. package/dist/Model/filter/filterApi.d.ts +0 -30
  226. package/dist/Model/filter/filterApi.d.ts.map +0 -1
  227. package/dist/Model/filter/filterApi.js +0 -2
  228. package/dist/Model/filter/types/errors.d.ts +0 -29
  229. package/dist/Model/filter/types/errors.d.ts.map +0 -1
  230. package/dist/Model/filter/types/errors.js +0 -2
  231. package/dist/Model/filter/types/fields.d.ts +0 -15
  232. package/dist/Model/filter/types/fields.d.ts.map +0 -1
  233. package/dist/Model/filter/types/fields.js +0 -2
  234. package/dist/Model/filter/types/path/common.d.ts +0 -316
  235. package/dist/Model/filter/types/path/common.d.ts.map +0 -1
  236. package/dist/Model/filter/types/path/common.js +0 -2
  237. package/dist/Model/filter/types/path/eager.d.ts +0 -95
  238. package/dist/Model/filter/types/path/eager.d.ts.map +0 -1
  239. package/dist/Model/filter/types/path/eager.js +0 -31
  240. package/dist/Model/filter/types/path/index.d.ts +0 -4
  241. package/dist/Model/filter/types/path/index.d.ts.map +0 -1
  242. package/dist/Model/filter/types/path/index.js +0 -3
  243. package/dist/Model/filter/types/utils.d.ts +0 -79
  244. package/dist/Model/filter/types/utils.d.ts.map +0 -1
  245. package/dist/Model/filter/types/utils.js +0 -2
  246. package/dist/Model/filter/types/validator.d.ts +0 -30
  247. package/dist/Model/filter/types/validator.d.ts.map +0 -1
  248. package/dist/Model/filter/types/validator.js +0 -2
  249. package/dist/Model/filter/types.d.ts +0 -5
  250. package/dist/Model/filter/types.d.ts.map +0 -1
  251. package/dist/Model/filter/types.js +0 -7
  252. package/dist/Model/query/dsl.d.ts +0 -446
  253. package/dist/Model/query/dsl.d.ts.map +0 -1
  254. package/dist/Model/query/dsl.js +0 -339
  255. package/dist/Model/query/new-kid-interpreter.d.ts +0 -136
  256. package/dist/Model/query/new-kid-interpreter.d.ts.map +0 -1
  257. package/dist/Model/query/new-kid-interpreter.js +0 -336
  258. package/dist/Model/query.d.ts +0 -15
  259. package/dist/Model/query.d.ts.map +0 -1
  260. package/dist/Model/query.js +0 -3
  261. package/dist/Model.d.ts +0 -5
  262. package/dist/Model.d.ts.map +0 -1
  263. package/dist/Model.js +0 -5
  264. package/dist/QueueMaker/service.d.ts +0 -13
  265. package/dist/QueueMaker/service.d.ts.map +0 -1
  266. package/dist/QueueMaker/service.js +0 -4
  267. package/dist/RequestContext.d.ts +0 -103
  268. package/dist/RequestContext.d.ts.map +0 -1
  269. package/dist/RequestContext.js +0 -49
  270. package/dist/Store/service.d.ts +0 -138
  271. package/dist/Store/service.d.ts.map +0 -1
  272. package/dist/Store/service.js +0 -95
  273. package/dist/Store.d.ts +0 -2
  274. package/dist/Store.d.ts.map +0 -1
  275. package/dist/Store.js +0 -2
  276. package/dist/adapters/SQL/Model.d.ts.map +0 -1
  277. package/dist/adapters/SQL/Model.js +0 -469
  278. package/dist/adapters/SQL.d.ts.map +0 -1
  279. package/dist/adapters/ServiceBus.d.ts.map +0 -1
  280. package/dist/adapters/ServiceBus.js +0 -108
  281. package/dist/adapters/cosmos-client.d.ts.map +0 -1
  282. package/dist/adapters/cosmos-client.js +0 -11
  283. package/dist/adapters/index.d.ts +0 -8
  284. package/dist/adapters/index.d.ts.map +0 -1
  285. package/dist/adapters/index.js +0 -8
  286. package/dist/adapters/logger.d.ts +0 -9
  287. package/dist/adapters/logger.d.ts.map +0 -1
  288. package/dist/adapters/logger.js +0 -3
  289. package/dist/adapters/memQueue.d.ts.map +0 -1
  290. package/dist/adapters/memQueue.js +0 -21
  291. package/dist/adapters/mongo-client.d.ts.map +0 -1
  292. package/dist/adapters/mongo-client.js +0 -15
  293. package/dist/adapters/redis-client.d.ts.map +0 -1
  294. package/dist/adapters/redis-client.js +0 -98
  295. package/dist/api/ContextProvider.d.ts +0 -34
  296. package/dist/api/ContextProvider.d.ts.map +0 -1
  297. package/dist/api/ContextProvider.js +0 -40
  298. package/dist/api/codec.d.ts.map +0 -1
  299. package/dist/api/codec.js +0 -5
  300. package/dist/api/internal/RequestContextMiddleware.d.ts.map +0 -1
  301. package/dist/api/internal/RequestContextMiddleware.js +0 -46
  302. package/dist/api/internal/auth.d.ts.map +0 -1
  303. package/dist/api/internal/auth.js +0 -180
  304. package/dist/api/internal/events.d.ts.map +0 -1
  305. package/dist/api/internal/events.js +0 -49
  306. package/dist/api/internal/health.d.ts.map +0 -1
  307. package/dist/api/internal/health.js +0 -5
  308. package/dist/api/layerUtils.d.ts +0 -32
  309. package/dist/api/layerUtils.d.ts.map +0 -1
  310. package/dist/api/layerUtils.js +0 -17
  311. package/dist/api/middlewares.d.ts.map +0 -1
  312. package/dist/api/reportError.d.ts +0 -4
  313. package/dist/api/reportError.d.ts.map +0 -1
  314. package/dist/api/reportError.js +0 -28
  315. package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +0 -1
  316. package/dist/api/routing/middleware/middleware.d.ts.map +0 -1
  317. package/dist/api/routing/middleware/middleware.js +0 -128
  318. package/dist/api/routing/middleware.d.ts.map +0 -1
  319. package/dist/api/routing/schema/jwt.d.ts.map +0 -1
  320. package/dist/api/routing/schema/jwt.js +0 -13
  321. package/dist/api/routing/tsort.d.ts +0 -8
  322. package/dist/api/routing/tsort.d.ts.map +0 -1
  323. package/dist/api/routing/tsort.js +0 -51
  324. package/dist/api/routing/utils.d.ts.map +0 -1
  325. package/dist/api/routing/utils.js +0 -45
  326. package/dist/api/routing.d.ts +0 -184
  327. package/dist/api/routing.d.ts.map +0 -1
  328. package/dist/api/setupRequest.d.ts.map +0 -1
  329. package/dist/api/setupRequest.js +0 -70
  330. package/dist/api/util.d.ts.map +0 -1
  331. package/dist/api/util.js +0 -14
  332. package/src/Emailer/service.ts +0 -62
  333. package/src/Emailer.ts +0 -1
  334. package/src/Model/Repository/Registry.ts +0 -34
  335. package/src/Model/Repository/ext.ts +0 -375
  336. package/src/Model/Repository/internal/internal.ts +0 -692
  337. package/src/Model/Repository/legacy.ts +0 -29
  338. package/src/Model/Repository/makeRepo.ts +0 -144
  339. package/src/Model/Repository/service.ts +0 -639
  340. package/src/Model/Repository/validation.ts +0 -31
  341. package/src/Model/Repository.ts +0 -6
  342. package/src/Model/dsl.ts +0 -129
  343. package/src/Model/filter/filterApi.ts +0 -60
  344. package/src/Model/filter/types/errors.ts +0 -47
  345. package/src/Model/filter/types/fields.ts +0 -50
  346. package/src/Model/filter/types/path/common.ts +0 -404
  347. package/src/Model/filter/types/path/eager.ts +0 -297
  348. package/src/Model/filter/types/path/index.ts +0 -4
  349. package/src/Model/filter/types/utils.ts +0 -128
  350. package/src/Model/filter/types/validator.ts +0 -46
  351. package/src/Model/filter/types.ts +0 -6
  352. package/src/Model/query/dsl.ts +0 -2546
  353. package/src/Model/query/new-kid-interpreter.ts +0 -484
  354. package/src/Model/query.ts +0 -13
  355. package/src/Model.ts +0 -4
  356. package/src/QueueMaker/service.ts +0 -19
  357. package/src/RequestContext.ts +0 -62
  358. package/src/Store/service.ts +0 -233
  359. package/src/Store.ts +0 -1
  360. package/src/adapters/index.ts +0 -7
  361. package/src/adapters/logger.ts +0 -3
  362. /package/src/{api/ContextProvider.ts → ContextProvider.ts} +0 -0
  363. /package/src/{adapters/SQL.ts → SQL.ts} +0 -0
  364. /package/src/{api/codec.ts → codec.ts} +0 -0
  365. /package/src/{adapters/cosmos-client.ts → cosmos-client.ts} +0 -0
  366. /package/src/{api/internal → internal}/auth.ts +0 -0
  367. /package/src/{api/internal → internal}/health.ts +0 -0
  368. /package/src/{adapters/memQueue.ts → memQueue.ts} +0 -0
  369. /package/src/{api/middlewares.ts → middlewares.ts} +0 -0
  370. /package/src/{adapters/mongo-client.ts → mongo-client.ts} +0 -0
  371. /package/src/{api/routing → routing}/middleware/RouterMiddleware.ts +0 -0
  372. /package/src/{api/routing → routing}/middleware.ts +0 -0
  373. /package/src/{api/routing → routing}/schema/jwt.ts +0 -0
  374. /package/src/{api/routing → routing}/tsort.ts +0 -0
  375. /package/src/{api/routing → routing}/utils.ts +0 -0
  376. /package/src/{api/routing.ts → routing.ts} +0 -0
  377. /package/src/{api/util.ts → util.ts} +0 -0
package/src/Model/dsl.ts DELETED
@@ -1,129 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { NonEmptyReadonlyArray } from "effect-app/Array"
3
- import { toNonEmptyArray } from "effect-app/Array"
4
- import * as Effect from "effect-app/Effect"
5
- import { type FixEnv, get, logMany, type Pure, type PureEnvEnv, type PureLogT, set } from "effect-app/Pure"
6
-
7
- export interface PureDSL<S, S2, W> {
8
- get: Pure<never, S, S, never, never, S>
9
- set: (s: S2) => Pure<never, S2, S2, never, never, void>
10
- log: (...w: W[]) => PureLogT<W>
11
- }
12
-
13
- export const AnyPureDSL: PureDSL<any, any, any> = {
14
- get: get(),
15
- set: set as any,
16
- log: (...evt: any[]) => logMany(evt)
17
- }
18
-
19
- const anyDSL = makeDSL<any, any, any>()
20
-
21
- export type AllDSL<T, Evt> =
22
- & (<R, A, E, S1 extends T, S2 extends T>(
23
- pure: (dsl: PureDSL<S1[], S2[], Evt>) => Effect.Effect<A, E, R>
24
- ) => Effect.Effect<A, E, FixEnv<R, Evt, S1[], S2[]>>)
25
- & AllDSLExt<T, Evt>
26
-
27
- export interface AllDSLExt<T, Evt> {
28
- modify: <R, E, A, S1 extends T, S2 extends T>(
29
- pure: (items: readonly S1[], dsl: PureDSL<readonly S1[], readonly S2[], Evt>) => Effect.Effect<A, E, R>
30
- ) => Effect.Effect<A, E, FixEnv<R, Evt, readonly S1[], readonly S2[]>>
31
- update: <R, E, S1 extends T, S2 extends T>(
32
- pure: (items: readonly S1[], log: (...evt: Evt[]) => PureLogT<Evt>) => Effect.Effect<readonly S2[], E, R>
33
- ) => Effect.Effect<readonly S2[], E, FixEnv<R, Evt, readonly S1[], readonly S2[]>>
34
- updateWith: <S1 extends T, S2 extends T>(
35
- upd: (item: readonly S1[]) => readonly S2[]
36
- ) => Effect.Effect<readonly S2[], never, PureEnvEnv<Evt, readonly S1[], readonly S2[]>>
37
- }
38
-
39
- export function makeAllDSL<T, Evt>() {
40
- const dsl: AllDSL<T, Evt> = anyDSL
41
- return dsl
42
- }
43
-
44
- export type OneDSL<T, Evt> =
45
- & (<R, A, E, S1 extends T, S2 extends T>(
46
- pure: (dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
47
- ) => Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>>)
48
- & OneDSLExt<T, Evt>
49
-
50
- export interface OneDSLExt<T, Evt> {
51
- modify: <R, E, A, S1 extends T, S2 extends T>(
52
- pure: (items: S1, dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
53
- ) => Effect.Effect<A, E, FixEnv<R, Evt, S1, S2> | PureEnvEnv<Evt, S1, S1>>
54
- update: <R, E, S1 extends T, S2 extends T>(
55
- pure: (items: S1, log: (...evt: Evt[]) => PureLogT<Evt>) => Effect.Effect<S2, E, R>
56
- ) => Effect.Effect<S2, E, FixEnv<R, Evt, S1, S2>>
57
- updateWith: <S1 extends T, S2 extends T>(
58
- upd: (item: S1) => S2
59
- ) => Effect.Effect<S2, never, PureEnvEnv<Evt, S1, S2>>
60
- }
61
-
62
- export function makeOneDSL<T, Evt>(): OneDSL<T, Evt> {
63
- return anyDSL
64
- }
65
-
66
- export function makeDSL<S1, S2, Evt>() {
67
- const dsl: PureDSL<S1, S2, Evt> = AnyPureDSL
68
-
69
- function modify<
70
- R,
71
- E,
72
- A
73
- >(
74
- pure: (
75
- items: S1,
76
- dsl: PureDSL<S1, S2, Evt>
77
- ) => Effect.Effect<A, E, R>
78
- ): Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>> {
79
- return dsl.get.pipe(Effect.flatMap((items) => pure(items, dsl))) as any
80
- }
81
-
82
- function update<
83
- R,
84
- E
85
- >(
86
- pure: (
87
- items: S1,
88
- log: (...evt: Evt[]) => PureLogT<Evt>
89
- ) => Effect.Effect<S2, E, R>
90
- ): Effect.Effect<S2, E, FixEnv<R, Evt, S1, S2>> {
91
- return dsl.get.pipe(Effect.flatMap((items) => pure(items, dsl.log).pipe(Effect.tap(dsl.set)))) as any
92
- }
93
-
94
- function withDSL<
95
- R,
96
- A,
97
- E
98
- >(
99
- pure: (dsl: PureDSL<S1, S2, Evt>) => Effect.Effect<A, E, R>
100
- ): Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>> {
101
- return pure(AnyPureDSL) as any
102
- }
103
-
104
- function updateWith(upd: (item: S1) => S2) {
105
- return update((_: S1) => Effect.sync(() => upd(_)))
106
- }
107
-
108
- return Object.assign(
109
- withDSL,
110
- {
111
- modify,
112
- update,
113
- updateWith
114
- }
115
- )
116
- }
117
-
118
- export interface DSLExt<S1, S2, Evt> extends ReturnType<typeof makeDSL<S1, S2, Evt>> {}
119
-
120
- export function ifAny<T, R, E, A>(fn: (items: NonEmptyReadonlyArray<T>) => Effect.Effect<A, E, R>) {
121
- return (items: Iterable<T>) => Effect.flatMapOption(Effect.sync(() => toNonEmptyArray([...items])), fn)
122
- }
123
-
124
- export function ifAny_<T, R, E, A>(
125
- items: Iterable<T>,
126
- fn: (items: NonEmptyReadonlyArray<T>) => Effect.Effect<A, E, R>
127
- ) {
128
- return Effect.flatMapOption(Effect.sync(() => toNonEmptyArray([...items])), fn)
129
- }
@@ -1,60 +0,0 @@
1
- import { type RelationDirection } from "../query.js"
2
-
3
- export type InOps =
4
- | "in"
5
- | "notIn"
6
-
7
- export type OtherOps =
8
- | "endsWith"
9
- | "startsWith"
10
- | "notEndsWith"
11
- | "notStartsWith"
12
- | "contains"
13
- | "notContains"
14
- | "includes"
15
- | "notIncludes"
16
- | "includes-any"
17
- | "notIncludes-any"
18
- | "includes-all"
19
- | "notIncludes-all"
20
- | "eq"
21
- | "neq"
22
- | "gt"
23
- | "gte"
24
- | "lt"
25
- | "lte"
26
-
27
- export type Ops = OtherOps | InOps
28
-
29
- export type FilterScopes = {
30
- t: "or-scope"
31
- result: readonly FilterResult[]
32
- relation: RelationDirection
33
- } | {
34
- t: "and-scope"
35
- result: readonly FilterResult[]
36
- relation: RelationDirection
37
- } | {
38
- t: "where-scope"
39
- result: readonly FilterResult[]
40
- relation: RelationDirection
41
- }
42
-
43
- export type FilterR = {
44
- op: Ops
45
-
46
- path: string
47
- value: string // ToDO: Value[]
48
- }
49
-
50
- export type FilterResult =
51
- | {
52
- t: "where"
53
- } & FilterR
54
- | {
55
- t: "or"
56
- } & FilterR
57
- | {
58
- t: "and"
59
- } & FilterR
60
- | FilterScopes
@@ -1,47 +0,0 @@
1
- import type { FieldValues, InternalFieldName } from "./fields.js"
2
- import type { BrowserNativeObject, IsAny, LiteralUnion, Merge } from "./utils.js"
3
- import type { RegisterOptions, ValidateResult } from "./validator.js"
4
-
5
- export type Message = string
6
-
7
- export type MultipleFieldErrors =
8
- & {
9
- [K in keyof RegisterOptions]?: ValidateResult
10
- }
11
- & {
12
- [key: string]: ValidateResult
13
- }
14
-
15
- export type FieldError = {
16
- type: LiteralUnion<keyof RegisterOptions, string>
17
- root?: FieldError
18
- // ref?: Ref
19
- types?: MultipleFieldErrors
20
- message?: Message
21
- }
22
-
23
- export type ErrorOption = {
24
- message?: Message
25
- type?: LiteralUnion<keyof RegisterOptions, string>
26
- types?: MultipleFieldErrors
27
- }
28
-
29
- export type DeepRequired<T> = T extends BrowserNativeObject | Blob ? T
30
- : {
31
- [K in keyof T]-?: NonNullable<DeepRequired<T[K]>>
32
- }
33
-
34
- export type FieldErrorsImpl<T extends FieldValues = FieldValues> = {
35
- [K in keyof T]?: T[K] extends BrowserNativeObject | Blob ? FieldError
36
- : T[K] extends object ? Merge<FieldError, FieldErrorsImpl<T[K]>>
37
- : FieldError
38
- }
39
-
40
- export type FieldErrors<T extends FieldValues = FieldValues> = Partial<
41
- FieldValues extends IsAny<FieldValues> ? any
42
- : FieldErrorsImpl<DeepRequired<T>>
43
- >
44
-
45
- export type InternalFieldErrors = Partial<
46
- Record<InternalFieldName, FieldError>
47
- >
@@ -1,50 +0,0 @@
1
- import type { IsFlatObject } from "./utils.js"
2
- import type { RegisterOptions } from "./validator.js"
3
-
4
- export type InternalFieldName = string
5
-
6
- export type FieldName<TFieldValues extends FieldValues> = IsFlatObject<TFieldValues> extends true
7
- ? Extract<keyof TFieldValues, string>
8
- : string
9
-
10
- // export type CustomElement<TFieldValues extends FieldValues> = {
11
- // name: FieldName<TFieldValues>
12
- // type?: string
13
- // value?: any
14
- // disabled?: boolean
15
- // checked?: boolean
16
- // options?: HTMLOptionsCollection
17
- // files?: FileList | null
18
- // focus?: Noop
19
- // }
20
-
21
- export type FieldValue<TFieldValues extends FieldValues> = TFieldValues[InternalFieldName]
22
-
23
- export type FieldValues = Record<string, any>
24
-
25
- export type NativeFieldValue =
26
- | string
27
- | number
28
- | boolean
29
- | null
30
- | undefined
31
- | unknown[]
32
-
33
- // export type FieldElement<TFieldValues extends FieldValues = FieldValues> =
34
- // | HTMLInputElement
35
- // | HTMLSelectElement
36
- // | HTMLTextAreaElement
37
- // | CustomElement<TFieldValues>
38
-
39
- // export type Ref = FieldElement
40
-
41
- export type Field = {
42
- _f: {
43
- // ref: Ref
44
- name: InternalFieldName
45
- // refs?: HTMLInputElement[]
46
- mount?: boolean
47
- } & RegisterOptions
48
- }
49
-
50
- export type FieldRefs = Partial<Record<InternalFieldName, Field>>
@@ -1,404 +0,0 @@
1
- import type { IsAny, IsNever } from "../utils.js"
2
-
3
- /**
4
- * Type alias to `string` which describes a lodash-like path through an object.
5
- * E.g. `'foo.bar.0.baz'`
6
- */
7
- export type PathString = string
8
-
9
- /**
10
- * Type which can be traversed through with a {@link PathString}.
11
- * I.e. objects, arrays, and tuples
12
- */
13
- export type Traversable = object
14
-
15
- /**
16
- * Type to query whether an array type T is a tuple type.
17
- * @typeParam T - type which may be an array or tuple
18
- * @example
19
- * ```
20
- * IsTuple<[number]> = true
21
- * IsTuple<number[]> = false
22
- * ```
23
- */
24
- export type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"] ? false
25
- : true
26
-
27
- /**
28
- * Type which can be used to index an array or tuple type.
29
- */
30
- export type ArrayKey = number
31
-
32
- /**
33
- * Type which can be used to index an object.
34
- */
35
- export type Key = string
36
-
37
- /**
38
- * Type to assert that a type is a {@link Key}.
39
- * @typeParam T - type which may be a {@link Key}
40
- */
41
- export type AsKey<T> = Extract<T, Key>
42
-
43
- /**
44
- * Type to convert a type to a {@link Key}.
45
- * @typeParam T - type which may be converted to a {@link Key}
46
- */
47
- export type ToKey<T> = T extends ArrayKey ? `${T}` : AsKey<T>
48
-
49
- /**
50
- * Type which describes a path through an object
51
- * as a list of individual {@link Key}s.
52
- */
53
- export type PathTuple = Key[]
54
-
55
- /**
56
- * Type to assert that a type is a {@link PathTuple}.
57
- * @typeParam T - type which may be a {@link PathTuple}
58
- */
59
- export type AsPathTuple<T> = Extract<T, PathTuple>
60
-
61
- /**
62
- * Type to intersect a union type.
63
- * See https://fettblog.eu/typescript-union-to-intersection/
64
- * @typeParam U - union
65
- * @example
66
- * ```
67
- * UnionToIntersection<{ foo: string } | { bar: number }>
68
- * = { foo: string; bar: number }
69
- * ```
70
- */
71
- export type UnionToIntersection<U> = (
72
- U extends any ? (_: U) => any : never
73
- ) extends (_: infer I) => any ? I
74
- : never
75
-
76
- /**
77
- * Type which appends a {@link Key} to the {@link PathTuple} only if it is not
78
- * blank, i.e. not the empty string.
79
- * @typeParam PT - path
80
- * @typeParam K - key
81
- * @example
82
- * ```
83
- * AppendNonBlankKey<['foo'], 'bar'> = ['foo', 'bar']
84
- * AppendNonBlankKey<['foo'], ''> = ['foo']
85
- * ```
86
- */
87
- type AppendNonBlankKey<PT extends PathTuple, K extends Key> = K extends "" ? PT
88
- : [...PT, K]
89
-
90
- /**
91
- * Type to implement {@link SplitPathString} tail recursively.
92
- * @typeParam PS - remaining {@link PathString} which should be split into its
93
- * individual {@link Key}s
94
- * @typeParam PT - accumulator of the {@link Key}s which have been split from
95
- * the original {@link PathString} already
96
- */
97
- type SplitPathStringImpl<
98
- PS extends PathString,
99
- PT extends PathTuple
100
- > = PS extends `${infer K}.${infer R}` ? SplitPathStringImpl<R, AppendNonBlankKey<PT, K>>
101
- : AppendNonBlankKey<PT, PS>
102
-
103
- /**
104
- * Type to split a {@link PathString} into a {@link PathTuple}.
105
- * The individual {@link Key}s may be empty strings.
106
- * @typeParam PS - {@link PathString} which should be split into its
107
- * individual {@link Key}s
108
- * @example
109
- * ```
110
- * SplitPathString<'foo'> = ['foo']
111
- * SplitPathString<'foo.bar.0.baz'> = ['foo', 'bar', '0', 'baz']
112
- * SplitPathString<'.'> = []
113
- * ```
114
- */
115
- export type SplitPathString<PS extends PathString> = SplitPathStringImpl<
116
- PS,
117
- []
118
- >
119
-
120
- /**
121
- * Type to implement {@link JoinPathTuple} tail-recursively.
122
- * @typeParam PT - remaining {@link Key}s which needs to be joined
123
- * @typeParam PS - accumulator of the already joined {@link Key}s
124
- */
125
- type JoinPathTupleImpl<
126
- PT extends PathTuple,
127
- PS extends PathString
128
- > = PT extends [infer K, ...infer R] ? JoinPathTupleImpl<AsPathTuple<R>, `${PS}.${AsKey<K>}`>
129
- : PS
130
-
131
- /**
132
- * Type to join a {@link PathTuple} to a {@link PathString}.
133
- * @typeParam PT - {@link PathTuple} which should be joined.
134
- * @example
135
- * ```
136
- * JoinPathTuple<['foo']> = 'foo'
137
- * JoinPathTuple<['foo', 'bar', '0', 'baz']> = 'foo.bar.0.baz'
138
- * JoinPathTuple<[]> = never
139
- * ```
140
- */
141
- export type JoinPathTuple<PT extends PathTuple> = PT extends [
142
- infer K,
143
- ...infer R
144
- ] ? JoinPathTupleImpl<AsPathTuple<R>, AsKey<K>>
145
- : never
146
-
147
- /**
148
- * Type which converts all keys of an object to {@link Key}s.
149
- * @typeParam T - object type
150
- * @example
151
- * ```
152
- * MapKeys<{0: string}> = {'0': string}
153
- * ```
154
- */
155
- type MapKeys<T> = { [K in keyof T as ToKey<K>]: T[K] }
156
-
157
- /**
158
- * Type to access a type by a key.
159
- * - Returns undefined if it can't be indexed by that key.
160
- * - Returns null if the type is null.
161
- * - Returns undefined if the type is not traversable.
162
- * @typeParam T - type which is indexed by the key
163
- * @typeParam K - key into the type
164
- * ```
165
- * TryAccess<{foo: string}, 'foo'> = string
166
- * TryAccess<{foo: string}, 'bar'> = undefined
167
- * TryAccess<null, 'foo'> = null
168
- * TryAccess<string, 'foo'> = undefined
169
- * ```
170
- */
171
- type TryAccess<T, K> = K extends keyof T ? T[K]
172
- : T extends null ? null
173
- : undefined
174
-
175
- /**
176
- * Type to access an array type by a key.
177
- * Returns undefined if the key is non-numeric.
178
- * @typeParam T - type which is indexed by the key
179
- * @typeParam K - key into the type
180
- * ```
181
- * TryAccessArray<string[], '0'> = string
182
- * TryAccessArray<string[], 'foo'> = undefined
183
- * ```
184
- */
185
- type TryAccessArray<
186
- T extends ReadonlyArray<any>,
187
- K extends Key
188
- > = K extends `${ArrayKey}` ? T[number] : TryAccess<T, K>
189
-
190
- /**
191
- * Type to evaluate the type which the given key points to.
192
- * @typeParam T - type which is indexed by the key
193
- * @typeParam K - key into the type
194
- * @example
195
- * ```
196
- * EvaluateKey<{foo: string}, 'foo'> = string
197
- * EvaluateKey<[number, string], '1'> = string
198
- * EvaluateKey<string[], '1'> = string
199
- * ```
200
- */
201
- export type EvaluateKey<T, K extends Key> = T extends ReadonlyArray<any> ? IsTuple<T> extends true ? TryAccess<T, K>
202
- : TryAccessArray<T, K>
203
- : TryAccess<MapKeys<T>, K>
204
-
205
- /**
206
- * Type to evaluate the type which the given path points to.
207
- * @typeParam T - deeply nested type which is indexed by the path
208
- * @typeParam PT - path into the deeply nested type
209
- * @example
210
- * ```
211
- * EvaluatePath<{foo: {bar: string}}, ['foo', 'bar']> = string
212
- * EvaluatePath<[number, string], ['1']> = string
213
- * EvaluatePath<number, []> = number
214
- * EvaluatePath<number, ['foo']> = undefined
215
- * ```
216
- */
217
- export type EvaluatePath<T, PT extends PathTuple> = PT extends [
218
- infer K,
219
- ...infer R
220
- ] ? EvaluatePath<EvaluateKey<T, AsKey<K>>, AsPathTuple<R>>
221
- : T
222
-
223
- /**
224
- * Type which given a tuple type returns its own keys, i.e. only its indices.
225
- * @typeParam T - tuple type
226
- * @example
227
- * ```
228
- * TupleKeys<[number, string]> = '0' | '1'
229
- * ```
230
- */
231
- export type TupleKeys<T extends ReadonlyArray<any>> = Exclude<
232
- keyof T,
233
- keyof any[]
234
- >
235
-
236
- /**
237
- * Type which extracts all numeric keys from an object.
238
- * @typeParam T - type
239
- * @example
240
- * ```
241
- * NumericObjectKeys<{0: string, '1': string, foo: string}> = '0' | '1'
242
- * ```
243
- */
244
- type NumericObjectKeys<T extends Traversable> = ToKey<
245
- Extract<keyof T, ArrayKey | `${ArrayKey}`>
246
- >
247
-
248
- /**
249
- * Type which extracts all numeric keys from an object, tuple, or array.
250
- * If a union is passed, it evaluates to the overlapping numeric keys.
251
- * @typeParam T - type
252
- * @example
253
- * ```
254
- * NumericKeys<{0: string, '1': string, foo: string}> = '0' | '1'
255
- * NumericKeys<number[]> = `${number}`
256
- * NumericKeys<[string, number]> = '0' | '1'
257
- * NumericKeys<{0: string, '1': string} | [number] | number[]> = '0'
258
- * ```
259
- */
260
- export type NumericKeys<T extends Traversable> = UnionToIntersection<
261
- T extends ReadonlyArray<any> ? IsTuple<T> extends true ? [TupleKeys<T>]
262
- : [ToKey<ArrayKey>]
263
- : [NumericObjectKeys<T>]
264
- >[never]
265
-
266
- /**
267
- * Type which extracts all keys from an object.
268
- * If a union is passed, it evaluates to the overlapping keys.
269
- * @typeParam T - object type
270
- * @example
271
- * ```
272
- * ObjectKeys<{foo: string, bar: string}, string> = 'foo' | 'bar'
273
- * ObjectKeys<{foo: string, bar: number}, string> = 'foo'
274
- * ```
275
- */
276
- export type ObjectKeys<T extends Traversable> = Exclude<
277
- ToKey<keyof T>,
278
- `${string}.${string}` | ""
279
- >
280
-
281
- /**
282
- * Type to check whether a type's property matches the constraint type
283
- * and return its key. Converts the key to a {@link Key}.
284
- * @typeParam T - type whose property should be checked
285
- * @typeParam K - key of the property
286
- * @typeParam U - constraint type
287
- * @example
288
- * ```
289
- * CheckKeyConstraint<{foo: string}, 'foo', string> = 'foo'
290
- * CheckKeyConstraint<{foo: string}, 'foo', number> = never
291
- * CheckKeyConstraint<string[], number, string> = `${number}`
292
- * ```
293
- */
294
- export type CheckKeyConstraint<T, K extends Key, U> = K extends any ? EvaluateKey<T, K> extends U ? K
295
- : never
296
- : never
297
-
298
- /**
299
- * Type which evaluates to true when the type is an array or tuple or is a union
300
- * which contains an array or tuple.
301
- * @typeParam T - type
302
- * @example
303
- * ```
304
- * ContainsIndexable<{foo: string}> = false
305
- * ContainsIndexable<{foo: string} | number[]> = true
306
- * ```
307
- */
308
- export type ContainsIndexable<T> = IsNever<
309
- Extract<T, ReadonlyArray<any>>
310
- > extends true ? false
311
- : true
312
-
313
- /**
314
- * Type to implement {@link Keys} for non-nullable values.
315
- * @typeParam T - non-nullable type whose property should be checked
316
- */
317
- type KeysImpl<T> = [T] extends [Traversable] ? ContainsIndexable<T> extends true ? NumericKeys<T>
318
- : ObjectKeys<T>
319
- : never
320
-
321
- /**
322
- * Type to find all properties of a type that match the constraint type
323
- * and return their keys.
324
- * If a union is passed, it evaluates to the overlapping keys.
325
- * @typeParam T - type whose property should be checked
326
- * @typeParam U - constraint type
327
- * @example
328
- * ```
329
- * Keys<{foo: string, bar: string}, string> = 'foo' | 'bar'
330
- * Keys<{foo?: string, bar?: string}> = 'foo' | 'bar'
331
- * Keys<{foo: string, bar: number}, string> = 'foo'
332
- * Keys<[string, number], string> = '0'
333
- * Keys<string[], string> = `${number}`
334
- * Keys<{0: string, '1': string} | [number] | number[]> = '0'
335
- * ```
336
- */
337
- export type Keys<T, U = unknown> = IsAny<T> extends true ? Key
338
- : IsNever<T> extends true ? Key
339
- : IsNever<NonNullable<T>> extends true ? never
340
- : CheckKeyConstraint<T, KeysImpl<NonNullable<T>>, U>
341
-
342
- /**
343
- * Type to check whether a {@link Key} is present in a type.
344
- * If a union of {@link Key}s is passed, all {@link Key}s have to be present
345
- * in the type.
346
- * @typeParam T - type which is introspected
347
- * @typeParam K - key
348
- * @example
349
- * ```
350
- * HasKey<{foo: string}, 'foo'> = true
351
- * HasKey<{foo: string}, 'bar'> = false
352
- * HasKey<{foo: string}, 'foo' | 'bar'> = false
353
- * ```
354
- */
355
- export type HasKey<T, K extends Key> = IsNever<Exclude<K, Keys<T>>>
356
-
357
- /**
358
- * Type to implement {@link ValidPathPrefix} tail recursively.
359
- * @typeParam T - type which the path should be checked against
360
- * @typeParam PT - path which should exist within the given type
361
- * @typeParam VPT - accumulates the prefix of {@link Key}s which have been
362
- * confirmed to exist already
363
- */
364
- type ValidPathPrefixImpl<
365
- T,
366
- PT extends PathTuple,
367
- VPT extends PathTuple
368
- > = PT extends [infer K, ...infer R] ? HasKey<T, AsKey<K>> extends true ? ValidPathPrefixImpl<
369
- EvaluateKey<T, AsKey<K>>,
370
- AsPathTuple<R>,
371
- AsPathTuple<[...VPT, K]>
372
- >
373
- : VPT
374
- : VPT
375
-
376
- /**
377
- * Type to find the longest path prefix which is still valid,
378
- * i.e. exists within the given type.
379
- * @typeParam T - type which the path should be checked against
380
- * @typeParam PT - path which should exist within the given type
381
- * @example
382
- * ```
383
- * ValidPathPrefix<{foo: {bar: string}}, ['foo', 'bar']> = ['foo', 'bar']
384
- * ValidPathPrefix<{foo: {bar: string}}, ['foo', 'ba']> = ['foo']
385
- * ```
386
- */
387
- export type ValidPathPrefix<T, PT extends PathTuple> = ValidPathPrefixImpl<
388
- T,
389
- PT,
390
- []
391
- >
392
-
393
- /**
394
- * Type to check whether a path through a type exists.
395
- * @typeParam T - type which the path should be checked against
396
- * @typeParam PT - path which should exist within the given type
397
- * @example
398
- * ```
399
- * HasPath<{foo: {bar: string}}, ['foo', 'bar']> = true
400
- * HasPath<{foo: {bar: string}}, ['foo', 'ba']> = false
401
- * ```
402
- */
403
- export type HasPath<T, PT extends PathTuple> = ValidPathPrefix<T, PT> extends PT ? true
404
- : false