bupkis 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -4
- package/src/assertion/assertion-types.ts +4 -4
- package/src/assertion/impl/async-parametric.ts +4 -21
- package/src/assertion/impl/sync-parametric.ts +5 -17
- package/src/expect.ts +0 -4
- package/src/guards.ts +24 -24
- package/src/internal-schema.ts +16 -32
- package/src/value-to-schema.ts +1 -1
- package/dist/assertion/assertion-async.cjs +0 -268
- package/dist/assertion/assertion-async.cjs.map +0 -1
- package/dist/assertion/assertion-async.d.cts +0 -40
- package/dist/assertion/assertion-async.d.cts.map +0 -1
- package/dist/assertion/assertion-async.d.ts +0 -40
- package/dist/assertion/assertion-async.d.ts.map +0 -1
- package/dist/assertion/assertion-async.js +0 -259
- package/dist/assertion/assertion-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
- package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.js +0 -128
- package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
- package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.js +0 -137
- package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
- package/dist/assertion/assertion-sync.cjs +0 -284
- package/dist/assertion/assertion-sync.cjs.map +0 -1
- package/dist/assertion/assertion-sync.d.cts +0 -60
- package/dist/assertion/assertion-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-sync.d.ts +0 -60
- package/dist/assertion/assertion-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-sync.js +0 -275
- package/dist/assertion/assertion-sync.js.map +0 -1
- package/dist/assertion/assertion-types.cjs +0 -20
- package/dist/assertion/assertion-types.cjs.map +0 -1
- package/dist/assertion/assertion-types.d.cts +0 -1086
- package/dist/assertion/assertion-types.d.cts.map +0 -1
- package/dist/assertion/assertion-types.d.ts +0 -1086
- package/dist/assertion/assertion-types.d.ts.map +0 -1
- package/dist/assertion/assertion-types.js +0 -19
- package/dist/assertion/assertion-types.js.map +0 -1
- package/dist/assertion/assertion.cjs +0 -382
- package/dist/assertion/assertion.cjs.map +0 -1
- package/dist/assertion/assertion.d.cts +0 -109
- package/dist/assertion/assertion.d.cts.map +0 -1
- package/dist/assertion/assertion.d.ts +0 -109
- package/dist/assertion/assertion.d.ts.map +0 -1
- package/dist/assertion/assertion.js +0 -375
- package/dist/assertion/assertion.js.map +0 -1
- package/dist/assertion/create.cjs +0 -148
- package/dist/assertion/create.cjs.map +0 -1
- package/dist/assertion/create.d.cts +0 -85
- package/dist/assertion/create.d.cts.map +0 -1
- package/dist/assertion/create.d.ts +0 -85
- package/dist/assertion/create.d.ts.map +0 -1
- package/dist/assertion/create.js +0 -143
- package/dist/assertion/create.js.map +0 -1
- package/dist/assertion/format-assertion-failure.cjs +0 -63
- package/dist/assertion/format-assertion-failure.cjs.map +0 -1
- package/dist/assertion/format-assertion-failure.d.cts +0 -21
- package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
- package/dist/assertion/format-assertion-failure.d.ts +0 -21
- package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
- package/dist/assertion/format-assertion-failure.js +0 -59
- package/dist/assertion/format-assertion-failure.js.map +0 -1
- package/dist/assertion/impl/assertion-util.cjs +0 -68
- package/dist/assertion/impl/assertion-util.cjs.map +0 -1
- package/dist/assertion/impl/assertion-util.d.cts +0 -36
- package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
- package/dist/assertion/impl/assertion-util.d.ts +0 -36
- package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
- package/dist/assertion/impl/assertion-util.js +0 -62
- package/dist/assertion/impl/assertion-util.js.map +0 -1
- package/dist/assertion/impl/async-iterable.cjs +0 -627
- package/dist/assertion/impl/async-iterable.cjs.map +0 -1
- package/dist/assertion/impl/async-iterable.d.cts +0 -406
- package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/async-iterable.d.ts +0 -406
- package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/async-iterable.js +0 -624
- package/dist/assertion/impl/async-iterable.js.map +0 -1
- package/dist/assertion/impl/async-parametric.cjs +0 -423
- package/dist/assertion/impl/async-parametric.cjs.map +0 -1
- package/dist/assertion/impl/async-parametric.d.cts +0 -278
- package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/async-parametric.d.ts +0 -278
- package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/async-parametric.js +0 -420
- package/dist/assertion/impl/async-parametric.js.map +0 -1
- package/dist/assertion/impl/async.cjs +0 -56
- package/dist/assertion/impl/async.cjs.map +0 -1
- package/dist/assertion/impl/async.d.cts +0 -179
- package/dist/assertion/impl/async.d.cts.map +0 -1
- package/dist/assertion/impl/async.d.ts +0 -179
- package/dist/assertion/impl/async.d.ts.map +0 -1
- package/dist/assertion/impl/async.js +0 -39
- package/dist/assertion/impl/async.js.map +0 -1
- package/dist/assertion/impl/index.cjs +0 -37
- package/dist/assertion/impl/index.cjs.map +0 -1
- package/dist/assertion/impl/index.d.cts +0 -21
- package/dist/assertion/impl/index.d.cts.map +0 -1
- package/dist/assertion/impl/index.d.ts +0 -21
- package/dist/assertion/impl/index.d.ts.map +0 -1
- package/dist/assertion/impl/index.js +0 -21
- package/dist/assertion/impl/index.js.map +0 -1
- package/dist/assertion/impl/iteration-util.cjs +0 -297
- package/dist/assertion/impl/iteration-util.cjs.map +0 -1
- package/dist/assertion/impl/iteration-util.d.cts +0 -12
- package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
- package/dist/assertion/impl/iteration-util.d.ts +0 -12
- package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
- package/dist/assertion/impl/iteration-util.js +0 -282
- package/dist/assertion/impl/iteration-util.js.map +0 -1
- package/dist/assertion/impl/snapshot.cjs +0 -276
- package/dist/assertion/impl/snapshot.cjs.map +0 -1
- package/dist/assertion/impl/snapshot.d.cts +0 -278
- package/dist/assertion/impl/snapshot.d.cts.map +0 -1
- package/dist/assertion/impl/snapshot.d.ts +0 -278
- package/dist/assertion/impl/snapshot.d.ts.map +0 -1
- package/dist/assertion/impl/snapshot.js +0 -273
- package/dist/assertion/impl/snapshot.js.map +0 -1
- package/dist/assertion/impl/sync-basic.cjs +0 -553
- package/dist/assertion/impl/sync-basic.cjs.map +0 -1
- package/dist/assertion/impl/sync-basic.d.cts +0 -528
- package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
- package/dist/assertion/impl/sync-basic.d.ts +0 -528
- package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
- package/dist/assertion/impl/sync-basic.js +0 -550
- package/dist/assertion/impl/sync-basic.js.map +0 -1
- package/dist/assertion/impl/sync-collection.cjs +0 -856
- package/dist/assertion/impl/sync-collection.cjs.map +0 -1
- package/dist/assertion/impl/sync-collection.d.cts +0 -607
- package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
- package/dist/assertion/impl/sync-collection.d.ts +0 -607
- package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
- package/dist/assertion/impl/sync-collection.js +0 -850
- package/dist/assertion/impl/sync-collection.js.map +0 -1
- package/dist/assertion/impl/sync-date.cjs +0 -341
- package/dist/assertion/impl/sync-date.cjs.map +0 -1
- package/dist/assertion/impl/sync-date.d.cts +0 -209
- package/dist/assertion/impl/sync-date.d.cts.map +0 -1
- package/dist/assertion/impl/sync-date.d.ts +0 -209
- package/dist/assertion/impl/sync-date.d.ts.map +0 -1
- package/dist/assertion/impl/sync-date.js +0 -338
- package/dist/assertion/impl/sync-date.js.map +0 -1
- package/dist/assertion/impl/sync-esoteric.cjs +0 -214
- package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.js +0 -211
- package/dist/assertion/impl/sync-esoteric.js.map +0 -1
- package/dist/assertion/impl/sync-iterable.cjs +0 -512
- package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.cts +0 -334
- package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.ts +0 -334
- package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/sync-iterable.js +0 -509
- package/dist/assertion/impl/sync-iterable.js.map +0 -1
- package/dist/assertion/impl/sync-parametric.cjs +0 -812
- package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.cts +0 -560
- package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.ts +0 -560
- package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-parametric.js +0 -809
- package/dist/assertion/impl/sync-parametric.js.map +0 -1
- package/dist/assertion/impl/sync.cjs +0 -214
- package/dist/assertion/impl/sync.cjs.map +0 -1
- package/dist/assertion/impl/sync.d.cts +0 -512
- package/dist/assertion/impl/sync.d.cts.map +0 -1
- package/dist/assertion/impl/sync.d.ts +0 -512
- package/dist/assertion/impl/sync.d.ts.map +0 -1
- package/dist/assertion/impl/sync.js +0 -197
- package/dist/assertion/impl/sync.js.map +0 -1
- package/dist/assertion/index.cjs +0 -38
- package/dist/assertion/index.cjs.map +0 -1
- package/dist/assertion/index.d.cts +0 -18
- package/dist/assertion/index.d.cts.map +0 -1
- package/dist/assertion/index.d.ts +0 -18
- package/dist/assertion/index.d.ts.map +0 -1
- package/dist/assertion/index.js +0 -17
- package/dist/assertion/index.js.map +0 -1
- package/dist/assertion/slotify.cjs +0 -165
- package/dist/assertion/slotify.cjs.map +0 -1
- package/dist/assertion/slotify.d.cts +0 -11
- package/dist/assertion/slotify.d.cts.map +0 -1
- package/dist/assertion/slotify.d.ts +0 -11
- package/dist/assertion/slotify.d.ts.map +0 -1
- package/dist/assertion/slotify.js +0 -161
- package/dist/assertion/slotify.js.map +0 -1
- package/dist/bootstrap.cjs +0 -43
- package/dist/bootstrap.cjs.map +0 -1
- package/dist/bootstrap.d.cts +0 -27
- package/dist/bootstrap.d.cts.map +0 -1
- package/dist/bootstrap.d.ts +0 -27
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -40
- package/dist/bootstrap.js.map +0 -1
- package/dist/constant.cjs +0 -82
- package/dist/constant.cjs.map +0 -1
- package/dist/constant.d.cts +0 -69
- package/dist/constant.d.cts.map +0 -1
- package/dist/constant.d.ts +0 -69
- package/dist/constant.d.ts.map +0 -1
- package/dist/constant.js +0 -79
- package/dist/constant.js.map +0 -1
- package/dist/diff.cjs +0 -340
- package/dist/diff.cjs.map +0 -1
- package/dist/diff.d.cts +0 -51
- package/dist/diff.d.cts.map +0 -1
- package/dist/diff.d.ts +0 -51
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js +0 -334
- package/dist/diff.js.map +0 -1
- package/dist/error.cjs +0 -204
- package/dist/error.cjs.map +0 -1
- package/dist/error.d.cts +0 -212
- package/dist/error.d.cts.map +0 -1
- package/dist/error.d.ts +0 -212
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -191
- package/dist/error.js.map +0 -1
- package/dist/expect.cjs +0 -590
- package/dist/expect.cjs.map +0 -1
- package/dist/expect.d.cts +0 -138
- package/dist/expect.d.cts.map +0 -1
- package/dist/expect.d.ts +0 -138
- package/dist/expect.d.ts.map +0 -1
- package/dist/expect.js +0 -582
- package/dist/expect.js.map +0 -1
- package/dist/guards.cjs +0 -297
- package/dist/guards.cjs.map +0 -1
- package/dist/guards.d.cts +0 -231
- package/dist/guards.d.cts.map +0 -1
- package/dist/guards.d.ts +0 -231
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -277
- package/dist/guards.js.map +0 -1
- package/dist/index.cjs +0 -111
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -448
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -448
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -71
- package/dist/index.js.map +0 -1
- package/dist/internal-schema.cjs +0 -253
- package/dist/internal-schema.cjs.map +0 -1
- package/dist/internal-schema.d.cts +0 -8
- package/dist/internal-schema.d.cts.map +0 -1
- package/dist/internal-schema.d.ts +0 -8
- package/dist/internal-schema.d.ts.map +0 -1
- package/dist/internal-schema.js +0 -248
- package/dist/internal-schema.js.map +0 -1
- package/dist/metadata.cjs +0 -57
- package/dist/metadata.cjs.map +0 -1
- package/dist/metadata.d.cts +0 -27
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.ts +0 -27
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -54
- package/dist/metadata.js.map +0 -1
- package/dist/schema.cjs +0 -1522
- package/dist/schema.cjs.map +0 -1
- package/dist/schema.d.cts +0 -1196
- package/dist/schema.d.cts.map +0 -1
- package/dist/schema.d.ts +0 -1196
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -1516
- package/dist/schema.js.map +0 -1
- package/dist/snapshot/adapter.cjs +0 -31
- package/dist/snapshot/adapter.cjs.map +0 -1
- package/dist/snapshot/adapter.d.cts +0 -258
- package/dist/snapshot/adapter.d.cts.map +0 -1
- package/dist/snapshot/adapter.d.ts +0 -258
- package/dist/snapshot/adapter.d.ts.map +0 -1
- package/dist/snapshot/adapter.js +0 -27
- package/dist/snapshot/adapter.js.map +0 -1
- package/dist/snapshot/adapters/fallback.cjs +0 -453
- package/dist/snapshot/adapters/fallback.cjs.map +0 -1
- package/dist/snapshot/adapters/fallback.d.cts +0 -185
- package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
- package/dist/snapshot/adapters/fallback.d.ts +0 -185
- package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
- package/dist/snapshot/adapters/fallback.js +0 -446
- package/dist/snapshot/adapters/fallback.js.map +0 -1
- package/dist/snapshot/adapters/node-test.cjs +0 -301
- package/dist/snapshot/adapters/node-test.cjs.map +0 -1
- package/dist/snapshot/adapters/node-test.d.cts +0 -131
- package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
- package/dist/snapshot/adapters/node-test.d.ts +0 -131
- package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
- package/dist/snapshot/adapters/node-test.js +0 -297
- package/dist/snapshot/adapters/node-test.js.map +0 -1
- package/dist/snapshot/index.cjs +0 -61
- package/dist/snapshot/index.cjs.map +0 -1
- package/dist/snapshot/index.d.cts +0 -40
- package/dist/snapshot/index.d.cts.map +0 -1
- package/dist/snapshot/index.d.ts +0 -40
- package/dist/snapshot/index.d.ts.map +0 -1
- package/dist/snapshot/index.js +0 -44
- package/dist/snapshot/index.js.map +0 -1
- package/dist/snapshot/node-version.cjs +0 -49
- package/dist/snapshot/node-version.cjs.map +0 -1
- package/dist/snapshot/node-version.d.cts +0 -34
- package/dist/snapshot/node-version.d.cts.map +0 -1
- package/dist/snapshot/node-version.d.ts +0 -34
- package/dist/snapshot/node-version.d.ts.map +0 -1
- package/dist/snapshot/node-version.js +0 -44
- package/dist/snapshot/node-version.js.map +0 -1
- package/dist/snapshot/select-adapter.cjs +0 -170
- package/dist/snapshot/select-adapter.cjs.map +0 -1
- package/dist/snapshot/select-adapter.d.cts +0 -128
- package/dist/snapshot/select-adapter.d.cts.map +0 -1
- package/dist/snapshot/select-adapter.d.ts +0 -128
- package/dist/snapshot/select-adapter.d.ts.map +0 -1
- package/dist/snapshot/select-adapter.js +0 -164
- package/dist/snapshot/select-adapter.js.map +0 -1
- package/dist/snapshot/serializer.cjs +0 -246
- package/dist/snapshot/serializer.cjs.map +0 -1
- package/dist/snapshot/serializer.d.cts +0 -126
- package/dist/snapshot/serializer.d.cts.map +0 -1
- package/dist/snapshot/serializer.d.ts +0 -126
- package/dist/snapshot/serializer.d.ts.map +0 -1
- package/dist/snapshot/serializer.js +0 -238
- package/dist/snapshot/serializer.js.map +0 -1
- package/dist/standard-schema.cjs +0 -13
- package/dist/standard-schema.cjs.map +0 -1
- package/dist/standard-schema.d.cts +0 -192
- package/dist/standard-schema.d.cts.map +0 -1
- package/dist/standard-schema.d.ts +0 -192
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/standard-schema.js +0 -12
- package/dist/standard-schema.js.map +0 -1
- package/dist/types.cjs +0 -22
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -905
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.ts +0 -905
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -21
- package/dist/types.js.map +0 -1
- package/dist/use.cjs +0 -240
- package/dist/use.cjs.map +0 -1
- package/dist/use.d.cts +0 -8
- package/dist/use.d.cts.map +0 -1
- package/dist/use.d.ts +0 -8
- package/dist/use.d.ts.map +0 -1
- package/dist/use.js +0 -236
- package/dist/use.js.map +0 -1
- package/dist/util.cjs +0 -255
- package/dist/util.cjs.map +0 -1
- package/dist/util.d.cts +0 -141
- package/dist/util.d.cts.map +0 -1
- package/dist/util.d.ts +0 -141
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -234
- package/dist/util.js.map +0 -1
- package/dist/value-to-schema.cjs +0 -537
- package/dist/value-to-schema.cjs.map +0 -1
- package/dist/value-to-schema.d.cts +0 -144
- package/dist/value-to-schema.d.cts.map +0 -1
- package/dist/value-to-schema.d.ts +0 -144
- package/dist/value-to-schema.d.ts.map +0 -1
- package/dist/value-to-schema.js +0 -533
- package/dist/value-to-schema.js.map +0 -1
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialization utilities for converting values to snapshot strings.
|
|
3
|
-
*
|
|
4
|
-
* Provides default serialization logic that handles:
|
|
5
|
-
*
|
|
6
|
-
* - Circular references
|
|
7
|
-
* - Non-JSON types (Functions, Symbols, BigInt, etc.)
|
|
8
|
-
* - Error objects
|
|
9
|
-
* - Map and Set collections
|
|
10
|
-
* - Key sorting for deterministic output
|
|
11
|
-
*
|
|
12
|
-
* @packageDocumentation
|
|
13
|
-
*/
|
|
14
|
-
const { entries, getOwnPropertyNames } = Object;
|
|
15
|
-
const { isArray } = Array;
|
|
16
|
-
import stringify from 'json-stable-stringify';
|
|
17
|
-
import { isA, isError } from "../guards.js";
|
|
18
|
-
/**
|
|
19
|
-
* Default JSON replacer that handles non-JSON types.
|
|
20
|
-
*
|
|
21
|
-
* Converts JavaScript-specific types into JSON-serializable representations:
|
|
22
|
-
*
|
|
23
|
-
* - Functions: omitted (`undefined`)
|
|
24
|
-
* - Symbols: converted to string
|
|
25
|
-
* - BigInt: converted to string with `n` suffix
|
|
26
|
-
* - `undefined`: converted to string `'undefined'`
|
|
27
|
-
* - RegExp: converted to string representation
|
|
28
|
-
* - Date: converted to ISO string
|
|
29
|
-
* - Error: converted to object with name, message, and other properties
|
|
30
|
-
* - Map: converted to `{ __type: 'Map', entries: [...] }`
|
|
31
|
-
* - Set: converted to `{ __type: 'Set', values: [...] }`
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* defaultReplacer(Symbol('test')); // 'Symbol(test)'
|
|
37
|
-
* defaultReplacer(42n); // '42n'
|
|
38
|
-
* defaultReplacer(() => {}); // undefined (omitted)
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @function
|
|
42
|
-
* @param value - Value to convert
|
|
43
|
-
* @returns Converted value, or `undefined` to omit
|
|
44
|
-
*/
|
|
45
|
-
const defaultReplacer = (value) => {
|
|
46
|
-
// Functions are omitted
|
|
47
|
-
if (typeof value === 'function' || value === undefined) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
// Symbols converted to string
|
|
51
|
-
if (typeof value === 'symbol') {
|
|
52
|
-
return value.toString();
|
|
53
|
-
}
|
|
54
|
-
// BigInt converted to string with suffix
|
|
55
|
-
if (typeof value === 'bigint') {
|
|
56
|
-
return `${value.toString()}n`;
|
|
57
|
-
}
|
|
58
|
-
if (isA(value, RegExp)) {
|
|
59
|
-
return value.toString();
|
|
60
|
-
}
|
|
61
|
-
if (isA(value, Date)) {
|
|
62
|
-
return value.toISOString();
|
|
63
|
-
}
|
|
64
|
-
if (isError(value)) {
|
|
65
|
-
const errorProps = {
|
|
66
|
-
message: value.message,
|
|
67
|
-
name: value.name,
|
|
68
|
-
};
|
|
69
|
-
// Include other enumerable properties
|
|
70
|
-
for (const prop of getOwnPropertyNames(value)) {
|
|
71
|
-
if (prop !== 'stack') {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
73
|
-
errorProps[prop] = value[prop];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return errorProps;
|
|
77
|
-
}
|
|
78
|
-
// Map to array of entries
|
|
79
|
-
if (isA(value, Map)) {
|
|
80
|
-
return {
|
|
81
|
-
__type: 'Map',
|
|
82
|
-
entries: [...value.entries()],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
// Set to array
|
|
86
|
-
if (isA(value, Set)) {
|
|
87
|
-
return {
|
|
88
|
-
__type: 'Set',
|
|
89
|
-
values: [...value.values()],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return value;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Detects and marks circular references in an object graph, and applies
|
|
96
|
-
* replacer for special types.
|
|
97
|
-
*
|
|
98
|
-
* Uses a WeakSet to track visited objects without holding strong references.
|
|
99
|
-
* Circular references are replaced with the string `'[Circular]'`.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
*
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const obj: any = { a: 1 };
|
|
105
|
-
* obj.self = obj;
|
|
106
|
-
* detectCircular(obj, defaultReplacer); // { a: 1, self: '[Circular]' }
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* @function
|
|
110
|
-
* @param value - Value to process
|
|
111
|
-
* @param replacer - Function to transform values
|
|
112
|
-
* @returns Value with circular references replaced and special types converted
|
|
113
|
-
*/
|
|
114
|
-
const detectCircular = (value, replacer) => {
|
|
115
|
-
const seen = new WeakSet();
|
|
116
|
-
/**
|
|
117
|
-
* @function
|
|
118
|
-
*/
|
|
119
|
-
const visit = (val) => {
|
|
120
|
-
// Apply replacer first (handles special types)
|
|
121
|
-
const replaced = replacer(val);
|
|
122
|
-
// If replacer returned something different, use it
|
|
123
|
-
if (replaced !== val) {
|
|
124
|
-
// If replaced is an object, we need to visit it recursively
|
|
125
|
-
if (typeof replaced === 'object' && replaced !== null) {
|
|
126
|
-
val = replaced;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
// Primitive or special transformation, return as-is
|
|
130
|
-
return replaced;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Primitives can't be circular
|
|
134
|
-
if (typeof val !== 'object' || val === null) {
|
|
135
|
-
return val;
|
|
136
|
-
}
|
|
137
|
-
// Check if we've seen this object before
|
|
138
|
-
if (seen.has(val)) {
|
|
139
|
-
return '[Circular]';
|
|
140
|
-
}
|
|
141
|
-
// Mark as seen
|
|
142
|
-
seen.add(val);
|
|
143
|
-
// Handle arrays
|
|
144
|
-
if (isArray(val)) {
|
|
145
|
-
return val.map((item) => visit(item));
|
|
146
|
-
}
|
|
147
|
-
// Handle plain objects
|
|
148
|
-
const result = {};
|
|
149
|
-
for (const [key, value] of entries(val)) {
|
|
150
|
-
const visited = visit(value);
|
|
151
|
-
// Only include if not undefined (functions are omitted)
|
|
152
|
-
if (visited !== undefined) {
|
|
153
|
-
result[key] = visited;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
};
|
|
158
|
-
return visit(value);
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Default serializer using JSON.stringify with custom handling.
|
|
162
|
-
*
|
|
163
|
-
* This serializer provides robust handling of JavaScript values including:
|
|
164
|
-
*
|
|
165
|
-
* - Circular reference detection
|
|
166
|
-
* - Non-JSON type conversion
|
|
167
|
-
* - Optional key sorting for deterministic output
|
|
168
|
-
* - Custom replacer support
|
|
169
|
-
*
|
|
170
|
-
* The output is formatted with 2-space indentation for readability.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
*
|
|
174
|
-
* ```typescript
|
|
175
|
-
* const obj = { b: 2, a: 1, date: new Date('2025-01-01') };
|
|
176
|
-
* defaultSerializer(obj, { sortKeys: true });
|
|
177
|
-
* // Returns:
|
|
178
|
-
* // {
|
|
179
|
-
* // "a": 1,
|
|
180
|
-
* // "b": 2,
|
|
181
|
-
* // "date": "2025-01-01T00:00:00.000Z"
|
|
182
|
-
* // }
|
|
183
|
-
* ```
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
*
|
|
187
|
-
* ```typescript
|
|
188
|
-
* const circular: any = { a: 1 };
|
|
189
|
-
* circular.self = circular;
|
|
190
|
-
* defaultSerializer(circular);
|
|
191
|
-
* // Returns:
|
|
192
|
-
* // {
|
|
193
|
-
* // "a": 1,
|
|
194
|
-
* // "self": "[Circular]"
|
|
195
|
-
* // }
|
|
196
|
-
* ```
|
|
197
|
-
*
|
|
198
|
-
* @function
|
|
199
|
-
* @param value - Value to serialize
|
|
200
|
-
* @param options - Serialization options
|
|
201
|
-
* @returns JSON string representation
|
|
202
|
-
*/
|
|
203
|
-
export const defaultSerializer = (value, options = {}) => {
|
|
204
|
-
const { replacer = defaultReplacer } = options;
|
|
205
|
-
// Handle circular references and apply replacer
|
|
206
|
-
const processed = detectCircular(value, replacer);
|
|
207
|
-
// Don't pass replacer to stringify - it's already been applied
|
|
208
|
-
return String(stringify(processed, { space: 2 }));
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* Serializer compatible with node:test's snapshot format.
|
|
212
|
-
*
|
|
213
|
-
* This is currently an alias for {@link defaultSerializer}, but exists as a
|
|
214
|
-
* separate export to allow for future node:test-specific customization.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
*
|
|
218
|
-
* ```typescript
|
|
219
|
-
* import test from 'node:test';
|
|
220
|
-
* import { nodeTestCompatibleSerializer } from 'bupkis/snapshot';
|
|
221
|
-
*
|
|
222
|
-
* test('my test', (t) => {
|
|
223
|
-
* const data = { foo: 'bar' };
|
|
224
|
-
* expect(data, 'to match snapshot', t, {
|
|
225
|
-
* serializer: nodeTestCompatibleSerializer,
|
|
226
|
-
* });
|
|
227
|
-
* });
|
|
228
|
-
* ```
|
|
229
|
-
*
|
|
230
|
-
* @function
|
|
231
|
-
* @param value - Value to serialize
|
|
232
|
-
* @returns JSON string representation
|
|
233
|
-
*/
|
|
234
|
-
export const nodeTestCompatibleSerializer = (value) => {
|
|
235
|
-
// Node:test expects the same format as our default serializer
|
|
236
|
-
return defaultSerializer(value);
|
|
237
|
-
};
|
|
238
|
-
//# sourceMappingURL=serializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/snapshot/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;AAChD,MAA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;AAClC,CAAC,CAAC"}
|
package/dist/standard-schema.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Standard Schema v1 specification types.
|
|
4
|
-
*
|
|
5
|
-
* These types define the Standard Schema interface that enables
|
|
6
|
-
* interoperability between different validation libraries (Zod, Valibot,
|
|
7
|
-
* ArkType, etc.).
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
* @see {@link https://standardschema.dev | Standard Schema Specification}
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
//# sourceMappingURL=standard-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard Schema v1 specification types.
|
|
3
|
-
*
|
|
4
|
-
* These types define the Standard Schema interface that enables
|
|
5
|
-
* interoperability between different validation libraries (Zod, Valibot,
|
|
6
|
-
* ArkType, etc.).
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
* @see {@link https://standardschema.dev | Standard Schema Specification}
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* The Standard Schema interface.
|
|
13
|
-
*
|
|
14
|
-
* This is the primary interface that validation libraries implement to be
|
|
15
|
-
* Standard Schema compliant. The interface is designed to be minimal and
|
|
16
|
-
* non-invasive, tucked behind the `~standard` property to avoid API conflicts.
|
|
17
|
-
*
|
|
18
|
-
* @template Input - The input type accepted by the schema
|
|
19
|
-
* @template Output - The output type produced after successful validation
|
|
20
|
-
*/
|
|
21
|
-
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
22
|
-
/**
|
|
23
|
-
* The Standard Schema properties.
|
|
24
|
-
*
|
|
25
|
-
* This property uses a tilde prefix to:
|
|
26
|
-
*
|
|
27
|
-
* - Avoid conflicts with existing library APIs
|
|
28
|
-
* - De-prioritize in IDE autocomplete (tilde sorts after alphanumeric)
|
|
29
|
-
* - Signal special/internal nature of the property
|
|
30
|
-
*/
|
|
31
|
-
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
32
|
-
}
|
|
33
|
-
export declare namespace StandardSchemaV1 {
|
|
34
|
-
/**
|
|
35
|
-
* The result interface if validation fails.
|
|
36
|
-
*
|
|
37
|
-
* Contains an array of issues describing what went wrong during validation.
|
|
38
|
-
*/
|
|
39
|
-
interface FailureResult {
|
|
40
|
-
/**
|
|
41
|
-
* The issues of failed validation.
|
|
42
|
-
*
|
|
43
|
-
* Always present and non-empty when validation fails.
|
|
44
|
-
*/
|
|
45
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Infers the input type of a Standard Schema.
|
|
49
|
-
*
|
|
50
|
-
* Utility type for extracting the input type from a schema instance.
|
|
51
|
-
*
|
|
52
|
-
* @template Schema - The Standard Schema to extract the input type from
|
|
53
|
-
*/
|
|
54
|
-
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
55
|
-
/**
|
|
56
|
-
* Infers the output type of a Standard Schema.
|
|
57
|
-
*
|
|
58
|
-
* Utility type for extracting the output type from a schema instance.
|
|
59
|
-
*
|
|
60
|
-
* @template Schema - The Standard Schema to extract the output type from
|
|
61
|
-
*/
|
|
62
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
63
|
-
/**
|
|
64
|
-
* The issue interface of the failure output.
|
|
65
|
-
*
|
|
66
|
-
* Describes a single validation problem, including a human-readable message
|
|
67
|
-
* and optional path to the problematic value in nested structures.
|
|
68
|
-
*/
|
|
69
|
-
interface Issue {
|
|
70
|
-
/**
|
|
71
|
-
* The error message of the issue.
|
|
72
|
-
*
|
|
73
|
-
* Human-readable description of what validation rule was violated.
|
|
74
|
-
*/
|
|
75
|
-
readonly message: string;
|
|
76
|
-
/**
|
|
77
|
-
* The path of the issue, if any.
|
|
78
|
-
*
|
|
79
|
-
* For nested structures, indicates where in the object/array hierarchy the
|
|
80
|
-
* validation failed. Can contain property keys or path segment objects.
|
|
81
|
-
*/
|
|
82
|
-
readonly path?: ReadonlyArray<PathSegment | PropertyKey> | undefined;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The path segment interface of the issue.
|
|
86
|
-
*
|
|
87
|
-
* Allows path elements to carry additional metadata beyond just the key.
|
|
88
|
-
*/
|
|
89
|
-
interface PathSegment {
|
|
90
|
-
/**
|
|
91
|
-
* The key representing a path segment.
|
|
92
|
-
*
|
|
93
|
-
* Can be a string, number, or symbol identifying the path component.
|
|
94
|
-
*/
|
|
95
|
-
readonly key: PropertyKey;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* The Standard Schema properties interface.
|
|
99
|
-
*
|
|
100
|
-
* Contains the actual validation logic and metadata required by the spec.
|
|
101
|
-
*
|
|
102
|
-
* @template Input - The input type accepted by the schema
|
|
103
|
-
* @template Output - The output type produced after successful validation
|
|
104
|
-
*/
|
|
105
|
-
interface Props<Input = unknown, Output = Input> {
|
|
106
|
-
/**
|
|
107
|
-
* Inferred types associated with the schema.
|
|
108
|
-
*
|
|
109
|
-
* Optional property that allows TypeScript type inference for the schema.
|
|
110
|
-
* Not all libraries may provide this.
|
|
111
|
-
*/
|
|
112
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
113
|
-
/**
|
|
114
|
-
* Validates unknown input values.
|
|
115
|
-
*
|
|
116
|
-
* This function performs validation and returns either a success result
|
|
117
|
-
* with the validated/transformed data, or a failure result with validation
|
|
118
|
-
* issues. May return a Promise for async validation.
|
|
119
|
-
*
|
|
120
|
-
* @param value - The unknown value to validate
|
|
121
|
-
* @returns Result object or Promise resolving to result object
|
|
122
|
-
*/
|
|
123
|
-
readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
|
|
124
|
-
/**
|
|
125
|
-
* The vendor name of the schema library.
|
|
126
|
-
*
|
|
127
|
-
* Examples: 'zod', 'valibot', 'arktype', 'yup', etc.
|
|
128
|
-
*/
|
|
129
|
-
readonly vendor: string;
|
|
130
|
-
/**
|
|
131
|
-
* The version number of the standard.
|
|
132
|
-
*
|
|
133
|
-
* Currently only version 1 is defined. Future versions will increment this
|
|
134
|
-
* number to maintain backward compatibility.
|
|
135
|
-
*/
|
|
136
|
-
readonly version: 1;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* The result interface of the validate function.
|
|
140
|
-
*
|
|
141
|
-
* A discriminated union that represents either successful or failed
|
|
142
|
-
* validation.
|
|
143
|
-
*/
|
|
144
|
-
type Result<Output> = FailureResult | SuccessResult<Output>;
|
|
145
|
-
/**
|
|
146
|
-
* The result interface if validation succeeds.
|
|
147
|
-
*
|
|
148
|
-
* Contains the validated/transformed output value and explicitly sets
|
|
149
|
-
* `issues` to undefined to distinguish from failure results.
|
|
150
|
-
*
|
|
151
|
-
* @template Output - The output type after successful validation
|
|
152
|
-
*/
|
|
153
|
-
interface SuccessResult<Output> {
|
|
154
|
-
/**
|
|
155
|
-
* The non-existent issues.
|
|
156
|
-
*
|
|
157
|
-
* Explicitly undefined to create a discriminated union with FailureResult.
|
|
158
|
-
*/
|
|
159
|
-
readonly issues?: undefined;
|
|
160
|
-
/**
|
|
161
|
-
* The typed output value.
|
|
162
|
-
*
|
|
163
|
-
* This may be the same as the input or a transformed version, depending on
|
|
164
|
-
* the schema's validation logic.
|
|
165
|
-
*/
|
|
166
|
-
readonly value: Output;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The Standard Schema types interface.
|
|
170
|
-
*
|
|
171
|
-
* Provides TypeScript type information for schemas that support type
|
|
172
|
-
* inference.
|
|
173
|
-
*
|
|
174
|
-
* @template Input - The input type of the schema
|
|
175
|
-
* @template Output - The output type of the schema
|
|
176
|
-
*/
|
|
177
|
-
interface Types<Input = unknown, Output = Input> {
|
|
178
|
-
/**
|
|
179
|
-
* The input type of the schema.
|
|
180
|
-
*
|
|
181
|
-
* The type of values that can be passed to the validate function.
|
|
182
|
-
*/
|
|
183
|
-
readonly input: Input;
|
|
184
|
-
/**
|
|
185
|
-
* The output type of the schema.
|
|
186
|
-
*
|
|
187
|
-
* The type of values produced after successful validation.
|
|
188
|
-
*/
|
|
189
|
-
readonly output: Output;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;IAC/D;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC7D;AAGD,MAAM,CAAC,OAAO,WAAW,gBAAgB,CAAC;IACxC;;;;OAIG;IACH,UAAiB,aAAa;QAC5B;;;;WAIG;QACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;KACvC;IAED;;;;;;OAMG;IACH,KAAY,UAAU,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACnE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC7B,CAAC,OAAO,CAAC,CAAC;IAEX;;;;;;OAMG;IACH,KAAY,WAAW,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACpE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC7B,CAAC,QAAQ,CAAC,CAAC;IAEZ;;;;;OAKG;IACH,UAAiB,KAAK;QACpB;;;;WAIG;QACH,QAAQ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|
|
|
1
|
-
/**
|
|
2
|
-
* Standard Schema v1 specification types.
|
|
3
|
-
*
|
|
4
|
-
* These types define the Standard Schema interface that enables
|
|
5
|
-
* interoperability between different validation libraries (Zod, Valibot,
|
|
6
|
-
* ArkType, etc.).
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
* @see {@link https://standardschema.dev | Standard Schema Specification}
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* The Standard Schema interface.
|
|
13
|
-
*
|
|
14
|
-
* This is the primary interface that validation libraries implement to be
|
|
15
|
-
* Standard Schema compliant. The interface is designed to be minimal and
|
|
16
|
-
* non-invasive, tucked behind the `~standard` property to avoid API conflicts.
|
|
17
|
-
*
|
|
18
|
-
* @template Input - The input type accepted by the schema
|
|
19
|
-
* @template Output - The output type produced after successful validation
|
|
20
|
-
*/
|
|
21
|
-
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
22
|
-
/**
|
|
23
|
-
* The Standard Schema properties.
|
|
24
|
-
*
|
|
25
|
-
* This property uses a tilde prefix to:
|
|
26
|
-
*
|
|
27
|
-
* - Avoid conflicts with existing library APIs
|
|
28
|
-
* - De-prioritize in IDE autocomplete (tilde sorts after alphanumeric)
|
|
29
|
-
* - Signal special/internal nature of the property
|
|
30
|
-
*/
|
|
31
|
-
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
32
|
-
}
|
|
33
|
-
export declare namespace StandardSchemaV1 {
|
|
34
|
-
/**
|
|
35
|
-
* The result interface if validation fails.
|
|
36
|
-
*
|
|
37
|
-
* Contains an array of issues describing what went wrong during validation.
|
|
38
|
-
*/
|
|
39
|
-
interface FailureResult {
|
|
40
|
-
/**
|
|
41
|
-
* The issues of failed validation.
|
|
42
|
-
*
|
|
43
|
-
* Always present and non-empty when validation fails.
|
|
44
|
-
*/
|
|
45
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Infers the input type of a Standard Schema.
|
|
49
|
-
*
|
|
50
|
-
* Utility type for extracting the input type from a schema instance.
|
|
51
|
-
*
|
|
52
|
-
* @template Schema - The Standard Schema to extract the input type from
|
|
53
|
-
*/
|
|
54
|
-
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
55
|
-
/**
|
|
56
|
-
* Infers the output type of a Standard Schema.
|
|
57
|
-
*
|
|
58
|
-
* Utility type for extracting the output type from a schema instance.
|
|
59
|
-
*
|
|
60
|
-
* @template Schema - The Standard Schema to extract the output type from
|
|
61
|
-
*/
|
|
62
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
63
|
-
/**
|
|
64
|
-
* The issue interface of the failure output.
|
|
65
|
-
*
|
|
66
|
-
* Describes a single validation problem, including a human-readable message
|
|
67
|
-
* and optional path to the problematic value in nested structures.
|
|
68
|
-
*/
|
|
69
|
-
interface Issue {
|
|
70
|
-
/**
|
|
71
|
-
* The error message of the issue.
|
|
72
|
-
*
|
|
73
|
-
* Human-readable description of what validation rule was violated.
|
|
74
|
-
*/
|
|
75
|
-
readonly message: string;
|
|
76
|
-
/**
|
|
77
|
-
* The path of the issue, if any.
|
|
78
|
-
*
|
|
79
|
-
* For nested structures, indicates where in the object/array hierarchy the
|
|
80
|
-
* validation failed. Can contain property keys or path segment objects.
|
|
81
|
-
*/
|
|
82
|
-
readonly path?: ReadonlyArray<PathSegment | PropertyKey> | undefined;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The path segment interface of the issue.
|
|
86
|
-
*
|
|
87
|
-
* Allows path elements to carry additional metadata beyond just the key.
|
|
88
|
-
*/
|
|
89
|
-
interface PathSegment {
|
|
90
|
-
/**
|
|
91
|
-
* The key representing a path segment.
|
|
92
|
-
*
|
|
93
|
-
* Can be a string, number, or symbol identifying the path component.
|
|
94
|
-
*/
|
|
95
|
-
readonly key: PropertyKey;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* The Standard Schema properties interface.
|
|
99
|
-
*
|
|
100
|
-
* Contains the actual validation logic and metadata required by the spec.
|
|
101
|
-
*
|
|
102
|
-
* @template Input - The input type accepted by the schema
|
|
103
|
-
* @template Output - The output type produced after successful validation
|
|
104
|
-
*/
|
|
105
|
-
interface Props<Input = unknown, Output = Input> {
|
|
106
|
-
/**
|
|
107
|
-
* Inferred types associated with the schema.
|
|
108
|
-
*
|
|
109
|
-
* Optional property that allows TypeScript type inference for the schema.
|
|
110
|
-
* Not all libraries may provide this.
|
|
111
|
-
*/
|
|
112
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
113
|
-
/**
|
|
114
|
-
* Validates unknown input values.
|
|
115
|
-
*
|
|
116
|
-
* This function performs validation and returns either a success result
|
|
117
|
-
* with the validated/transformed data, or a failure result with validation
|
|
118
|
-
* issues. May return a Promise for async validation.
|
|
119
|
-
*
|
|
120
|
-
* @param value - The unknown value to validate
|
|
121
|
-
* @returns Result object or Promise resolving to result object
|
|
122
|
-
*/
|
|
123
|
-
readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
|
|
124
|
-
/**
|
|
125
|
-
* The vendor name of the schema library.
|
|
126
|
-
*
|
|
127
|
-
* Examples: 'zod', 'valibot', 'arktype', 'yup', etc.
|
|
128
|
-
*/
|
|
129
|
-
readonly vendor: string;
|
|
130
|
-
/**
|
|
131
|
-
* The version number of the standard.
|
|
132
|
-
*
|
|
133
|
-
* Currently only version 1 is defined. Future versions will increment this
|
|
134
|
-
* number to maintain backward compatibility.
|
|
135
|
-
*/
|
|
136
|
-
readonly version: 1;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* The result interface of the validate function.
|
|
140
|
-
*
|
|
141
|
-
* A discriminated union that represents either successful or failed
|
|
142
|
-
* validation.
|
|
143
|
-
*/
|
|
144
|
-
type Result<Output> = FailureResult | SuccessResult<Output>;
|
|
145
|
-
/**
|
|
146
|
-
* The result interface if validation succeeds.
|
|
147
|
-
*
|
|
148
|
-
* Contains the validated/transformed output value and explicitly sets
|
|
149
|
-
* `issues` to undefined to distinguish from failure results.
|
|
150
|
-
*
|
|
151
|
-
* @template Output - The output type after successful validation
|
|
152
|
-
*/
|
|
153
|
-
interface SuccessResult<Output> {
|
|
154
|
-
/**
|
|
155
|
-
* The non-existent issues.
|
|
156
|
-
*
|
|
157
|
-
* Explicitly undefined to create a discriminated union with FailureResult.
|
|
158
|
-
*/
|
|
159
|
-
readonly issues?: undefined;
|
|
160
|
-
/**
|
|
161
|
-
* The typed output value.
|
|
162
|
-
*
|
|
163
|
-
* This may be the same as the input or a transformed version, depending on
|
|
164
|
-
* the schema's validation logic.
|
|
165
|
-
*/
|
|
166
|
-
readonly value: Output;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The Standard Schema types interface.
|
|
170
|
-
*
|
|
171
|
-
* Provides TypeScript type information for schemas that support type
|
|
172
|
-
* inference.
|
|
173
|
-
*
|
|
174
|
-
* @template Input - The input type of the schema
|
|
175
|
-
* @template Output - The output type of the schema
|
|
176
|
-
*/
|
|
177
|
-
interface Types<Input = unknown, Output = Input> {
|
|
178
|
-
/**
|
|
179
|
-
* The input type of the schema.
|
|
180
|
-
*
|
|
181
|
-
* The type of values that can be passed to the validate function.
|
|
182
|
-
*/
|
|
183
|
-
readonly input: Input;
|
|
184
|
-
/**
|
|
185
|
-
* The output type of the schema.
|
|
186
|
-
*
|
|
187
|
-
* The type of values produced after successful validation.
|
|
188
|
-
*/
|
|
189
|
-
readonly output: Output;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM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C,MAAM,CAAC,CAAC;QAE9C;;;;WAIG;QACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAExB;;;;;WAKG;QACH,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;KACrB;IAED;;;;;OAKG;IACH,KAAY,MAAM,CAAC,MAAM,IAAI,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEnE;;;;;;;OAOG;IACH,UAAiB,aAAa,CAAC,MAAM;QACnC;;;;WAIG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;QAE5B;;;;;WAKG;QACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB;IAED;;;;;;;;OAQG;IACH,UAAiB,KAAK,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;QACpD;;;;WAIG;QACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;QAEtB;;;;WAIG;QACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB;CACF"}
|
package/dist/standard-schema.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard Schema v1 specification types.
|
|
3
|
-
*
|
|
4
|
-
* These types define the Standard Schema interface that enables
|
|
5
|
-
* interoperability between different validation libraries (Zod, Valibot,
|
|
6
|
-
* ArkType, etc.).
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
* @see {@link https://standardschema.dev | Standard Schema Specification}
|
|
10
|
-
*/
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=standard-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|