bupkis 0.18.1 → 0.18.2

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 (376) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -4
  3. package/src/assertion/assertion-types.ts +4 -4
  4. package/src/assertion/impl/sync-parametric.ts +1 -1
  5. package/src/expect.ts +0 -4
  6. package/src/guards.ts +24 -24
  7. package/src/internal-schema.ts +16 -32
  8. package/src/value-to-schema.ts +1 -1
  9. package/dist/assertion/assertion-async.cjs +0 -268
  10. package/dist/assertion/assertion-async.cjs.map +0 -1
  11. package/dist/assertion/assertion-async.d.cts +0 -40
  12. package/dist/assertion/assertion-async.d.cts.map +0 -1
  13. package/dist/assertion/assertion-async.d.ts +0 -40
  14. package/dist/assertion/assertion-async.d.ts.map +0 -1
  15. package/dist/assertion/assertion-async.js +0 -259
  16. package/dist/assertion/assertion-async.js.map +0 -1
  17. package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
  18. package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
  19. package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
  20. package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
  21. package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
  22. package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
  23. package/dist/assertion/assertion-standard-schema-async.js +0 -128
  24. package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
  25. package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
  26. package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
  27. package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
  28. package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
  29. package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
  30. package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
  31. package/dist/assertion/assertion-standard-schema-sync.js +0 -137
  32. package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
  33. package/dist/assertion/assertion-sync.cjs +0 -284
  34. package/dist/assertion/assertion-sync.cjs.map +0 -1
  35. package/dist/assertion/assertion-sync.d.cts +0 -60
  36. package/dist/assertion/assertion-sync.d.cts.map +0 -1
  37. package/dist/assertion/assertion-sync.d.ts +0 -60
  38. package/dist/assertion/assertion-sync.d.ts.map +0 -1
  39. package/dist/assertion/assertion-sync.js +0 -275
  40. package/dist/assertion/assertion-sync.js.map +0 -1
  41. package/dist/assertion/assertion-types.cjs +0 -20
  42. package/dist/assertion/assertion-types.cjs.map +0 -1
  43. package/dist/assertion/assertion-types.d.cts +0 -1086
  44. package/dist/assertion/assertion-types.d.cts.map +0 -1
  45. package/dist/assertion/assertion-types.d.ts +0 -1086
  46. package/dist/assertion/assertion-types.d.ts.map +0 -1
  47. package/dist/assertion/assertion-types.js +0 -19
  48. package/dist/assertion/assertion-types.js.map +0 -1
  49. package/dist/assertion/assertion.cjs +0 -382
  50. package/dist/assertion/assertion.cjs.map +0 -1
  51. package/dist/assertion/assertion.d.cts +0 -109
  52. package/dist/assertion/assertion.d.cts.map +0 -1
  53. package/dist/assertion/assertion.d.ts +0 -109
  54. package/dist/assertion/assertion.d.ts.map +0 -1
  55. package/dist/assertion/assertion.js +0 -375
  56. package/dist/assertion/assertion.js.map +0 -1
  57. package/dist/assertion/create.cjs +0 -148
  58. package/dist/assertion/create.cjs.map +0 -1
  59. package/dist/assertion/create.d.cts +0 -85
  60. package/dist/assertion/create.d.cts.map +0 -1
  61. package/dist/assertion/create.d.ts +0 -85
  62. package/dist/assertion/create.d.ts.map +0 -1
  63. package/dist/assertion/create.js +0 -143
  64. package/dist/assertion/create.js.map +0 -1
  65. package/dist/assertion/format-assertion-failure.cjs +0 -63
  66. package/dist/assertion/format-assertion-failure.cjs.map +0 -1
  67. package/dist/assertion/format-assertion-failure.d.cts +0 -21
  68. package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
  69. package/dist/assertion/format-assertion-failure.d.ts +0 -21
  70. package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
  71. package/dist/assertion/format-assertion-failure.js +0 -59
  72. package/dist/assertion/format-assertion-failure.js.map +0 -1
  73. package/dist/assertion/impl/assertion-util.cjs +0 -68
  74. package/dist/assertion/impl/assertion-util.cjs.map +0 -1
  75. package/dist/assertion/impl/assertion-util.d.cts +0 -36
  76. package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
  77. package/dist/assertion/impl/assertion-util.d.ts +0 -36
  78. package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
  79. package/dist/assertion/impl/assertion-util.js +0 -62
  80. package/dist/assertion/impl/assertion-util.js.map +0 -1
  81. package/dist/assertion/impl/async-iterable.cjs +0 -627
  82. package/dist/assertion/impl/async-iterable.cjs.map +0 -1
  83. package/dist/assertion/impl/async-iterable.d.cts +0 -406
  84. package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
  85. package/dist/assertion/impl/async-iterable.d.ts +0 -406
  86. package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
  87. package/dist/assertion/impl/async-iterable.js +0 -624
  88. package/dist/assertion/impl/async-iterable.js.map +0 -1
  89. package/dist/assertion/impl/async-parametric.cjs +0 -412
  90. package/dist/assertion/impl/async-parametric.cjs.map +0 -1
  91. package/dist/assertion/impl/async-parametric.d.cts +0 -278
  92. package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
  93. package/dist/assertion/impl/async-parametric.d.ts +0 -278
  94. package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
  95. package/dist/assertion/impl/async-parametric.js +0 -409
  96. package/dist/assertion/impl/async-parametric.js.map +0 -1
  97. package/dist/assertion/impl/async.cjs +0 -56
  98. package/dist/assertion/impl/async.cjs.map +0 -1
  99. package/dist/assertion/impl/async.d.cts +0 -179
  100. package/dist/assertion/impl/async.d.cts.map +0 -1
  101. package/dist/assertion/impl/async.d.ts +0 -179
  102. package/dist/assertion/impl/async.d.ts.map +0 -1
  103. package/dist/assertion/impl/async.js +0 -39
  104. package/dist/assertion/impl/async.js.map +0 -1
  105. package/dist/assertion/impl/index.cjs +0 -37
  106. package/dist/assertion/impl/index.cjs.map +0 -1
  107. package/dist/assertion/impl/index.d.cts +0 -21
  108. package/dist/assertion/impl/index.d.cts.map +0 -1
  109. package/dist/assertion/impl/index.d.ts +0 -21
  110. package/dist/assertion/impl/index.d.ts.map +0 -1
  111. package/dist/assertion/impl/index.js +0 -21
  112. package/dist/assertion/impl/index.js.map +0 -1
  113. package/dist/assertion/impl/iteration-util.cjs +0 -297
  114. package/dist/assertion/impl/iteration-util.cjs.map +0 -1
  115. package/dist/assertion/impl/iteration-util.d.cts +0 -12
  116. package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
  117. package/dist/assertion/impl/iteration-util.d.ts +0 -12
  118. package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
  119. package/dist/assertion/impl/iteration-util.js +0 -282
  120. package/dist/assertion/impl/iteration-util.js.map +0 -1
  121. package/dist/assertion/impl/snapshot.cjs +0 -276
  122. package/dist/assertion/impl/snapshot.cjs.map +0 -1
  123. package/dist/assertion/impl/snapshot.d.cts +0 -278
  124. package/dist/assertion/impl/snapshot.d.cts.map +0 -1
  125. package/dist/assertion/impl/snapshot.d.ts +0 -278
  126. package/dist/assertion/impl/snapshot.d.ts.map +0 -1
  127. package/dist/assertion/impl/snapshot.js +0 -273
  128. package/dist/assertion/impl/snapshot.js.map +0 -1
  129. package/dist/assertion/impl/sync-basic.cjs +0 -553
  130. package/dist/assertion/impl/sync-basic.cjs.map +0 -1
  131. package/dist/assertion/impl/sync-basic.d.cts +0 -528
  132. package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
  133. package/dist/assertion/impl/sync-basic.d.ts +0 -528
  134. package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
  135. package/dist/assertion/impl/sync-basic.js +0 -550
  136. package/dist/assertion/impl/sync-basic.js.map +0 -1
  137. package/dist/assertion/impl/sync-collection.cjs +0 -856
  138. package/dist/assertion/impl/sync-collection.cjs.map +0 -1
  139. package/dist/assertion/impl/sync-collection.d.cts +0 -607
  140. package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
  141. package/dist/assertion/impl/sync-collection.d.ts +0 -607
  142. package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
  143. package/dist/assertion/impl/sync-collection.js +0 -850
  144. package/dist/assertion/impl/sync-collection.js.map +0 -1
  145. package/dist/assertion/impl/sync-date.cjs +0 -341
  146. package/dist/assertion/impl/sync-date.cjs.map +0 -1
  147. package/dist/assertion/impl/sync-date.d.cts +0 -209
  148. package/dist/assertion/impl/sync-date.d.cts.map +0 -1
  149. package/dist/assertion/impl/sync-date.d.ts +0 -209
  150. package/dist/assertion/impl/sync-date.d.ts.map +0 -1
  151. package/dist/assertion/impl/sync-date.js +0 -338
  152. package/dist/assertion/impl/sync-date.js.map +0 -1
  153. package/dist/assertion/impl/sync-esoteric.cjs +0 -214
  154. package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
  155. package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
  156. package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
  157. package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
  158. package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
  159. package/dist/assertion/impl/sync-esoteric.js +0 -211
  160. package/dist/assertion/impl/sync-esoteric.js.map +0 -1
  161. package/dist/assertion/impl/sync-iterable.cjs +0 -512
  162. package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
  163. package/dist/assertion/impl/sync-iterable.d.cts +0 -334
  164. package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
  165. package/dist/assertion/impl/sync-iterable.d.ts +0 -334
  166. package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
  167. package/dist/assertion/impl/sync-iterable.js +0 -509
  168. package/dist/assertion/impl/sync-iterable.js.map +0 -1
  169. package/dist/assertion/impl/sync-parametric.cjs +0 -805
  170. package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
  171. package/dist/assertion/impl/sync-parametric.d.cts +0 -560
  172. package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
  173. package/dist/assertion/impl/sync-parametric.d.ts +0 -560
  174. package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
  175. package/dist/assertion/impl/sync-parametric.js +0 -802
  176. package/dist/assertion/impl/sync-parametric.js.map +0 -1
  177. package/dist/assertion/impl/sync.cjs +0 -214
  178. package/dist/assertion/impl/sync.cjs.map +0 -1
  179. package/dist/assertion/impl/sync.d.cts +0 -512
  180. package/dist/assertion/impl/sync.d.cts.map +0 -1
  181. package/dist/assertion/impl/sync.d.ts +0 -512
  182. package/dist/assertion/impl/sync.d.ts.map +0 -1
  183. package/dist/assertion/impl/sync.js +0 -197
  184. package/dist/assertion/impl/sync.js.map +0 -1
  185. package/dist/assertion/index.cjs +0 -38
  186. package/dist/assertion/index.cjs.map +0 -1
  187. package/dist/assertion/index.d.cts +0 -18
  188. package/dist/assertion/index.d.cts.map +0 -1
  189. package/dist/assertion/index.d.ts +0 -18
  190. package/dist/assertion/index.d.ts.map +0 -1
  191. package/dist/assertion/index.js +0 -17
  192. package/dist/assertion/index.js.map +0 -1
  193. package/dist/assertion/slotify.cjs +0 -165
  194. package/dist/assertion/slotify.cjs.map +0 -1
  195. package/dist/assertion/slotify.d.cts +0 -11
  196. package/dist/assertion/slotify.d.cts.map +0 -1
  197. package/dist/assertion/slotify.d.ts +0 -11
  198. package/dist/assertion/slotify.d.ts.map +0 -1
  199. package/dist/assertion/slotify.js +0 -161
  200. package/dist/assertion/slotify.js.map +0 -1
  201. package/dist/bootstrap.cjs +0 -43
  202. package/dist/bootstrap.cjs.map +0 -1
  203. package/dist/bootstrap.d.cts +0 -27
  204. package/dist/bootstrap.d.cts.map +0 -1
  205. package/dist/bootstrap.d.ts +0 -27
  206. package/dist/bootstrap.d.ts.map +0 -1
  207. package/dist/bootstrap.js +0 -40
  208. package/dist/bootstrap.js.map +0 -1
  209. package/dist/constant.cjs +0 -82
  210. package/dist/constant.cjs.map +0 -1
  211. package/dist/constant.d.cts +0 -69
  212. package/dist/constant.d.cts.map +0 -1
  213. package/dist/constant.d.ts +0 -69
  214. package/dist/constant.d.ts.map +0 -1
  215. package/dist/constant.js +0 -79
  216. package/dist/constant.js.map +0 -1
  217. package/dist/diff.cjs +0 -340
  218. package/dist/diff.cjs.map +0 -1
  219. package/dist/diff.d.cts +0 -51
  220. package/dist/diff.d.cts.map +0 -1
  221. package/dist/diff.d.ts +0 -51
  222. package/dist/diff.d.ts.map +0 -1
  223. package/dist/diff.js +0 -334
  224. package/dist/diff.js.map +0 -1
  225. package/dist/error.cjs +0 -204
  226. package/dist/error.cjs.map +0 -1
  227. package/dist/error.d.cts +0 -212
  228. package/dist/error.d.cts.map +0 -1
  229. package/dist/error.d.ts +0 -212
  230. package/dist/error.d.ts.map +0 -1
  231. package/dist/error.js +0 -191
  232. package/dist/error.js.map +0 -1
  233. package/dist/expect.cjs +0 -590
  234. package/dist/expect.cjs.map +0 -1
  235. package/dist/expect.d.cts +0 -138
  236. package/dist/expect.d.cts.map +0 -1
  237. package/dist/expect.d.ts +0 -138
  238. package/dist/expect.d.ts.map +0 -1
  239. package/dist/expect.js +0 -582
  240. package/dist/expect.js.map +0 -1
  241. package/dist/guards.cjs +0 -297
  242. package/dist/guards.cjs.map +0 -1
  243. package/dist/guards.d.cts +0 -231
  244. package/dist/guards.d.cts.map +0 -1
  245. package/dist/guards.d.ts +0 -231
  246. package/dist/guards.d.ts.map +0 -1
  247. package/dist/guards.js +0 -277
  248. package/dist/guards.js.map +0 -1
  249. package/dist/index.cjs +0 -111
  250. package/dist/index.cjs.map +0 -1
  251. package/dist/index.d.cts +0 -448
  252. package/dist/index.d.cts.map +0 -1
  253. package/dist/index.d.ts +0 -448
  254. package/dist/index.d.ts.map +0 -1
  255. package/dist/index.js +0 -71
  256. package/dist/index.js.map +0 -1
  257. package/dist/internal-schema.cjs +0 -253
  258. package/dist/internal-schema.cjs.map +0 -1
  259. package/dist/internal-schema.d.cts +0 -8
  260. package/dist/internal-schema.d.cts.map +0 -1
  261. package/dist/internal-schema.d.ts +0 -8
  262. package/dist/internal-schema.d.ts.map +0 -1
  263. package/dist/internal-schema.js +0 -248
  264. package/dist/internal-schema.js.map +0 -1
  265. package/dist/metadata.cjs +0 -57
  266. package/dist/metadata.cjs.map +0 -1
  267. package/dist/metadata.d.cts +0 -27
  268. package/dist/metadata.d.cts.map +0 -1
  269. package/dist/metadata.d.ts +0 -27
  270. package/dist/metadata.d.ts.map +0 -1
  271. package/dist/metadata.js +0 -54
  272. package/dist/metadata.js.map +0 -1
  273. package/dist/schema.cjs +0 -1522
  274. package/dist/schema.cjs.map +0 -1
  275. package/dist/schema.d.cts +0 -1196
  276. package/dist/schema.d.cts.map +0 -1
  277. package/dist/schema.d.ts +0 -1196
  278. package/dist/schema.d.ts.map +0 -1
  279. package/dist/schema.js +0 -1516
  280. package/dist/schema.js.map +0 -1
  281. package/dist/snapshot/adapter.cjs +0 -31
  282. package/dist/snapshot/adapter.cjs.map +0 -1
  283. package/dist/snapshot/adapter.d.cts +0 -258
  284. package/dist/snapshot/adapter.d.cts.map +0 -1
  285. package/dist/snapshot/adapter.d.ts +0 -258
  286. package/dist/snapshot/adapter.d.ts.map +0 -1
  287. package/dist/snapshot/adapter.js +0 -27
  288. package/dist/snapshot/adapter.js.map +0 -1
  289. package/dist/snapshot/adapters/fallback.cjs +0 -453
  290. package/dist/snapshot/adapters/fallback.cjs.map +0 -1
  291. package/dist/snapshot/adapters/fallback.d.cts +0 -185
  292. package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
  293. package/dist/snapshot/adapters/fallback.d.ts +0 -185
  294. package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
  295. package/dist/snapshot/adapters/fallback.js +0 -446
  296. package/dist/snapshot/adapters/fallback.js.map +0 -1
  297. package/dist/snapshot/adapters/node-test.cjs +0 -301
  298. package/dist/snapshot/adapters/node-test.cjs.map +0 -1
  299. package/dist/snapshot/adapters/node-test.d.cts +0 -131
  300. package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
  301. package/dist/snapshot/adapters/node-test.d.ts +0 -131
  302. package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
  303. package/dist/snapshot/adapters/node-test.js +0 -297
  304. package/dist/snapshot/adapters/node-test.js.map +0 -1
  305. package/dist/snapshot/index.cjs +0 -61
  306. package/dist/snapshot/index.cjs.map +0 -1
  307. package/dist/snapshot/index.d.cts +0 -40
  308. package/dist/snapshot/index.d.cts.map +0 -1
  309. package/dist/snapshot/index.d.ts +0 -40
  310. package/dist/snapshot/index.d.ts.map +0 -1
  311. package/dist/snapshot/index.js +0 -44
  312. package/dist/snapshot/index.js.map +0 -1
  313. package/dist/snapshot/node-version.cjs +0 -49
  314. package/dist/snapshot/node-version.cjs.map +0 -1
  315. package/dist/snapshot/node-version.d.cts +0 -34
  316. package/dist/snapshot/node-version.d.cts.map +0 -1
  317. package/dist/snapshot/node-version.d.ts +0 -34
  318. package/dist/snapshot/node-version.d.ts.map +0 -1
  319. package/dist/snapshot/node-version.js +0 -44
  320. package/dist/snapshot/node-version.js.map +0 -1
  321. package/dist/snapshot/select-adapter.cjs +0 -170
  322. package/dist/snapshot/select-adapter.cjs.map +0 -1
  323. package/dist/snapshot/select-adapter.d.cts +0 -128
  324. package/dist/snapshot/select-adapter.d.cts.map +0 -1
  325. package/dist/snapshot/select-adapter.d.ts +0 -128
  326. package/dist/snapshot/select-adapter.d.ts.map +0 -1
  327. package/dist/snapshot/select-adapter.js +0 -164
  328. package/dist/snapshot/select-adapter.js.map +0 -1
  329. package/dist/snapshot/serializer.cjs +0 -246
  330. package/dist/snapshot/serializer.cjs.map +0 -1
  331. package/dist/snapshot/serializer.d.cts +0 -126
  332. package/dist/snapshot/serializer.d.cts.map +0 -1
  333. package/dist/snapshot/serializer.d.ts +0 -126
  334. package/dist/snapshot/serializer.d.ts.map +0 -1
  335. package/dist/snapshot/serializer.js +0 -238
  336. package/dist/snapshot/serializer.js.map +0 -1
  337. package/dist/standard-schema.cjs +0 -13
  338. package/dist/standard-schema.cjs.map +0 -1
  339. package/dist/standard-schema.d.cts +0 -192
  340. package/dist/standard-schema.d.cts.map +0 -1
  341. package/dist/standard-schema.d.ts +0 -192
  342. package/dist/standard-schema.d.ts.map +0 -1
  343. package/dist/standard-schema.js +0 -12
  344. package/dist/standard-schema.js.map +0 -1
  345. package/dist/types.cjs +0 -22
  346. package/dist/types.cjs.map +0 -1
  347. package/dist/types.d.cts +0 -905
  348. package/dist/types.d.cts.map +0 -1
  349. package/dist/types.d.ts +0 -905
  350. package/dist/types.d.ts.map +0 -1
  351. package/dist/types.js +0 -21
  352. package/dist/types.js.map +0 -1
  353. package/dist/use.cjs +0 -240
  354. package/dist/use.cjs.map +0 -1
  355. package/dist/use.d.cts +0 -8
  356. package/dist/use.d.cts.map +0 -1
  357. package/dist/use.d.ts +0 -8
  358. package/dist/use.d.ts.map +0 -1
  359. package/dist/use.js +0 -236
  360. package/dist/use.js.map +0 -1
  361. package/dist/util.cjs +0 -255
  362. package/dist/util.cjs.map +0 -1
  363. package/dist/util.d.cts +0 -141
  364. package/dist/util.d.cts.map +0 -1
  365. package/dist/util.d.ts +0 -141
  366. package/dist/util.d.ts.map +0 -1
  367. package/dist/util.js +0 -234
  368. package/dist/util.js.map +0 -1
  369. package/dist/value-to-schema.cjs +0 -537
  370. package/dist/value-to-schema.cjs.map +0 -1
  371. package/dist/value-to-schema.d.cts +0 -144
  372. package/dist/value-to-schema.d.cts.map +0 -1
  373. package/dist/value-to-schema.d.ts +0 -144
  374. package/dist/value-to-schema.d.ts.map +0 -1
  375. package/dist/value-to-schema.js +0 -533
  376. package/dist/value-to-schema.js.map +0 -1
