bupkis 0.5.1 → 0.6.0
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.
- package/CHANGELOG.md +13 -0
- package/README.md +19 -19
- package/dist/commonjs/assertion/assertion-types.d.ts +183 -13
- package/dist/commonjs/assertion/assertion-types.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-types.js +39 -0
- package/dist/commonjs/assertion/assertion-types.js.map +1 -1
- package/dist/commonjs/assertion/assertion.d.ts +14 -8
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +11 -8
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/create.d.ts +3 -1
- package/dist/commonjs/assertion/create.d.ts.map +1 -1
- package/dist/commonjs/assertion/create.js +26 -6
- package/dist/commonjs/assertion/create.js.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.d.ts +0 -165
- package/dist/commonjs/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.js +1 -303
- package/dist/commonjs/assertion/impl/assertion-util.js.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.js +4 -1
- package/dist/commonjs/assertion/impl/async-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/async.d.ts +3 -96
- package/dist/commonjs/assertion/impl/async.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async.js +18 -25
- package/dist/commonjs/assertion/impl/async.js.map +1 -1
- package/dist/commonjs/assertion/impl/index.d.ts +0 -1
- package/dist/commonjs/assertion/impl/index.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/index.js +0 -1
- package/dist/commonjs/assertion/impl/index.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.d.ts +13 -2
- package/dist/commonjs/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.js +10 -2
- package/dist/commonjs/assertion/impl/sync-basic.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.d.ts +20 -12
- package/dist/commonjs/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.js +24 -24
- package/dist/commonjs/assertion/impl/sync-collection.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts +44 -5
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js +61 -4
- package/dist/commonjs/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts +10 -10
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +11 -7
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +81 -99
- package/dist/commonjs/assertion/impl/sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync.js +37 -54
- package/dist/commonjs/assertion/impl/sync.js.map +1 -1
- package/dist/commonjs/assertion/index.d.ts +2 -1
- package/dist/commonjs/assertion/index.d.ts.map +1 -1
- package/dist/commonjs/assertion/index.js +4 -1
- package/dist/commonjs/assertion/index.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +42 -91
- package/dist/commonjs/bootstrap.d.ts.map +1 -1
- package/dist/commonjs/bootstrap.js +2 -0
- package/dist/commonjs/bootstrap.js.map +1 -1
- package/dist/commonjs/error.d.ts +2 -0
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +2 -0
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/index.d.ts +49 -94
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +8 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/schema.d.ts +42 -0
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +47 -1
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/types.d.ts +178 -90
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +5 -2
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/use.d.ts +7 -3
- package/dist/commonjs/use.d.ts.map +1 -1
- package/dist/commonjs/use.js +178 -1
- package/dist/commonjs/use.js.map +1 -1
- package/dist/esm/assertion/assertion-types.d.ts +183 -13
- package/dist/esm/assertion/assertion-types.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-types.js +38 -1
- package/dist/esm/assertion/assertion-types.js.map +1 -1
- package/dist/esm/assertion/assertion.d.ts +14 -8
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +10 -7
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/create.d.ts +3 -1
- package/dist/esm/assertion/create.d.ts.map +1 -1
- package/dist/esm/assertion/create.js +26 -6
- package/dist/esm/assertion/create.js.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.d.ts +0 -165
- package/dist/esm/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.js +0 -291
- package/dist/esm/assertion/impl/assertion-util.js.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.js +4 -1
- package/dist/esm/assertion/impl/async-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/async.d.ts +3 -96
- package/dist/esm/assertion/impl/async.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async.js +3 -24
- package/dist/esm/assertion/impl/async.js.map +1 -1
- package/dist/esm/assertion/impl/index.d.ts +0 -1
- package/dist/esm/assertion/impl/index.d.ts.map +1 -1
- package/dist/esm/assertion/impl/index.js +0 -1
- package/dist/esm/assertion/impl/index.js.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.d.ts +13 -2
- package/dist/esm/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.js +11 -3
- package/dist/esm/assertion/impl/sync-basic.js.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.d.ts +20 -12
- package/dist/esm/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.js +25 -25
- package/dist/esm/assertion/impl/sync-collection.js.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.d.ts +44 -5
- package/dist/esm/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.js +60 -3
- package/dist/esm/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts +10 -10
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +12 -8
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +81 -99
- package/dist/esm/assertion/impl/sync.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync.js +37 -54
- package/dist/esm/assertion/impl/sync.js.map +1 -1
- package/dist/esm/assertion/index.d.ts +2 -1
- package/dist/esm/assertion/index.d.ts.map +1 -1
- package/dist/esm/assertion/index.js +2 -0
- package/dist/esm/assertion/index.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +42 -91
- package/dist/esm/bootstrap.d.ts.map +1 -1
- package/dist/esm/bootstrap.js +2 -0
- package/dist/esm/bootstrap.js.map +1 -1
- package/dist/esm/error.d.ts +2 -0
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +2 -0
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/index.d.ts +49 -94
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schema.d.ts +42 -0
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +46 -0
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/types.d.ts +178 -90
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +5 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/use.d.ts +7 -3
- package/dist/esm/use.d.ts.map +1 -1
- package/dist/esm/use.js +178 -1
- package/dist/esm/use.js.map +1 -1
- package/package.json +5 -4
- package/src/assertion/assertion-types.ts +239 -14
- package/src/assertion/assertion.ts +15 -7
- package/src/assertion/create.ts +37 -8
- package/src/assertion/impl/assertion-util.ts +0 -353
- package/src/assertion/impl/async-parametric.ts +5 -1
- package/src/assertion/impl/async.ts +3 -36
- package/src/assertion/impl/index.ts +0 -1
- package/src/assertion/impl/sync-basic.ts +12 -3
- package/src/assertion/impl/sync-collection.ts +28 -25
- package/src/assertion/impl/sync-esoteric.ts +65 -7
- package/src/assertion/impl/sync-parametric.ts +13 -8
- package/src/assertion/impl/sync.ts +38 -66
- package/src/assertion/index.ts +2 -1
- package/src/bootstrap.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +11 -4
- package/src/schema.ts +47 -0
- package/src/types.ts +205 -139
- package/src/use.ts +199 -10
- package/dist/commonjs/assertion/impl/async-callback.d.ts +0 -273
- package/dist/commonjs/assertion/impl/async-callback.d.ts.map +0 -1
- package/dist/commonjs/assertion/impl/async-callback.js +0 -427
- package/dist/commonjs/assertion/impl/async-callback.js.map +0 -1
- package/dist/commonjs/assertion/impl/sync-callback.d.ts +0 -281
- package/dist/commonjs/assertion/impl/sync-callback.d.ts.map +0 -1
- package/dist/commonjs/assertion/impl/sync-callback.js +0 -413
- package/dist/commonjs/assertion/impl/sync-callback.js.map +0 -1
- package/dist/esm/assertion/impl/async-callback.d.ts +0 -273
- package/dist/esm/assertion/impl/async-callback.d.ts.map +0 -1
- package/dist/esm/assertion/impl/async-callback.js +0 -424
- package/dist/esm/assertion/impl/async-callback.js.map +0 -1
- package/dist/esm/assertion/impl/sync-callback.d.ts +0 -281
- package/dist/esm/assertion/impl/sync-callback.d.ts.map +0 -1
- package/dist/esm/assertion/impl/sync-callback.js +0 -410
- package/dist/esm/assertion/impl/sync-callback.js.map +0 -1
- package/src/assertion/impl/async-callback.ts +0 -507
- package/src/assertion/impl/sync-callback.ts +0 -483
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/boneskull/bupkis/compare/bupkis-v0.5.1...bupkis-v0.6.0) (2025-09-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **assertions:** create expectAsync.it ([fb4db5a](https://github.com/boneskull/bupkis/commit/fb4db5afc4d2ab6e0affc073ab03c670264a3bbd))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **assertions:** "map/set to have size greater than" now expects nonnegative int size ([2355ba0](https://github.com/boneskull/bupkis/commit/2355ba0494baeb5050024e6fadd8a28a900f5dcc))
|
|
14
|
+
* **assertions:** narrow some schemas ([fc0b708](https://github.com/boneskull/bupkis/commit/fc0b7086ba898a43f3c9558aff6ede30723e38c6))
|
|
15
|
+
|
|
3
16
|
## [0.5.1](https://github.com/boneskull/bupkis/compare/bupkis-v0.5.0...bupkis-v0.5.1) (2025-09-18)
|
|
4
17
|
|
|
5
18
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="./site/media/bupkis-logo-512.png" width="512px" align="center" alt="BUPKIS: The Glory of Certainty"
|
|
2
|
+
<a href="/"><img src="./site/media/bupkis-logo-512.png" width="512px" align="center" alt="BUPKIS: The Glory of Certainty"/></a>
|
|
3
3
|
<h1 align="center"><span class="bupkis">⁓ BUPKIS ⁓<span></h1>
|
|
4
4
|
<p align="center">
|
|
5
|
-
Uncommonly
|
|
5
|
+
<em>“Uncommonly Extensible Assertions for The Beautiful People”</em>
|
|
6
6
|
<br/>
|
|
7
7
|
<small>by <a href="https://github.com/boneskull" title="@boneskull on GitHub">@boneskull</a></small>
|
|
8
8
|
</p>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
Look, we're ~~old~~ ~~wizened~~ ~~experienced~~ knowledgeable and we've written a lot of tests. We've used a lot of assertion libraries. There are ones we prefer and ones we don't.
|
|
25
25
|
|
|
26
|
-
But none of them do quite what
|
|
26
|
+
But none of them do quite what **BUPKIS** does. We want an assertion library that prioritizes:
|
|
27
27
|
|
|
28
28
|
- Type safety
|
|
29
29
|
- Uncompromisable extensibility
|
|
@@ -33,7 +33,7 @@ We can think of several that tick two-thirds of those boxes! But _we demand the
|
|
|
33
33
|
|
|
34
34
|
> ⚠️ **Caution!**
|
|
35
35
|
>
|
|
36
|
-
> Assertion libraries tend come in two flavors: chainable or stiff & traditional. But because these styles are likely _familiar_ to you, you may hate
|
|
36
|
+
> Assertion libraries tend come in two flavors: chainable or stiff & traditional. But because these styles are likely _familiar_ to you, you may hate **BUPKIS**.
|
|
37
37
|
>
|
|
38
38
|
> We _want_ you to like it, yes. But if you don't, we're content with just making our point and asking the following favor of the reader:
|
|
39
39
|
>
|
|
@@ -43,9 +43,9 @@ The following is a brief overview of the design choices we made to serve these g
|
|
|
43
43
|
|
|
44
44
|
### Natural Language Assertions
|
|
45
45
|
|
|
46
|
-
In
|
|
46
|
+
In **BUPKIS**, "natural language" is the means to the end of "a small API surface".
|
|
47
47
|
|
|
48
|
-
When you're using
|
|
48
|
+
When you're using **BUPKIS**, you **don't** write this:
|
|
49
49
|
|
|
50
50
|
```js
|
|
51
51
|
expect(actual).toEqual(expected);
|
|
@@ -73,7 +73,7 @@ If another assertion library wants you to write:
|
|
|
73
73
|
expect(actual).to.be.a('string');
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
Then
|
|
76
|
+
Then **BUPKIS** wants you to write:
|
|
77
77
|
|
|
78
78
|
```js
|
|
79
79
|
expect(actual, 'to be a string');
|
|
@@ -81,7 +81,7 @@ expect(actual, 'to be a string');
|
|
|
81
81
|
expect(actual, 'to be an string');
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Can't remember the phrase? Did you forget a word or make a typo? Maybe you also forgot **
|
|
84
|
+
Can't remember the phrase? Did you forget a word or make a typo? Maybe you also forgot \***\*BUPKIS** is type-safe?!\*\* You'll get a nice squiggly for your trouble.
|
|
85
85
|
|
|
86
86
|
This isn't black magic. It ain't no _cauldron_. We're not just _throwing rat tails and `string`s into a function and stirring that shit up._
|
|
87
87
|
|
|
@@ -95,9 +95,9 @@ You may wonder how this could this be anything _but_ loosey-goosey _senselessnes
|
|
|
95
95
|
|
|
96
96
|
To formalize the conventions at a high level:
|
|
97
97
|
|
|
98
|
-
- The first parameter to a
|
|
98
|
+
- The first parameter to a **BUPKIS** assertion is always the _subject_ ([def.](https://bupkis.zip/documents/Reference.Glossary_of_Terms#subject)).
|
|
99
99
|
|
|
100
|
-
- The "string" part of a
|
|
100
|
+
- The "string" part of a **BUPKIS** assertion is known as a _phrase_. Every expectation will contain _at minimum_ one (1) phrase. As you can see from the above "to be a string" example, phrases often have aliases.
|
|
101
101
|
|
|
102
102
|
- Assertions may have multiple phrases or parameters, but the simplest assertions always look like this:
|
|
103
103
|
|
|
@@ -155,7 +155,7 @@ To formalize the conventions at a high level:
|
|
|
155
155
|
|
|
156
156
|
### Custom Assertions Built With Zod
|
|
157
157
|
|
|
158
|
-
[Zod][] is a popular object validation library which does some heavy lifting for
|
|
158
|
+
[Zod][] is a popular object validation library which does some heavy lifting for **BUPKIS**—most of the built-in assertions are implemented using Zod schemas. And so **BUPKIS** extends this capability to you.
|
|
159
159
|
|
|
160
160
|
An example will be illuminating. What follows is a ~~stupid~~ ~~quick~~ _stupid_ example of a creating and "registering" a basic assertion _which can be invoked using two different phrases_:
|
|
161
161
|
|
|
@@ -189,7 +189,7 @@ expect('skiball lavatory', 'to be a string');
|
|
|
189
189
|
|
|
190
190
|
### Excruciating Type Safety
|
|
191
191
|
|
|
192
|
-
We have tried to make
|
|
192
|
+
We have tried to make **BUPKIS** is as type-safe as possible. To be clear, _that is pretty damn possible_. This means:
|
|
193
193
|
|
|
194
194
|
- Every built-in assertion is fully type-safe and is declared as an overload for `expect()` or `expectAsync()`.
|
|
195
195
|
- Every _custom_ assertion is _also_ fully type-safe and is declared as an overload for `expect()` or `expectAsync()` (as returned from `use()`)
|
|
@@ -201,15 +201,15 @@ We have tried to make _BUPKIS_ is as type-safe as possible. To be clear, _that i
|
|
|
201
201
|
|
|
202
202
|
**Node.js**: ^20.19.0, ^22.12.0, >=23
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
**BUPKIS** has a peer dependency on [Zod][] v4+, but will install it as an optional dependency if you are not already using it.
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
**BUPKIS** ships as a dual CJS/ESM package.
|
|
207
207
|
|
|
208
|
-
> Disclaimer:
|
|
208
|
+
> Disclaimer: **BUPKIS** has been designed to run on Node.js in a development environment. Anyone attempting to deploy **BUPKIS** to some server somewhere will get what is coming to them.
|
|
209
209
|
|
|
210
210
|
## Installation
|
|
211
211
|
|
|
212
|
-
```
|
|
212
|
+
```sh
|
|
213
213
|
npm install bupkis -D
|
|
214
214
|
```
|
|
215
215
|
|
|
@@ -221,14 +221,14 @@ npm install bupkis -D
|
|
|
221
221
|
|
|
222
222
|
## Acknowledgements
|
|
223
223
|
|
|
224
|
-
- [Unexpected][] is the main inspiration for
|
|
225
|
-
- [Zod][] is a popular object validation library upon which
|
|
224
|
+
- [Unexpected][] is the main inspiration for **BUPKIS**. However, creating types for this library was exceedingly difficult (and was in fact the first thing we tried). Despite that drawback, we found it exquisitely usable.
|
|
225
|
+
- [Zod][] is a popular object validation library upon which **BUPKIS** builds many of its own assertions.
|
|
226
226
|
- [fast-check][]: Thanks to Nicholas Dubien for this library. There is **no better library** for an assertion library to use to test itself! Well, besides itself, we mean. How about _in addition to_ itself? Yes. Thank you!
|
|
227
227
|
- [tshy][] from Isaac Schlueter. Thanks for making dual ESM/CJS packages easy and not too fancy.
|
|
228
228
|
- [TypeDoc][] it really documents the hell out of TypeScript projects.
|
|
229
229
|
- [@cjihrig](https://github.com/cjihrig) and other Node.js contributors for the thoughtfulness put into [`node:test`](https://nodejs.org/api/test.html) that make it my current test-runner-of-choice.
|
|
230
230
|
|
|
231
|
-
## Why is it called
|
|
231
|
+
## Why is it called **BUPKIS**?
|
|
232
232
|
|
|
233
233
|
TODO: think of good reason and fill in later
|
|
234
234
|
|
|
@@ -7,15 +7,23 @@
|
|
|
7
7
|
* creation and execution.
|
|
8
8
|
*
|
|
9
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.
|
|
10
17
|
*/
|
|
11
18
|
import { type NonEmptyTuple } from 'type-fest';
|
|
12
|
-
import {
|
|
19
|
+
import { z } from 'zod/v4';
|
|
13
20
|
/**
|
|
14
21
|
* Union type representing any assertion, either synchronous or asynchronous.
|
|
15
22
|
*
|
|
16
23
|
* This type combines all possible assertion types into a single union for cases
|
|
17
24
|
* where the synchronous/asynchronous nature is not known at compile time.
|
|
18
25
|
*
|
|
26
|
+
* @group Internal Assertion Types
|
|
19
27
|
* @see {@link AnyAsyncAssertion} for async-specific assertions
|
|
20
28
|
* @see {@link AnySyncAssertion} for sync-specific assertions
|
|
21
29
|
*/
|
|
@@ -26,6 +34,7 @@ export type AnyAssertion = AnyAsyncAssertion | AnySyncAssertion;
|
|
|
26
34
|
* Used to represent collections of assertions where at least one assertion must
|
|
27
35
|
* be present.
|
|
28
36
|
*
|
|
37
|
+
* @group Internal Assertion Types
|
|
29
38
|
* @see {@link AnyAssertion} for individual assertion types
|
|
30
39
|
*/
|
|
31
40
|
export type AnyAssertions = NonEmptyTuple<AnyAssertion>;
|
|
@@ -35,6 +44,7 @@ export type AnyAssertions = NonEmptyTuple<AnyAssertion>;
|
|
|
35
44
|
* This includes both function-based and schema-based async assertions but
|
|
36
45
|
* excludes synchronous assertions to maintain type safety.
|
|
37
46
|
*
|
|
47
|
+
* @group Internal Assertion Types
|
|
38
48
|
* @see {@link AssertionFunctionAsync} for function-based async assertions
|
|
39
49
|
* @see {@link AssertionSchemaAsync} for schema-based async assertions
|
|
40
50
|
*/
|
|
@@ -54,6 +64,7 @@ export type AnyAsyncAssertions = NonEmptyTuple<AnyAsyncAssertion>;
|
|
|
54
64
|
* This includes both function-based and schema-based sync assertions but
|
|
55
65
|
* excludes asynchronous assertions to maintain type safety.
|
|
56
66
|
*
|
|
67
|
+
* @group Internal Assertion Types
|
|
57
68
|
* @see {@link AssertionFunctionSync} for function-based sync assertions
|
|
58
69
|
* @see {@link AssertionSchemaSync} for schema-based sync assertions
|
|
59
70
|
*/
|
|
@@ -64,6 +75,7 @@ export type AnySyncAssertion = AssertionFunctionSync<any, any, any> | AssertionS
|
|
|
64
75
|
* Used to represent collections of sync assertions where at least one assertion
|
|
65
76
|
* must be present.
|
|
66
77
|
*
|
|
78
|
+
* @group Internal Assertion Types
|
|
67
79
|
* @see {@link AnySyncAssertion} for individual sync assertion types
|
|
68
80
|
*/
|
|
69
81
|
export type AnySyncAssertions = NonEmptyTuple<AnySyncAssertion>;
|
|
@@ -73,6 +85,8 @@ export type AnySyncAssertions = NonEmptyTuple<AnySyncAssertion>;
|
|
|
73
85
|
* This interface defines the contract for assertion instances, including
|
|
74
86
|
* properties for assertion parts, implementation, slots, and methods for
|
|
75
87
|
* parsing and executing assertions both synchronously and asynchronously.
|
|
88
|
+
*
|
|
89
|
+
* @group Internal Assertion Interfaces
|
|
76
90
|
*/
|
|
77
91
|
export interface Assertion<Parts extends AssertionParts, Impl extends AssertionImpl<Parts>, Slots extends AssertionSlots<Parts>> {
|
|
78
92
|
readonly id: string;
|
|
@@ -95,6 +109,11 @@ export interface Assertion<Parts extends AssertionParts, Impl extends AssertionI
|
|
|
95
109
|
*/
|
|
96
110
|
toString(): string;
|
|
97
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Type for an object which represents a discrete asynchronous assertion.
|
|
114
|
+
*
|
|
115
|
+
* @group Internal Assertion Interfaces
|
|
116
|
+
*/
|
|
98
117
|
export interface AssertionAsync<Parts extends AssertionParts = AssertionParts, Impl extends AssertionImplAsync<Parts> = AssertionImplAsync<Parts>, Slots extends AssertionSlots<Parts> = AssertionSlots<Parts>> extends Assertion<Parts, Impl, Slots> {
|
|
99
118
|
/**
|
|
100
119
|
* Execute the assertion implementation asynchronously.
|
|
@@ -114,6 +133,12 @@ export interface AssertionAsync<Parts extends AssertionParts = AssertionParts, I
|
|
|
114
133
|
*/
|
|
115
134
|
parseValuesAsync<Args extends readonly unknown[]>(args: Args): Promise<ParsedResult<Parts>>;
|
|
116
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Object which may be returned from assertion function implementations to
|
|
138
|
+
* provide better failure reporting to the end-user.
|
|
139
|
+
*
|
|
140
|
+
* @group Assertion Creation
|
|
141
|
+
*/
|
|
117
142
|
export interface AssertionFailure {
|
|
118
143
|
/**
|
|
119
144
|
* The actual value or condition that was encountered
|
|
@@ -130,18 +155,24 @@ export interface AssertionFailure {
|
|
|
130
155
|
}
|
|
131
156
|
/**
|
|
132
157
|
* An async assertion with a function implementation.
|
|
158
|
+
*
|
|
159
|
+
* @group Internal Assertion Interfaces
|
|
133
160
|
*/
|
|
134
161
|
export interface AssertionFunctionAsync<Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionAsync<Parts, Impl, Slots> {
|
|
135
162
|
impl: Impl;
|
|
136
163
|
}
|
|
137
164
|
/**
|
|
138
165
|
* A synchronous assertion with a function implementation.
|
|
166
|
+
*
|
|
167
|
+
* @group Internal Assertion Interfaces
|
|
139
168
|
*/
|
|
140
169
|
export interface AssertionFunctionSync<Parts extends AssertionParts, Impl extends AssertionImplFnSync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionSync<Parts, Impl, Slots> {
|
|
141
170
|
impl: Impl;
|
|
142
171
|
}
|
|
143
172
|
/**
|
|
144
173
|
* Any type of assertion implementation.
|
|
174
|
+
*
|
|
175
|
+
* @group Assertion Implementation
|
|
145
176
|
*/
|
|
146
177
|
export type AssertionImpl<Parts extends AssertionParts> = AssertionImplAsync<Parts> | AssertionImplSync<Parts>;
|
|
147
178
|
/**
|
|
@@ -152,6 +183,7 @@ export type AssertionImpl<Parts extends AssertionParts> = AssertionImplAsync<Par
|
|
|
152
183
|
* logic.
|
|
153
184
|
*
|
|
154
185
|
* @template Parts - The assertion parts defining the structure
|
|
186
|
+
* @group Assertion Implementation
|
|
155
187
|
* @see {@link AssertionImplFnAsync} for function-based async implementations
|
|
156
188
|
* @see {@link AssertionImplSchemaAsync} for schema-based async implementations
|
|
157
189
|
*/
|
|
@@ -169,12 +201,15 @@ export type AssertionImplAsync<Parts extends AssertionParts> = AssertionImplFnAs
|
|
|
169
201
|
* @returns Promise resolving to boolean indicating pass/fail, void for success,
|
|
170
202
|
* ZodType for dynamic validation, or AssertionFailure object for detailed
|
|
171
203
|
* error information
|
|
204
|
+
* @group Assertion Implementation
|
|
172
205
|
* @see {@link AssertionImplFnSync} for sync function implementations
|
|
173
206
|
* @see {@link ParsedValues} for the input parameter structure
|
|
174
207
|
*/
|
|
175
208
|
export type AssertionImplFnAsync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) => AssertionImplFnReturnType<Parts> | Promise<AssertionImplFnReturnType<Parts>>;
|
|
176
209
|
/**
|
|
177
210
|
* The return type of an assertion implementation function.
|
|
211
|
+
*
|
|
212
|
+
* @group Assertion Implementation
|
|
178
213
|
*/
|
|
179
214
|
export type AssertionImplFnReturnType<Parts extends AssertionParts> = AssertionFailure | boolean | void | z.ZodError | z.ZodType<ParsedSubject<Parts>>;
|
|
180
215
|
/**
|
|
@@ -189,6 +224,7 @@ export type AssertionImplFnReturnType<Parts extends AssertionParts> = AssertionF
|
|
|
189
224
|
* @param values - The parsed values corresponding to assertion parts
|
|
190
225
|
* @returns Boolean indicating pass/fail, void for success, ZodType for dynamic
|
|
191
226
|
* validation, or AssertionFailure object for detailed error information
|
|
227
|
+
* @group Assertion Implementation
|
|
192
228
|
* @see {@link AssertionImplFnAsync} for async function implementations
|
|
193
229
|
* @see {@link ParsedValues} for the input parameter structure
|
|
194
230
|
*/
|
|
@@ -197,10 +233,14 @@ export type AssertionImplFnSync<Parts extends AssertionParts> = (...values: Pars
|
|
|
197
233
|
* Maps an {@link AssertionPart} to a parameter to an {@link AssertionImpl}.
|
|
198
234
|
*
|
|
199
235
|
* This omits {@link Phrase} parts, which are not received by the implementation.
|
|
236
|
+
*
|
|
237
|
+
* @group Assertion Implementation
|
|
200
238
|
*/
|
|
201
239
|
export type AssertionImplPart<Part extends AssertionPart> = Part extends PhraseLiteral | PhraseLiteralChoice ? never : Part extends z.ZodPromise ? Promise<z.infer<Part>> : z.infer<Part>;
|
|
202
240
|
/**
|
|
203
241
|
* Maps {@link AssertionParts} to their corresponding {@link AssertionImplPart}.
|
|
242
|
+
*
|
|
243
|
+
* @group Assertion Implementation
|
|
204
244
|
*/
|
|
205
245
|
export type AssertionImplParts<Parts extends readonly AssertionPart[]> = Parts extends readonly [
|
|
206
246
|
infer First extends AssertionPart,
|
|
@@ -219,6 +259,7 @@ export type AssertionImplParts<Parts extends readonly AssertionPart[]> = Parts e
|
|
|
219
259
|
* safety.
|
|
220
260
|
*
|
|
221
261
|
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
262
|
+
* @group Assertion Implementation
|
|
222
263
|
* @see {@link AssertionImplSchemaSync} for synchronous schema implementations
|
|
223
264
|
* @see {@link AssertionImplFnAsync} for function-based async implementations
|
|
224
265
|
* @see {@link ParsedSubject} for subject type derivation
|
|
@@ -233,6 +274,7 @@ export type AssertionImplSchemaAsync<Parts extends AssertionParts> = z.core.$Zod
|
|
|
233
274
|
* safety.
|
|
234
275
|
*
|
|
235
276
|
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
277
|
+
* @group Assertion Implementation
|
|
236
278
|
* @see {@link AssertionImplSchemaAsync} for asynchronous schema implementations
|
|
237
279
|
* @see {@link AssertionImplFnSync} for function-based sync implementations
|
|
238
280
|
* @see {@link ParsedSubject} for subject type derivation
|
|
@@ -246,18 +288,7 @@ export type AssertionImplSchemaSync<Parts extends AssertionParts> = z.core.$ZodB
|
|
|
246
288
|
* logic, while schema implementations use Zod schemas for validation.
|
|
247
289
|
*
|
|
248
290
|
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
249
|
-
* @
|
|
250
|
-
* @see {@link AssertionImplSchemaSync} for schema-based implementations
|
|
251
|
-
* @see {@link AssertionImplAsync} for async implementation unions
|
|
252
|
-
*/
|
|
253
|
-
/**
|
|
254
|
-
* Union type for all synchronous assertion implementations.
|
|
255
|
-
*
|
|
256
|
-
* This represents either a function-based or schema-based implementation for
|
|
257
|
-
* synchronous assertions. Function implementations provide custom validation
|
|
258
|
-
* logic, while schema implementations use Zod schemas for validation.
|
|
259
|
-
*
|
|
260
|
-
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
291
|
+
* @group Assertion Implementation
|
|
261
292
|
* @see {@link AssertionImplFnSync} for function-based implementations
|
|
262
293
|
* @see {@link AssertionImplSchemaSync} for schema-based implementations
|
|
263
294
|
* @see {@link AssertionImplAsync} for async implementation unions
|
|
@@ -283,6 +314,7 @@ export type AssertionImplSync<Parts extends AssertionParts> = AssertionImplFnSyn
|
|
|
283
314
|
* type Part3 = z.ZodString;
|
|
284
315
|
* ```
|
|
285
316
|
*
|
|
317
|
+
* @group Internal Assertion Types
|
|
286
318
|
* @see {@link Phrase} for phrase-based parts
|
|
287
319
|
* @see {@link AssertionParts} for complete assertion structure
|
|
288
320
|
* @see {@link AssertionSlot} for compiled slot representation
|
|
@@ -310,6 +342,7 @@ export type AssertionPart = Phrase | z.ZodType;
|
|
|
310
342
|
* ```
|
|
311
343
|
*
|
|
312
344
|
* @template Parts - Extends the base AssertionPart array with tuple constraints
|
|
345
|
+
* @group Internal Assertion Types
|
|
313
346
|
* @see {@link AssertionPart} for individual part types
|
|
314
347
|
* @see {@link AssertionSlots} for compiled slot representation
|
|
315
348
|
* @see {@link createAssertion} for assertion creation from parts
|
|
@@ -335,6 +368,7 @@ export type AssertionParts = NonEmptyTuple<AssertionPart>;
|
|
|
335
368
|
* ```
|
|
336
369
|
*
|
|
337
370
|
* @template Parts - The readonly array of assertion parts to process
|
|
371
|
+
* @group Internal Assertion Types
|
|
338
372
|
* @see {@link AssertionSlot} for individual slot type mapping
|
|
339
373
|
* @see {@link AssertionSlots} for filtered and properly typed slot tuples
|
|
340
374
|
* @see {@link NoNeverTuple} for filtering never entries
|
|
@@ -343,9 +377,19 @@ export type AssertionPartsToSlots<Parts extends readonly AssertionPart[]> = Part
|
|
|
343
377
|
infer First extends AssertionPart,
|
|
344
378
|
...infer Rest extends readonly AssertionPart[]
|
|
345
379
|
] ? readonly [AssertionSlot<First>, ...AssertionPartsToSlots<Rest>] : readonly [];
|
|
380
|
+
/**
|
|
381
|
+
* An async assertion which is implemented using a Zod schema.
|
|
382
|
+
*
|
|
383
|
+
* @group Internal Assertion Interfaces
|
|
384
|
+
*/
|
|
346
385
|
export interface AssertionSchemaAsync<Parts extends AssertionParts, Impl extends AssertionImplSchemaAsync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionAsync<Parts, Impl, Slots> {
|
|
347
386
|
impl: Impl;
|
|
348
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* A synchronous assertion which is implemented using a Zod schema.
|
|
390
|
+
*
|
|
391
|
+
* @group Internal Assertion Interfaces
|
|
392
|
+
*/
|
|
349
393
|
export interface AssertionSchemaSync<Parts extends AssertionParts, Impl extends AssertionImplSchemaSync<Parts>, Slots extends AssertionSlots<Parts>> extends AssertionSync<Parts, Impl, Slots> {
|
|
350
394
|
impl: Impl;
|
|
351
395
|
}
|
|
@@ -375,6 +419,7 @@ export interface AssertionSchemaSync<Parts extends AssertionParts, Impl extends
|
|
|
375
419
|
* ```
|
|
376
420
|
*
|
|
377
421
|
* @template Part - The assertion part to convert to a slot
|
|
422
|
+
* @group Internal Assertion Types
|
|
378
423
|
* @see {@link PhraseLiteralSlot} for string literal slots
|
|
379
424
|
* @see {@link PhraseLiteralChoiceSlot} for choice-based slots
|
|
380
425
|
* @see {@link AssertionSlots} for complete slot tuples
|
|
@@ -411,6 +456,7 @@ export type AssertionSlot<Part extends AssertionPart> = Part extends string ? Ph
|
|
|
411
456
|
* ```
|
|
412
457
|
*
|
|
413
458
|
* @template Parts - The assertion parts to convert to slots
|
|
459
|
+
* @group Internal Assertion Types
|
|
414
460
|
* @see {@link AssertionSlot} for individual slot mapping
|
|
415
461
|
* @see {@link AssertionPartsToSlots} for the underlying mapping logic
|
|
416
462
|
* @see {@link NoNeverTuple} for never filtering
|
|
@@ -419,6 +465,11 @@ export type AssertionSlots<Parts extends AssertionParts = AssertionParts> = Part
|
|
|
419
465
|
infer First extends AssertionPart,
|
|
420
466
|
...infer _ extends AssertionParts
|
|
421
467
|
] ? First extends PhraseLiteral | PhraseLiteralChoice ? NoNeverTuple<readonly [z.ZodUnknown, ...AssertionPartsToSlots<Parts>]> : NoNeverTuple<AssertionPartsToSlots<Parts>> : never;
|
|
468
|
+
/**
|
|
469
|
+
* A synchronous assertion of no specific implementation type.
|
|
470
|
+
*
|
|
471
|
+
* @group Internal Assertion Interfaces
|
|
472
|
+
*/
|
|
422
473
|
export interface AssertionSync<Parts extends AssertionParts = AssertionParts, Impl extends AssertionImplSync<Parts> = AssertionImplSync<Parts>, Slots extends AssertionSlots<Parts> = AssertionSlots<Parts>> extends Assertion<Parts, Impl, Slots> {
|
|
423
474
|
/**
|
|
424
475
|
* Execute the assertion implementation synchronously.
|
|
@@ -440,6 +491,8 @@ export interface AssertionSync<Parts extends AssertionParts = AssertionParts, Im
|
|
|
440
491
|
}
|
|
441
492
|
/**
|
|
442
493
|
* The base structure for parsed assertion results.
|
|
494
|
+
*
|
|
495
|
+
* @group Internal Assertion Types
|
|
443
496
|
*/
|
|
444
497
|
export interface BaseParsedResult<Parts extends AssertionParts> {
|
|
445
498
|
/**
|
|
@@ -458,6 +511,66 @@ export interface BaseParsedResult<Parts extends AssertionParts> {
|
|
|
458
511
|
*/
|
|
459
512
|
success: boolean;
|
|
460
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* The main factory function for creating synchronous assertions.
|
|
516
|
+
*
|
|
517
|
+
* @group Core API
|
|
518
|
+
*/
|
|
519
|
+
export interface CreateAssertionFn {
|
|
520
|
+
/**
|
|
521
|
+
* Create a synchronous `Assertion` from {@link AssertionParts | parts} and a
|
|
522
|
+
* {@link z.ZodType | Zod schema}.
|
|
523
|
+
*
|
|
524
|
+
* @template Parts Parts defining the shape of the assertion, including
|
|
525
|
+
* Phrases and Zod schemas
|
|
526
|
+
* @template Impl Assertion implementation as a Zod schema
|
|
527
|
+
* @template Slots Inferred slots based on the provided `Parts`
|
|
528
|
+
* @returns New `AssertionSchemaSync` object
|
|
529
|
+
*/
|
|
530
|
+
<const Parts extends AssertionParts, Impl extends RawAssertionImplSchemaSync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl, metadata?: AssertionMetadata): AssertionSchemaSync<Parts, AssertionImplSchemaSync<Parts>, Slots>;
|
|
531
|
+
/**
|
|
532
|
+
* Create a synchronous `Assertion` from {@link AssertionParts | parts} and an
|
|
533
|
+
* implementation function.
|
|
534
|
+
*
|
|
535
|
+
* @template Parts Parts defining the shape of the assertion, including
|
|
536
|
+
* Phrases and Zod schemas
|
|
537
|
+
* @template Impl Assertion implementation as a function
|
|
538
|
+
* @template Slots Inferred slots based on the provided `Parts`
|
|
539
|
+
* @returns New `AssertionFunctionSync` object
|
|
540
|
+
*/
|
|
541
|
+
<const Parts extends AssertionParts, Impl extends AssertionImplFnSync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl, metadata?: AssertionMetadata): AssertionFunctionSync<Parts, Impl, Slots>;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* The main factory function for creating asynchronous assertions.
|
|
545
|
+
*
|
|
546
|
+
* @group Core API
|
|
547
|
+
*/
|
|
548
|
+
export interface CreateAsyncAssertionFn {
|
|
549
|
+
/**
|
|
550
|
+
* Create an async {@link Assertion} from {@link AssertionParts | parts} and an
|
|
551
|
+
* {@link z.ZodType | Zod schema}.
|
|
552
|
+
*
|
|
553
|
+
* The Zod schema need not be async itself.
|
|
554
|
+
*
|
|
555
|
+
* @template Parts Parts defining the shape of the assertion, including
|
|
556
|
+
* Phrases and Zod schemas
|
|
557
|
+
* @template Impl Assertion implementation as a Zod schema
|
|
558
|
+
* @template Slots Inferred slots based on the provided `Parts`
|
|
559
|
+
* @returns New `AssertionSchemaAsync` object
|
|
560
|
+
*/
|
|
561
|
+
<const Parts extends AssertionParts, Impl extends RawAssertionImplSchemaAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl, metadata?: AssertionMetadata): AssertionSchemaAsync<Parts, AssertionImplSchemaAsync<Parts>, Slots>;
|
|
562
|
+
/**
|
|
563
|
+
* Create an async `Assertion` from {@link AssertionParts | parts} and an
|
|
564
|
+
* implementation function.
|
|
565
|
+
*
|
|
566
|
+
* @template Parts Parts defining the shape of the assertion, including
|
|
567
|
+
* Phrases and Zod schemas
|
|
568
|
+
* @template Impl Assertion implementation as a function
|
|
569
|
+
* @template Slots Inferred slots based on the provided `Parts`
|
|
570
|
+
* @returns New `AssertionFunctionAsync` object
|
|
571
|
+
*/
|
|
572
|
+
<const Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl, metadata?: AssertionMetadata): AssertionFunctionAsync<Parts, Impl, Slots>;
|
|
573
|
+
}
|
|
461
574
|
/**
|
|
462
575
|
* Utility type for parsed values that may be empty.
|
|
463
576
|
*
|
|
@@ -467,6 +580,7 @@ export interface BaseParsedResult<Parts extends AssertionParts> {
|
|
|
467
580
|
* during the recursive processing.
|
|
468
581
|
*
|
|
469
582
|
* @template Parts - The assertion parts to process
|
|
583
|
+
* @group Internal Assertion Types
|
|
470
584
|
* @see {@link ParsedValues} for the standard parsed values type
|
|
471
585
|
* @see {@link NoNeverTuple} for never-type filtering
|
|
472
586
|
*/
|
|
@@ -497,6 +611,7 @@ export type MaybeEmptyParsedValues<Parts extends readonly AssertionPart[]> = NoN
|
|
|
497
611
|
* ```
|
|
498
612
|
*
|
|
499
613
|
* @template T - The readonly tuple type to filter
|
|
614
|
+
* @group Utility Types
|
|
500
615
|
* @see {@link AssertionPartsToSlots} for usage in slot processing
|
|
501
616
|
* @see {@link AssertionSlots} for filtered slot tuples
|
|
502
617
|
*/
|
|
@@ -529,6 +644,7 @@ export type NoNeverTuple<T extends readonly unknown[]> = T extends readonly [
|
|
|
529
644
|
* ```
|
|
530
645
|
*
|
|
531
646
|
* @template Parts - The assertion parts tuple defining expected structure
|
|
647
|
+
* @group Internal Assertion Types
|
|
532
648
|
* @see {@link ParsedResultSuccess} for successful parse results
|
|
533
649
|
* @see {@link ParsedResultFailure} for failed parse results
|
|
534
650
|
* @see {@link AssertionSync.parseValues} and {@link AssertionAsync.parseValuesAsync} for usage context
|
|
@@ -542,6 +658,7 @@ export type ParsedResult<Parts extends AssertionParts = AssertionParts> = Parsed
|
|
|
542
658
|
* returns this interface. The assertion cannot be executed with the provided
|
|
543
659
|
* arguments.
|
|
544
660
|
*
|
|
661
|
+
* @group Internal Assertion Types
|
|
545
662
|
* @see {@link ParsedResultSuccess} for successful parsing results
|
|
546
663
|
* @see {@link BaseParsedResult} for shared result properties
|
|
547
664
|
*/
|
|
@@ -558,6 +675,7 @@ export interface ParsedResultFailure extends BaseParsedResult<never> {
|
|
|
558
675
|
* quality. The assertion can be executed using the `parsedValues`.
|
|
559
676
|
*
|
|
560
677
|
* @template Parts - The assertion parts tuple defining the expected structure
|
|
678
|
+
* @group Internal Assertion Types
|
|
561
679
|
* @see {@link ParsedResultFailure} for failed parsing results
|
|
562
680
|
* @see {@link BaseParsedResult} for shared result properties
|
|
563
681
|
*/
|
|
@@ -596,6 +714,7 @@ export interface ParsedResultSuccess<Parts extends AssertionParts> extends BaseP
|
|
|
596
714
|
* ```
|
|
597
715
|
*
|
|
598
716
|
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
717
|
+
* @group Internal Assertion Types
|
|
599
718
|
* @see {@link ParsedValues} for the complete parsed values tuple
|
|
600
719
|
* @see {@link AssertionImpl} for how subjects are used in implementations
|
|
601
720
|
*/
|
|
@@ -619,6 +738,7 @@ export type ParsedSubject<Parts extends AssertionParts> = ParsedValues<Parts> ex
|
|
|
619
738
|
* ```
|
|
620
739
|
*
|
|
621
740
|
* @template Parts - The assertion parts tuple defining the expected structure
|
|
741
|
+
* @group Internal Assertion Types
|
|
622
742
|
* @see {@link ParsedSubject} for extracting just the subject
|
|
623
743
|
* @see {@link MaybeEmptyParsedValues} for the underlying value processing
|
|
624
744
|
* @see {@link AssertionImpl} for how these values are consumed
|
|
@@ -641,6 +761,7 @@ export type ParsedValues<Parts extends AssertionParts = AssertionParts> = MaybeE
|
|
|
641
761
|
* type Phrase2 = PhraseLiteralChoice; // ["to be", "to equal"]
|
|
642
762
|
* ```
|
|
643
763
|
*
|
|
764
|
+
* @group Assertion Creation
|
|
644
765
|
* @see {@link PhraseLiteral} for single string phrases
|
|
645
766
|
* @see {@link PhraseLiteralChoice} for choice-based phrases
|
|
646
767
|
* @see {@link AssertionPart} for how phrases fit into assertion structure
|
|
@@ -669,6 +790,7 @@ export type Phrase = PhraseLiteral | PhraseLiteralChoice;
|
|
|
669
790
|
* // expect(value, 'to be a string') ✓
|
|
670
791
|
* ```
|
|
671
792
|
*
|
|
793
|
+
* @group Assertion Creation
|
|
672
794
|
* @see {@link PhraseLiteralChoice} for multi-option phrases
|
|
673
795
|
* @see {@link PhraseLiteralSlot} for compiled slot representation
|
|
674
796
|
* @see {@link AssertionPart} for how phrases fit into assertion structure
|
|
@@ -698,6 +820,7 @@ export type PhraseLiteral = string;
|
|
|
698
820
|
* // expect(value, 'to equal', expected) ✓
|
|
699
821
|
* ```
|
|
700
822
|
*
|
|
823
|
+
* @group Assertion Creation
|
|
701
824
|
* @see {@link PhraseLiteral} for single phrase options
|
|
702
825
|
* @see {@link PhraseLiteralChoiceSlot} for compiled slot representation
|
|
703
826
|
* @see {@link AssertionPart} for how phrases fit into assertion structure
|
|
@@ -715,6 +838,7 @@ export type PhraseLiteralChoice = NonEmptyTuple<string>;
|
|
|
715
838
|
* from the ZodLiteral metadata, but it provides type-level access to the
|
|
716
839
|
* choices.
|
|
717
840
|
* @template H - The readonly tuple of string choices
|
|
841
|
+
* @group Internal Assertion Types
|
|
718
842
|
* @see {@link PhraseLiteralChoice} for the source type
|
|
719
843
|
* @see {@link PhraseLiteralSlot} for single phrase slots
|
|
720
844
|
* @see {@link AssertionSlot} for slot type mapping
|
|
@@ -734,11 +858,27 @@ export type PhraseLiteralChoiceSlot<H extends readonly [string, ...string[]]> =
|
|
|
734
858
|
* ZodLiteral's value property, but it provides type-level access to the
|
|
735
859
|
* literal.
|
|
736
860
|
* @template T - The string literal type
|
|
861
|
+
* @group Internal Assertion Types
|
|
737
862
|
* @see {@link PhraseLiteral} for the source type
|
|
738
863
|
* @see {@link PhraseLiteralChoiceSlot} for choice phrase slots
|
|
739
864
|
* @see {@link AssertionSlot} for slot type mapping
|
|
740
865
|
*/
|
|
741
866
|
export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLiteral<T>, 'string-literal'>;
|
|
867
|
+
/**
|
|
868
|
+
* Type for a raw (unbranded) asynchronous schema assertion implementation.
|
|
869
|
+
*
|
|
870
|
+
* This represents a standard Zod schema without branding that validates the
|
|
871
|
+
* assertion subject synchronously. Unlike {@link AssertionImplSchemaAsync}, this
|
|
872
|
+
* type is not branded and represents the underlying schema before it is
|
|
873
|
+
* processed by the assertion creation system.
|
|
874
|
+
*
|
|
875
|
+
* @template Parts The tuple defining the assertion structure
|
|
876
|
+
* @useDeclaredType
|
|
877
|
+
* @group Assertion Implementation
|
|
878
|
+
* @see {@link AssertionImplSchemaAsync} for the branded version
|
|
879
|
+
* @see {@link ParsedSubject} for subject type derivation
|
|
880
|
+
*/
|
|
881
|
+
export type RawAssertionImplSchemaAsync<Parts extends AssertionParts> = z.ZodType<ParsedSubject<Parts>>;
|
|
742
882
|
/**
|
|
743
883
|
* Type for a raw (unbranded) synchronous schema assertion implementation.
|
|
744
884
|
*
|
|
@@ -749,8 +889,38 @@ export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLitera
|
|
|
749
889
|
*
|
|
750
890
|
* @template Parts The tuple defining the assertion structure
|
|
751
891
|
* @useDeclaredType
|
|
892
|
+
* @group Assertion Implementation
|
|
752
893
|
* @see {@link AssertionImplSchemaSync} for the branded version
|
|
753
894
|
* @see {@link ParsedSubject} for subject type derivation
|
|
754
895
|
*/
|
|
755
896
|
export type RawAssertionImplSchemaSync<Parts extends AssertionParts> = z.ZodType<ParsedSubject<Parts>>;
|
|
897
|
+
/**
|
|
898
|
+
* Metadata associated with an assertion, for internal use by documentation
|
|
899
|
+
* tooling.
|
|
900
|
+
*
|
|
901
|
+
* @private
|
|
902
|
+
*/
|
|
903
|
+
export declare const AssertionMetadataSchema: z.ZodObject<{
|
|
904
|
+
anchor: z.ZodString;
|
|
905
|
+
category: z.ZodEnum<{
|
|
906
|
+
object: "object";
|
|
907
|
+
function: "function";
|
|
908
|
+
date: "date";
|
|
909
|
+
promise: "promise";
|
|
910
|
+
error: "error";
|
|
911
|
+
collections: "collections";
|
|
912
|
+
equality: "equality";
|
|
913
|
+
numeric: "numeric";
|
|
914
|
+
other: "other";
|
|
915
|
+
primitives: "primitives";
|
|
916
|
+
strings: "strings";
|
|
917
|
+
}>;
|
|
918
|
+
redirectName: z.ZodOptional<z.ZodString>;
|
|
919
|
+
}, z.core.$loose>;
|
|
920
|
+
/**
|
|
921
|
+
* {@inheritDoc AssertionMetadataSchema}
|
|
922
|
+
*
|
|
923
|
+
* @private
|
|
924
|
+
*/
|
|
925
|
+
export type AssertionMetadata = z.infer<typeof AssertionMetadataSchema>;
|
|
756
926
|
//# sourceMappingURL=assertion-types.d.ts.map
|