@depup/typebox 1.1.18-depup.0 → 1.1.19-depup.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/README.md +1 -1
- package/build/value/codec/from-intersect.mjs +42 -12
- package/changes.json +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @depup/typebox
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [typebox](https://www.npmjs.com/package/typebox) @ 1.1.
|
|
16
|
+
| Original | [typebox](https://www.npmjs.com/package/typebox) @ 1.1.19 |
|
|
17
17
|
| Processed | 2026-04-07 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 0 |
|
|
@@ -2,27 +2,57 @@
|
|
|
2
2
|
import { Guard } from '../../guard/index.mjs';
|
|
3
3
|
import { FromType } from './from-type.mjs';
|
|
4
4
|
import { Callback } from './callback.mjs';
|
|
5
|
+
import { Clone } from '../clone/index.mjs';
|
|
6
|
+
import { Clean } from '../clean/index.mjs';
|
|
7
|
+
// ------------------------------------------------------------------
|
|
8
|
+
// MergeInteriors
|
|
9
|
+
//
|
|
10
|
+
// Merges all interior operand results into a single object. Each
|
|
11
|
+
// subsequent operand's properties override those of prior operands.
|
|
12
|
+
//
|
|
13
|
+
// ------------------------------------------------------------------
|
|
14
|
+
function MergeInteriors(interiors) {
|
|
15
|
+
return interiors.reduce((results, interior) => ({ ...results, ...interior }), {});
|
|
16
|
+
}
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
// NonMatchingInterior
|
|
19
|
+
//
|
|
20
|
+
// Used when Intersect operands do not all produce Objects. Returns
|
|
21
|
+
// the first interior result that differs from the original value,
|
|
22
|
+
// indicating a Codec has transformed the data. If no operand
|
|
23
|
+
// produced a change, defaults to the first interior result.
|
|
24
|
+
//
|
|
25
|
+
// ------------------------------------------------------------------
|
|
26
|
+
function NonMatchingInterior(value, interiors) {
|
|
27
|
+
for (const interior of interiors)
|
|
28
|
+
if (!Guard.IsDeepEqual(value, interior))
|
|
29
|
+
return interior;
|
|
30
|
+
return value; // value-unchanged
|
|
31
|
+
}
|
|
5
32
|
// ------------------------------------------------------------------
|
|
6
33
|
// Decode
|
|
7
34
|
// ------------------------------------------------------------------
|
|
8
35
|
function Decode(direction, context, type, value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
36
|
+
if (Guard.IsEqual(type.allOf.length, 0))
|
|
37
|
+
return Callback(direction, context, type, value);
|
|
38
|
+
const interiors = type.allOf.map((schema) => FromType(direction, context, schema, Clean(schema, Clone(value))));
|
|
39
|
+
const structural = interiors.every((result) => Guard.IsObject(result));
|
|
40
|
+
const exterior = structural ? MergeInteriors(interiors) : NonMatchingInterior(value, interiors);
|
|
41
|
+
return Callback(direction, context, type, exterior);
|
|
13
42
|
}
|
|
14
43
|
// ------------------------------------------------------------------
|
|
15
44
|
// Encode
|
|
16
45
|
// ------------------------------------------------------------------
|
|
17
46
|
function Encode(direction, context, type, value) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
if (Guard.IsEqual(type.allOf.length, 0))
|
|
48
|
+
return Callback(direction, context, type, value);
|
|
49
|
+
const exterior = Callback(direction, context, type, value);
|
|
50
|
+
const interiors = type.allOf.map((schema) => FromType(direction, context, schema, Clean(schema, Clone(exterior))));
|
|
51
|
+
const structural = interiors.every((result) => Guard.IsObject(result));
|
|
52
|
+
if (structural)
|
|
53
|
+
return MergeInteriors(interiors);
|
|
54
|
+
return NonMatchingInterior(exterior, interiors);
|
|
23
55
|
}
|
|
24
56
|
export function FromIntersect(direction, context, type, value) {
|
|
25
|
-
return Guard.IsEqual(direction, 'Decode')
|
|
26
|
-
? Decode(direction, context, type, value)
|
|
27
|
-
: Encode(direction, context, type, value);
|
|
57
|
+
return Guard.IsEqual(direction, 'Decode') ? Decode(direction, context, type, value) : Encode(direction, context, type, value);
|
|
28
58
|
}
|
package/changes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/typebox",
|
|
3
3
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript (with updated dependencies)",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.19-depup.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typebox",
|
|
7
7
|
"depup",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"changes": {},
|
|
95
95
|
"depsUpdated": 0,
|
|
96
96
|
"originalPackage": "typebox",
|
|
97
|
-
"originalVersion": "1.1.
|
|
98
|
-
"processedAt": "2026-04-
|
|
97
|
+
"originalVersion": "1.1.19",
|
|
98
|
+
"processedAt": "2026-04-07T12:27:34.842Z",
|
|
99
99
|
"smokeTest": "passed"
|
|
100
100
|
}
|
|
101
101
|
}
|