ts-fortress 12.4.2 → 12.4.3
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/dist/compose/union.d.mts.map +1 -1
- package/dist/compose/union.mjs +84 -36
- package/dist/compose/union.mjs.map +1 -1
- package/dist/utils/validation-error.d.mts +5 -3
- package/dist/utils/validation-error.d.mts.map +1 -1
- package/dist/utils/validation-error.mjs +2 -0
- package/dist/utils/validation-error.mjs.map +1 -1
- package/package.json +8 -8
- package/src/compose/union-closest-member.test.mts +240 -2
- package/src/compose/union.mts +124 -43
- package/src/utils/validation-error.mts +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.mts","sourceRoot":"","sources":["../../src/compose/union.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"union.d.mts","sourceRoot":"","sources":["../../src/compose/union.mts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAc,MAAM,eAAe,CAAC;AAC7E,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,MAAM,EAEX,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAUrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,CAAC,KAAK,SAAS,aAAa,CAAC,WAAW,CAAC,SAC3D,KAAK,YACF,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;CAC/B,CAAC,CACH,KACA,SAAS,CAAC,KAAK,CA8MjB,CAAC;AAwHF,KAAK,SAAS,CAAC,KAAK,SAAS,aAAa,CAAC,WAAW,CAAC,IAAI,IAAI,CAC7D,cAAc,CAAC,KAAK,CAAC,CACtB,CAAC;AAEF,KAAK,cAAc,CAAC,KAAK,SAAS,aAAa,CAAC,WAAW,CAAC,IAC1D,kBAAkB,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAE/C,kBAAU,kBAAkB,CAAC;IAC3B,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,aAAa,CAAC,WAAW,CAAC,IACrE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAEnC,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;;CAC3E"}
|
package/dist/compose/union.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Arr, memoizeFunction, Result } from 'ts-data-forge';
|
|
1
|
+
import { Arr, hasKey, isRecord, memoizeFunction, Result, } from 'ts-data-forge';
|
|
2
2
|
import { flattenShapeStructure, recordViewOf, tupleElementTypesOf, unionMembersOf, } from '../type.mjs';
|
|
3
|
-
import { createAssertFn, createCastFn,
|
|
3
|
+
import { createAssertFn, createCastFn, runtimeTypeNameOf, toUnionString, UNION_MEMBER_LISTING_MAX_LENGTH, } from '../utils/index.mjs';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -47,40 +47,54 @@ export const union = (types, options) => {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
const memberTypes = types.flatMap(unionMembersOf);
|
|
50
|
-
const validate = (a) => {
|
|
51
|
-
if (memberTypes.some((t) => t.is(a))) {
|
|
52
50
|
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const is = (a) => memberTypes.some((t) => t.is(a));
|
|
54
|
+
const memberTypeNames = types.map((t) => t.typeName);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const isListable = toUnionString(memberTypeNames).length <= UNION_MEMBER_LISTING_MAX_LENGTH;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const hasNestedUnion = types.some((t) => t.structure?.kind === 'union');
|
|
63
|
+
const validate = (a) => {
|
|
64
|
+
if (is(a)) {
|
|
53
65
|
return Result.ok(a);
|
|
54
66
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const header = {
|
|
68
|
+
path: [],
|
|
69
|
+
actualValue: a,
|
|
70
|
+
expectedType: typeNameFilled,
|
|
71
|
+
typeName: typeNameFilled,
|
|
72
|
+
};
|
|
73
|
+
const listingError = {
|
|
74
|
+
...header,
|
|
75
|
+
details: {
|
|
76
|
+
kind: 'union',
|
|
77
|
+
typeNames: memberTypeNames,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
if (isListable && hasNestedUnion) {
|
|
81
|
+
return Result.err([listingError]);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
|
|
72
|
-
|
|
73
85
|
const actualCategory = runtimeTypeNameOf(a);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
const candidateTypes = memberTypes.filter((t) => runtimeTypeNameOf(t.defaultValue) === actualCategory);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if (isListable &&
|
|
90
|
+
candidateTypes.every((t) => checkedKeysOf(t) === undefined)) {
|
|
91
|
+
return Result.err([listingError]);
|
|
92
|
+
}
|
|
93
|
+
const candidates = candidateTypes.map((t) => evaluateMember(t, a));
|
|
77
94
|
if (!Arr.isNonEmpty(candidates)) {
|
|
78
95
|
return Result.err([
|
|
79
96
|
{
|
|
80
|
-
|
|
81
|
-
actualValue: a,
|
|
82
|
-
expectedType: typeNameFilled,
|
|
83
|
-
typeName: typeNameFilled,
|
|
97
|
+
...header,
|
|
84
98
|
details: {
|
|
85
99
|
kind: 'union-category-mismatch',
|
|
86
100
|
memberCount: memberTypes.length,
|
|
@@ -96,11 +110,16 @@ export const union = (types, options) => {
|
|
|
96
110
|
|
|
97
111
|
const closest = Arr.minBy(candidates, (candidate) => candidate, compareByCloseness).value;
|
|
98
112
|
const equallyClose = candidates.filter((c) => c !== closest && compareByCloseness(c, closest) === 0);
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if (isListable &&
|
|
118
|
+
(Arr.isNonEmpty(equallyClose) || acceptedKeyCountOf(closest, a) === 0)) {
|
|
119
|
+
return Result.err([listingError]);
|
|
120
|
+
}
|
|
99
121
|
return Result.err(Arr.toUnshifted({
|
|
100
|
-
|
|
101
|
-
actualValue: a,
|
|
102
|
-
expectedType: typeNameFilled,
|
|
103
|
-
typeName: typeNameFilled,
|
|
122
|
+
...header,
|
|
104
123
|
details: {
|
|
105
124
|
kind: 'union-closest-member',
|
|
106
125
|
memberCount: memberTypes.length,
|
|
@@ -109,7 +128,6 @@ export const union = (types, options) => {
|
|
|
109
128
|
},
|
|
110
129
|
})(closest.errors));
|
|
111
130
|
};
|
|
112
|
-
const is = createIsFn(validate);
|
|
113
131
|
const fill = (a) => (is(a) ? a : getDefaultSource().fill(a));
|
|
114
132
|
|
|
115
133
|
const prune = (a) => {
|
|
@@ -139,15 +157,44 @@ export const union = (types, options) => {
|
|
|
139
157
|
|
|
140
158
|
|
|
141
159
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const checkCountOf = (memberType) => {
|
|
160
|
+
const checkedKeysOf = (memberType) => {
|
|
145
161
|
const view = recordViewOf(memberType);
|
|
146
162
|
if (view !== undefined) {
|
|
147
163
|
const shape = flattenShapeStructure(view.shapeStructure);
|
|
148
|
-
return shape === undefined ?
|
|
164
|
+
return shape === undefined ? undefined : Object.keys(shape);
|
|
165
|
+
}
|
|
166
|
+
return tupleElementTypesOf(memberType)?.map((_, index) => index.toString());
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
const checkCountOf = (memberType) => checkedKeysOf(memberType)?.length ?? 1;
|
|
175
|
+
|
|
176
|
+
const valueAt = (a, key) => Arr.isArray(a)
|
|
177
|
+
? a.find((_, index) => index.toString() === key)
|
|
178
|
+
: isRecord(a) && hasKey(a, key)
|
|
179
|
+
? a[key]
|
|
180
|
+
: undefined;
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
const acceptedKeyCountOf = (closeness, a) => {
|
|
191
|
+
const keys = checkedKeysOf(closeness.memberType);
|
|
192
|
+
if (keys === undefined ||
|
|
193
|
+
closeness.errors.some((e) => !Arr.isNonEmpty(e.path))) {
|
|
194
|
+
return 0;
|
|
149
195
|
}
|
|
150
|
-
return
|
|
196
|
+
return keys.filter((key) => valueAt(a, key) !== undefined &&
|
|
197
|
+
closeness.errors.every((e) => e.path[0] !== key)).length;
|
|
151
198
|
};
|
|
152
199
|
const validationErrorsOf = (result) => Result.isErr(result) ? result.value : [];
|
|
153
200
|
const evaluateMember = (memberType, a) => {
|
|
@@ -156,6 +203,7 @@ const evaluateMember = (memberType, a) => {
|
|
|
156
203
|
|
|
157
204
|
const satisfiedCheckCount = Math.max(0, checkCountOf(memberType) - errors.length);
|
|
158
205
|
return {
|
|
206
|
+
memberType,
|
|
159
207
|
typeName: memberType.typeName,
|
|
160
208
|
errors,
|
|
161
209
|
satisfiedCheckCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.mjs","sourceRoot":"","sources":["../../src/compose/union.mts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"union.mjs","sourceRoot":"","sources":["../../src/compose/union.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,UAAU,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EACf,MAAM,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EAGnB,cAAc,GAEf,MAAM,aAAa,CA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imitiveValidationError: ({ actualValue, expectedTyp
|
|
|
172
172
|
/**
|
|
173
173
|
* Maximum length of the ` | `-joined listing of union member type names that a
|
|
174
174
|
* message may spell out. Beyond it a listing is more noise than help, so both
|
|
175
|
-
* users of this bound summarize instead: `union`
|
|
176
|
-
*
|
|
177
|
-
*
|
|
175
|
+
* users of this bound summarize instead: `union` reports the closest member, or
|
|
176
|
+
* the runtime types it accepts when no member is of the value's, rather than
|
|
177
|
+
* listing every member (within the bound, only a closest member that stands out
|
|
178
|
+
* replaces the listing), and the closest-member message stops naming the
|
|
179
|
+
* members that tie with it.
|
|
178
180
|
*/
|
|
179
181
|
export declare const UNION_MEMBER_LISTING_MAX_LENGTH = 60;
|
|
180
182
|
//# sourceMappingURL=validation-error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-error.d.mts","sourceRoot":"","sources":["../../src/utils/validation-error.mts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CACzC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,yBAAyB,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI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;IACrB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC9C,CAAC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,UAC5B,eAAe,gCACO,MAAM,KAClC,MAgBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,MAS3B,CAAC;AAqBzB;;;GAGG;AACH,eAAO,MAAM,0BAA0B,WAC7B,SAAS,eAAe,EAAE,gCACL,MAAM,KAClC,SAAS,MAAM,EAC2D,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,6BAA6B,WAChC,SAAS,eAAe,EAAE,eACrB,MAAM,KAClB,SAAS,eAAe,EAItB,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,8BAA8B,WACjC,SAAS,eAAe,EAAE,SAC3B,MAAM,KACZ,SAAS,eAAe,EAC8B,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,8BAA8B,sDAKxC,QAAQ,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC7C,CAAC,KAAG,eAOQ,CAAC;AA+Dd
|
|
1
|
+
{"version":3,"file":"validation-error.d.mts","sourceRoot":"","sources":["../../src/utils/validation-error.mts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CACzC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CAC5B,GACD;IACE,IAAI,E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
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@sindresorhus/is": "8.1.0",
|
|
39
|
-
"ts-data-forge": "~14.
|
|
40
|
-
"ts-std-forge": "~0.5.
|
|
39
|
+
"ts-data-forge": "~14.11.0",
|
|
40
|
+
"ts-std-forge": "~0.5.3",
|
|
41
41
|
"ts-type-forge": "~9.2.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@sumi-lang/cli": "0.1.
|
|
44
|
+
"@sumi-lang/cli": "0.1.6",
|
|
45
45
|
"@vitest/browser-playwright": "5.0.5",
|
|
46
46
|
"@vitest/ui": "5.0.5",
|
|
47
47
|
"ajv": "8.20.0",
|
|
48
|
-
"eslint-config-typed": "7.
|
|
49
|
-
"eslint-plugin-ts-data-forge": "0.10.
|
|
50
|
-
"eslint-plugin-ts-type-forge": "0.8.
|
|
48
|
+
"eslint-config-typed": "7.4.0",
|
|
49
|
+
"eslint-plugin-ts-data-forge": "0.10.9",
|
|
50
|
+
"eslint-plugin-ts-type-forge": "0.8.18",
|
|
51
51
|
"fp-ts": "2.16.11",
|
|
52
52
|
"io-ts": "2.2.22",
|
|
53
53
|
"playwright": "1.64.1",
|
|
54
54
|
"prettier": "3.9.10",
|
|
55
55
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
56
56
|
"prettier-plugin-packagejson": "3.0.2",
|
|
57
|
-
"ts-repo-utils": "10.7.
|
|
57
|
+
"ts-repo-utils": "10.7.2",
|
|
58
58
|
"typedoc": "0.28.20",
|
|
59
59
|
"typedoc-github-theme": "0.4.0",
|
|
60
60
|
"vite": "8.3.5",
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Result } from 'ts-data-forge';
|
|
2
|
+
import { tuple } from '../array/index.mjs';
|
|
3
|
+
import { enumType } from '../enum/index.mjs';
|
|
2
4
|
import { literal } from '../other-types/index.mjs';
|
|
3
5
|
import { number, string } from '../primitives/index.mjs';
|
|
4
|
-
import { record } from '../record/index.mjs';
|
|
6
|
+
import { optional, record } from '../record/index.mjs';
|
|
5
7
|
import type { UnknownType } from '../type.mjs';
|
|
6
8
|
import { validationErrorsToMessages } from '../utils/index.mjs';
|
|
7
9
|
import { union } from './union.mjs';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* When a union's member listing is too long to print, the error reports a
|
|
11
|
-
* single member instead
|
|
13
|
+
* single member instead; when it is short enough, it does so only if that
|
|
14
|
+
* member stands out (see `named members` below). That member is chosen in two
|
|
15
|
+
* steps:
|
|
12
16
|
*
|
|
13
17
|
* 1. keep the members whose runtime type category (taken from their default
|
|
14
18
|
* value) matches the value's,
|
|
@@ -325,4 +329,238 @@ describe('union - closest member selection', () => {
|
|
|
325
329
|
);
|
|
326
330
|
});
|
|
327
331
|
});
|
|
332
|
+
|
|
333
|
+
describe('named members', () => {
|
|
334
|
+
// Named members make the listing short enough to print, but a value that
|
|
335
|
+
// satisfies most of one member is still better explained by that member's
|
|
336
|
+
// errors than by the list of names; the name then labels the member.
|
|
337
|
+
const taskDependency = record(
|
|
338
|
+
{
|
|
339
|
+
from: record({ kind: literal('task'), id: string() }),
|
|
340
|
+
type: enumType(['fs', 'ss']),
|
|
341
|
+
lagMs: number(),
|
|
342
|
+
},
|
|
343
|
+
{ typeName: 'TaskDependency' },
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
const milestoneDependency = record(
|
|
347
|
+
{
|
|
348
|
+
from: record({ kind: literal('milestone'), id: string() }),
|
|
349
|
+
lagMs: number(),
|
|
350
|
+
},
|
|
351
|
+
{ typeName: 'MilestoneDependency' },
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
const dependency = union([taskDependency, milestoneDependency]);
|
|
355
|
+
|
|
356
|
+
test('a value that stands out as one member reports that member', () => {
|
|
357
|
+
// taskDependency fails 1 of its 3 checks, scoring -1; milestoneDependency
|
|
358
|
+
// fails 1 of its 2, scoring 0.
|
|
359
|
+
assert.deepStrictEqual(
|
|
360
|
+
validationErrorsToMessages(
|
|
361
|
+
Result.unwrapErrThrow(
|
|
362
|
+
dependency.validate({
|
|
363
|
+
from: { kind: 'task', id: 'a' },
|
|
364
|
+
type: 'xx',
|
|
365
|
+
lagMs: 0,
|
|
366
|
+
}),
|
|
367
|
+
),
|
|
368
|
+
),
|
|
369
|
+
[
|
|
370
|
+
'Error: the value did not match any of the 2 members of the union; the closest member type is <TaskDependency>, which failed as follows:',
|
|
371
|
+
'Error at type: expected one of { fs, ss } but "xx" was passed.',
|
|
372
|
+
],
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test('naming the members does not change which member is reported', () => {
|
|
377
|
+
const value = {
|
|
378
|
+
from: { kind: 'milestone', id: 'm' },
|
|
379
|
+
lagMs: '0',
|
|
380
|
+
} as const;
|
|
381
|
+
|
|
382
|
+
const unnamed = union([
|
|
383
|
+
record({
|
|
384
|
+
from: record({ kind: literal('task'), id: string() }),
|
|
385
|
+
type: enumType(['fs', 'ss']),
|
|
386
|
+
lagMs: number(),
|
|
387
|
+
}),
|
|
388
|
+
record({
|
|
389
|
+
from: record({ kind: literal('milestone'), id: string() }),
|
|
390
|
+
lagMs: number(),
|
|
391
|
+
}),
|
|
392
|
+
]);
|
|
393
|
+
|
|
394
|
+
const withoutHeader = (type: UnknownType): readonly string[] => {
|
|
395
|
+
const [, ...memberErrors] = validationErrorsToMessages(
|
|
396
|
+
Result.unwrapErrThrow(type.validate(value)),
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
return memberErrors;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
assert.deepStrictEqual(withoutHeader(dependency), [
|
|
403
|
+
'Error at lagMs: expected <number> type but <string> type value "0" was passed.',
|
|
404
|
+
]);
|
|
405
|
+
|
|
406
|
+
assert.deepStrictEqual(withoutHeader(dependency), withoutHeader(unnamed));
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
test('a value no member stands out for keeps the listing', () => {
|
|
410
|
+
// Both members fail every check they make: milestoneDependency fails
|
|
411
|
+
// fewer, but the value satisfies nothing of it either.
|
|
412
|
+
assert.deepStrictEqual(
|
|
413
|
+
validationErrorsToMessages(
|
|
414
|
+
Result.unwrapErrThrow(dependency.validate({})),
|
|
415
|
+
),
|
|
416
|
+
[
|
|
417
|
+
'Error: expected one of <TaskDependency>, <MilestoneDependency> but <object> type value `{}` was passed.',
|
|
418
|
+
],
|
|
419
|
+
);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test('members that tie keep the listing', () => {
|
|
423
|
+
// Each member fails 1 of its 2 checks, so neither stands out.
|
|
424
|
+
const point = record({ x: number(), y: number() }, { typeName: 'XY' });
|
|
425
|
+
|
|
426
|
+
const column = record({ x: number(), z: number() }, { typeName: 'XZ' });
|
|
427
|
+
|
|
428
|
+
assert.deepStrictEqual(
|
|
429
|
+
validationErrorsToMessages(
|
|
430
|
+
Result.unwrapErrThrow(union([point, column]).validate({ x: 1 })),
|
|
431
|
+
),
|
|
432
|
+
[
|
|
433
|
+
'Error: expected one of <XY>, <XZ> but <object> type value `{"x":1}` was passed.',
|
|
434
|
+
],
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
test('a key with several errors beneath it fails once', () => {
|
|
439
|
+
// `from` reports two errors, but `lagMs` is still accepted.
|
|
440
|
+
assert.deepStrictEqual(
|
|
441
|
+
validationErrorsToMessages(
|
|
442
|
+
Result.unwrapErrThrow(dependency.validate({ from: {}, lagMs: 0 })),
|
|
443
|
+
),
|
|
444
|
+
[
|
|
445
|
+
'Error: the value did not match any of the 2 members of the union; the closest member type is <MilestoneDependency>, which failed as follows:',
|
|
446
|
+
'Error at from.kind: missing required key "kind".',
|
|
447
|
+
'Error at from.id: missing required key "id".',
|
|
448
|
+
],
|
|
449
|
+
);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test('an optional key the value leaves out is not a resemblance', () => {
|
|
453
|
+
// `a` scores best because its absent optional keys pass, but the value
|
|
454
|
+
// has no key `a` accepts.
|
|
455
|
+
const a = record(
|
|
456
|
+
{
|
|
457
|
+
kind: literal('a'),
|
|
458
|
+
note: optional(string()),
|
|
459
|
+
tag: optional(string()),
|
|
460
|
+
},
|
|
461
|
+
{ typeName: 'A' },
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
const b = record({ kind: literal('b'), v: number() }, { typeName: 'B' });
|
|
465
|
+
|
|
466
|
+
assert.deepStrictEqual(
|
|
467
|
+
validationErrorsToMessages(
|
|
468
|
+
Result.unwrapErrThrow(union([a, b]).validate({ kind: 'b' })),
|
|
469
|
+
),
|
|
470
|
+
[
|
|
471
|
+
'Error: expected one of <A>, <B> but <object> type value `{"kind":"b"}` was passed.',
|
|
472
|
+
],
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
assert.deepStrictEqual(
|
|
476
|
+
validationErrorsToMessages(
|
|
477
|
+
Result.unwrapErrThrow(
|
|
478
|
+
union([a, b]).validate({ kind: 'b', note: undefined }),
|
|
479
|
+
),
|
|
480
|
+
),
|
|
481
|
+
[
|
|
482
|
+
'Error: expected one of <A>, <B> but <object> type value `{"kind":"b"}` was passed.',
|
|
483
|
+
],
|
|
484
|
+
);
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
test('a nested union keeps the listing under its own name', () => {
|
|
488
|
+
const outer = union([
|
|
489
|
+
union([taskDependency, milestoneDependency], {
|
|
490
|
+
typeName: 'Dependency',
|
|
491
|
+
}),
|
|
492
|
+
literal('none'),
|
|
493
|
+
]);
|
|
494
|
+
|
|
495
|
+
assert.deepStrictEqual(
|
|
496
|
+
validationErrorsToMessages(
|
|
497
|
+
Result.unwrapErrThrow(
|
|
498
|
+
outer.validate({
|
|
499
|
+
from: { kind: 'task', id: 'a' },
|
|
500
|
+
type: 'xx',
|
|
501
|
+
lagMs: 0,
|
|
502
|
+
}),
|
|
503
|
+
),
|
|
504
|
+
),
|
|
505
|
+
[
|
|
506
|
+
'Error: expected one of <Dependency>, <"none"> but a value of type <object> matching none of them was passed.',
|
|
507
|
+
],
|
|
508
|
+
);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
test('a tuple stands out by the elements it accepts', () => {
|
|
512
|
+
const entry = tuple([string(), number()], { typeName: 'Entry' });
|
|
513
|
+
|
|
514
|
+
const range = tuple([number(), number()], { typeName: 'Range' });
|
|
515
|
+
|
|
516
|
+
assert.deepStrictEqual(
|
|
517
|
+
validationErrorsToMessages(
|
|
518
|
+
Result.unwrapErrThrow(union([entry, range]).validate(['a', 'b'])),
|
|
519
|
+
),
|
|
520
|
+
[
|
|
521
|
+
'Error: the value did not match any of the 2 members of the union; the closest member type is <Entry>, which failed as follows:',
|
|
522
|
+
'Error at 1: expected <number> type but <string> type value "b" was passed.',
|
|
523
|
+
],
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
test('a nested union of one member keeps the listing', () => {
|
|
528
|
+
const outer = union([
|
|
529
|
+
union([taskDependency], { typeName: 'Dependency' }),
|
|
530
|
+
literal('none'),
|
|
531
|
+
]);
|
|
532
|
+
|
|
533
|
+
assert.deepStrictEqual(
|
|
534
|
+
validationErrorsToMessages(
|
|
535
|
+
Result.unwrapErrThrow(
|
|
536
|
+
outer.validate({
|
|
537
|
+
from: { kind: 'task', id: 'a' },
|
|
538
|
+
type: 'xx',
|
|
539
|
+
lagMs: 0,
|
|
540
|
+
}),
|
|
541
|
+
),
|
|
542
|
+
),
|
|
543
|
+
[
|
|
544
|
+
'Error: expected one of <Dependency>, <"none"> but a value of type <object> matching none of them was passed.',
|
|
545
|
+
],
|
|
546
|
+
);
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
test('a tuple of the wrong length checked none of the elements', () => {
|
|
550
|
+
const triple = tuple([string(), string(), string()], {
|
|
551
|
+
typeName: 'S3',
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
const pair = tuple([number(), number()], { typeName: 'N2' });
|
|
555
|
+
|
|
556
|
+
assert.deepStrictEqual(
|
|
557
|
+
validationErrorsToMessages(
|
|
558
|
+
Result.unwrapErrThrow(union([triple, pair]).validate([1, 2, 3, 4])),
|
|
559
|
+
),
|
|
560
|
+
[
|
|
561
|
+
'Error: expected one of <S3>, <N2> but <array> type value `[1,2,3,4]` was passed.',
|
|
562
|
+
],
|
|
563
|
+
);
|
|
564
|
+
});
|
|
565
|
+
});
|
|
328
566
|
});
|
package/src/compose/union.mts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Arr,
|
|
3
|
+
expectType,
|
|
4
|
+
hasKey,
|
|
5
|
+
isRecord,
|
|
6
|
+
memoizeFunction,
|
|
7
|
+
Result,
|
|
8
|
+
} from 'ts-data-forge';
|
|
2
9
|
import type { ArrayElement, NonEmptyTuple, StrictPick } from 'ts-type-forge';
|
|
3
10
|
import {
|
|
4
11
|
flattenShapeStructure,
|
|
@@ -12,7 +19,6 @@ import {
|
|
|
12
19
|
import {
|
|
13
20
|
createAssertFn,
|
|
14
21
|
createCastFn,
|
|
15
|
-
createIsFn,
|
|
16
22
|
runtimeTypeNameOf,
|
|
17
23
|
toUnionString,
|
|
18
24
|
UNION_MEMBER_LISTING_MAX_LENGTH,
|
|
@@ -109,47 +115,71 @@ export const union = <const Types extends NonEmptyTuple<UnknownType>>(
|
|
|
109
115
|
*/
|
|
110
116
|
const memberTypes: readonly UnknownType[] = types.flatMap(unionMembersOf);
|
|
111
117
|
|
|
118
|
+
// Not derived from `validate`, whose failure path validates the members once
|
|
119
|
+
// more to build its report; a rejected value would pay for that at every
|
|
120
|
+
// level of nesting.
|
|
121
|
+
const is = (a: unknown): a is T => memberTypes.some((t) => t.is(a));
|
|
122
|
+
|
|
123
|
+
const memberTypeNames = types.map((t) => t.typeName);
|
|
124
|
+
|
|
125
|
+
// A listing short enough to print is the default report. It is not the best
|
|
126
|
+
// one when the value stands out as a near-miss of a single member — which is
|
|
127
|
+
// common once the members carry names, since names are what make a listing
|
|
128
|
+
// short — so the closest member is looked for either way.
|
|
129
|
+
const isListable =
|
|
130
|
+
toUnionString(memberTypeNames).length <= UNION_MEMBER_LISTING_MAX_LENGTH;
|
|
131
|
+
|
|
132
|
+
// A nested union is listed under its own name, which the closest member would
|
|
133
|
+
// replace with one of its members'.
|
|
134
|
+
const hasNestedUnion = types.some((t) => t.structure?.kind === 'union');
|
|
135
|
+
|
|
112
136
|
const validate: Type<T>['validate'] = (a) => {
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
return Result.ok(a as T);
|
|
137
|
+
if (is(a)) {
|
|
138
|
+
return Result.ok(a);
|
|
116
139
|
}
|
|
117
140
|
|
|
118
|
-
const
|
|
141
|
+
const header = {
|
|
142
|
+
path: [],
|
|
143
|
+
actualValue: a,
|
|
144
|
+
expectedType: typeNameFilled,
|
|
145
|
+
typeName: typeNameFilled,
|
|
146
|
+
} as const;
|
|
147
|
+
|
|
148
|
+
const listingError = {
|
|
149
|
+
...header,
|
|
150
|
+
details: {
|
|
151
|
+
kind: 'union',
|
|
152
|
+
typeNames: memberTypeNames,
|
|
153
|
+
},
|
|
154
|
+
} as const satisfies ValidationError;
|
|
155
|
+
|
|
156
|
+
if (isListable && hasNestedUnion) {
|
|
157
|
+
return Result.err([listingError]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Narrow the report down to the members whose runtime type category
|
|
161
|
+
// (derived from each member's default value) matches the value.
|
|
162
|
+
const actualCategory = runtimeTypeNameOf(a);
|
|
163
|
+
|
|
164
|
+
const candidateTypes = memberTypes.filter(
|
|
165
|
+
(t) => runtimeTypeNameOf(t.defaultValue) === actualCategory,
|
|
166
|
+
);
|
|
119
167
|
|
|
168
|
+
// Only a record or a tuple can stand out (see below), so without one the
|
|
169
|
+
// listing is known without validating the members again.
|
|
120
170
|
if (
|
|
121
|
-
|
|
171
|
+
isListable &&
|
|
172
|
+
candidateTypes.every((t) => checkedKeysOf(t) === undefined)
|
|
122
173
|
) {
|
|
123
|
-
return Result.err([
|
|
124
|
-
{
|
|
125
|
-
path: [],
|
|
126
|
-
actualValue: a,
|
|
127
|
-
expectedType: typeNameFilled,
|
|
128
|
-
typeName: typeNameFilled,
|
|
129
|
-
details: {
|
|
130
|
-
kind: 'union',
|
|
131
|
-
typeNames: memberTypeNames,
|
|
132
|
-
},
|
|
133
|
-
} satisfies ValidationError,
|
|
134
|
-
]);
|
|
174
|
+
return Result.err([listingError]);
|
|
135
175
|
}
|
|
136
176
|
|
|
137
|
-
|
|
138
|
-
// the report down to the members whose runtime type category (derived from
|
|
139
|
-
// each member's default value) matches the value.
|
|
140
|
-
const actualCategory = runtimeTypeNameOf(a);
|
|
141
|
-
|
|
142
|
-
const candidates = memberTypes
|
|
143
|
-
.filter((t) => runtimeTypeNameOf(t.defaultValue) === actualCategory)
|
|
144
|
-
.map((t) => evaluateMember(t, a));
|
|
177
|
+
const candidates = candidateTypes.map((t) => evaluateMember(t, a));
|
|
145
178
|
|
|
146
179
|
if (!Arr.isNonEmpty(candidates)) {
|
|
147
180
|
return Result.err([
|
|
148
181
|
{
|
|
149
|
-
|
|
150
|
-
actualValue: a,
|
|
151
|
-
expectedType: typeNameFilled,
|
|
152
|
-
typeName: typeNameFilled,
|
|
182
|
+
...header,
|
|
153
183
|
details: {
|
|
154
184
|
kind: 'union-category-mismatch',
|
|
155
185
|
memberCount: memberTypes.length,
|
|
@@ -176,12 +206,20 @@ export const union = <const Types extends NonEmptyTuple<UnknownType>>(
|
|
|
176
206
|
(c) => c !== closest && compareByCloseness(c, closest) === 0,
|
|
177
207
|
);
|
|
178
208
|
|
|
209
|
+
// When the listing can be printed, the closest member replaces it only if
|
|
210
|
+
// it stands out: no other member is as close, and the value has at least
|
|
211
|
+
// one key the member checks and accepts. Otherwise the listing says more
|
|
212
|
+
// than any one member would.
|
|
213
|
+
if (
|
|
214
|
+
isListable &&
|
|
215
|
+
(Arr.isNonEmpty(equallyClose) || acceptedKeyCountOf(closest, a) === 0)
|
|
216
|
+
) {
|
|
217
|
+
return Result.err([listingError]);
|
|
218
|
+
}
|
|
219
|
+
|
|
179
220
|
return Result.err(
|
|
180
221
|
Arr.toUnshifted({
|
|
181
|
-
|
|
182
|
-
actualValue: a,
|
|
183
|
-
expectedType: typeNameFilled,
|
|
184
|
-
typeName: typeNameFilled,
|
|
222
|
+
...header,
|
|
185
223
|
details: {
|
|
186
224
|
kind: 'union-closest-member',
|
|
187
225
|
memberCount: memberTypes.length,
|
|
@@ -192,8 +230,6 @@ export const union = <const Types extends NonEmptyTuple<UnknownType>>(
|
|
|
192
230
|
);
|
|
193
231
|
};
|
|
194
232
|
|
|
195
|
-
const is = createIsFn<T>(validate);
|
|
196
|
-
|
|
197
233
|
const fill: Type<T>['fill'] = (a) => (is(a) ? a : getDefaultSource().fill(a));
|
|
198
234
|
|
|
199
235
|
// Prunes with the first member type that matches the value.
|
|
@@ -242,28 +278,72 @@ export const union = <const Types extends NonEmptyTuple<UnknownType>>(
|
|
|
242
278
|
* rules were chosen against.
|
|
243
279
|
*/
|
|
244
280
|
type MemberCloseness = Readonly<{
|
|
281
|
+
memberType: UnknownType;
|
|
245
282
|
typeName: string;
|
|
246
283
|
errors: readonly ValidationError[];
|
|
247
284
|
satisfiedCheckCount: number;
|
|
248
285
|
score: number;
|
|
249
286
|
}>;
|
|
250
287
|
|
|
288
|
+
/**
|
|
289
|
+
* The keys of a record, or the indices of a tuple, that a member checks one by
|
|
290
|
+
* one; `undefined` for a member that checks the value as a whole.
|
|
291
|
+
*/
|
|
292
|
+
const checkedKeysOf = (
|
|
293
|
+
memberType: UnknownType,
|
|
294
|
+
): readonly string[] | undefined => {
|
|
295
|
+
const view = recordViewOf(memberType);
|
|
296
|
+
|
|
297
|
+
if (view !== undefined) {
|
|
298
|
+
const shape = flattenShapeStructure(view.shapeStructure);
|
|
299
|
+
|
|
300
|
+
return shape === undefined ? undefined : Object.keys(shape);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return tupleElementTypesOf(memberType)?.map((_, index) => index.toString());
|
|
304
|
+
};
|
|
305
|
+
|
|
251
306
|
/**
|
|
252
307
|
* How many checks a member performs on a value: one per key for a record, one
|
|
253
308
|
* per element for a tuple, and a single check for everything else, which either
|
|
254
309
|
* matches or does not. A record whose shape cannot be flattened to a single set
|
|
255
310
|
* of keys (a union of shapes) also counts as one check.
|
|
256
311
|
*/
|
|
257
|
-
const checkCountOf = (memberType: UnknownType): number =>
|
|
258
|
-
|
|
312
|
+
const checkCountOf = (memberType: UnknownType): number =>
|
|
313
|
+
checkedKeysOf(memberType)?.length ?? 1;
|
|
259
314
|
|
|
260
|
-
|
|
261
|
-
|
|
315
|
+
/** The value under a record key or a tuple index, if `a` has one. */
|
|
316
|
+
const valueAt = (a: unknown, key: string): unknown =>
|
|
317
|
+
Arr.isArray(a)
|
|
318
|
+
? a.find((_, index) => index.toString() === key)
|
|
319
|
+
: isRecord(a) && hasKey(a, key)
|
|
320
|
+
? a[key]
|
|
321
|
+
: undefined;
|
|
262
322
|
|
|
263
|
-
|
|
323
|
+
/**
|
|
324
|
+
* How many of the keys a member checks are present in the value and accepted.
|
|
325
|
+
*
|
|
326
|
+
* Unlike `satisfiedCheckCount`, this does not credit an optional key the value
|
|
327
|
+
* leaves out (or sets to `undefined`), nor count a key as failed twice because
|
|
328
|
+
* it reported two errors beneath it, so it tells whether the value resembles
|
|
329
|
+
* the member at all. An error about the value as a whole, such as a tuple of
|
|
330
|
+
* the wrong length, means the member checked no key of it.
|
|
331
|
+
*/
|
|
332
|
+
const acceptedKeyCountOf = (closeness: MemberCloseness, a: unknown): number => {
|
|
333
|
+
const keys = checkedKeysOf(closeness.memberType);
|
|
334
|
+
|
|
335
|
+
if (
|
|
336
|
+
keys === undefined ||
|
|
337
|
+
closeness.errors.some((e) => !Arr.isNonEmpty(e.path))
|
|
338
|
+
) {
|
|
339
|
+
return 0;
|
|
264
340
|
}
|
|
265
341
|
|
|
266
|
-
return
|
|
342
|
+
return keys.filter(
|
|
343
|
+
(key) =>
|
|
344
|
+
valueAt(a, key) !== undefined &&
|
|
345
|
+
closeness.errors.every((e) => e.path[0] !== key),
|
|
346
|
+
).length;
|
|
267
347
|
};
|
|
268
348
|
|
|
269
349
|
const validationErrorsOf = (
|
|
@@ -285,6 +365,7 @@ const evaluateMember = (
|
|
|
285
365
|
);
|
|
286
366
|
|
|
287
367
|
return {
|
|
368
|
+
memberType,
|
|
288
369
|
typeName: memberType.typeName,
|
|
289
370
|
errors,
|
|
290
371
|
satisfiedCheckCount,
|
|
@@ -362,9 +362,11 @@ const bareValueClause = (
|
|
|
362
362
|
/**
|
|
363
363
|
* Maximum length of the ` | `-joined listing of union member type names that a
|
|
364
364
|
* message may spell out. Beyond it a listing is more noise than help, so both
|
|
365
|
-
* users of this bound summarize instead: `union`
|
|
366
|
-
*
|
|
367
|
-
*
|
|
365
|
+
* users of this bound summarize instead: `union` reports the closest member, or
|
|
366
|
+
* the runtime types it accepts when no member is of the value's, rather than
|
|
367
|
+
* listing every member (within the bound, only a closest member that stands out
|
|
368
|
+
* replaces the listing), and the closest-member message stops naming the
|
|
369
|
+
* members that tie with it.
|
|
368
370
|
*/
|
|
369
371
|
export const UNION_MEMBER_LISTING_MAX_LENGTH = 60;
|
|
370
372
|
|