bupkis 0.7.2 → 0.9.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 +15 -0
- package/README.md +19 -2
- package/dist/commonjs/assertion/assertion-async.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-async.js +37 -7
- package/dist/commonjs/assertion/assertion-async.js.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.js +32 -8
- package/dist/commonjs/assertion/assertion-sync.js.map +1 -1
- package/dist/commonjs/assertion/assertion-types.d.ts +37 -31
- package/dist/commonjs/assertion/assertion-types.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-types.js +0 -32
- package/dist/commonjs/assertion/assertion-types.js.map +1 -1
- package/dist/commonjs/assertion/assertion.d.ts +3 -21
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +42 -27
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/create.d.ts +2 -0
- package/dist/commonjs/assertion/create.d.ts.map +1 -1
- package/dist/commonjs/assertion/create.js +38 -42
- package/dist/commonjs/assertion/create.js.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.d.ts +16 -4
- package/dist/commonjs/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.js +20 -15
- package/dist/commonjs/assertion/impl/assertion-util.js.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.d.ts +63 -11
- package/dist/commonjs/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.js +89 -52
- package/dist/commonjs/assertion/impl/async-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/async.d.ts +116 -12
- package/dist/commonjs/assertion/impl/async.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async.js +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.js +6 -4
- package/dist/commonjs/assertion/impl/sync-basic.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.js +24 -14
- package/dist/commonjs/assertion/impl/sync-collection.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts +1 -5
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js +11 -13
- package/dist/commonjs/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts +27 -7
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +75 -51
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +54 -22
- package/dist/commonjs/assertion/impl/sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync.js +1 -1
- package/dist/commonjs/assertion/impl/sync.js.map +1 -1
- package/dist/commonjs/assertion/index.d.ts +1 -1
- package/dist/commonjs/assertion/index.d.ts.map +1 -1
- package/dist/commonjs/assertion/index.js +0 -1
- package/dist/commonjs/assertion/index.js.map +1 -1
- package/dist/commonjs/assertion/slotify.d.ts +1 -13
- package/dist/commonjs/assertion/slotify.d.ts.map +1 -1
- package/dist/commonjs/assertion/slotify.js +49 -16
- package/dist/commonjs/assertion/slotify.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +85 -17
- package/dist/commonjs/bootstrap.d.ts.map +1 -1
- package/dist/commonjs/bootstrap.js +1 -0
- package/dist/commonjs/bootstrap.js.map +1 -1
- package/dist/commonjs/diff.d.ts +51 -0
- package/dist/commonjs/diff.d.ts.map +1 -0
- package/dist/commonjs/diff.js +279 -0
- package/dist/commonjs/diff.js.map +1 -0
- package/dist/commonjs/error.d.ts +37 -18
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +44 -30
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/expect.d.ts.map +1 -1
- package/dist/commonjs/expect.js +131 -78
- package/dist/commonjs/expect.js.map +1 -1
- package/dist/commonjs/guards.d.ts +24 -10
- package/dist/commonjs/guards.d.ts.map +1 -1
- package/dist/commonjs/guards.js +56 -39
- package/dist/commonjs/guards.js.map +1 -1
- package/dist/commonjs/index.d.ts +85 -17
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/internal-schema.d.ts +25 -0
- package/dist/commonjs/internal-schema.d.ts.map +1 -0
- package/dist/commonjs/internal-schema.js +209 -0
- package/dist/commonjs/internal-schema.js.map +1 -0
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +3 -2
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/use.js +22 -8
- package/dist/commonjs/use.js.map +1 -1
- package/dist/commonjs/util.d.ts +1 -0
- package/dist/commonjs/util.d.ts.map +1 -1
- package/dist/commonjs/util.js +14 -10
- package/dist/commonjs/util.js.map +1 -1
- package/dist/commonjs/value-to-schema.d.ts +1 -0
- package/dist/commonjs/value-to-schema.d.ts.map +1 -1
- package/dist/commonjs/value-to-schema.js +19 -12
- package/dist/commonjs/value-to-schema.js.map +1 -1
- package/dist/esm/assertion/assertion-async.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-async.js +37 -7
- package/dist/esm/assertion/assertion-async.js.map +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-sync.js +32 -8
- package/dist/esm/assertion/assertion-sync.js.map +1 -1
- package/dist/esm/assertion/assertion-types.d.ts +37 -31
- package/dist/esm/assertion/assertion-types.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-types.js +1 -31
- package/dist/esm/assertion/assertion-types.js.map +1 -1
- package/dist/esm/assertion/assertion.d.ts +3 -21
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +42 -27
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/create.d.ts +2 -0
- package/dist/esm/assertion/create.d.ts.map +1 -1
- package/dist/esm/assertion/create.js +37 -41
- package/dist/esm/assertion/create.js.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.d.ts +16 -4
- package/dist/esm/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.js +20 -15
- package/dist/esm/assertion/impl/assertion-util.js.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.d.ts +63 -11
- package/dist/esm/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.js +89 -52
- package/dist/esm/assertion/impl/async-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/async.d.ts +116 -12
- package/dist/esm/assertion/impl/async.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async.js +2 -2
- package/dist/esm/assertion/impl/async.js.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.js +6 -4
- package/dist/esm/assertion/impl/sync-basic.js.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.js +24 -14
- package/dist/esm/assertion/impl/sync-collection.js.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.d.ts +1 -5
- package/dist/esm/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.js +11 -13
- package/dist/esm/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts +27 -7
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +75 -51
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +54 -22
- package/dist/esm/assertion/impl/sync.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync.js +2 -2
- package/dist/esm/assertion/impl/sync.js.map +1 -1
- package/dist/esm/assertion/index.d.ts +1 -1
- package/dist/esm/assertion/index.d.ts.map +1 -1
- package/dist/esm/assertion/index.js +0 -1
- package/dist/esm/assertion/index.js.map +1 -1
- package/dist/esm/assertion/slotify.d.ts +1 -13
- package/dist/esm/assertion/slotify.d.ts.map +1 -1
- package/dist/esm/assertion/slotify.js +50 -17
- package/dist/esm/assertion/slotify.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +85 -17
- package/dist/esm/bootstrap.d.ts.map +1 -1
- package/dist/esm/bootstrap.js +1 -0
- package/dist/esm/bootstrap.js.map +1 -1
- package/dist/esm/diff.d.ts +51 -0
- package/dist/esm/diff.d.ts.map +1 -0
- package/dist/esm/diff.js +273 -0
- package/dist/esm/diff.js.map +1 -0
- package/dist/esm/error.d.ts +37 -18
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +41 -27
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +133 -80
- package/dist/esm/expect.js.map +1 -1
- package/dist/esm/guards.d.ts +24 -10
- package/dist/esm/guards.d.ts.map +1 -1
- package/dist/esm/guards.js +52 -36
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/index.d.ts +85 -17
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internal-schema.d.ts +25 -0
- package/dist/esm/internal-schema.d.ts.map +1 -0
- package/dist/esm/internal-schema.js +203 -0
- package/dist/esm/internal-schema.js.map +1 -0
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +3 -2
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/use.js +19 -6
- package/dist/esm/use.js.map +1 -1
- package/dist/esm/util.d.ts +1 -0
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +14 -10
- package/dist/esm/util.js.map +1 -1
- package/dist/esm/value-to-schema.d.ts +1 -0
- package/dist/esm/value-to-schema.d.ts.map +1 -1
- package/dist/esm/value-to-schema.js +20 -13
- package/dist/esm/value-to-schema.js.map +1 -1
- package/package.json +29 -11
- package/src/assertion/assertion-async.ts +42 -14
- package/src/assertion/assertion-sync.ts +40 -17
- package/src/assertion/assertion-types.ts +55 -45
- package/src/assertion/assertion.ts +49 -32
- package/src/assertion/create.ts +46 -65
- package/src/assertion/impl/assertion-util.ts +31 -18
- package/src/assertion/impl/async-parametric.ts +93 -52
- package/src/assertion/impl/async.ts +2 -2
- package/src/assertion/impl/sync-basic.ts +7 -4
- package/src/assertion/impl/sync-collection.ts +34 -14
- package/src/assertion/impl/sync-esoteric.ts +17 -13
- package/src/assertion/impl/sync-parametric.ts +79 -52
- package/src/assertion/impl/sync.ts +2 -2
- package/src/assertion/index.ts +1 -1
- package/src/assertion/slotify.ts +67 -21
- package/src/bootstrap.ts +1 -0
- package/src/diff.ts +343 -0
- package/src/error.ts +66 -31
- package/src/expect.ts +195 -129
- package/src/guards.ts +74 -48
- package/src/internal-schema.ts +246 -0
- package/src/schema.ts +4 -2
- package/src/use.ts +21 -7
- package/src/util.ts +15 -12
- package/src/value-to-schema.ts +21 -13
package/dist/commonjs/guards.js
CHANGED
|
@@ -17,35 +17,39 @@
|
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.isExpectItExecutor = exports.isError = exports.isA = exports.
|
|
20
|
+
exports.isAssertionParts = exports.isAssertionPart = exports.isExpectItExecutor = exports.isError = exports.isA = exports.isPhrase = exports.isPhraseLiteral = exports.isPhraseLiteralChoice = exports.isWeakKey = exports.isNonNullObject = exports.isString = exports.isFunction = exports.isBoolean = exports.isConstructible = exports.isPromiseLike = exports.isZodPromise = exports.isObject = void 0;
|
|
21
21
|
exports.isZodType = isZodType;
|
|
22
|
-
const v4_1 = require("zod/v4");
|
|
23
22
|
const constant_js_1 = require("./constant.js");
|
|
23
|
+
const { isArray } = Array;
|
|
24
24
|
function isZodType(value, type) {
|
|
25
25
|
const isValid = (0, exports.isObject)(value) &&
|
|
26
26
|
'def' in value &&
|
|
27
27
|
!!value.def &&
|
|
28
28
|
typeof value.def === 'object' &&
|
|
29
29
|
'type' in value.def;
|
|
30
|
-
if (!isValid)
|
|
30
|
+
if (!isValid) {
|
|
31
31
|
return false;
|
|
32
|
-
|
|
32
|
+
}
|
|
33
|
+
if (type === undefined) {
|
|
33
34
|
return true;
|
|
35
|
+
}
|
|
34
36
|
return value.def.type === type;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Type guard for a plain object.
|
|
38
40
|
*
|
|
41
|
+
* @function
|
|
39
42
|
* @param value Value to test
|
|
40
43
|
* @returns `true` if the value is a plain object, `false` otherwise
|
|
41
44
|
*/
|
|
42
45
|
const isObject = (value) => {
|
|
43
|
-
return typeof value === 'object' && value !== null && !
|
|
46
|
+
return typeof value === 'object' && value !== null && !isArray(value);
|
|
44
47
|
};
|
|
45
48
|
exports.isObject = isObject;
|
|
46
49
|
/**
|
|
47
50
|
* Returns `true` if the given value is a {@link z.ZodPromise} schema.
|
|
48
51
|
*
|
|
52
|
+
* @function
|
|
49
53
|
* @param value - Value to test
|
|
50
54
|
* @returns `true` if the value is a `ZodPromise` schema; `false` otherwise
|
|
51
55
|
*/
|
|
@@ -54,6 +58,7 @@ exports.isZodPromise = isZodPromise;
|
|
|
54
58
|
/**
|
|
55
59
|
* Checks if a value is "promise-like", meaning it is a "thenable" object.
|
|
56
60
|
*
|
|
61
|
+
* @function
|
|
57
62
|
* @param value - Value to test
|
|
58
63
|
* @returns `true` if the value is promise-like, `false` otherwise
|
|
59
64
|
*/
|
|
@@ -74,6 +79,7 @@ exports.isPromiseLike = isPromiseLike;
|
|
|
74
79
|
* This may be the only way we can determine, at runtime, if a function is a
|
|
75
80
|
* constructor without actually calling it. I am unsure if this only works for
|
|
76
81
|
* classes.
|
|
82
|
+
* @function
|
|
77
83
|
* @param fn - Function to test
|
|
78
84
|
* @returns Whether the function is constructable
|
|
79
85
|
*/
|
|
@@ -83,7 +89,7 @@ const isConstructible = (fn) => {
|
|
|
83
89
|
}
|
|
84
90
|
try {
|
|
85
91
|
// this will throw if there is no `[[construct]]` slot.. or so I've heard.
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, custom/require-function-tag-in-arrow-functions
|
|
87
93
|
new new Proxy(fn, { construct: () => ({}) })();
|
|
88
94
|
return true;
|
|
89
95
|
}
|
|
@@ -95,6 +101,7 @@ exports.isConstructible = isConstructible;
|
|
|
95
101
|
/**
|
|
96
102
|
* Type guard for a boolean value
|
|
97
103
|
*
|
|
104
|
+
* @function
|
|
98
105
|
* @param value Value to check
|
|
99
106
|
* @returns `true` if the value is a boolean, `false` otherwise
|
|
100
107
|
*/
|
|
@@ -103,37 +110,16 @@ exports.isBoolean = isBoolean;
|
|
|
103
110
|
/**
|
|
104
111
|
* Type guard for a function value
|
|
105
112
|
*
|
|
113
|
+
* @function
|
|
106
114
|
* @param value Value to check
|
|
107
115
|
* @returns `true` if the value is a function, `false` otherwise
|
|
108
116
|
*/
|
|
109
117
|
const isFunction = (value) => typeof value === 'function';
|
|
110
118
|
exports.isFunction = isFunction;
|
|
111
|
-
const AssertionFailureSchema = v4_1.z.object({
|
|
112
|
-
actual: v4_1.z
|
|
113
|
-
.unknown()
|
|
114
|
-
.optional()
|
|
115
|
-
.describe('The actual value or description of what actually occurred'),
|
|
116
|
-
expected: v4_1.z
|
|
117
|
-
.unknown()
|
|
118
|
-
.optional()
|
|
119
|
-
.describe('The expected value or description of what was expected to occur'),
|
|
120
|
-
message: v4_1.z
|
|
121
|
-
.string()
|
|
122
|
-
.optional()
|
|
123
|
-
.describe('A human-readable message describing the failure'),
|
|
124
|
-
});
|
|
125
|
-
/**
|
|
126
|
-
* Type guard for a {@link AssertionFailure} object
|
|
127
|
-
*
|
|
128
|
-
* @param value Value to check
|
|
129
|
-
* @returns `true` if the value is an `AssertionFailure`, `false` otherwise
|
|
130
|
-
* @internal
|
|
131
|
-
*/
|
|
132
|
-
const isAssertionFailure = (value) => AssertionFailureSchema.safeParse(value).success;
|
|
133
|
-
exports.isAssertionFailure = isAssertionFailure;
|
|
134
119
|
/**
|
|
135
120
|
* Type guard for a string value
|
|
136
121
|
*
|
|
122
|
+
* @function
|
|
137
123
|
* @param value Value to check
|
|
138
124
|
* @returns `true` if the value is a string, `false` otherwise
|
|
139
125
|
*/
|
|
@@ -142,25 +128,19 @@ exports.isString = isString;
|
|
|
142
128
|
/**
|
|
143
129
|
* Type guard for a non-null object value
|
|
144
130
|
*
|
|
131
|
+
* @function
|
|
145
132
|
* @param value Value to check
|
|
146
133
|
* @returns `true` if the value is an object and not null, `false` otherwise
|
|
147
134
|
*/
|
|
148
135
|
const isNonNullObject = (value) => typeof value === 'object' && value !== null;
|
|
149
136
|
exports.isNonNullObject = isNonNullObject;
|
|
150
|
-
/**
|
|
151
|
-
* Type guard for a null or non-object value
|
|
152
|
-
*
|
|
153
|
-
* @param value Value to check
|
|
154
|
-
* @returns `true` if the value is null or not an object, `false` otherwise
|
|
155
|
-
*/
|
|
156
|
-
const isNullOrNonObject = (value) => typeof value !== 'object' || value === null;
|
|
157
|
-
exports.isNullOrNonObject = isNullOrNonObject;
|
|
158
137
|
/**
|
|
159
138
|
* Type guard for a valid WeakKey (object, function, or symbol).
|
|
160
139
|
*
|
|
161
140
|
* WeakMaps and WeakSets can only use objects (including functions) or symbols
|
|
162
141
|
* as keys, not primitives like strings, numbers, booleans, null, or undefined.
|
|
163
142
|
*
|
|
143
|
+
* @function
|
|
164
144
|
* @param value Value to check
|
|
165
145
|
* @returns `true` if the value is a valid WeakKey (object, function, or
|
|
166
146
|
* symbol), `false` otherwise
|
|
@@ -172,22 +152,34 @@ exports.isWeakKey = isWeakKey;
|
|
|
172
152
|
/**
|
|
173
153
|
* Type guard for a {@link PhraseLiteralChoice}, which is a tuple of strings.
|
|
174
154
|
*
|
|
155
|
+
* @function
|
|
175
156
|
* @param value Assertion part to check
|
|
176
157
|
* @returns `true` if the part is a `PhraseLiteralChoice`, `false` otherwise
|
|
177
158
|
* @internal
|
|
178
159
|
*/
|
|
179
|
-
const isPhraseLiteralChoice = (value) =>
|
|
160
|
+
const isPhraseLiteralChoice = (value) => isArray(value) && value.every(exports.isPhraseLiteral);
|
|
180
161
|
exports.isPhraseLiteralChoice = isPhraseLiteralChoice;
|
|
181
162
|
/**
|
|
182
163
|
* Type guard for a {@link PhraseLiteral}, which is just a string that does not
|
|
183
164
|
* begin with `not `.
|
|
184
165
|
*
|
|
166
|
+
* @function
|
|
185
167
|
* @param value Assertion part to check
|
|
186
168
|
* @returns `true` if the part is a `PhraseLiteral`, `false` otherwise
|
|
187
169
|
* @internal
|
|
188
170
|
*/
|
|
189
|
-
const isPhraseLiteral = (value) => (0, exports.isString)(value) && !value.startsWith('not ');
|
|
171
|
+
const isPhraseLiteral = (value) => (0, exports.isString)(value) && !value.startsWith('not ') && value !== 'and';
|
|
190
172
|
exports.isPhraseLiteral = isPhraseLiteral;
|
|
173
|
+
/**
|
|
174
|
+
* Type guard for a {@link PhraseLiteral} or {@link PhraseLiteralChoice}.
|
|
175
|
+
*
|
|
176
|
+
* @function
|
|
177
|
+
* @param value Value to check
|
|
178
|
+
* @returns `true` if the value is a `PhraseLiteral` or `PhraseLiteralChoice`,
|
|
179
|
+
* `false` otherwise
|
|
180
|
+
*/
|
|
181
|
+
const isPhrase = (value) => (0, exports.isPhraseLiteral)(value) || (0, exports.isPhraseLiteralChoice)(value);
|
|
182
|
+
exports.isPhrase = isPhrase;
|
|
191
183
|
/**
|
|
192
184
|
* Generic type guard for instanceof checks.
|
|
193
185
|
*
|
|
@@ -207,6 +199,7 @@ exports.isPhraseLiteral = isPhraseLiteral;
|
|
|
207
199
|
* ```
|
|
208
200
|
*
|
|
209
201
|
* @template T - The constructor type to check against
|
|
202
|
+
* @function
|
|
210
203
|
* @param value - Value to test
|
|
211
204
|
* @param ctor - Constructor function to check instanceof
|
|
212
205
|
* @returns `true` if the value is an instance of the constructor, `false`
|
|
@@ -236,6 +229,7 @@ exports.isA = isA;
|
|
|
236
229
|
* }
|
|
237
230
|
* ```
|
|
238
231
|
*
|
|
232
|
+
* @function
|
|
239
233
|
* @param value - Value to test
|
|
240
234
|
* @returns `true` if the value is an Error instance, `false` otherwise
|
|
241
235
|
*/
|
|
@@ -262,6 +256,7 @@ exports.isError = isError;
|
|
|
262
256
|
* ```
|
|
263
257
|
*
|
|
264
258
|
* @template Subject - The subject type that the executor function operates on
|
|
259
|
+
* @function
|
|
265
260
|
* @param value - Value to test
|
|
266
261
|
* @returns `true` if the value is an ExpectItExecutor function, `false`
|
|
267
262
|
* otherwise
|
|
@@ -270,4 +265,26 @@ const isExpectItExecutor = (value) => {
|
|
|
270
265
|
return (0, exports.isFunction)(value) && constant_js_1.kExpectIt in value && value[constant_js_1.kExpectIt] === true;
|
|
271
266
|
};
|
|
272
267
|
exports.isExpectItExecutor = isExpectItExecutor;
|
|
268
|
+
/**
|
|
269
|
+
* Type guard for an {@link AssertionPart}, which can be a {@link PhraseLiteral},
|
|
270
|
+
* {@link PhraseLiteralChoice}, or a Zod schema.
|
|
271
|
+
*
|
|
272
|
+
* @function
|
|
273
|
+
* @param value Value to check
|
|
274
|
+
* @returns `true` if the value is an `AssertionPart`, `false` otherwise
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
const isAssertionPart = (value) => (0, exports.isPhraseLiteral)(value) || (0, exports.isPhraseLiteralChoice)(value) || isZodType(value);
|
|
278
|
+
exports.isAssertionPart = isAssertionPart;
|
|
279
|
+
/**
|
|
280
|
+
* Type guard for {@link AssertionParts}, which is an array of
|
|
281
|
+
* {@link AssertionPart}.
|
|
282
|
+
*
|
|
283
|
+
* @function
|
|
284
|
+
* @param value Value to check
|
|
285
|
+
* @returns `true` if the value is an `AssertionParts`, `false` otherwise
|
|
286
|
+
* @internal
|
|
287
|
+
*/
|
|
288
|
+
const isAssertionParts = (value) => isArray(value) && !!value.length && value.every(exports.isAssertionPart);
|
|
289
|
+
exports.isAssertionParts = isAssertionParts;
|
|
273
290
|
//# sourceMappingURL=guards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":"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"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -182,15 +182,35 @@ use: import("./types.js").UseFn<readonly [import("./types.js").AssertionFunction
|
|
|
182
182
|
}, z.core.$loose>]>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to deep equal", "to deeply equal"]>, z.ZodAny]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, "to throw"], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown) => {
|
|
183
183
|
actual: unknown;
|
|
184
184
|
message: string;
|
|
185
|
-
} | undefined, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralSlot<"to throw">]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to throw a", "to throw an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, ctor: import("./types.js").Constructor) =>
|
|
186
|
-
actual:
|
|
187
|
-
expected:
|
|
185
|
+
} | undefined, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralSlot<"to throw">]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to throw a", "to throw an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, ctor: import("./types.js").Constructor) => {
|
|
186
|
+
actual: unknown;
|
|
187
|
+
expected: string;
|
|
188
|
+
message: string;
|
|
189
|
+
} | undefined, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to throw a", "to throw an"]>, z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to throw", "to throw error satisfying"], z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, param: any) => {
|
|
190
|
+
actual: unknown;
|
|
191
|
+
expected: string;
|
|
188
192
|
message: string;
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
schema?: never;
|
|
194
|
+
subject?: never;
|
|
195
|
+
} | {
|
|
196
|
+
schema: z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>;
|
|
197
|
+
subject: {} | null;
|
|
198
|
+
actual?: never;
|
|
199
|
+
expected?: never;
|
|
200
|
+
message?: never;
|
|
201
|
+
}, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to throw", "to throw error satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to throw a", "to throw an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>, "satisfying", z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, ctor: import("./types.js").Constructor, param: any) => {
|
|
202
|
+
actual: unknown;
|
|
191
203
|
expected: string;
|
|
192
204
|
message: string;
|
|
193
|
-
|
|
205
|
+
schema?: never;
|
|
206
|
+
subject?: never;
|
|
207
|
+
} | {
|
|
208
|
+
schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
209
|
+
subject: {} | null;
|
|
210
|
+
actual?: never;
|
|
211
|
+
expected?: never;
|
|
212
|
+
message?: never;
|
|
213
|
+
}, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to throw a", "to throw an"]>, z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>, import("./types.js").PhraseLiteralSlot<"satisfying">, z.ZodAny]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodString, readonly ["includes", "contains", "to include", "to contain"], z.ZodString], (subject: string, expected: string) => {
|
|
194
214
|
actual: string;
|
|
195
215
|
expected: string;
|
|
196
216
|
message: string;
|
|
@@ -211,11 +231,7 @@ use: import("./types.js").UseFn<readonly [import("./types.js").AssertionFunction
|
|
|
211
231
|
actual: boolean;
|
|
212
232
|
expected: boolean;
|
|
213
233
|
message: string;
|
|
214
|
-
} | undefined, readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>, import("./types.js").PhraseLiteralSlot<"to be an enumerable property of">, z.ZodNonOptional<z.ZodUnknown>]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodNonOptional<z.ZodUnknown>, "to have enumerable property", z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>], (
|
|
215
|
-
actual: boolean;
|
|
216
|
-
expected: boolean;
|
|
217
|
-
message: string;
|
|
218
|
-
} | undefined, readonly [z.ZodNonOptional<z.ZodUnknown>, import("./types.js").PhraseLiteralSlot<"to have enumerable property">, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>]>, import("./types.js").AssertionSchemaSync<readonly ["to be sealed"], import("./types.js").AssertionImplSchemaSync<readonly ["to be sealed"]>, never>, import("./types.js").AssertionSchemaSync<readonly ["to be extensible"], import("./types.js").AssertionImplSchemaSync<readonly ["to be extensible"]>, never>], readonly [import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to resolve", "to fulfill"]], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown) => Promise<{
|
|
234
|
+
} | undefined, readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>, import("./types.js").PhraseLiteralSlot<"to be an enumerable property of">, z.ZodNonOptional<z.ZodUnknown>]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodNonOptional<z.ZodUnknown>, "to have enumerable property", z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>], (_subject: unknown, key: string | number | symbol) => z.ZodCustom<unknown, unknown>, readonly [z.ZodNonOptional<z.ZodUnknown>, import("./types.js").PhraseLiteralSlot<"to have enumerable property">, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodSymbol]>]>, import("./types.js").AssertionSchemaSync<readonly ["to be sealed"], import("./types.js").AssertionImplSchemaSync<readonly ["to be sealed"]>, never>, import("./types.js").AssertionSchemaSync<readonly ["to be extensible"], import("./types.js").AssertionImplSchemaSync<readonly ["to be extensible"]>, never>], readonly [import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to resolve", "to fulfill"]], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown) => Promise<{
|
|
219
235
|
actual: string;
|
|
220
236
|
expected: string;
|
|
221
237
|
message: string;
|
|
@@ -231,21 +247,73 @@ use: import("./types.js").UseFn<readonly [import("./types.js").AssertionFunction
|
|
|
231
247
|
actual: string;
|
|
232
248
|
expected: string;
|
|
233
249
|
message: string;
|
|
234
|
-
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralSlot<"to reject">]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to reject with a", "to reject with an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, ctor: import("./types.js").Constructor) => Promise<
|
|
250
|
+
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralSlot<"to reject">]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to reject with a", "to reject with an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, ctor: import("./types.js").Constructor) => Promise<{
|
|
235
251
|
actual: string;
|
|
236
252
|
expect: string;
|
|
237
253
|
message: string;
|
|
238
|
-
|
|
254
|
+
expected?: never;
|
|
255
|
+
} | {
|
|
256
|
+
actual: string;
|
|
257
|
+
expected: string;
|
|
258
|
+
message: string;
|
|
259
|
+
expect?: never;
|
|
260
|
+
} | undefined>, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with a", "to reject with an"]>, z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, readonly ["to reject with a", "to reject with an"], z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>], (subject: PromiseLike<unknown>, ctor: import("./types.js").Constructor) => Promise<{
|
|
239
261
|
actual: string;
|
|
240
262
|
expect: string;
|
|
241
263
|
message: string;
|
|
242
|
-
|
|
243
|
-
|
|
264
|
+
expected?: never;
|
|
265
|
+
} | {
|
|
266
|
+
actual: string;
|
|
267
|
+
expected: string;
|
|
268
|
+
message: string;
|
|
269
|
+
expect?: never;
|
|
270
|
+
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with a", "to reject with an"]>, z.ZodCustom<import("./types.js").Constructor, import("./types.js").Constructor>]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to reject with error satisfying"], z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, param: any) => Promise<{
|
|
271
|
+
actual: string;
|
|
272
|
+
expect: string;
|
|
273
|
+
message: string;
|
|
274
|
+
schema?: never;
|
|
275
|
+
subject?: never;
|
|
276
|
+
} | {
|
|
277
|
+
schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
278
|
+
subject: {} | null;
|
|
279
|
+
actual?: never;
|
|
280
|
+
expect?: never;
|
|
281
|
+
message?: never;
|
|
282
|
+
}>, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with error satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, readonly ["to reject with error satisfying"], z.ZodAny], (subject: PromiseLike<unknown>, param: any) => Promise<{
|
|
283
|
+
actual: string;
|
|
284
|
+
expect: string;
|
|
285
|
+
message: string;
|
|
286
|
+
schema?: never;
|
|
287
|
+
subject?: never;
|
|
288
|
+
} | {
|
|
289
|
+
schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
290
|
+
subject: {} | null;
|
|
291
|
+
actual?: never;
|
|
292
|
+
expect?: never;
|
|
293
|
+
message?: never;
|
|
294
|
+
}>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with error satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (promise: PromiseLike<unknown>, param: any) => Promise<{
|
|
295
|
+
actual: string;
|
|
244
296
|
expect: string;
|
|
245
297
|
message: string;
|
|
246
|
-
|
|
298
|
+
schema?: never;
|
|
299
|
+
subject?: never;
|
|
300
|
+
} | {
|
|
301
|
+
schema: z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>;
|
|
302
|
+
subject: unknown;
|
|
303
|
+
actual?: never;
|
|
304
|
+
expect?: never;
|
|
305
|
+
message?: never;
|
|
306
|
+
}>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to fulfill with value satisfying", "to resolve with value satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, param: any) => Promise<{
|
|
247
307
|
actual: string;
|
|
248
308
|
expect: string;
|
|
249
309
|
message: string;
|
|
250
|
-
|
|
310
|
+
schema?: never;
|
|
311
|
+
subject?: never;
|
|
312
|
+
} | {
|
|
313
|
+
schema: z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>;
|
|
314
|
+
subject: unknown;
|
|
315
|
+
actual?: never;
|
|
316
|
+
expect?: never;
|
|
317
|
+
message?: never;
|
|
318
|
+
}>, readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to fulfill with value satisfying", "to resolve with value satisfying"]>, z.ZodAny]>]>;
|
|
251
319
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;GASG;AACH,YAAY,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,CAAC;AAEb;;GAEG;AACH,YAAY,EACV,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,EACN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAC5D,QAAA;AACE;;;;;;;;;GASG;AACH,eAAe;AACf;;;;;;;;;GASG;AACH,oBAAoB;AACpB;;;;;;GAMG;AACH,IAAI;AACJ;;;;;;GAMG;AACH,GAAG
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;GASG;AACH,YAAY,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,CAAC;AAEb;;GAEG;AACH,YAAY,EACV,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,EACN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAC5D,QAAA;AACE;;;;;;;;;GASG;AACH,eAAe;AACf;;;;;;;;;GASG;AACH,oBAAoB;AACpB;;;;;;GAMG;AACH,IAAI;AACJ;;;;;;GAMG;AACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0TAEgB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal schemas
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { AssertionMetadata, AssertionParseRequest } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Schema for internal assertion metadata.
|
|
10
|
+
*
|
|
11
|
+
* Used by documentation tooling.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AssertionMetadataSchema: z.ZodType<AssertionMetadata>;
|
|
14
|
+
/**
|
|
15
|
+
* @function
|
|
16
|
+
*/
|
|
17
|
+
export declare const isAssertionParseRequest: (value: unknown) => value is AssertionParseRequest;
|
|
18
|
+
/**
|
|
19
|
+
* @function
|
|
20
|
+
* @param value
|
|
21
|
+
* @returns
|
|
22
|
+
* @knipignore
|
|
23
|
+
*/
|
|
24
|
+
export declare const isMetadata: (value: unknown) => value is AssertionMetadata;
|
|
25
|
+
//# sourceMappingURL=internal-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-schema.d.ts","sourceRoot":"","sources":["../../src/internal-schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAEV,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAIpB;;;;GAIG;AAEH,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CA2B9D,CAAC;AA6JJ;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,OAAO,KACb,KAAK,IAAI,qBAEX,CAAC;AAwBF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,iBACH,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Internal schemas
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isMetadata = exports.CreateAssertionInputSchemaAsync = exports.CreateAssertionInputSchema = exports.isAssertionParseRequest = exports.isAssertionFailure = exports.AssertionMetadataSchema = void 0;
|
|
10
|
+
const v4_1 = require("zod/v4");
|
|
11
|
+
const guards_js_1 = require("./guards.js");
|
|
12
|
+
/**
|
|
13
|
+
* Schema for internal assertion metadata.
|
|
14
|
+
*
|
|
15
|
+
* Used by documentation tooling.
|
|
16
|
+
*/
|
|
17
|
+
exports.AssertionMetadataSchema = v4_1.z
|
|
18
|
+
.looseObject({
|
|
19
|
+
anchor: v4_1.z.string().describe('Anchor ID for linking to this assertion.'),
|
|
20
|
+
category: v4_1.z
|
|
21
|
+
.enum([
|
|
22
|
+
'collections',
|
|
23
|
+
'date',
|
|
24
|
+
'equality',
|
|
25
|
+
'error',
|
|
26
|
+
'function',
|
|
27
|
+
'numeric',
|
|
28
|
+
'object',
|
|
29
|
+
'other',
|
|
30
|
+
'primitives',
|
|
31
|
+
'promise',
|
|
32
|
+
'strings',
|
|
33
|
+
])
|
|
34
|
+
.describe('Category to map to page of logically grouped assertions'),
|
|
35
|
+
redirect: v4_1.z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Redirect for assertion to its documentation page, including anchor'),
|
|
39
|
+
})
|
|
40
|
+
.describe('Metadata associated with an assertion, for internal use by documentation tooling.');
|
|
41
|
+
/**
|
|
42
|
+
* Schema for {@link AssertionFailure}.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
const AssertionFailureSchema = v4_1.z
|
|
47
|
+
.object({
|
|
48
|
+
actual: v4_1.z
|
|
49
|
+
.unknown()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('The actual value or description of what actually occurred'),
|
|
52
|
+
expected: v4_1.z
|
|
53
|
+
.unknown()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('The expected value or description of what was expected to occur'),
|
|
56
|
+
message: v4_1.z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe('A human-readable message describing the failure'),
|
|
60
|
+
})
|
|
61
|
+
.describe('Potential return type of an assertion implementation function');
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
const ZodTypeSchema = v4_1.z
|
|
66
|
+
.custom(guards_js_1.isZodType, {
|
|
67
|
+
error: 'Must be a Zod schema',
|
|
68
|
+
})
|
|
69
|
+
.describe('A Zod schema within AssertionParts');
|
|
70
|
+
/** @internal */
|
|
71
|
+
const BaseAssertionParseRequestSchema = v4_1.z.object({
|
|
72
|
+
subject: v4_1.z.unknown().describe('The subject value to be validated'),
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
const AssertionParseRequestSchema = v4_1.z.union([
|
|
78
|
+
v4_1.z.object({
|
|
79
|
+
...BaseAssertionParseRequestSchema.shape,
|
|
80
|
+
schema: ZodTypeSchema.describe('The sync Zod schema to validate against'),
|
|
81
|
+
}),
|
|
82
|
+
v4_1.z.object({
|
|
83
|
+
...BaseAssertionParseRequestSchema.shape,
|
|
84
|
+
asyncSchema: ZodTypeSchema.describe('The async Zod schema to validate against'),
|
|
85
|
+
}),
|
|
86
|
+
]);
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
const PhraseLiteralSchema = v4_1.z
|
|
91
|
+
.stringFormat('PhraseLiteral', (value) => !value.startsWith('not '), {
|
|
92
|
+
error: 'Phrase literals may not begin with "not "',
|
|
93
|
+
})
|
|
94
|
+
.min(1, { error: 'Phrase literals must be at least 1 character long' })
|
|
95
|
+
.describe('A phrase literal within AssertionParts');
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
const PhraseLiteralChoiceSchema = v4_1.z
|
|
100
|
+
.array(PhraseLiteralSchema)
|
|
101
|
+
.min(1, { error: 'Phrase literal choices must have at least one option' })
|
|
102
|
+
.describe('A choice of phrase literals, represented as an array of strings, within AssertionParts');
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
const AssertionImplSchemaSync = v4_1.z
|
|
107
|
+
.union([
|
|
108
|
+
ZodTypeSchema,
|
|
109
|
+
v4_1.z.function({
|
|
110
|
+
input: v4_1.z.tuple([v4_1.z.unknown()], v4_1.z.unknown()),
|
|
111
|
+
output: v4_1.z.union([
|
|
112
|
+
v4_1.z.void(),
|
|
113
|
+
v4_1.z.boolean(),
|
|
114
|
+
ZodTypeSchema,
|
|
115
|
+
AssertionFailureSchema,
|
|
116
|
+
AssertionParseRequestSchema,
|
|
117
|
+
]),
|
|
118
|
+
}),
|
|
119
|
+
])
|
|
120
|
+
.describe('A synchronous assertion implementation function');
|
|
121
|
+
const AssertionImplSchemaAsync = v4_1.z
|
|
122
|
+
.union([
|
|
123
|
+
ZodTypeSchema,
|
|
124
|
+
v4_1.z.function({
|
|
125
|
+
input: v4_1.z.tuple([v4_1.z.unknown()], v4_1.z.unknown()),
|
|
126
|
+
output: v4_1.z.union([
|
|
127
|
+
v4_1.z.void(),
|
|
128
|
+
v4_1.z.boolean(),
|
|
129
|
+
ZodTypeSchema,
|
|
130
|
+
AssertionFailureSchema,
|
|
131
|
+
AssertionParseRequestSchema,
|
|
132
|
+
v4_1.z.promise(v4_1.z.void()),
|
|
133
|
+
v4_1.z.promise(v4_1.z.boolean()),
|
|
134
|
+
v4_1.z.promise(ZodTypeSchema),
|
|
135
|
+
v4_1.z.promise(AssertionFailureSchema),
|
|
136
|
+
v4_1.z.promise(AssertionParseRequestSchema),
|
|
137
|
+
]),
|
|
138
|
+
}),
|
|
139
|
+
])
|
|
140
|
+
.describe('An async assertion implementation function');
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
const AssertionPartsSchema = v4_1.z
|
|
145
|
+
.array(v4_1.z.union([PhraseLiteralSchema, PhraseLiteralChoiceSchema, ZodTypeSchema]))
|
|
146
|
+
.min(1, { error: 'At least one part is required for an assertion' })
|
|
147
|
+
.refine((parts) => {
|
|
148
|
+
// Special validation for 'and': it can only appear if followed by a ZodType
|
|
149
|
+
for (let i = 0; i < parts.length; i++) {
|
|
150
|
+
if (parts[i] === 'and') {
|
|
151
|
+
// 'and' must be followed by another part, and that part must be a ZodType
|
|
152
|
+
if (i === parts.length - 1 || !(0, guards_js_1.isZodType)(parts[i + 1])) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}, { error: '"and" can only appear when followed by a Zod schema' })
|
|
159
|
+
.describe('Assertion "parts" which define the input of an assertion');
|
|
160
|
+
/**
|
|
161
|
+
* Type guard for a {@link AssertionFailure}.
|
|
162
|
+
*
|
|
163
|
+
* This cannot live in `guards.ts` because it would create a cycle.
|
|
164
|
+
*
|
|
165
|
+
* @function
|
|
166
|
+
* @param value Value to check
|
|
167
|
+
* @returns `true` if value is an AssertionFailure
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
const isAssertionFailure = (value) => {
|
|
171
|
+
return AssertionFailureSchema.safeParse(value).success;
|
|
172
|
+
};
|
|
173
|
+
exports.isAssertionFailure = isAssertionFailure;
|
|
174
|
+
/**
|
|
175
|
+
* @function
|
|
176
|
+
*/
|
|
177
|
+
const isAssertionParseRequest = (value) => {
|
|
178
|
+
return AssertionParseRequestSchema.safeParse(value).success;
|
|
179
|
+
};
|
|
180
|
+
exports.isAssertionParseRequest = isAssertionParseRequest;
|
|
181
|
+
/**
|
|
182
|
+
* @internal
|
|
183
|
+
*/
|
|
184
|
+
exports.CreateAssertionInputSchema = v4_1.z
|
|
185
|
+
.tuple([
|
|
186
|
+
AssertionPartsSchema,
|
|
187
|
+
AssertionImplSchemaSync,
|
|
188
|
+
v4_1.z.optional(exports.AssertionMetadataSchema),
|
|
189
|
+
])
|
|
190
|
+
.describe('Parameters for createAssertion()');
|
|
191
|
+
/**
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
exports.CreateAssertionInputSchemaAsync = v4_1.z
|
|
195
|
+
.tuple([
|
|
196
|
+
AssertionPartsSchema,
|
|
197
|
+
AssertionImplSchemaAsync,
|
|
198
|
+
v4_1.z.optional(exports.AssertionMetadataSchema),
|
|
199
|
+
])
|
|
200
|
+
.describe('Parameters for createAsyncAssertion()');
|
|
201
|
+
/**
|
|
202
|
+
* @function
|
|
203
|
+
* @param value
|
|
204
|
+
* @returns
|
|
205
|
+
* @knipignore
|
|
206
|
+
*/
|
|
207
|
+
const isMetadata = (value) => exports.AssertionMetadataSchema.safeParse(value).success;
|
|
208
|
+
exports.isMetadata = isMetadata;
|
|
209
|
+
//# sourceMappingURL=internal-schema.js.map
|