bupkis 0.1.2 → 0.3.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 +28 -0
- package/README.md +16 -16
- package/dist/commonjs/assertion/assertion-async.d.ts +2 -1
- package/dist/commonjs/assertion/assertion-async.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-async.js +84 -2
- package/dist/commonjs/assertion/assertion-async.js.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.js +5 -1
- package/dist/commonjs/assertion/assertion-sync.js.map +1 -1
- package/dist/commonjs/assertion/assertion-types.d.ts +39 -84
- package/dist/commonjs/assertion/assertion-types.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.d.ts +1 -1
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +1 -14
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/create.d.ts +5 -33
- package/dist/commonjs/assertion/create.d.ts.map +1 -1
- package/dist/commonjs/assertion/create.js +17 -6
- package/dist/commonjs/assertion/create.js.map +1 -1
- package/dist/commonjs/assertion/impl/async.d.ts +122 -21
- package/dist/commonjs/assertion/impl/async.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async.js +114 -90
- package/dist/commonjs/assertion/impl/async.js.map +1 -1
- package/dist/commonjs/assertion/impl/callback.d.ts +104 -0
- package/dist/commonjs/assertion/impl/callback.d.ts.map +1 -0
- package/dist/commonjs/assertion/impl/callback.js +694 -0
- package/dist/commonjs/assertion/impl/callback.js.map +1 -0
- package/dist/commonjs/assertion/impl/index.d.ts +1 -1
- package/dist/commonjs/assertion/impl/index.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/index.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts +37 -34
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +32 -47
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +105 -58
- package/dist/commonjs/assertion/impl/sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync.js +4 -1
- package/dist/commonjs/assertion/impl/sync.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +199 -85
- package/dist/commonjs/bootstrap.d.ts.map +1 -1
- package/dist/commonjs/bootstrap.js +19 -10
- package/dist/commonjs/bootstrap.js.map +1 -1
- package/dist/commonjs/constant.js +7 -1
- package/dist/commonjs/constant.js.map +1 -1
- package/dist/commonjs/error.d.ts +32 -5
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +60 -5
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/expect.d.ts +130 -3
- package/dist/commonjs/expect.d.ts.map +1 -1
- package/dist/commonjs/expect.js +116 -1
- package/dist/commonjs/expect.js.map +1 -1
- package/dist/commonjs/guards.d.ts +45 -20
- package/dist/commonjs/guards.d.ts.map +1 -1
- package/dist/commonjs/guards.js +56 -40
- package/dist/commonjs/guards.js.map +1 -1
- package/dist/commonjs/index.d.ts +241 -86
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +44 -42
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/metadata.d.ts +1 -27
- package/dist/commonjs/metadata.d.ts.map +1 -1
- package/dist/commonjs/metadata.js +16 -15
- package/dist/commonjs/metadata.js.map +1 -1
- package/dist/commonjs/schema.d.ts +76 -33
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +77 -34
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/types.d.ts +480 -39
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +12 -2
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/util.d.ts +72 -49
- package/dist/commonjs/util.d.ts.map +1 -1
- package/dist/commonjs/util.js +175 -155
- package/dist/commonjs/util.js.map +1 -1
- package/dist/commonjs/value-to-schema.d.ts +122 -0
- package/dist/commonjs/value-to-schema.d.ts.map +1 -0
- package/dist/commonjs/value-to-schema.js +309 -0
- package/dist/commonjs/value-to-schema.js.map +1 -0
- package/dist/esm/assertion/assertion-async.d.ts +2 -1
- package/dist/esm/assertion/assertion-async.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-async.js +85 -3
- package/dist/esm/assertion/assertion-async.js.map +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-sync.js +6 -2
- package/dist/esm/assertion/assertion-sync.js.map +1 -1
- package/dist/esm/assertion/assertion-types.d.ts +39 -84
- package/dist/esm/assertion/assertion-types.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.d.ts +1 -1
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +1 -14
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/create.d.ts +5 -33
- package/dist/esm/assertion/create.d.ts.map +1 -1
- package/dist/esm/assertion/create.js +14 -4
- package/dist/esm/assertion/create.js.map +1 -1
- package/dist/esm/assertion/impl/async.d.ts +122 -21
- package/dist/esm/assertion/impl/async.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async.js +113 -89
- package/dist/esm/assertion/impl/async.js.map +1 -1
- package/dist/esm/assertion/impl/callback.d.ts +104 -0
- package/dist/esm/assertion/impl/callback.d.ts.map +1 -0
- package/dist/esm/assertion/impl/callback.js +691 -0
- package/dist/esm/assertion/impl/callback.js.map +1 -0
- package/dist/esm/assertion/impl/index.d.ts +1 -1
- package/dist/esm/assertion/impl/index.d.ts.map +1 -1
- package/dist/esm/assertion/impl/index.js +1 -1
- package/dist/esm/assertion/impl/index.js.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.js +2 -2
- package/dist/esm/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts +37 -34
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +32 -47
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +105 -58
- package/dist/esm/assertion/impl/sync.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync.js +3 -1
- package/dist/esm/assertion/impl/sync.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +199 -85
- package/dist/esm/bootstrap.d.ts.map +1 -1
- package/dist/esm/bootstrap.js +19 -10
- package/dist/esm/bootstrap.js.map +1 -1
- package/dist/esm/constant.js +6 -0
- package/dist/esm/constant.js.map +1 -1
- package/dist/esm/error.d.ts +32 -5
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +59 -5
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/expect.d.ts +130 -3
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +117 -2
- package/dist/esm/expect.js.map +1 -1
- package/dist/esm/guards.d.ts +45 -20
- package/dist/esm/guards.d.ts.map +1 -1
- package/dist/esm/guards.js +48 -31
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/index.d.ts +241 -86
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +46 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metadata.d.ts +1 -27
- package/dist/esm/metadata.d.ts.map +1 -1
- package/dist/esm/metadata.js +2 -1
- package/dist/esm/metadata.js.map +1 -1
- package/dist/esm/schema.d.ts +76 -33
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +77 -34
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/types.d.ts +480 -39
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +12 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/util.d.ts +72 -49
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +159 -153
- package/dist/esm/util.js.map +1 -1
- package/dist/esm/value-to-schema.d.ts +122 -0
- package/dist/esm/value-to-schema.d.ts.map +1 -0
- package/dist/esm/value-to-schema.js +305 -0
- package/dist/esm/value-to-schema.js.map +1 -0
- package/package.json +94 -17
- package/src/assertion/assertion-async.ts +113 -3
- package/src/assertion/assertion-sync.ts +5 -2
- package/src/assertion/assertion-types.ts +52 -45
- package/src/assertion/assertion.ts +2 -17
- package/src/assertion/create.ts +16 -65
- package/src/assertion/impl/async.ts +132 -92
- package/src/assertion/impl/callback.ts +882 -0
- package/src/assertion/impl/index.ts +1 -1
- package/src/assertion/impl/sync-esoteric.ts +2 -2
- package/src/assertion/impl/sync-parametric.ts +41 -49
- package/src/assertion/impl/sync.ts +3 -0
- package/src/bootstrap.ts +21 -11
- package/src/constant.ts +8 -0
- package/src/error.ts +75 -4
- package/src/expect.ts +275 -20
- package/src/guards.ts +74 -69
- package/src/index.ts +72 -11
- package/src/metadata.ts +3 -4
- package/src/schema.ts +80 -36
- package/src/types.ts +625 -72
- package/src/util.ts +174 -222
- package/src/value-to-schema.ts +464 -0
- package/dist/commonjs/api.d.ts +0 -93
- package/dist/commonjs/api.d.ts.map +0 -1
- package/dist/commonjs/api.js +0 -8
- package/dist/commonjs/api.js.map +0 -1
- package/dist/esm/api.d.ts +0 -93
- package/dist/esm/api.d.ts.map +0 -1
- package/dist/esm/api.js +0 -7
- package/dist/esm/api.js.map +0 -1
- package/src/api.ts +0 -149
- package/src/schema.md +0 -15
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
|
-
import { type
|
|
11
|
+
import { type NonEmptyTuple } from 'type-fest';
|
|
12
12
|
import { type z } from 'zod/v4';
|
|
13
|
-
import type { AsyncAssertions, SyncAssertions } from './impl/index.js';
|
|
14
13
|
/**
|
|
15
14
|
* Union type representing any assertion, either synchronous or asynchronous.
|
|
16
15
|
*
|
|
@@ -152,7 +151,7 @@ export type AssertionImpl<Parts extends AssertionParts> = AssertionImplAsync<Par
|
|
|
152
151
|
* asynchronous assertions, providing a type-safe way to handle async assertion
|
|
153
152
|
* logic.
|
|
154
153
|
*
|
|
155
|
-
* @
|
|
154
|
+
* @template Parts - The assertion parts defining the structure
|
|
156
155
|
* @see {@link AssertionImplFnAsync} for function-based async implementations
|
|
157
156
|
* @see {@link AssertionImplSchemaAsync} for schema-based async implementations
|
|
158
157
|
*/
|
|
@@ -165,7 +164,7 @@ export type AssertionImplAsync<Parts extends AssertionParts> = AssertionImplFnAs
|
|
|
165
164
|
* parsed values from the assertion parts and can return various types
|
|
166
165
|
* indicating validation success or failure.
|
|
167
166
|
*
|
|
168
|
-
* @
|
|
167
|
+
* @template Parts - The assertion parts defining the structure
|
|
169
168
|
* @param values - The parsed values corresponding to assertion parts
|
|
170
169
|
* @returns Promise resolving to boolean indicating pass/fail, void for success,
|
|
171
170
|
* ZodType for dynamic validation, or AssertionFailure object for detailed
|
|
@@ -173,7 +172,11 @@ export type AssertionImplAsync<Parts extends AssertionParts> = AssertionImplFnAs
|
|
|
173
172
|
* @see {@link AssertionImplFnSync} for sync function implementations
|
|
174
173
|
* @see {@link ParsedValues} for the input parameter structure
|
|
175
174
|
*/
|
|
176
|
-
export type AssertionImplFnAsync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) =>
|
|
175
|
+
export type AssertionImplFnAsync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) => AssertionImplFnReturnType<Parts> | Promise<AssertionImplFnReturnType<Parts>>;
|
|
176
|
+
/**
|
|
177
|
+
* The return type of an assertion implementation function.
|
|
178
|
+
*/
|
|
179
|
+
export type AssertionImplFnReturnType<Parts extends AssertionParts> = AssertionFailure | boolean | void | z.ZodError | z.ZodType<ParsedSubject<Parts>>;
|
|
177
180
|
/**
|
|
178
181
|
* The implementation of an assertion as a sync function.
|
|
179
182
|
*
|
|
@@ -182,26 +185,22 @@ export type AssertionImplFnAsync<Parts extends AssertionParts> = (...values: Par
|
|
|
182
185
|
* assertion parts and can return various types indicating validation success or
|
|
183
186
|
* failure.
|
|
184
187
|
*
|
|
185
|
-
* @
|
|
188
|
+
* @template Parts - The assertion parts defining the structure
|
|
186
189
|
* @param values - The parsed values corresponding to assertion parts
|
|
187
190
|
* @returns Boolean indicating pass/fail, void for success, ZodType for dynamic
|
|
188
191
|
* validation, or AssertionFailure object for detailed error information
|
|
189
192
|
* @see {@link AssertionImplFnAsync} for async function implementations
|
|
190
193
|
* @see {@link ParsedValues} for the input parameter structure
|
|
191
194
|
*/
|
|
192
|
-
export type AssertionImplFnSync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) =>
|
|
195
|
+
export type AssertionImplFnSync<Parts extends AssertionParts> = (...values: ParsedValues<Parts>) => AssertionImplFnReturnType<Parts>;
|
|
193
196
|
/**
|
|
194
197
|
* Maps an {@link AssertionPart} to a parameter to an {@link AssertionImpl}.
|
|
195
198
|
*
|
|
196
199
|
* This omits {@link Phrase} parts, which are not received by the implementation.
|
|
197
|
-
*
|
|
198
|
-
* @knipignore
|
|
199
200
|
*/
|
|
200
201
|
export type AssertionImplPart<Part extends AssertionPart> = Part extends PhraseLiteral | PhraseLiteralChoice ? never : Part extends z.ZodPromise ? Promise<z.infer<Part>> : z.infer<Part>;
|
|
201
202
|
/**
|
|
202
203
|
* Maps {@link AssertionParts} to their corresponding {@link AssertionImplPart}.
|
|
203
|
-
*
|
|
204
|
-
* @knipignore
|
|
205
204
|
*/
|
|
206
205
|
export type AssertionImplParts<Parts extends readonly AssertionPart[]> = Parts extends readonly [
|
|
207
206
|
infer First extends AssertionPart,
|
|
@@ -219,7 +218,7 @@ export type AssertionImplParts<Parts extends readonly AssertionPart[]> = Parts e
|
|
|
219
218
|
* the assertion parts and is branded with 'async-schema' for compile-time type
|
|
220
219
|
* safety.
|
|
221
220
|
*
|
|
222
|
-
* @
|
|
221
|
+
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
223
222
|
* @see {@link AssertionImplSchemaSync} for synchronous schema implementations
|
|
224
223
|
* @see {@link AssertionImplFnAsync} for function-based async implementations
|
|
225
224
|
* @see {@link ParsedSubject} for subject type derivation
|
|
@@ -233,7 +232,7 @@ export type AssertionImplSchemaAsync<Parts extends AssertionParts> = z.core.$Zod
|
|
|
233
232
|
* assertion parts and is branded with 'sync-schema' for compile-time type
|
|
234
233
|
* safety.
|
|
235
234
|
*
|
|
236
|
-
* @
|
|
235
|
+
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
237
236
|
* @see {@link AssertionImplSchemaAsync} for asynchronous schema implementations
|
|
238
237
|
* @see {@link AssertionImplFnSync} for function-based sync implementations
|
|
239
238
|
* @see {@link ParsedSubject} for subject type derivation
|
|
@@ -246,7 +245,7 @@ export type AssertionImplSchemaSync<Parts extends AssertionParts> = z.core.$ZodB
|
|
|
246
245
|
* synchronous assertions. Function implementations provide custom validation
|
|
247
246
|
* logic, while schema implementations use Zod schemas for validation.
|
|
248
247
|
*
|
|
249
|
-
* @
|
|
248
|
+
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
250
249
|
* @see {@link AssertionImplFnSync} for function-based implementations
|
|
251
250
|
* @see {@link AssertionImplSchemaSync} for schema-based implementations
|
|
252
251
|
* @see {@link AssertionImplAsync} for async implementation unions
|
|
@@ -258,7 +257,7 @@ export type AssertionImplSchemaSync<Parts extends AssertionParts> = z.core.$ZodB
|
|
|
258
257
|
* synchronous assertions. Function implementations provide custom validation
|
|
259
258
|
* logic, while schema implementations use Zod schemas for validation.
|
|
260
259
|
*
|
|
261
|
-
* @
|
|
260
|
+
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
262
261
|
* @see {@link AssertionImplFnSync} for function-based implementations
|
|
263
262
|
* @see {@link AssertionImplSchemaSync} for schema-based implementations
|
|
264
263
|
* @see {@link AssertionImplAsync} for async implementation unions
|
|
@@ -310,11 +309,10 @@ export type AssertionPart = Phrase | z.ZodType;
|
|
|
310
309
|
* type ChoiceAssertion = [z.any(), ['to be', 'to equal'], z.any()];
|
|
311
310
|
* ```
|
|
312
311
|
*
|
|
313
|
-
* @
|
|
314
|
-
* constraints
|
|
312
|
+
* @template Parts - Extends the base AssertionPart array with tuple constraints
|
|
315
313
|
* @see {@link AssertionPart} for individual part types
|
|
316
314
|
* @see {@link AssertionSlots} for compiled slot representation
|
|
317
|
-
* @see {@link
|
|
315
|
+
* @see {@link createAssertion} for assertion creation from parts
|
|
318
316
|
*/
|
|
319
317
|
export type AssertionParts = NonEmptyTuple<AssertionPart>;
|
|
320
318
|
/**
|
|
@@ -336,7 +334,7 @@ export type AssertionParts = NonEmptyTuple<AssertionPart>;
|
|
|
336
334
|
* type Slots = [PhraseLiteralSlot<'to be a string'>, z.ZodNumber];
|
|
337
335
|
* ```
|
|
338
336
|
*
|
|
339
|
-
* @
|
|
337
|
+
* @template Parts - The readonly array of assertion parts to process
|
|
340
338
|
* @see {@link AssertionSlot} for individual slot type mapping
|
|
341
339
|
* @see {@link AssertionSlots} for filtered and properly typed slot tuples
|
|
342
340
|
* @see {@link NoNeverTuple} for filtering never entries
|
|
@@ -376,7 +374,7 @@ export interface AssertionSchemaSync<Parts extends AssertionParts, Impl extends
|
|
|
376
374
|
* type Slot3 = AssertionSlot<z.ZodString>; // z.ZodString
|
|
377
375
|
* ```
|
|
378
376
|
*
|
|
379
|
-
* @
|
|
377
|
+
* @template Part - The assertion part to convert to a slot
|
|
380
378
|
* @see {@link PhraseLiteralSlot} for string literal slots
|
|
381
379
|
* @see {@link PhraseLiteralChoiceSlot} for choice-based slots
|
|
382
380
|
* @see {@link AssertionSlots} for complete slot tuples
|
|
@@ -393,8 +391,12 @@ export type AssertionSlot<Part extends AssertionPart> = Part extends string ? Ph
|
|
|
393
391
|
* The resulting tuple:
|
|
394
392
|
*
|
|
395
393
|
* 1. Has `never` entries filtered out to maintain proper tuple structure
|
|
396
|
-
* 2.
|
|
397
|
-
*
|
|
394
|
+
* 2. Will include an implicit subject slot {@link AssertionParts} with a
|
|
395
|
+
* {@link PhraseLiteral}/{@link PhraseLiteralChoice} in the first position.
|
|
396
|
+
* 3. Contains branded slots for
|
|
397
|
+
* {@link PhraseLiteral PhraseLiterals}/{@link PhraseLiteralChoice PhraseLiteralChoices}
|
|
398
|
+
* to enable phrase matching; differentiates from a user-created
|
|
399
|
+
* {@link z.ZodLiteral ZodLiteral}.
|
|
398
400
|
*
|
|
399
401
|
* @example
|
|
400
402
|
*
|
|
@@ -408,7 +410,7 @@ export type AssertionSlot<Part extends AssertionPart> = Part extends string ? Ph
|
|
|
408
410
|
* // Result: [z.ZodString, PhraseLiteralSlot<'to match'>, z.ZodRegExp]
|
|
409
411
|
* ```
|
|
410
412
|
*
|
|
411
|
-
* @
|
|
413
|
+
* @template Parts - The assertion parts to convert to slots
|
|
412
414
|
* @see {@link AssertionSlot} for individual slot mapping
|
|
413
415
|
* @see {@link AssertionPartsToSlots} for the underlying mapping logic
|
|
414
416
|
* @see {@link NoNeverTuple} for never filtering
|
|
@@ -438,8 +440,6 @@ export interface AssertionSync<Parts extends AssertionParts = AssertionParts, Im
|
|
|
438
440
|
}
|
|
439
441
|
/**
|
|
440
442
|
* The base structure for parsed assertion results.
|
|
441
|
-
*
|
|
442
|
-
* @knipignore
|
|
443
443
|
*/
|
|
444
444
|
export interface BaseParsedResult<Parts extends AssertionParts> {
|
|
445
445
|
/**
|
|
@@ -449,58 +449,15 @@ export interface BaseParsedResult<Parts extends AssertionParts> {
|
|
|
449
449
|
exactMatch?: boolean;
|
|
450
450
|
/**
|
|
451
451
|
* Present only if `success` is `true`. The parsed values mapped to the slots
|
|
452
|
-
* of {@link
|
|
452
|
+
* of an {@link Assertion}.
|
|
453
453
|
*/
|
|
454
454
|
parsedValues?: ParsedValues<Parts>;
|
|
455
455
|
/**
|
|
456
|
-
* Whether the args were successfully parsed against the slots of
|
|
457
|
-
* {@link
|
|
456
|
+
* Whether the args were successfully parsed against the slots of an
|
|
457
|
+
* {@link Assertion}.
|
|
458
458
|
*/
|
|
459
459
|
success: boolean;
|
|
460
460
|
}
|
|
461
|
-
/**
|
|
462
|
-
* Type for extracting individual builtin async assertion types.
|
|
463
|
-
*
|
|
464
|
-
* This type extracts the element types from the builtin async assertions array,
|
|
465
|
-
* providing a union of all available async assertion types in the framework.
|
|
466
|
-
*
|
|
467
|
-
* @see {@link BuiltinAsyncAssertions} for the full array type
|
|
468
|
-
* @see {@link AsyncAssertions} for the actual assertion implementations
|
|
469
|
-
*/
|
|
470
|
-
export type BuiltinAsyncAssertion = ArrayValues<BuiltinAsyncAssertions>;
|
|
471
|
-
/**
|
|
472
|
-
* Type representing the collection of all builtin async assertions.
|
|
473
|
-
*
|
|
474
|
-
* This type represents the compile-time type of the `AsyncAssertions` constant,
|
|
475
|
-
* providing type information for all async assertion implementations included
|
|
476
|
-
* in the framework by default.
|
|
477
|
-
*
|
|
478
|
-
* @see {@link AsyncAssertions} for the actual assertion implementations
|
|
479
|
-
* @see {@link BuiltinAsyncAssertion} for individual assertion types
|
|
480
|
-
*/
|
|
481
|
-
export type BuiltinAsyncAssertions = typeof AsyncAssertions;
|
|
482
|
-
/**
|
|
483
|
-
* Type for extracting individual builtin sync assertion types.
|
|
484
|
-
*
|
|
485
|
-
* This type extracts the element types from the builtin sync assertions array,
|
|
486
|
-
* providing a union of all available synchronous assertion types in the
|
|
487
|
-
* framework.
|
|
488
|
-
*
|
|
489
|
-
* @see {@link BuiltinSyncAssertions} for the full array type
|
|
490
|
-
* @see {@link SyncAssertions} for the actual assertion implementations
|
|
491
|
-
*/
|
|
492
|
-
export type BuiltinSyncAssertion = ArrayValues<BuiltinSyncAssertions>;
|
|
493
|
-
/**
|
|
494
|
-
* Type representing the collection of all builtin sync assertions.
|
|
495
|
-
*
|
|
496
|
-
* This type represents the compile-time type of the `SyncAssertions` constant,
|
|
497
|
-
* providing type information for all synchronous assertion implementations
|
|
498
|
-
* included in the framework by default.
|
|
499
|
-
*
|
|
500
|
-
* @see {@link SyncAssertions} for the actual assertion implementations
|
|
501
|
-
* @see {@link BuiltinSyncAssertion} for individual assertion types
|
|
502
|
-
*/
|
|
503
|
-
export type BuiltinSyncAssertions = typeof SyncAssertions;
|
|
504
461
|
/**
|
|
505
462
|
* Utility type for parsed values that may be empty.
|
|
506
463
|
*
|
|
@@ -509,7 +466,7 @@ export type BuiltinSyncAssertions = typeof SyncAssertions;
|
|
|
509
466
|
* tuple). It uses `NoNeverTuple` to filter out `never` types that may arise
|
|
510
467
|
* during the recursive processing.
|
|
511
468
|
*
|
|
512
|
-
* @
|
|
469
|
+
* @template Parts - The assertion parts to process
|
|
513
470
|
* @see {@link ParsedValues} for the standard parsed values type
|
|
514
471
|
* @see {@link NoNeverTuple} for never-type filtering
|
|
515
472
|
*/
|
|
@@ -539,7 +496,7 @@ export type MaybeEmptyParsedValues<Parts extends readonly AssertionPart[]> = NoN
|
|
|
539
496
|
* type Mixed = NoNeverTuple<readonly [boolean, never, string]>; // readonly [boolean, string]
|
|
540
497
|
* ```
|
|
541
498
|
*
|
|
542
|
-
* @
|
|
499
|
+
* @template T - The readonly tuple type to filter
|
|
543
500
|
* @see {@link AssertionPartsToSlots} for usage in slot processing
|
|
544
501
|
* @see {@link AssertionSlots} for filtered slot tuples
|
|
545
502
|
*/
|
|
@@ -571,7 +528,7 @@ export type NoNeverTuple<T extends readonly unknown[]> = T extends readonly [
|
|
|
571
528
|
* };
|
|
572
529
|
* ```
|
|
573
530
|
*
|
|
574
|
-
* @
|
|
531
|
+
* @template Parts - The assertion parts tuple defining expected structure
|
|
575
532
|
* @see {@link ParsedResultSuccess} for successful parse results
|
|
576
533
|
* @see {@link ParsedResultFailure} for failed parse results
|
|
577
534
|
* @see {@link AssertionSync.parseValues} and {@link AssertionAsync.parseValuesAsync} for usage context
|
|
@@ -600,7 +557,7 @@ export interface ParsedResultFailure extends BaseParsedResult<never> {
|
|
|
600
557
|
* interface contains the validated arguments and metadata about the match
|
|
601
558
|
* quality. The assertion can be executed using the `parsedValues`.
|
|
602
559
|
*
|
|
603
|
-
* @
|
|
560
|
+
* @template Parts - The assertion parts tuple defining the expected structure
|
|
604
561
|
* @see {@link ParsedResultFailure} for failed parsing results
|
|
605
562
|
* @see {@link BaseParsedResult} for shared result properties
|
|
606
563
|
*/
|
|
@@ -638,7 +595,7 @@ export interface ParsedResultSuccess<Parts extends AssertionParts> extends BaseP
|
|
|
638
595
|
* type NumericSubject = ParsedSubject<NumericParts>; // number
|
|
639
596
|
* ```
|
|
640
597
|
*
|
|
641
|
-
* @
|
|
598
|
+
* @template Parts - The assertion parts tuple defining the assertion structure
|
|
642
599
|
* @see {@link ParsedValues} for the complete parsed values tuple
|
|
643
600
|
* @see {@link AssertionImpl} for how subjects are used in implementations
|
|
644
601
|
*/
|
|
@@ -661,7 +618,7 @@ export type ParsedSubject<Parts extends AssertionParts> = ParsedValues<Parts> ex
|
|
|
661
618
|
* // ParsedValues = [typeof obj, typeof shape]
|
|
662
619
|
* ```
|
|
663
620
|
*
|
|
664
|
-
* @
|
|
621
|
+
* @template Parts - The assertion parts tuple defining the expected structure
|
|
665
622
|
* @see {@link ParsedSubject} for extracting just the subject
|
|
666
623
|
* @see {@link MaybeEmptyParsedValues} for the underlying value processing
|
|
667
624
|
* @see {@link AssertionImpl} for how these values are consumed
|
|
@@ -757,7 +714,7 @@ export type PhraseLiteralChoice = NonEmptyTuple<string>;
|
|
|
757
714
|
* The `__values` property might be redundant since values should be derivable
|
|
758
715
|
* from the ZodLiteral metadata, but it provides type-level access to the
|
|
759
716
|
* choices.
|
|
760
|
-
* @
|
|
717
|
+
* @template H - The readonly tuple of string choices
|
|
761
718
|
* @see {@link PhraseLiteralChoice} for the source type
|
|
762
719
|
* @see {@link PhraseLiteralSlot} for single phrase slots
|
|
763
720
|
* @see {@link AssertionSlot} for slot type mapping
|
|
@@ -776,15 +733,12 @@ export type PhraseLiteralChoiceSlot<H extends readonly [string, ...string[]]> =
|
|
|
776
733
|
* This type might be redundant since the value should be derivable from the
|
|
777
734
|
* ZodLiteral's value property, but it provides type-level access to the
|
|
778
735
|
* literal.
|
|
779
|
-
* @
|
|
736
|
+
* @template T - The string literal type
|
|
780
737
|
* @see {@link PhraseLiteral} for the source type
|
|
781
738
|
* @see {@link PhraseLiteralChoiceSlot} for choice phrase slots
|
|
782
739
|
* @see {@link AssertionSlot} for slot type mapping
|
|
783
740
|
*/
|
|
784
|
-
export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLiteral<T>, 'string-literal'>;
|
|
785
|
-
* Object which can returned by assertion implementation functions to provide
|
|
786
|
-
* contextual information to an `AssertionError`
|
|
787
|
-
*/
|
|
741
|
+
export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLiteral<T>, 'string-literal'>;
|
|
788
742
|
/**
|
|
789
743
|
* Type for a raw (unbranded) synchronous schema assertion implementation.
|
|
790
744
|
*
|
|
@@ -793,7 +747,8 @@ export type PhraseLiteralSlot<T extends string> = z.core.$ZodBranded<z.ZodLitera
|
|
|
793
747
|
* type is not branded and represents the underlying schema before it is
|
|
794
748
|
* processed by the assertion creation system.
|
|
795
749
|
*
|
|
796
|
-
* @
|
|
750
|
+
* @template Parts The tuple defining the assertion structure
|
|
751
|
+
* @useDeclaredType
|
|
797
752
|
* @see {@link AssertionImplSchemaSync} for the branded version
|
|
798
753
|
* @see {@link ParsedSubject} for subject type derivation
|
|
799
754
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion-types.d.ts","sourceRoot":"","sources":["../../../src/assertion/assertion-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"assertion-types.d.ts","sourceRoot":"","sources":["../../../src/assertion/assertion-types.ts"],"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AAU,CAAC,CAAC,CAAC,EACf,gBAAgB,CACjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,cAAc,IACjE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
import { type ArrayValues } from 'type-fest';
|
|
12
|
-
import { z } from 'zod/v4';
|
|
12
|
+
import { type z } from 'zod/v4';
|
|
13
13
|
import { AssertionError } from '../error.js';
|
|
14
14
|
import { type Assertion, type AssertionImpl, type AssertionParts, type AssertionSlots, type ParsedResult, type ParsedValues } from './assertion-types.js';
|
|
15
15
|
export declare abstract class BupkisAssertion<Parts extends AssertionParts, Impl extends AssertionImpl<Parts>, Slots extends AssertionSlots<Parts>> implements Assertion<Parts, Impl, Slots> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion.d.ts","sourceRoot":"","sources":["../../../src/assertion/assertion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"assertion.d.ts","sourceRoot":"","sources":["../../../src/assertion/assertion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAY9B,8BAAsB,eAAe,CACnC,KAAK,SAAS,cAAc,EAC5B,IAAI,SAAS,aAAa,CAAC,KAAK,CAAC,EACjC,KAAK,SAAS,cAAc,CAAC,KAAK,CAAC,CACnC,YAAW,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;IAKtC,QAAQ,CAAC,KAAK,EAAE,KAAK;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,IAAI;IALrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAGT,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI;IAMrB;;;;;;OAMG;IAEH;;OAEG;IACI,QAAQ,IAAI,MAAM;IAqDzB,SAAS,CAAC,2BAA2B,CAAC,IAAI,SAAS,SAAS,OAAO,EAAE,EACnE,IAAI,EAAE,IAAI,GACT,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS;IAQlC;;;;;;;OAOG;IACH,SAAS,CAAC,mBAAmB,CAAC,IAAI,SAAS,WAAW,CAAC,KAAK,CAAC,EAC3D,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC;IA4BhC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,iBAAiB,CACzB,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACrC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,GAAG,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,GAC7B,cAAc;IAIjB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
|
|
@@ -17,7 +17,6 @@ exports.BupkisAssertion = void 0;
|
|
|
17
17
|
const debug_1 = __importDefault(require("debug"));
|
|
18
18
|
const slug_1 = __importDefault(require("slug"));
|
|
19
19
|
const util_1 = require("util");
|
|
20
|
-
const v4_1 = require("zod/v4");
|
|
21
20
|
const constant_js_1 = require("../constant.js");
|
|
22
21
|
const error_js_1 = require("../error.js");
|
|
23
22
|
const metadata_js_1 = require("../metadata.js");
|
|
@@ -157,19 +156,7 @@ class BupkisAssertion {
|
|
|
157
156
|
* @returns New `AssertionError`
|
|
158
157
|
*/
|
|
159
158
|
translateZodError(stackStartFn, zodError, ...values) {
|
|
160
|
-
|
|
161
|
-
let pretty = flat.formErrors.join('; ');
|
|
162
|
-
for (const [keypath, errors] of Object.entries(flat.fieldErrors)) {
|
|
163
|
-
pretty += `; ${keypath}: ${errors.join('; ')}`;
|
|
164
|
-
}
|
|
165
|
-
const [actual, ...expected] = values;
|
|
166
|
-
return new error_js_1.AssertionError({
|
|
167
|
-
actual,
|
|
168
|
-
expected: expected.length === 1 ? expected[0] : expected,
|
|
169
|
-
message: `Assertion ${this} failed: ${pretty}`,
|
|
170
|
-
operator: `${this}`,
|
|
171
|
-
stackStartFn,
|
|
172
|
-
});
|
|
159
|
+
return error_js_1.AssertionError.fromZodError(zodError, stackStartFn, values);
|
|
173
160
|
}
|
|
174
161
|
/**
|
|
175
162
|
* Generates a unique¹ ID for this assertion by combining content, structure,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../../src/assertion/assertion.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,kDAA0B;AAC1B,gDAAwB;AAExB,+BAA+B;
|
|
1
|
+
{"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../../src/assertion/assertion.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,kDAA0B;AAC1B,gDAAwB;AAExB,+BAA+B;AAG/B,gDAAgD;AAChD,0CAA6C;AAC7C,gDAAgD;AAUhD,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,EAAE,GA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IACO,iBAAiB,CACzB,YAAqC,EACrC,QAAoB,EACpB,GAAG,MAA2B;QAE9B,OAAO,yBAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACK,mBAAmB;QACzB,MAAM,QAAQ,GAAG,IAAA,cAAI,EAAC,GAAG,IAAI,EAAE,EAAE;YAC/B,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC;QAEH,qDAAqD;QACrD,2DAA2D;QAC3D,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAE/D,OAAO,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC;IACpC,CAAC;CACF;AAnLD,0CAmLC"}
|
|
@@ -65,45 +65,17 @@
|
|
|
65
65
|
* @see {@link AssertionImplSync} for synchronous implementation types
|
|
66
66
|
* @see {@link AssertionImplAsync} for asynchronous implementation types
|
|
67
67
|
*/
|
|
68
|
-
import
|
|
68
|
+
import { type CreateAssertionFn, type CreateAsyncAssertionFn } from '../types.js';
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
* {@link z.ZodType Zod schema}.
|
|
70
|
+
* {@inheritDoc CreateAssertionFn}
|
|
72
71
|
*
|
|
73
|
-
* @param parts Assertion parts defining the shape of the assertion
|
|
74
|
-
* @param impl Implementation as a Zod schema
|
|
75
|
-
* @returns New `SchemaAssertion` instance
|
|
76
72
|
* @throws {TypeError} Invalid assertion implementation type
|
|
77
73
|
*/
|
|
78
|
-
export declare
|
|
74
|
+
export declare const createAssertion: CreateAssertionFn;
|
|
79
75
|
/**
|
|
80
|
-
*
|
|
81
|
-
* implementation function.
|
|
76
|
+
* {@inheritDoc CreateAsyncAssertionFn}
|
|
82
77
|
*
|
|
83
|
-
* @param parts Assertion parts defining the shape of the assertion
|
|
84
|
-
* @param impl Implementation as a function
|
|
85
|
-
* @returns New `FunctionAssertion` instance
|
|
86
78
|
* @throws {TypeError} Invalid assertion implementation type
|
|
87
79
|
*/
|
|
88
|
-
export declare
|
|
89
|
-
/**
|
|
90
|
-
* Create an async `Assertion` from {@link AssertionParts parts} and an async
|
|
91
|
-
* {@link z.ZodType Zod schema}.
|
|
92
|
-
*
|
|
93
|
-
* @param parts Assertion parts defining the shape of the assertion
|
|
94
|
-
* @param impl Implementation as a Zod schema (potentially async)
|
|
95
|
-
* @returns New `BupkisAssertionSchemaAsync` instance
|
|
96
|
-
* @throws {TypeError} Invalid assertion implementation type
|
|
97
|
-
*/
|
|
98
|
-
export declare function createAsyncAssertion<const Parts extends AssertionParts, Impl extends AssertionImplSchemaAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionSchemaAsync<Parts, Impl, Slots>;
|
|
99
|
-
/**
|
|
100
|
-
* Create an async `Assertion` from {@link AssertionParts parts} and an
|
|
101
|
-
* implementation function.
|
|
102
|
-
*
|
|
103
|
-
* @param parts Assertion parts defining the shape of the assertion
|
|
104
|
-
* @param impl Implementation as a function (potentially async)
|
|
105
|
-
* @returns New `FunctionAssertion` instance
|
|
106
|
-
* @throws {TypeError} Invalid assertion implementation type
|
|
107
|
-
*/
|
|
108
|
-
export declare function createAsyncAssertion<const Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionFunctionAsync<Parts, Impl, Slots>;
|
|
80
|
+
export declare const createAsyncAssertion: CreateAsyncAssertionFn;
|
|
109
81
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/assertion/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/assertion/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAWH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AAWrB;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,iBAwC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,sBAiClC,CAAC"}
|
|
@@ -67,14 +67,18 @@
|
|
|
67
67
|
* @see {@link AssertionImplAsync} for asynchronous implementation types
|
|
68
68
|
*/
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
exports.createAssertion =
|
|
71
|
-
exports.createAsyncAssertion = createAsyncAssertion;
|
|
70
|
+
exports.createAsyncAssertion = exports.createAssertion = void 0;
|
|
72
71
|
const v4_1 = require("zod/v4");
|
|
73
72
|
const guards_js_1 = require("../guards.js");
|
|
74
73
|
const assertion_async_js_1 = require("./assertion-async.js");
|
|
75
74
|
const assertion_sync_js_1 = require("./assertion-sync.js");
|
|
76
75
|
const slotify_js_1 = require("./slotify.js");
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* {@inheritDoc CreateAssertionFn}
|
|
78
|
+
*
|
|
79
|
+
* @throws {TypeError} Invalid assertion implementation type
|
|
80
|
+
*/
|
|
81
|
+
const createAssertion = (parts, impl) => {
|
|
78
82
|
if (!Array.isArray(parts)) {
|
|
79
83
|
throw new TypeError('First parameter must be an array');
|
|
80
84
|
}
|
|
@@ -103,8 +107,14 @@ function createAssertion(parts, impl) {
|
|
|
103
107
|
throw err;
|
|
104
108
|
}
|
|
105
109
|
throw new TypeError('Assertion implementation must be a function, Zod schema or Zod schema factory');
|
|
106
|
-
}
|
|
107
|
-
|
|
110
|
+
};
|
|
111
|
+
exports.createAssertion = createAssertion;
|
|
112
|
+
/**
|
|
113
|
+
* {@inheritDoc CreateAsyncAssertionFn}
|
|
114
|
+
*
|
|
115
|
+
* @throws {TypeError} Invalid assertion implementation type
|
|
116
|
+
*/
|
|
117
|
+
const createAsyncAssertion = (parts, impl) => {
|
|
108
118
|
if (!Array.isArray(parts)) {
|
|
109
119
|
throw new TypeError('First parameter must be an array');
|
|
110
120
|
}
|
|
@@ -125,5 +135,6 @@ function createAsyncAssertion(parts, impl) {
|
|
|
125
135
|
return new assertion_async_js_1.BupkisAssertionFunctionAsync(parts, slots, impl);
|
|
126
136
|
}
|
|
127
137
|
throw new TypeError('Assertion implementation must be a function, Zod schema or Zod schema factory');
|
|
128
|
-
}
|
|
138
|
+
};
|
|
139
|
+
exports.createAsyncAssertion = createAsyncAssertion;
|
|
129
140
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/assertion/create.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/assertion/create.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;;;AAEH,+BAA2B;AAQ3B,4CAA+D;AAK/D,6DAG8B;AAC9B,2DAG6B;AAC7B,6CAAuC;AAEvC;;;;GAIG;AACI,MAAM,eAAe,GAAsB,CAIhD,KAAY,EACZ,IAAU,EACV,EAAE;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CAAC,iDAA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