@@ -1,1086 +0,0 @@
1
- /**
2
- * Core type definitions for the assertion system.
3
- *
4
- * This module defines all the fundamental types used throughout the assertion
5
- * framework, including assertion parts, implementation functions, parsed
6
- * values, and type inference utilities. These types enable type-safe assertion
7
- * creation and execution.
8
- *
9
- * @packageDocumentation
10
- *
11
- * @groupDescription Assertion Types
12
- * Types related to the implementation of assertions.
13
- * @groupDescription Internal Assertion Interfaces
14
- * Interfaces which define the structure of assertions and their components.
15
- * @groupDescription Assertion Implementation
16
- * Types related to the implementation of an assertion.
17
- */
18
- import { type NonEmptyTuple } from 'type-fest';
19
- import { type z } from 'zod';
20
- import type { DiffOptions } from "../diff.cjs";
21
- import type { StandardSchemaV1 } from "../standard-schema.cjs";
22
- import type { AsyncAssertions, SyncAssertions } from "./impl/index.cjs";
23
- /**
24
- * Union type representing any assertion, either synchronous or asynchronous.
25
- *
26
- * This type combines all possible assertion types into a single union for cases
27
- * where the synchronous/asynchronous nature is not known at compile time.
28
- *
29
- * @group Internal Assertion Types
30
- * @see {@link AnyAsyncAssertion} for async-specific assertions
31
- * @see {@link AnySyncAssertion} for sync-specific assertions
32
- */
33
- export type AnyAssertion = AnyAsyncAssertion | AnySyncAssertion;
34
- /**
35
- * Non-empty tuple type containing any assertions.
36
- *
37
- * Used to represent collections of assertions where at least one assertion must
38
- * be present.
39
- *
40
- * @group Internal Assertion Types
41
- * @see {@link AnyAssertion} for individual assertion types
42
- */
43
- export type AnyAssertions = NonEmptyTuple<AnyAssertion>;
44
- /**
45
- * Union type representing any asynchronous assertion.
46
- *
47
- * This includes both function-based and schema-based async assertions but
48
- * excludes synchronous assertions to maintain type safety.
49
- *
50
- * @group Internal Assertion Types
51
- * @see {@link AssertionFunctionAsync} for function-based async assertions
52
- * @see {@link AssertionSchemaAsync} for schema-based async assertions
53
- */
54
- export type AnyAsyncAssertion = AssertionAsync<any, any, any>;
55
- /**
56
- * Non-empty tuple type containing any asynchronous assertions.
57
- *
58
- * Used to represent collections of async assertions where at least one
59
- * assertion must be present.
60
- *
61
- * @see {@link AnyAsyncAssertion} for individual async assertion types
62
- */
63
- export type AnyAsyncAssertions = NonEmptyTuple<AnyAsyncAssertion>;
64
- /**
65
- * Union type representing any synchronous assertion.
66
- *
67
- * This includes both function-based and schema-based sync assertions but
68
- * excludes asynchronous assertions to maintain type safety.
69
- *
70
- * @group Internal Assertion Types
71
- * @see {@link AssertionFunctionSync} for function-based sync assertions
72
- * @see {@link AssertionSchemaSync} for schema-based sync assertions
73
- */
74
- export type AnySyncAssertion = AssertionSync<any, any, any>;
75
- /**
76
- * Non-empty tuple type containing any synchronous assertions.
77
- *
78
- * Used to represent collections of sync assertions where at least one assertion
79
- * must be present.
80
- *
81
- * @group Internal Assertion Types
82
- * @see {@link AnySyncAssertion} for individual sync assertion types
83
- */
84
- export type AnySyncAssertions = NonEmptyTuple<AnySyncAssertion>;
85
- /**
86
- * Interface for the base abstract `Assertion` class.
87
- *
88
- * This interface defines the contract for assertion instances, including
89
- * properties for assertion parts, implementation, slots, and methods for
90
- * parsing and executing assertions both synchronously and asynchronously.
91
- *
92
- * @group Internal Assertion Interfaces
93
- */
94
- export interface Assertion<Parts extends AssertionParts, Impl extends AssertionImpl<Parts>, Slots extends AssertionSlots<Parts>> {
95
- /**
96
- * Extracts phrase literals from this assertion for use in dispatch indexing.
97
- *
98
- * Returns phrases from the first phrase literal slot found (typically slot 1
99
- * for subject-first assertions, or slot 0 for phrase-first assertions).
100
- * Handles both single phrase literals and phrase literal choices.
101
- *
102
- * @returns Array of phrase strings for indexing, or empty array if none found
103
- */
104
- getIndexPhrases(): readonly string[];
105
- /**
106
- * Unique identifier for this assertion
107
- */
108
- readonly id: string;
109
- /**
110
- * The implementation function or schema for this assertion.
111
- */
112
- readonly impl: Impl;
113
- /**
114
- * The assertion parts used to create this assertion.
115
- *
116
- * Available at runtime for introspection.
117
- */
118
- readonly parts: Parts;
119
- /**
120
- * The slots derived from assertion parts for validation.
121
- */
122
- readonly slots: Slots;
123
- /**
124
- * Returns the string representation of this assertion.
125
- *
126
- * @privateRemarks
127
- * The existence of this method suppresses
128
- * `@typescript-eslint/no-base-to-string` lint errors.
129
- */
130
- toString(): string;
131
- }
132
- /**
133
- * Type for an object which represents a discrete asynchronous assertion.
134
- *
135
- * @group Internal Assertion Interfaces
136
- */
137
- export interface AssertionAsync<Parts extends AssertionParts = AssertionParts, Impl extends AssertionImplAsync<Parts> = AssertionImplAsync<Parts>, Slots extends AssertionSlots<Parts> = AssertionSlots<Parts>> extends Assertion<Parts, Impl, Slots> {
138
- /**
139
- * Execute the assertion implementation asynchronously.
140
- *
141
- * @param parsedValues Parameters for the assertion implementation
142
- * @param args Raw parameters passed to `expectAsync()`
143
- * @param stackStartFn Function to use as stack start for error reporting
144
- * @param parseResult Optional parse result containing cached validation data
145
- */
146
- executeAsync(parsedValues: ParsedValues<Parts>, args: unknown[], stackStartFn: (...args: any[]) => any, parseResult?: ParsedResult<Parts>): Promise<void>;
147
- /**
148
- * Parses raw arguments asynchronously against this assertion's slots to
149
- * determine if they match this assertion.
150
- *
151
- * @param args Raw arguments provided to `expectAsync()`
152
- * @returns Result of parsing attempt
153
- */
154
- parseValuesAsync<Args extends readonly unknown[]>(args: Args): Promise<ParsedResult<Parts>>;
155
- }
156
- /**
157
- * Object which may be returned from assertion function implementations to
158
- * provide better failure reporting to the end-user.
159
- *
160
- * @group Assertion Creation
161
- */
162
- export interface AssertionFailure {
163
- /**
164
- * The actual value or condition that was encountered
165
- */
166
- actual?: unknown;
167
- /**
168
- * Pre-computed diff string. When provided, this bypasses jest-diff entirely
169
- * and is used as-is in the error output. Takes precedence over
170
- * `formatActual`, `formatExpected`, and `diffOptions`.
171
- *
172
- * @example
173
- *
174
- * ```typescript
175
- * return {
176
- * actual: myDate,
177
- * expected: otherDate,
178
- * diff: ` Expected: ${formatDate(otherDate)}\n Actual: ${formatDate(myDate)}`,
179
- * message: 'Dates are not on the same day',
180
- * };
181
- * ```
182
- */
183
- diff?: string;
184
- /**
185
- * Override default jest-diff options. Only used when `diff` is not provided.
186
- *
187
- * @see {@link https://npm.im/jest-diff | jest-diff} for available options
188
- */
189
- diffOptions?: DiffOptions;
190
- /**
191
- * The expected value or condition that was not met
192
- */
193
- expected?: unknown;
194
- /**
195
- * Custom formatter for the actual value in diff output. Only used when `diff`
196
- * is not provided. The returned string is passed to jest-diff.
197
- *
198
- * @example
199
- *
200
- * ```typescript
201
- * return {
202
- * actual: sortedActual,
203
- * expected: sortedExpected,
204
- * formatActual: (v) => `[sorted] ${inspect(v)}`,
205
- * formatExpected: (v) => `[sorted] ${inspect(v)}`,
206
- * };
207
- * ```
208
- *
209
- * @param value - The actual value to format
210
- * @returns String representation for diff display
211
- */
212
- formatActual?: (value: unknown) => string;
213
- /**
214
- * Custom formatter for the expected value in diff output. Only used when
215
- * `diff` is not provided. The returned string is passed to jest-diff.
216
- *
217
- * @param value - The expected value to format
218
- * @returns String representation for diff display
219
- */
220
- formatExpected?: (value: unknown) => string;
221
- /**
222
- * A human-readable message describing the failure
223
- */
224
- message?: string | undefined;
225
- }
226
- /**
227
- * An async assertion with a function implementation.
228
- *
229
- * @group Internal Assertion Interfaces
230
- */
231
- export interface AssertionFunctionAsync<Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionAsync<Parts, Impl, Slots> {
232
- impl: Impl;
233
- }
234
- /**
235
- * A synchronous assertion with a function implementation.
236
- *
237
- * @group Internal Assertion Interfaces
238
- */
239
- export interface AssertionFunctionSync<Parts extends AssertionParts, Impl extends AssertionImplFnSync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionSync<Parts, Impl, Slots> {
240
- impl: Impl;
241
- }
242
- /**
243
- * Any type of assertion implementation.
244
- *
245
- * @group Assertion Implementation
246
- */
247
- export type AssertionImpl<Parts extends AssertionParts> = AssertionImplAsync<Parts> | AssertionImplSync<Parts>;
248
- /**
249
- * Union type representing any async assertion implementation.
250
- *
251
- * This encompasses both function-based and schema-based implementations for
252
- * asynchronous assertions, providing a type-safe way to handle async assertion
253
- * logic including Standard Schema validators.
254
- *
255
- * @template Parts - The assertion parts defining the structure
256
- * @group Assertion Implementation
257
- * @see {@link AssertionImplFnAsync} for function-based async implementations
258
- * @see {@link AssertionImplSchemaAsync} for schema-based async implementations
259
- */
260
- export type AssertionImplAsync<Parts extends AssertionParts> = AssertionImplFnAsync<Parts> | AssertionImplSchemaAsync<Parts> | StandardSchemaV1;
261
- /**
262
- * The implementation of an assertion as an async function.
263
- *
264
- * An asynchronous implementation function that validates assertion arguments
265
- * and returns a Promise resolving to validation results. The function receives
266
- * parsed values from the assertion parts and can return various types
267
- * indicating validation success or failure.
268
- *
269
- * @template Parts - The assertion parts defining the structure
270
- * @param values - The parsed values corresponding to assertion parts
271
- * @returns Promise resolving to boolean indicating pass/fail, void for success,
272
- * ZodType for dynamic validation, or AssertionFailure object for detailed
273
- * error information
274
- * @group Assertion Implementation
275
- * @see {@link AssertionImplFnSync} for sync function implementations
276
- * @see {@link ParsedValues} for the input parameter structure
277
- */
278
- export type AssertionImplFnAsync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) => AssertionImplFnReturnType<Parts> | Promise<AssertionImplFnReturnType<Parts>>;
279
- /**
280
- * The return type of an assertion implementation function.
281
- *
282
- * Functions can return various types to indicate validation results, including
283
- * Standard Schema validators for dynamic validation.
284
- *
285
- * @group Assertion Implementation
286
- */
287
- export type AssertionImplFnReturnType<Parts extends AssertionParts> = AssertionFailure | AssertionParseRequest | boolean | StandardSchemaV1<ParsedSubject<Parts>> | void | z.ZodError | z.ZodType<ParsedSubject<Parts>>;
288
- /**
289
- * The implementation of an assertion as a sync function.
290
- *
291
- * A synchronous implementation function that validates assertion arguments and
292
- * returns validation results. The function receives parsed values from the
293
- * assertion parts and can return various types indicating validation success or
294
- * failure.
295
- *
296
- * @template Parts - The assertion parts defining the structure
297
- * @param values - The parsed values corresponding to assertion parts
298
- * @returns Boolean indicating pass/fail, void for success, ZodType for dynamic
299
- * validation, or AssertionFailure object for detailed error information
300
- * @group Assertion Implementation
301
- * @see {@link AssertionImplFnAsync} for async function implementations
302
- * @see {@link ParsedValues} for the input parameter structure
303
- */
304
- export type AssertionImplFnSync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) => AssertionImplFnReturnType<Parts>;
305
- /**
306
- * Maps an {@link AssertionPart} to a parameter to an {@link AssertionImpl}.
307
- *
308
- * This omits {@link Phrase} parts, which are not received by the implementation.
309
- *
310
- * @group Assertion Implementation
311
- */
312
- export type AssertionImplPart<Part extends AssertionPart> = Part extends PhraseLiteral | PhraseLiteralChoice ? never : Part extends z.ZodPromise ? Promise<z.infer<Part>> : Part extends z.ZodType ? z.infer<Part> : Part extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Part> : never;
313
- /**
314
- * Maps {@link AssertionParts} to their corresponding {@link AssertionImplPart}.
315
- *
316
- * @group Assertion Implementation
317
- */
318
- export type AssertionImplParts<Parts extends readonly AssertionPart[]> = Parts extends readonly [
319
- infer First extends AssertionPart,
320
- ...infer Rest extends readonly AssertionPart[]
321
- ] ? readonly [AssertionImplPart<First>, ...AssertionImplParts<Rest>] : readonly [];
322
- /**
323
- * A Zod schema implementation created with createAsync() - potentially
324
- * asynchronous
325
- */
326
- /**
327
- * Type for an async assertion implementation using a Zod schema.
328
- *
329
- * This represents a branded Zod schema that validates the assertion subject
330
- * asynchronously. The schema must match the parsed subject type derived from
331
- * the assertion parts and is branded with 'async-schema' for compile-time type
332
- * safety.
333
- *
334
- * @template Parts - The assertion parts tuple defining the assertion structure
335
- * @group Assertion Implementation
336
- * @see {@link AssertionImplSchemaSync} for synchronous schema implementations
337
- * @see {@link AssertionImplFnAsync} for function-based async implementations
338
- * @see {@link ParsedSubject} for subject type derivation
339
- */
340
- export type AssertionImplSchemaAsync<Parts extends AssertionParts> = z.core.$ZodBranded<z.ZodType<ParsedSubject<Parts>>, 'async-schema'>;
341
- /**
342
- * Type for a synchronous assertion implementation using a Zod schema.
343
- *
344
- * This represents a branded Zod schema that validates the assertion subject
345
- * synchronously. The schema must match the parsed subject type derived from the
346
- * assertion parts and is branded with 'sync-schema' for compile-time type
347
- * safety.
348
- *
349
- * @template Parts - The assertion parts tuple defining the assertion structure
350
- * @group Assertion Implementation
351
- * @see {@link AssertionImplSchemaAsync} for asynchronous schema implementations
352
- * @see {@link AssertionImplFnSync} for function-based sync implementations
353
- * @see {@link ParsedSubject} for subject type derivation
354
- */
355
- export type AssertionImplSchemaSync<Parts extends AssertionParts> = z.core.$ZodBranded<z.ZodType<ParsedSubject<Parts>>, 'sync-schema'>;
356
- /**
357
- * Union type for all synchronous assertion implementations.
358
- *
359
- * This represents either a function-based or schema-based implementation for
360
- * synchronous assertions. Function implementations provide custom validation
361
- * logic, while schema implementations use Zod schemas or Standard Schema
362
- * validators.
363
- *
364
- * @template Parts - The assertion parts tuple defining the assertion structure
365
- * @group Assertion Implementation
366
- * @see {@link AssertionImplFnSync} for function-based implementations
367
- * @see {@link AssertionImplSchemaSync} for schema-based implementations
368
- * @see {@link AssertionImplAsync} for async implementation unions
369
- */
370
- export type AssertionImplSync<Parts extends AssertionParts> = AssertionImplFnSync<Parts> | AssertionImplSchemaSync<Parts> | StandardSchemaV1;
371
- /**
372
- * When you want to use a schema in an assertion implementation function against
373
- * some value that _isn't_ the subject, you can return this object and <span
374
- * class="bupkis">BUPKIS</span> will do it for you (with better diffs).
375
- *
376
- * Supports both Zod schemas and Standard Schema v1 compliant validators.
377
- *
378
- * @group Assertion Creation
379
- */
380
- export type AssertionParseRequest = {
381
- subject: unknown;
382
- } & ({
383
- asyncSchema: StandardSchemaV1 | z.ZodType;
384
- schema?: never;
385
- } | {
386
- asyncSchema?: never;
387
- schema: StandardSchemaV1 | z.ZodType;
388
- });
389
- /**
390
- * Union type representing the fundamental building blocks of an assertion.
391
- *
392
- * An assertion part can be either a phrase (string literal or choice of
393
- * literals) that describes the natural language portion of the assertion, or a
394
- * schema (Zod or Standard Schema) that defines validation constraints for
395
- * assertion arguments.
396
- *
397
- * @example
398
- *
399
- * ```ts
400
- * // String literal phrase
401
- * type Part1 = 'to be a string';
402
- *
403
- * // String literal choice
404
- * type Part2 = ['to be', 'to equal'];
405
- *
406
- * // Zod schema for validation
407
- * type Part3 = z.ZodString;
408
- *
409
- * // Standard Schema for validation
410
- * type Part4 = StandardSchemaV1<string>;
411
- * ```
412
- *
413
- * @group Internal Assertion Types
414
- * @see {@link Phrase} for phrase-based parts
415
- * @see {@link AssertionParts} for complete assertion structure
416
- * @see {@link AssertionSlot} for compiled slot representation
417
- */
418
- export type AssertionPart = Phrase | StandardSchemaV1 | z.ZodType;
419
- /**
420
- * Non-empty tuple type representing the complete structure of an assertion.
421
- *
422
- * This defines the signature of an assertion by combining phrases (natural
423
- * language) and Zod schemas (validation constraints). The tuple must contain at
424
- * least one element and typically starts with a subject schema followed by
425
- * phrase literals and additional parameter schemas.
426
- *
427
- * @example
428
- *
429
- * ```ts
430
- * // Basic assertion: expect(value, 'to be a string')
431
- * type SimpleAssertion = ['to be a string'];
432
- *
433
- * // Parameterized assertion: expect(value, 'to be greater than', 5)
434
- * type ParametricAssertion = [z.number(), 'to be greater than', z.number()];
435
- *
436
- * // Choice-based assertion: expect(value, ['to be', 'to equal'], expected)
437
- * type ChoiceAssertion = [z.any(), ['to be', 'to equal'], z.any()];
438
- * ```
439
- *
440
- * @template Parts - Extends the base AssertionPart array with tuple constraints
441
- * @group Internal Assertion Types
442
- * @see {@link AssertionPart} for individual part types
443
- * @see {@link AssertionSlots} for compiled slot representation
444
- * @see {@link createAssertion} for assertion creation from parts
445
- */
446
- export type AssertionParts = readonly [Phrase, ...AssertionPart[]] | readonly [StandardSchemaV1 | z.ZodType, Phrase, ...AssertionPart[]];
447
- /**
448
- * Type-level mapping from assertion parts to their corresponding validation
449
- * slots.
450
- *
451
- * This recursive type processes each assertion part and converts it to a slot
452
- * that can be used for runtime validation. Phrase literals become branded
453
- * string schemas, while Zod types are preserved as-is. The resulting tuple may
454
- * contain `never` entries for invalid parts that should be filtered out.
455
- *
456
- * @example
457
- *
458
- * ```ts
459
- * // Input parts
460
- * type Parts = ['to be a string', z.number()];
461
- *
462
- * // Resulting slots (simplified)
463
- * type Slots = [PhraseLiteralSlot<'to be a string'>, z.ZodNumber];
464
- * ```
465
- *
466
- * @template Parts - The readonly array of assertion parts to process
467
- * @group Internal Assertion Types
468
- * @see {@link AssertionSlot} for individual slot type mapping
469
- * @see {@link AssertionSlots} for filtered and properly typed slot tuples
470
- * @see {@link NoNeverTuple} for filtering never entries
471
- */
472
- export type AssertionPartsToSlots<Parts extends readonly AssertionPart[]> = Parts extends readonly [
473
- infer First extends AssertionPart,
474
- ...infer Rest extends readonly AssertionPart[]
475
- ] ? readonly [AssertionSlot<First>, ...AssertionPartsToSlots<Rest>] : readonly [];
476
- /**
477
- * An async assertion which is implemented using a Zod schema.
478
- *
479
- * @group Internal Assertion Interfaces
480
- */
481
- export interface AssertionSchemaAsync<Parts extends AssertionParts, Impl extends AssertionImplSchemaAsync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionAsync<Parts, Impl, Slots> {
482
- impl: Impl;
483
- }
484
- /**
485
- * A synchronous assertion which is implemented using a Zod schema.
486
- *
487
- * @group Internal Assertion Interfaces
488
- */
489
- export interface AssertionSchemaSync<Parts extends AssertionParts, Impl extends AssertionImplSchemaSync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionSync<Parts, Impl, Slots> {
490
- impl: Impl;
491
- }
492
- /**
493
- * Type-level mapping that converts an assertion part to its corresponding
494
- * validation slot.
495
- *
496
- * This maps each type of assertion part to a specific Zod schema that can be
497
- * used for runtime validation:
498
- *
499
- * - String literals become branded phrase literal slots
500
- * - String literal choices become branded phrase choice slots
501
- * - Zod types are preserved as-is
502
- * - Standard Schema validators become Zod types (see note below)
503
- * - Invalid parts become `never`
504
- *
505
- * **Important:** Standard Schema parts are typed as `z.ZodType` because at
506
- * runtime they are wrapped in `z.custom()` by `slotify`. This type reflects the
507
- * **runtime reality** rather than the input type. The wrapper allows slots to
508
- * use Zod's `.safeParse()` and `.def` properties uniformly, while the Standard
509
- * Schema's actual validation is called internally.
510
- *
511
- * **Order matters:** Must check `z.ZodType` before `StandardSchemaV1` because
512
- * Zod v4 implements Standard Schema v1, so all Zod types would match both.
513
- *
514
- * @example
515
- *
516
- * ```ts
517
- * // String literal -> branded slot
518
- * type Slot1 = AssertionSlot<'to be a string'>; // PhraseLiteralSlot<'to be a string'>
519
- *
520
- * // Choice -> branded choice slot
521
- * type Slot2 = AssertionSlot<['to be', 'to equal']>; // PhraseLiteralChoiceSlot<['to be', 'to equal']>
522
- *
523
- * // Zod type -> preserved
524
- * type Slot3 = AssertionSlot<z.ZodString>; // z.ZodString
525
- *
526
- * // Standard Schema -> wrapped at runtime
527
- * type Slot4 = AssertionSlot<v.string()>; // z.ZodType (generic, not specific wrapper type)
528
- * ```
529
- *
530
- * @template Part - The assertion part to convert to a slot
531
- * @group Internal Assertion Types
532
- * @see {@link PhraseLiteralSlot} for string literal slots
533
- * @see {@link PhraseLiteralChoiceSlot} for choice-based slots
534
- * @see {@link AssertionSlots} for complete slot tuples
535
- * @see `slotify` for the runtime transformation that wraps Standard Schema validators
536
- */
537
- export type AssertionSlot<Part extends AssertionPart> = Part extends string ? PhraseLiteralSlot<Part> : Part extends readonly [string, ...string[]] ? PhraseLiteralChoiceSlot<Part> : Part extends z.ZodType ? Part : Part extends StandardSchemaV1 ? z.ZodType : never;
538
- /**
539
- * Tuple type representing all validation slots derived from assertion parts.
540
- *
541
- * This type processes assertion parts to create a tuple of Zod schemas that can
542
- * be used for runtime argument validation. If the first part is a phrase, a
543
- * subject slot (`z.ZodUnknown`) is automatically prepended to accept the
544
- * assertion subject.
545
- *
546
- * The resulting tuple:
547
- *
548
- * 1. Has `never` entries filtered out to maintain proper tuple structure
549
- * 2. Will include an implicit subject slot {@link AssertionParts} with a
550
- * {@link PhraseLiteral}/{@link PhraseLiteralChoice} in the first position.
551
- * 3. Contains branded slots for
552
- * {@link PhraseLiteral PhraseLiterals}/{@link PhraseLiteralChoice PhraseLiteralChoices}
553
- * to enable phrase matching; differentiates from a user-created
554
- * {@link z.ZodLiteral ZodLiteral}.
555
- *
556
- * @example
557
- *
558
- * ```ts
559
- * // Phrase-first assertion gets subject slot
560
- * type Slots1 = AssertionSlots<['to be a string']>;
561
- * // Result: [z.ZodUnknown, PhraseLiteralSlot<'to be a string'>]
562
- *
563
- * // Schema-first assertion preserves structure
564
- * type Slots2 = AssertionSlots<[z.string(), 'to match', z.regexp()]>;
565
- * // Result: [z.ZodString, PhraseLiteralSlot<'to match'>, z.ZodRegExp]
566
- * ```
567
- *
568
- * @template Parts - The assertion parts to convert to slots
569
- * @group Internal Assertion Types
570
- * @see {@link AssertionSlot} for individual slot mapping
571
- * @see {@link AssertionPartsToSlots} for the underlying mapping logic
572
- * @see {@link NoNeverTuple} for never filtering
573
- */
574
- export type AssertionSlots<Parts extends AssertionParts = AssertionParts> = Parts extends readonly [
575
- infer First extends AssertionPart,
576
- ...infer _ extends AssertionParts
577
- ] ? First extends PhraseLiteral | PhraseLiteralChoice ? NoNeverTuple<readonly [z.ZodUnknown, ...AssertionPartsToSlots<Parts>]> : NoNeverTuple<AssertionPartsToSlots<Parts>> : never;
578
- /**
579
- * An asynchronous assertion implemented using a Standard Schema v1 validator.
580
- *
581
- * This interface represents async assertions where the implementation is a
582
- * Standard Schema compliant validator that may perform asynchronous
583
- * validation.
584
- *
585
- * @template Parts - The assertion parts tuple defining structure
586
- * @template Impl - The Standard Schema implementation
587
- * @template Slots - The derived validation slots
588
- * @group Internal Assertion Interfaces
589
- */
590
- export interface AssertionStandardSchemaAsync<Parts extends AssertionParts, Impl extends StandardSchemaV1, Slots extends AssertionSlots<Parts>> extends AssertionAsync<Parts, Impl, Slots> {
591
- impl: Impl;
592
- }
593
- /**
594
- * A synchronous assertion implemented using a Standard Schema v1 validator.
595
- *
596
- * This interface represents assertions where the implementation is a Standard
597
- * Schema compliant validator (from any library such as Valibot, ArkType,
598
- * etc.).
599
- *
600
- * @template Parts - The assertion parts tuple defining structure
601
- * @template Impl - The Standard Schema implementation
602
- * @template Slots - The derived validation slots
603
- * @group Internal Assertion Interfaces
604
- */
605
- export interface AssertionStandardSchemaSync<Parts extends AssertionParts, Impl extends StandardSchemaV1, Slots extends AssertionSlots<Parts>> extends AssertionSync<Parts, Impl, Slots> {
606
- impl: Impl;
607
- }
608
- /**
609
- * A synchronous assertion of no specific implementation type.
610
- *
611
- * @group Internal Assertion Interfaces
612
- */
613
- export interface AssertionSync<Parts extends AssertionParts = AssertionParts, Impl extends AssertionImplSync<Parts> = AssertionImplSync<Parts>, Slots extends AssertionSlots<Parts> = AssertionSlots<Parts>> extends Assertion<Parts, Impl, Slots> {
614
- /**
615
- * Execute the assertion implementation synchronously.
616
- *
617
- * @param parsedValues Parameters for the assertion implementation
618
- * @param args Raw parameters passed to `expectSync()`
619
- * @param stackStartFn Function to use as stack start for error reporting
620
- * @param parseResult Optional parse result containing cached validation data
621
- */
622
- execute(parsedValues: ParsedValues<Parts>, args: unknown[], stackStartFn: (...args: any[]) => any, parseResult?: ParsedResult<Parts>): void;
623
- /**
624
- * Parses raw arguments synchronously against this assertion's slots to
625
- * determine if they match this assertion.
626
- *
627
- * @param args Raw arguments provided to `expectSync()`
628
- * @returns Result of parsing attempt
629
- */
630
- parseValues<Args extends readonly unknown[]>(args: Args): ParsedResult<Parts>;
631
- }
632
- /**
633
- * The base structure for parsed assertion results.
634
- *
635
- * @group Internal Assertion Types
636
- */
637
- export interface BaseParsedResult<Parts extends AssertionParts> {
638
- /**
639
- * If success is `true`, then this will be `true` if all args matched the
640
- * slots _and_ none of those args infer as `unknown` or `any`.
641
- */
642
- exactMatch?: boolean;
643
- /**
644
- * Present only if `success` is `true`. The parsed values mapped to the slots
645
- * of an {@link Assertion}.
646
- */
647
- parsedValues?: ParsedValues<Parts>;
648
- /**
649
- * Whether the args were successfully parsed against the slots of an
650
- * {@link Assertion}.
651
- */
652
- success: boolean;
653
- }
654
- /**
655
- * Type representing the collection of all builtin async assertions.
656
- *
657
- * This type represents the compile-time type of the `AsyncAssertions` constant,
658
- * providing type information for all async assertion implementations included
659
- * in the framework by default.
660
- *
661
- * @group Builtin Assertions
662
- * @see {@link AsyncAssertions} for the actual assertion implementations
663
- */
664
- export type BuiltinAsyncAssertions = typeof AsyncAssertions;
665
- /**
666
- * Type representing the collection of all builtin sync assertions.
667
- *
668
- * This type represents the compile-time type of the `SyncAssertions` constant,
669
- * providing type information for all synchronous assertion implementations
670
- * included in the framework by default.
671
- *
672
- * @group Builtin Assertions
673
- * @see {@link SyncAssertions} for the actual assertion implementations
674
- */
675
- export type BuiltinSyncAssertions = typeof SyncAssertions;
676
- /**
677
- * The main factory function for creating synchronous assertions.
678
- *
679
- * @group Core API
680
- */
681
- export interface CreateAssertionFn {
682
- /**
683
- * Create a synchronous `Assertion` from {@link AssertionParts | parts} and a
684
- * Standard Schema validator.
685
- *
686
- * @template Parts Parts defining the shape of the assertion, including
687
- * Phrases and Zod schemas
688
- * @template Impl Assertion implementation as a Standard Schema
689
- * @template Slots Inferred slots based on the provided `Parts`
690
- * @returns New `AssertionStandardSchemaSync` object
691
- */
692
- <const Parts extends AssertionParts, Impl extends StandardSchemaV1, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionStandardSchemaSync<Parts, Impl, Slots>;
693
- /**
694
- * Create a synchronous `Assertion` from {@link AssertionParts | parts} and a
695
- * {@link z.ZodType | Zod schema}.
696
- *
697
- * @template Parts Parts defining the shape of the assertion, including
698
- * Phrases and Zod schemas
699
- * @template Impl Assertion implementation as a Zod schema
700
- * @template Slots Inferred slots based on the provided `Parts`
701
- * @returns New `AssertionSchemaSync` object
702
- */
703
- <const Parts extends AssertionParts, Impl extends RawAssertionImplSchemaSync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionSchemaSync<Parts, AssertionImplSchemaSync<Parts>, Slots>;
704
- /**
705
- * Create a synchronous `Assertion` from {@link AssertionParts | parts} and an
706
- * implementation function.
707
- *
708
- * @template Parts Parts defining the shape of the assertion, including
709
- * Phrases and Zod schemas
710
- * @template Impl Assertion implementation as a function
711
- * @template Slots Inferred slots based on the provided `Parts`
712
- * @returns New `AssertionFunctionSync` object
713
- */
714
- <const Parts extends AssertionParts, Impl extends AssertionImplFnSync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionFunctionSync<Parts, Impl, Slots>;
715
- }
716
- /**
717
- * The main factory function for creating asynchronous assertions.
718
- *
719
- * @group Core API
720
- */
721
- export interface CreateAsyncAssertionFn {
722
- /**
723
- * Create an async `Assertion` from {@link AssertionParts | parts} and a
724
- * Standard Schema validator.
725
- *
726
- * @template Parts Parts defining the shape of the assertion, including
727
- * Phrases and Zod schemas
728
- * @template Impl Assertion implementation as a Standard Schema
729
- * @template Slots Inferred slots based on the provided `Parts`
730
- * @returns New `AssertionStandardSchemaAsync` object
731
- */
732
- <const Parts extends AssertionParts, Impl extends StandardSchemaV1, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionStandardSchemaAsync<Parts, Impl, Slots>;
733
- /**
734
- * Create an async {@link Assertion} from {@link AssertionParts | parts} and an
735
- * {@link z.ZodType | Zod schema}.
736
- *
737
- * The Zod schema need not be async itself.
738
- *
739
- * @template Parts Parts defining the shape of the assertion, including
740
- * Phrases and Zod schemas
741
- * @template Impl Assertion implementation as a Zod schema
742
- * @template Slots Inferred slots based on the provided `Parts`
743
- * @returns New `AssertionSchemaAsync` object
744
- */
745
- <const Parts extends AssertionParts, Impl extends RawAssertionImplSchemaAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionSchemaAsync<Parts, AssertionImplSchemaAsync<Parts>, Slots>;
746
- /**
747
- * Create an async `Assertion` from {@link AssertionParts | parts} and an
748
- * implementation function.
749
- *
750
- * @template Parts Parts defining the shape of the assertion, including
751
- * Phrases and Zod schemas
752
- * @template Impl Assertion implementation as a function
753
- * @template Slots Inferred slots based on the provided `Parts`
754
- * @returns New `AssertionFunctionAsync` object
755
- */
756
- <const Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionFunctionAsync<Parts, Impl, Slots>;
757
- }
758
- /**
759
- * Utility type for parsed values that may be empty.
760
- *
761
- * This type processes assertion parts recursively to produce parsed values,
762
- * handling the case where no assertion parts are present (resulting in an empty
763
- * tuple). It uses `NoNeverTuple` to filter out `never` types that may arise
764
- * during the recursive processing.
765
- *
766
- * @template Parts - The assertion parts to process
767
- * @group Internal Assertion Types
768
- * @see {@link ParsedValues} for the standard parsed values type
769
- * @see {@link NoNeverTuple} for never-type filtering
770
- */
771
- export type MaybeEmptyParsedValues<Parts extends readonly AssertionPart[]> = NoNeverTuple<Parts extends readonly [
772
- infer First extends AssertionPart,
773
- ...infer Rest extends readonly AssertionPart[]
774
- ] ? First extends PhraseLiteral | PhraseLiteralChoice ? readonly [
775
- unknown,
776
- AssertionImplPart<First>,
777
- ...AssertionImplParts<Rest>
778
- ] : readonly [AssertionImplPart<First>, ...AssertionImplParts<Rest>] : readonly []>;
779
- /**
780
- * Utility type that removes `never` entries from a tuple while preserving tuple
781
- * structure.
782
- *
783
- * This recursive type filters out `never` types from tuple types, which can
784
- * occur during type-level transformations. It maintains the readonly tuple
785
- * structure while removing invalid entries.
786
- *
787
- * @example
788
- *
789
- * ```ts
790
- * type WithNever = readonly [string, never, number, never];
791
- * type Filtered = NoNeverTuple<WithNever>; // readonly [string, number]
792
- *
793
- * type Empty = NoNeverTuple<readonly [never, never]>; // readonly []
794
- * type Mixed = NoNeverTuple<readonly [boolean, never, string]>; // readonly [boolean, string]
795
- * ```
796
- *
797
- * @template T - The readonly tuple type to filter
798
- * @group Utility Types
799
- * @see {@link AssertionPartsToSlots} for usage in slot processing
800
- * @see {@link AssertionSlots} for filtered slot tuples
801
- */
802
- export type NoNeverTuple<T extends readonly unknown[]> = T extends readonly [
803
- infer First,
804
- ...infer Rest
805
- ] ? [First] extends [never] ? readonly [...NoNeverTuple<Rest>] : readonly [First, ...NoNeverTuple<Rest>] : readonly [];
806
- /**
807
- * Union type representing the result of parsing assertion arguments.
808
- *
809
- * This represents either a successful parse (containing validated arguments) or
810
- * a parse failure (indicating arguments don't match the assertion). Used by
811
- * `parseValues()` and `parseValuesAsync()` methods to communicate whether the
812
- * assertion can be executed with the given arguments.
813
- *
814
- * @example
815
- *
816
- * ```ts
817
- * // Successful parse
818
- * const success: ParsedResult<Parts> = {
819
- * success: true,
820
- * exactMatch: true,
821
- * parsedValues: [subject, ...params],
822
- * };
823
- *
824
- * // Parse failure
825
- * const failure: ParsedResult<Parts> = {
826
- * success: false,
827
- * };
828
- * ```
829
- *
830
- * @template Parts - The assertion parts tuple defining expected structure
831
- * @group Internal Assertion Types
832
- * @see {@link ParsedResultSuccess} for successful parse results
833
- * @see {@link ParsedResultFailure} for failed parse results
834
- * @see {@link AssertionSync.parseValues} and {@link AssertionAsync.parseValuesAsync} for usage context
835
- */
836
- export type ParsedResult<Parts extends AssertionParts = AssertionParts> = ParsedResultFailure | ParsedResultSuccess<Parts>;
837
- /**
838
- * Interface representing a failed argument parsing attempt.
839
- *
840
- * When assertion arguments don't match the expected slots (wrong number of
841
- * arguments, type mismatches, phrase literal mismatches), parsing fails and
842
- * returns this interface. The assertion cannot be executed with the provided
843
- * arguments.
844
- *
845
- * @group Internal Assertion Types
846
- * @see {@link ParsedResultSuccess} for successful parsing results
847
- * @see {@link BaseParsedResult} for shared result properties
848
- */
849
- export interface ParsedResultFailure extends BaseParsedResult<never> {
850
- exactMatch?: never;
851
- parsedValues?: never;
852
- success: false;
853
- }
854
- /**
855
- * Interface representing a successful argument parsing attempt.
856
- *
857
- * When assertion arguments successfully match the expected slots, this
858
- * interface contains the validated arguments and metadata about the match
859
- * quality. The assertion can be executed using the `parsedValues`.
860
- *
861
- * @template Parts - The assertion parts tuple defining the expected structure
862
- * @group Internal Assertion Types
863
- * @see {@link ParsedResultFailure} for failed parsing results
864
- * @see {@link BaseParsedResult} for shared result properties
865
- */
866
- export interface ParsedResultSuccess<Parts extends AssertionParts> extends BaseParsedResult<Parts> {
867
- exactMatch: boolean;
868
- parsedValues: ParsedValues<Parts>;
869
- /**
870
- * Optional cached subject validation result for optimized schema assertions.
871
- * When present, indicates that subject validation was already performed
872
- * during parseValues() and doesn't need to be repeated in execute().
873
- *
874
- * Supports both Zod errors and Standard Schema issues.
875
- */
876
- subjectValidationResult?: {
877
- data: any;
878
- success: true;
879
- } | {
880
- error: z.ZodError;
881
- success: false;
882
- } | {
883
- issues: ReadonlyArray<StandardSchemaV1.Issue>;
884
- success: false;
885
- };
886
- success: true;
887
- }
888
- /**
889
- * Type extracting the subject (first argument) from parsed assertion values.
890
- *
891
- * This utility type extracts the subject of an assertion from the parsed values
892
- * tuple. The subject is always the first element and represents the value being
893
- * tested by the assertion.
894
- *
895
- * @example
896
- *
897
- * ```ts
898
- * // For assertion: expect(value, 'to be a string')
899
- * type Subject = ParsedSubject<Parts>; // typeof value
900
- *
901
- * // For assertion: expect(42, 'to be greater than', 10)
902
- * type NumericSubject = ParsedSubject<NumericParts>; // number
903
- * ```
904
- *
905
- * @template Parts - The assertion parts tuple defining the assertion structure
906
- * @group Internal Assertion Types
907
- * @see {@link ParsedValues} for the complete parsed values tuple
908
- * @see {@link AssertionImpl} for how subjects are used in implementations
909
- */
910
- export type ParsedSubject<Parts extends AssertionParts> = ParsedValues<Parts> extends readonly [infer Subject, ...any[]] ? Subject : never;
911
- /**
912
- * Tuple type containing validated arguments for assertion execution.
913
- *
914
- * This represents the final processed arguments that will be passed to an
915
- * assertion implementation function. The tuple contains the subject (first)
916
- * followed by any additional parameters, with phrase literals filtered out
917
- * since they're not passed to implementations.
918
- *
919
- * @example
920
- *
921
- * ```ts
922
- * // For assertion: expect(value, 'to be greater than', 10)
923
- * // ParsedValues = [typeof value, 10] (phrase literal removed)
924
- *
925
- * // For assertion: expect(obj, 'to satisfy', shape)
926
- * // ParsedValues = [typeof obj, typeof shape]
927
- * ```
928
- *
929
- * @template Parts - The assertion parts tuple defining the expected structure
930
- * @group Internal Assertion Types
931
- * @see {@link ParsedSubject} for extracting just the subject
932
- * @see {@link MaybeEmptyParsedValues} for the underlying value processing
933
- * @see {@link AssertionImpl} for how these values are consumed
934
- */
935
- export type ParsedValues<Parts extends AssertionParts = AssertionParts> = 0 extends 1 & Parts ? readonly unknown[] : MaybeEmptyParsedValues<Parts> extends readonly [] ? never : MaybeEmptyParsedValues<Parts>;
936
- /**
937
- * Union type combining both phrase literal types.
938
- *
939
- * A phrase represents the natural language portion of an assertion that
940
- * describes the expected behavior. It can be either a single string literal or
941
- * a choice between multiple string literals.
942
- *
943
- * @example
944
- *
945
- * ```ts
946
- * // Single phrase literal
947
- * type Phrase1 = PhraseLiteral; // "to be a string"
948
- *
949
- * // Choice phrase literal
950
- * type Phrase2 = PhraseLiteralChoice; // ["to be", "to equal"]
951
- * ```
952
- *
953
- * @group Assertion Creation
954
- * @see {@link PhraseLiteral} for single string phrases
955
- * @see {@link PhraseLiteralChoice} for choice-based phrases
956
- * @see {@link AssertionPart} for how phrases fit into assertion structure
957
- */
958
- export type Phrase = PhraseLiteral | PhraseLiteralChoice;
959
- /**
960
- * Type representing a single phrase literal string.
961
- *
962
- * This is a string literal that `expect()` will match exactly in its parameter
963
- * position. The phrase describes the natural language expectation for the
964
- * assertion. If the first item in assertion parts is a phrase literal, a
965
- * subject slot (`unknown`) is automatically added.
966
- *
967
- * Phrases cannot start with "not " as this would conflict with negation logic.
968
- *
969
- * @example
970
- *
971
- * ```ts
972
- * // Valid phrase literals
973
- * type Phrase1 = 'to be a string';
974
- * type Phrase2 = 'to have length';
975
- * type Phrase3 = 'to contain';
976
- *
977
- * // Usage in assertion
978
- * createAssertion(['to be a string'], z.string());
979
- * // expect(value, 'to be a string') ✓
980
- * ```
981
- *
982
- * @group Assertion Creation
983
- * @see {@link PhraseLiteralChoice} for multi-option phrases
984
- * @see {@link PhraseLiteralSlot} for compiled slot representation
985
- * @see {@link AssertionPart} for how phrases fit into assertion structure
986
- */
987
- export type PhraseLiteral = string;
988
- /**
989
- * Type representing a choice between multiple phrase literals.
990
- *
991
- * This allows an assertion to accept any of several equivalent phrase options,
992
- * providing flexibility in natural language expression. The type is a non-empty
993
- * readonly tuple of strings.
994
- *
995
- * @example
996
- *
997
- * ```ts
998
- * // Choice phrase literal
999
- * type Choice = ['to be', 'to equal'];
1000
- *
1001
- * // Usage in assertion
1002
- * createAssertion(
1003
- * [z.any(), ['to be', 'to equal'], z.any()],
1004
- * (subject, expected) => subject === expected,
1005
- * );
1006
- *
1007
- * // Both work:
1008
- * // expect(value, 'to be', expected) ✓
1009
- * // expect(value, 'to equal', expected) ✓
1010
- * ```
1011
- *
1012
- * @group Assertion Creation
1013
- * @see {@link PhraseLiteral} for single phrase options
1014
- * @see {@link PhraseLiteralChoiceSlot} for compiled slot representation
1015
- * @see {@link AssertionPart} for how phrases fit into assertion structure
1016
- */
1017
- export type PhraseLiteralChoice = NonEmptyTuple<string>;
1018
- /**
1019
- * Branded Zod type representing a compiled choice phrase slot.
1020
- *
1021
- * This is the runtime representation of a {@link PhraseLiteralChoice} that has
1022
- * been processed into a validation slot. It includes metadata about the
1023
- * available choice values for runtime phrase matching.
1024
- *
1025
- * @privateRemarks
1026
- * The `__values` property might be redundant since values should be derivable
1027
- * from the ZodLiteral metadata, but it provides type-level access to the
1028
- * choices.
1029
- * @template H - The readonly tuple of string choices
1030
- * @group Internal Assertion Types
1031
- * @see {@link PhraseLiteralChoice} for the source type
1032
- * @see {@link PhraseLiteralSlot} for single phrase slots
1033
- * @see {@link AssertionSlot} for slot type mapping
1034
- */
1035
- export type PhraseLiteralChoiceSlot<H extends readonly [string, ...string[]]> = z.core.$ZodBranded<z.ZodType, 'string-literal'> & {
1036
- readonly __values: H;
1037
- };
1038
- /**
1039
- * Branded Zod type representing a compiled phrase literal slot.
1040
- *
1041
- * This is the runtime representation of a {@link PhraseLiteral} that has been
1042
- * processed into a validation slot. The slot is branded with 'string-literal'
1043
- * to distinguish it from regular string validation during assertion matching.
1044
- *
1045
- * @privateRemarks
1046
- * This type might be redundant since the value should be derivable from the
1047
- * ZodLiteral's value property, but it provides type-level access to the
1048
- * literal.
1049
- * @template T - The string literal type
1050
- * @group Internal Assertion Types
1051
- * @see {@link PhraseLiteral} for the source type
1052
- * @see {@link PhraseLiteralChoiceSlot} for choice phrase slots
1053
- * @see {@link AssertionSlot} for slot type mapping
1054
- */
1055
- export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLiteral<T>, 'string-literal'>;
1056
- /**
1057
- * Type for a raw (unbranded) asynchronous schema assertion implementation.
1058
- *
1059
- * This represents a standard Zod schema without branding that validates the
1060
- * assertion subject synchronously. Unlike {@link AssertionImplSchemaAsync}, this
1061
- * type is not branded and represents the underlying schema before it is
1062
- * processed by the assertion creation system.
1063
- *
1064
- * @template Parts The tuple defining the assertion structure
1065
- * @useDeclaredType
1066
- * @group Assertion Implementation
1067
- * @see {@link AssertionImplSchemaAsync} for the branded version
1068
- * @see {@link ParsedSubject} for subject type derivation
1069
- */
1070
- export type RawAssertionImplSchemaAsync<Parts extends AssertionParts> = z.ZodType<ParsedSubject<Parts>>;
1071
- /**
1072
- * Type for a raw (unbranded) synchronous schema assertion implementation.
1073
- *
1074
- * This represents a standard Zod schema without branding that validates the
1075
- * assertion subject synchronously. Unlike {@link AssertionImplSchemaSync}, this
1076
- * type is not branded and represents the underlying schema before it is
1077
- * processed by the assertion creation system.
1078
- *
1079
- * @template Parts The tuple defining the assertion structure
1080
- * @useDeclaredType
1081
- * @group Assertion Implementation
1082
- * @see {@link AssertionImplSchemaSync} for the branded version
1083
- * @see {@link ParsedSubject} for subject type derivation
1084
- */
1085
- export type RawAssertionImplSchemaSync<Parts extends AssertionParts> = z.ZodType<ParsedSubject<Parts>>;
1086
- //# sourceMappingURL=assertion-types.d.ts.map