bupkis 0.15.0 → 0.17.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 +29 -0
- package/README.md +3 -2
- package/dist/assertion/assertion-async.cjs +6 -6
- package/dist/assertion/assertion-async.cjs.map +1 -1
- package/dist/assertion/assertion-async.js +1 -1
- package/dist/assertion/assertion-async.js.map +1 -1
- package/dist/assertion/assertion-sync.cjs +3 -3
- package/dist/assertion/assertion-sync.cjs.map +1 -1
- package/dist/assertion/assertion-sync.js +1 -1
- package/dist/assertion/assertion-sync.js.map +1 -1
- package/dist/assertion/assertion-types.d.cts +1 -1
- package/dist/assertion/assertion-types.d.cts.map +1 -1
- package/dist/assertion/assertion-types.d.ts +1 -1
- package/dist/assertion/assertion-types.d.ts.map +1 -1
- package/dist/assertion/assertion.cjs +2 -2
- package/dist/assertion/assertion.cjs.map +1 -1
- package/dist/assertion/assertion.d.cts +1 -1
- package/dist/assertion/assertion.d.cts.map +1 -1
- package/dist/assertion/assertion.d.ts +1 -1
- package/dist/assertion/assertion.d.ts.map +1 -1
- package/dist/assertion/assertion.js +1 -1
- package/dist/assertion/assertion.js.map +1 -1
- package/dist/assertion/create.cjs +7 -7
- package/dist/assertion/create.cjs.map +1 -1
- package/dist/assertion/create.d.cts +2 -2
- package/dist/assertion/create.d.ts +2 -2
- package/dist/assertion/create.js +3 -3
- package/dist/assertion/create.js.map +1 -1
- package/dist/assertion/impl/async-iterable.cjs +627 -0
- package/dist/assertion/impl/async-iterable.cjs.map +1 -0
- package/dist/assertion/impl/async-iterable.d.cts +406 -0
- package/dist/assertion/impl/async-iterable.d.cts.map +1 -0
- package/dist/assertion/impl/async-iterable.d.ts +406 -0
- package/dist/assertion/impl/async-iterable.d.ts.map +1 -0
- package/dist/assertion/impl/async-iterable.js +624 -0
- package/dist/assertion/impl/async-iterable.js.map +1 -0
- package/dist/assertion/impl/async-parametric.d.cts +1 -1
- package/dist/assertion/impl/async-parametric.d.cts.map +1 -1
- package/dist/assertion/impl/async-parametric.d.ts +1 -1
- package/dist/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/assertion/impl/async.cjs +7 -2
- package/dist/assertion/impl/async.cjs.map +1 -1
- package/dist/assertion/impl/async.d.cts +76 -31
- package/dist/assertion/impl/async.d.cts.map +1 -1
- package/dist/assertion/impl/async.d.ts +76 -31
- package/dist/assertion/impl/async.d.ts.map +1 -1
- package/dist/assertion/impl/async.js +7 -2
- package/dist/assertion/impl/async.js.map +1 -1
- package/dist/assertion/impl/iteration-util.cjs +297 -0
- package/dist/assertion/impl/iteration-util.cjs.map +1 -0
- package/dist/assertion/impl/iteration-util.d.cts +12 -0
- package/dist/assertion/impl/iteration-util.d.cts.map +1 -0
- package/dist/assertion/impl/iteration-util.d.ts +12 -0
- package/dist/assertion/impl/iteration-util.d.ts.map +1 -0
- package/dist/assertion/impl/iteration-util.js +282 -0
- package/dist/assertion/impl/iteration-util.js.map +1 -0
- package/dist/assertion/impl/snapshot.cjs +5 -5
- package/dist/assertion/impl/snapshot.cjs.map +1 -1
- package/dist/assertion/impl/snapshot.d.cts +1 -1
- package/dist/assertion/impl/snapshot.d.cts.map +1 -1
- package/dist/assertion/impl/snapshot.d.ts +1 -1
- package/dist/assertion/impl/snapshot.d.ts.map +1 -1
- package/dist/assertion/impl/snapshot.js +1 -1
- package/dist/assertion/impl/snapshot.js.map +1 -1
- package/dist/assertion/impl/sync-basic.cjs +8 -8
- package/dist/assertion/impl/sync-basic.cjs.map +1 -1
- package/dist/assertion/impl/sync-basic.d.cts +2 -2
- package/dist/assertion/impl/sync-basic.d.cts.map +1 -1
- package/dist/assertion/impl/sync-basic.d.ts +2 -2
- package/dist/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/assertion/impl/sync-basic.js +1 -1
- package/dist/assertion/impl/sync-basic.js.map +1 -1
- package/dist/assertion/impl/sync-collection.cjs +10 -10
- package/dist/assertion/impl/sync-collection.cjs.map +1 -1
- package/dist/assertion/impl/sync-collection.d.cts +1 -1
- package/dist/assertion/impl/sync-collection.d.cts.map +1 -1
- package/dist/assertion/impl/sync-collection.d.ts +1 -1
- package/dist/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/assertion/impl/sync-collection.js +1 -1
- package/dist/assertion/impl/sync-collection.js.map +1 -1
- package/dist/assertion/impl/sync-date.d.cts +14 -14
- package/dist/assertion/impl/sync-date.d.cts.map +1 -1
- package/dist/assertion/impl/sync-date.d.ts +14 -14
- package/dist/assertion/impl/sync-date.d.ts.map +1 -1
- package/dist/assertion/impl/sync-esoteric.cjs +3 -3
- package/dist/assertion/impl/sync-esoteric.cjs.map +1 -1
- package/dist/assertion/impl/sync-esoteric.d.cts +1 -1
- package/dist/assertion/impl/sync-esoteric.d.cts.map +1 -1
- package/dist/assertion/impl/sync-esoteric.d.ts +1 -1
- package/dist/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/assertion/impl/sync-esoteric.js +1 -1
- package/dist/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/assertion/impl/sync-iterable.cjs +512 -0
- package/dist/assertion/impl/sync-iterable.cjs.map +1 -0
- package/dist/assertion/impl/sync-iterable.d.cts +334 -0
- package/dist/assertion/impl/sync-iterable.d.cts.map +1 -0
- package/dist/assertion/impl/sync-iterable.d.ts +334 -0
- package/dist/assertion/impl/sync-iterable.d.ts.map +1 -0
- package/dist/assertion/impl/sync-iterable.js +509 -0
- package/dist/assertion/impl/sync-iterable.js.map +1 -0
- package/dist/assertion/impl/sync-parametric.cjs +3 -3
- package/dist/assertion/impl/sync-parametric.cjs.map +1 -1
- package/dist/assertion/impl/sync-parametric.d.cts +2 -2
- package/dist/assertion/impl/sync-parametric.d.cts.map +1 -1
- package/dist/assertion/impl/sync-parametric.d.ts +2 -2
- package/dist/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/assertion/impl/sync-parametric.js +1 -1
- package/dist/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/assertion/impl/sync.cjs +3 -0
- package/dist/assertion/impl/sync.cjs.map +1 -1
- package/dist/assertion/impl/sync.d.cts +178 -141
- package/dist/assertion/impl/sync.d.cts.map +1 -1
- package/dist/assertion/impl/sync.d.ts +178 -141
- package/dist/assertion/impl/sync.d.ts.map +1 -1
- package/dist/assertion/impl/sync.js +3 -0
- package/dist/assertion/impl/sync.js.map +1 -1
- package/dist/assertion/slotify.cjs +5 -5
- package/dist/assertion/slotify.cjs.map +1 -1
- package/dist/assertion/slotify.js +1 -1
- package/dist/assertion/slotify.js.map +1 -1
- package/dist/constant.cjs +10 -11
- package/dist/constant.cjs.map +1 -1
- package/dist/constant.d.cts +19 -3
- package/dist/constant.d.cts.map +1 -1
- package/dist/constant.d.ts +19 -3
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +10 -11
- package/dist/constant.js.map +1 -1
- package/dist/diff.d.cts +1 -1
- package/dist/diff.d.cts.map +1 -1
- package/dist/diff.d.ts +1 -1
- package/dist/diff.d.ts.map +1 -1
- package/dist/error.cjs +2 -4
- package/dist/error.cjs.map +1 -1
- package/dist/error.d.cts +21 -4
- package/dist/error.d.cts.map +1 -1
- package/dist/error.d.ts +21 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -4
- package/dist/error.js.map +1 -1
- package/dist/guards.cjs +4 -3
- package/dist/guards.cjs.map +1 -1
- package/dist/guards.d.cts +2 -3
- package/dist/guards.d.cts.map +1 -1
- package/dist/guards.d.ts +2 -3
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +4 -3
- package/dist/guards.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +85 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal-schema.cjs +41 -41
- package/dist/internal-schema.cjs.map +1 -1
- package/dist/internal-schema.js +1 -1
- package/dist/internal-schema.js.map +1 -1
- package/dist/metadata.cjs +16 -16
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +1 -4
- package/dist/metadata.d.cts.map +1 -1
- package/dist/metadata.d.ts +1 -4
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/schema.cjs +311 -67
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +221 -2
- package/dist/schema.d.cts.map +1 -1
- package/dist/schema.d.ts +221 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +245 -2
- package/dist/schema.js.map +1 -1
- package/dist/snapshot/adapters/node-test.cjs +25 -1
- package/dist/snapshot/adapters/node-test.cjs.map +1 -1
- package/dist/snapshot/adapters/node-test.d.cts +2 -1
- package/dist/snapshot/adapters/node-test.d.cts.map +1 -1
- package/dist/snapshot/adapters/node-test.d.ts +2 -1
- package/dist/snapshot/adapters/node-test.d.ts.map +1 -1
- package/dist/snapshot/adapters/node-test.js +25 -1
- package/dist/snapshot/adapters/node-test.js.map +1 -1
- package/dist/snapshot/index.cjs +7 -1
- package/dist/snapshot/index.cjs.map +1 -1
- package/dist/snapshot/index.d.cts +3 -2
- package/dist/snapshot/index.d.cts.map +1 -1
- package/dist/snapshot/index.d.ts +3 -2
- package/dist/snapshot/index.d.ts.map +1 -1
- package/dist/snapshot/index.js +2 -0
- package/dist/snapshot/index.js.map +1 -1
- package/dist/snapshot/node-version.cjs +49 -0
- package/dist/snapshot/node-version.cjs.map +1 -0
- package/dist/snapshot/node-version.d.cts +34 -0
- package/dist/snapshot/node-version.d.cts.map +1 -0
- package/dist/snapshot/node-version.d.ts +34 -0
- package/dist/snapshot/node-version.d.ts.map +1 -0
- package/dist/snapshot/node-version.js +44 -0
- package/dist/snapshot/node-version.js.map +1 -0
- package/dist/types.d.cts +1 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/util.cjs +2 -134
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.cts +1 -55
- package/dist/util.d.cts.map +1 -1
- package/dist/util.d.ts +1 -55
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +1 -131
- package/dist/util.js.map +1 -1
- package/dist/value-to-schema.cjs +89 -45
- package/dist/value-to-schema.cjs.map +1 -1
- package/dist/value-to-schema.d.cts +1 -1
- package/dist/value-to-schema.d.cts.map +1 -1
- package/dist/value-to-schema.d.ts +1 -1
- package/dist/value-to-schema.d.ts.map +1 -1
- package/dist/value-to-schema.js +53 -9
- package/dist/value-to-schema.js.map +1 -1
- package/package.json +44 -145
- package/src/assertion/assertion-async.ts +1 -1
- package/src/assertion/assertion-sync.ts +1 -1
- package/src/assertion/assertion-types.ts +1 -1
- package/src/assertion/assertion.ts +1 -1
- package/src/assertion/create.ts +3 -3
- package/src/assertion/impl/async-iterable.ts +749 -0
- package/src/assertion/impl/async-parametric.ts +1 -1
- package/src/assertion/impl/async.ts +7 -2
- package/src/assertion/impl/iteration-util.ts +379 -0
- package/src/assertion/impl/snapshot.ts +1 -1
- package/src/assertion/impl/sync-basic.ts +1 -1
- package/src/assertion/impl/sync-collection.ts +1 -1
- package/src/assertion/impl/sync-esoteric.ts +1 -1
- package/src/assertion/impl/sync-iterable.ts +593 -0
- package/src/assertion/impl/sync-parametric.ts +1 -1
- package/src/assertion/impl/sync.ts +3 -0
- package/src/assertion/slotify.ts +1 -1
- package/src/constant.ts +15 -13
- package/src/diff.ts +1 -1
- package/src/error.ts +2 -4
- package/src/guards.ts +7 -4
- package/src/index.ts +1 -1
- package/src/internal-schema.ts +1 -1
- package/src/metadata.ts +1 -1
- package/src/schema.ts +267 -2
- package/src/snapshot/adapters/node-test.ts +28 -1
- package/src/snapshot/index.ts +10 -2
- package/src/snapshot/node-version.ts +50 -0
- package/src/types.ts +1 -1
- package/src/util.ts +1 -149
- package/src/value-to-schema.ts +71 -12
- package/LICENSE.md +0 -55
package/src/value-to-schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
import { SatisfactionError } from './error.js';
|
|
4
4
|
import {
|
|
@@ -146,13 +146,6 @@ export const valueToSchema = (
|
|
|
146
146
|
visited.add(value);
|
|
147
147
|
|
|
148
148
|
try {
|
|
149
|
-
// Check for objects with own __proto__ property - these can cause unexpected behavior
|
|
150
|
-
if (hasOwn(value, '__proto__')) {
|
|
151
|
-
throw new SatisfactionError(
|
|
152
|
-
'Objects with an own "__proto__" property are not supported by valueToSchema',
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
149
|
// Handle built-in object types
|
|
157
150
|
if (value instanceof Date) {
|
|
158
151
|
// Check if it's a valid date
|
|
@@ -396,8 +389,25 @@ export const valueToSchema = (
|
|
|
396
389
|
const schemaShape: Record<string, z.ZodType<any>> = {};
|
|
397
390
|
const undefinedKeys: string[] = [];
|
|
398
391
|
|
|
392
|
+
// Handle __proto__ specially - Zod ignores it in z.object() shapes,
|
|
393
|
+
// so we validate it separately via superRefine
|
|
394
|
+
let protoSchema: null | z.ZodType = null;
|
|
395
|
+
if (hasOwn(value, '__proto__')) {
|
|
396
|
+
const protoValue = (value as Record<string, unknown>)['__proto__'];
|
|
397
|
+
protoSchema = valueToSchema(
|
|
398
|
+
protoValue,
|
|
399
|
+
{ ...options, _currentDepth: _currentDepth + 1 },
|
|
400
|
+
visited,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
399
404
|
for (const [key, val] of entries(value)) {
|
|
400
405
|
if (isString(key)) {
|
|
406
|
+
// Skip __proto__ - handled separately since Zod ignores it in object shapes
|
|
407
|
+
if (key === '__proto__') {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
|
|
401
411
|
// Skip undefined values unless we're in literalPrimitives mode
|
|
402
412
|
// This prevents objects with only undefined values from matching any object
|
|
403
413
|
if (val === undefined && !literalPrimitives) {
|
|
@@ -426,22 +436,71 @@ export const valueToSchema = (
|
|
|
426
436
|
? z.strictObject(schemaShape)
|
|
427
437
|
: z.looseObject(schemaShape);
|
|
428
438
|
|
|
429
|
-
//
|
|
430
|
-
|
|
439
|
+
// When __proto__ is present, we MUST use z.custom() because Zod strips
|
|
440
|
+
// __proto__ before it reaches superRefine. z.custom() receives the raw input.
|
|
441
|
+
if (protoSchema) {
|
|
442
|
+
const capturedProtoSchema = protoSchema;
|
|
443
|
+
const capturedUndefinedKeys = undefinedKeys;
|
|
444
|
+
const needsUndefinedValidation =
|
|
445
|
+
capturedUndefinedKeys.length > 0 && literalPrimitives;
|
|
446
|
+
|
|
447
|
+
return z.custom<Record<string, unknown>>(
|
|
448
|
+
(val) => {
|
|
449
|
+
if (typeof val !== 'object' || val === null) {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Validate __proto__ BEFORE Zod can strip it
|
|
454
|
+
if (!hasOwn(val, '__proto__')) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
const actualProto = (val as Record<string, unknown>)['__proto__'];
|
|
458
|
+
if (!capturedProtoSchema.safeParse(actualProto).success) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Validate the rest of the object via the base schema
|
|
463
|
+
if (!baseSchema.safeParse(val).success) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Validate undefined keys if needed
|
|
468
|
+
if (needsUndefinedValidation) {
|
|
469
|
+
for (const key of capturedUndefinedKeys) {
|
|
470
|
+
if (!hasOwn(val, key)) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return true;
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
message: 'Expected object to have own "__proto__" property',
|
|
480
|
+
},
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Apply refinements for undefined keys (no __proto__ case)
|
|
485
|
+
const needsUndefinedKeyValidation =
|
|
486
|
+
undefinedKeys.length > 0 && literalPrimitives;
|
|
487
|
+
if (needsUndefinedKeyValidation) {
|
|
431
488
|
return baseSchema.superRefine((data, ctx) => {
|
|
432
489
|
if (typeof data !== 'object' || data === null) {
|
|
433
490
|
ctx.addIssue({
|
|
434
|
-
code:
|
|
491
|
+
code: 'custom',
|
|
435
492
|
message: 'Expected an object',
|
|
436
493
|
});
|
|
437
494
|
return;
|
|
438
495
|
}
|
|
439
496
|
|
|
440
497
|
const obj = data as Record<string, unknown>;
|
|
498
|
+
|
|
499
|
+
// Validate undefined keys exist
|
|
441
500
|
for (const key of undefinedKeys) {
|
|
442
501
|
if (!hasOwn(obj, key)) {
|
|
443
502
|
ctx.addIssue({
|
|
444
|
-
code:
|
|
503
|
+
code: 'custom',
|
|
445
504
|
message: `Expected property "${key}" to exist with value undefined`,
|
|
446
505
|
path: [key],
|
|
447
506
|
});
|
package/LICENSE.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Blue Oak Model License
|
|
2
|
-
|
|
3
|
-
Version 1.0.0
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
This license gives everyone as much permission to work with
|
|
8
|
-
this software as possible, while protecting contributors
|
|
9
|
-
from liability.
|
|
10
|
-
|
|
11
|
-
## Acceptance
|
|
12
|
-
|
|
13
|
-
In order to receive this license, you must agree to its
|
|
14
|
-
rules. The rules of this license are both obligations
|
|
15
|
-
under that agreement and conditions to your license.
|
|
16
|
-
You must not do anything with this software that triggers
|
|
17
|
-
a rule that you cannot or will not follow.
|
|
18
|
-
|
|
19
|
-
## Copyright
|
|
20
|
-
|
|
21
|
-
Each contributor licenses you to do everything with this
|
|
22
|
-
software that would otherwise infringe that contributor's
|
|
23
|
-
copyright in it.
|
|
24
|
-
|
|
25
|
-
## Notices
|
|
26
|
-
|
|
27
|
-
You must ensure that everyone who gets a copy of
|
|
28
|
-
any part of this software from you, with or without
|
|
29
|
-
changes, also gets the text of this license or a link to
|
|
30
|
-
<https://blueoakcouncil.org/license/1.0.0>.
|
|
31
|
-
|
|
32
|
-
## Excuse
|
|
33
|
-
|
|
34
|
-
If anyone notifies you in writing that you have not
|
|
35
|
-
complied with [Notices](#notices), you can keep your
|
|
36
|
-
license by taking all practical steps to comply within 30
|
|
37
|
-
days after the notice. If you do not do so, your license
|
|
38
|
-
ends immediately.
|
|
39
|
-
|
|
40
|
-
## Patent
|
|
41
|
-
|
|
42
|
-
Each contributor licenses you to do everything with this
|
|
43
|
-
software that would otherwise infringe any patent claims
|
|
44
|
-
they can license or become able to license.
|
|
45
|
-
|
|
46
|
-
## Reliability
|
|
47
|
-
|
|
48
|
-
No contributor can revoke this license.
|
|
49
|
-
|
|
50
|
-
## No Liability
|
|
51
|
-
|
|
52
|
-
**_As far as the law allows, this software comes as is,
|
|
53
|
-
without any warranty or condition, and no contributor
|
|
54
|
-
will be liable to anyone for any damages related to this
|
|
55
|
-
software or this license, under any kind of legal claim._**
|