@sinclair/typebox 0.32.0-dev-14 → 0.32.0-dev-16
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/build/import/index.d.mts +12 -12
- package/build/import/index.mjs +5 -5
- package/build/import/type/array/array.d.mts +1 -1
- package/build/import/type/constructor/constructor.d.mts +4 -4
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +13 -0
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +14 -0
- package/build/import/type/exclude/exclude.d.mts +7 -4
- package/build/import/type/exclude/exclude.mjs +10 -4
- package/build/import/type/exclude/index.d.mts +1 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extends/extends-from-mapped-key.d.mts +17 -0
- package/build/import/type/extends/extends-from-mapped-key.mjs +21 -0
- package/build/import/type/extends/extends-from-mapped-result.d.mts +13 -0
- package/build/import/type/extends/extends-from-mapped-result.mjs +14 -0
- package/build/import/type/extends/extends.d.mts +4 -4
- package/build/import/type/extends/extends.mjs +5 -5
- package/build/import/type/extends/index.d.mts +2 -2
- package/build/import/type/extends/index.mjs +2 -2
- package/build/import/type/extract/extract-from-mapped-result.d.mts +13 -0
- package/build/import/type/extract/extract-from-mapped-result.mjs +14 -0
- package/build/import/type/extract/extract.d.mts +6 -3
- package/build/import/type/extract/extract.mjs +9 -3
- package/build/import/type/extract/index.d.mts +1 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/function/function.d.mts +4 -4
- package/build/import/type/indexed/index.d.mts +1 -1
- package/build/import/type/indexed/index.mjs +1 -1
- package/build/import/type/indexed/{indexed-mapped-result.d.mts → indexed-from-mapped-key.d.mts} +6 -6
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +18 -0
- package/build/import/type/indexed/indexed-result.d.mts +8 -8
- package/build/import/type/indexed/indexed-result.mjs +9 -8
- package/build/import/type/indexed/indexed.d.mts +2 -2
- package/build/import/type/indexed/indexed.mjs +5 -5
- package/build/import/type/intersect/index.d.mts +2 -0
- package/build/import/type/intersect/index.mjs +2 -0
- package/build/import/type/intersect/intersect-create.d.mts +3 -0
- package/build/import/type/intersect/intersect-create.mjs +12 -0
- package/build/import/type/intersect/intersect-evaluated.d.mts +16 -0
- package/build/import/type/intersect/intersect-evaluated.mjs +35 -0
- package/build/import/type/intersect/intersect-type.d.mts +15 -0
- package/build/import/type/intersect/intersect-type.mjs +1 -0
- package/build/import/type/intersect/intersect.d.mts +4 -20
- package/build/import/type/intersect/intersect.mjs +5 -17
- package/build/import/type/intrinsic/capitalize.mjs +1 -2
- package/build/import/type/intrinsic/index.d.mts +1 -1
- package/build/import/type/intrinsic/index.mjs +1 -1
- package/build/import/type/intrinsic/{intrinsic-mapped-result.d.mts → intrinsic-from-mapped-key.d.mts} +6 -5
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +21 -0
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -6
- package/build/import/type/intrinsic/intrinsic.mjs +8 -8
- package/build/import/type/intrinsic/lowercase.mjs +1 -2
- package/build/import/type/intrinsic/uncapitalize.mjs +1 -2
- package/build/import/type/intrinsic/uppercase.mjs +1 -2
- package/build/import/type/keyof/index.d.mts +1 -0
- package/build/import/type/keyof/index.mjs +1 -0
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +13 -0
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +14 -0
- package/build/import/type/keyof/keyof.d.mts +5 -2
- package/build/import/type/keyof/keyof.mjs +10 -3
- package/build/import/type/mapped/mapped.mjs +1 -2
- package/build/import/type/object/object.d.mts +5 -5
- package/build/import/type/omit/index.d.mts +1 -1
- package/build/import/type/omit/index.mjs +1 -1
- package/build/import/type/omit/omit-from-mapped-key.d.mts +15 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +20 -0
- package/build/import/type/omit/omit.d.mts +2 -2
- package/build/import/type/omit/omit.mjs +2 -2
- package/build/import/type/partial/index.d.mts +1 -0
- package/build/import/type/partial/index.mjs +1 -0
- package/build/import/type/partial/partial-from-mapped-result.d.mts +13 -0
- package/build/import/type/partial/partial-from-mapped-result.mjs +14 -0
- package/build/import/type/partial/partial.d.mts +5 -2
- package/build/import/type/partial/partial.mjs +11 -5
- package/build/import/type/pick/index.d.mts +1 -1
- package/build/import/type/pick/index.mjs +1 -1
- package/build/import/type/pick/pick-from-mapped-key.d.mts +15 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +20 -0
- package/build/import/type/pick/pick.d.mts +2 -2
- package/build/import/type/pick/pick.mjs +2 -2
- package/build/import/type/record/record.d.mts +0 -1
- package/build/import/type/record/record.mjs +1 -1
- package/build/import/type/recursive/recursive.d.mts +3 -2
- package/build/import/type/recursive/recursive.mjs +1 -5
- package/build/import/type/required/index.d.mts +1 -0
- package/build/import/type/required/index.mjs +1 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +13 -0
- package/build/import/type/required/required-from-mapped-result.mjs +14 -0
- package/build/import/type/required/required.d.mts +5 -2
- package/build/import/type/required/required.mjs +11 -5
- package/build/import/type/template-literal/syntax.d.mts +4 -4
- package/build/import/type/template-literal/template-literal.d.mts +4 -4
- package/build/import/type/transform/transform.d.mts +3 -2
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/tuple/tuple.d.mts +3 -3
- package/build/import/type/type/json.d.mts +25 -20
- package/build/import/type/type/json.mjs +3 -3
- package/build/import/type/union/index.d.mts +2 -0
- package/build/import/type/union/index.mjs +2 -0
- package/build/import/type/union/union-create.d.mts +3 -0
- package/build/import/type/union/union-create.mjs +5 -0
- package/build/import/type/union/union-evaluated.d.mts +16 -0
- package/build/import/type/union/union-evaluated.mjs +31 -0
- package/build/import/type/union/union-type.d.mts +12 -0
- package/build/import/type/union/union-type.mjs +1 -0
- package/build/import/type/union/union.d.mts +3 -13
- package/build/import/type/union/union.mjs +3 -10
- package/build/import/value/delta/delta.d.mts +1 -1
- package/build/require/index.d.ts +12 -12
- package/build/require/index.js +8 -3
- package/build/require/type/array/array.d.ts +1 -1
- package/build/require/type/constructor/constructor.d.ts +4 -4
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +13 -0
- package/build/require/type/exclude/exclude-from-mapped-result.js +18 -0
- package/build/require/type/exclude/exclude.d.ts +7 -4
- package/build/require/type/exclude/exclude.js +9 -4
- package/build/require/type/exclude/index.d.ts +1 -0
- package/build/require/type/exclude/index.js +1 -0
- package/build/require/type/extends/extends-from-mapped-key.d.ts +17 -0
- package/build/require/type/extends/extends-from-mapped-key.js +25 -0
- package/build/require/type/extends/extends-from-mapped-result.d.ts +13 -0
- package/build/require/type/extends/extends-from-mapped-result.js +18 -0
- package/build/require/type/extends/extends.d.ts +4 -4
- package/build/require/type/extends/extends.js +7 -7
- package/build/require/type/extends/index.d.ts +2 -2
- package/build/require/type/extends/index.js +2 -2
- package/build/require/type/extract/extract-from-mapped-result.d.ts +13 -0
- package/build/require/type/extract/extract-from-mapped-result.js +18 -0
- package/build/require/type/extract/extract.d.ts +6 -3
- package/build/require/type/extract/extract.js +8 -2
- package/build/require/type/extract/index.d.ts +1 -0
- package/build/require/type/extract/index.js +1 -0
- package/build/require/type/function/function.d.ts +4 -4
- package/build/require/type/indexed/index.d.ts +1 -1
- package/build/require/type/indexed/index.js +1 -1
- package/build/require/type/indexed/{indexed-mapped-result.d.ts → indexed-from-mapped-key.d.ts} +6 -6
- package/build/require/type/indexed/indexed-from-mapped-key.js +22 -0
- package/build/require/type/indexed/indexed-result.d.ts +8 -8
- package/build/require/type/indexed/indexed-result.js +14 -13
- package/build/require/type/indexed/indexed.d.ts +2 -2
- package/build/require/type/indexed/indexed.js +6 -6
- package/build/require/type/intersect/index.d.ts +2 -0
- package/build/require/type/intersect/index.js +2 -0
- package/build/require/type/intersect/intersect-create.d.ts +3 -0
- package/build/require/type/intersect/intersect-create.js +16 -0
- package/build/require/type/intersect/intersect-evaluated.d.ts +16 -0
- package/build/require/type/intersect/intersect-evaluated.js +39 -0
- package/build/require/type/intersect/intersect-type.d.ts +15 -0
- package/build/require/type/intersect/intersect-type.js +3 -0
- package/build/require/type/intersect/intersect.d.ts +4 -20
- package/build/require/type/intersect/intersect.js +5 -18
- package/build/require/type/intrinsic/capitalize.js +1 -2
- package/build/require/type/intrinsic/index.d.ts +1 -1
- package/build/require/type/intrinsic/index.js +1 -1
- package/build/require/type/intrinsic/{intrinsic-mapped-result.d.ts → intrinsic-from-mapped-key.d.ts} +6 -5
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +25 -0
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -6
- package/build/require/type/intrinsic/intrinsic.js +8 -8
- package/build/require/type/intrinsic/lowercase.js +1 -2
- package/build/require/type/intrinsic/uncapitalize.js +1 -2
- package/build/require/type/intrinsic/uppercase.js +1 -2
- package/build/require/type/keyof/index.d.ts +1 -0
- package/build/require/type/keyof/index.js +1 -0
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +13 -0
- package/build/require/type/keyof/keyof-from-mapped-result.js +18 -0
- package/build/require/type/keyof/keyof.d.ts +5 -2
- package/build/require/type/keyof/keyof.js +9 -2
- package/build/require/type/mapped/mapped.js +18 -19
- package/build/require/type/object/object.d.ts +5 -5
- package/build/require/type/omit/index.d.ts +1 -1
- package/build/require/type/omit/index.js +1 -1
- package/build/require/type/omit/omit-from-mapped-key.d.ts +15 -0
- package/build/require/type/omit/omit-from-mapped-key.js +24 -0
- package/build/require/type/omit/omit.d.ts +2 -2
- package/build/require/type/omit/omit.js +2 -2
- package/build/require/type/partial/index.d.ts +1 -0
- package/build/require/type/partial/index.js +1 -0
- package/build/require/type/partial/partial-from-mapped-result.d.ts +13 -0
- package/build/require/type/partial/partial-from-mapped-result.js +18 -0
- package/build/require/type/partial/partial.d.ts +5 -2
- package/build/require/type/partial/partial.js +10 -5
- package/build/require/type/pick/index.d.ts +1 -1
- package/build/require/type/pick/index.js +1 -1
- package/build/require/type/pick/pick-from-mapped-key.d.ts +15 -0
- package/build/require/type/pick/pick-from-mapped-key.js +24 -0
- package/build/require/type/pick/pick.d.ts +2 -2
- package/build/require/type/pick/pick.js +2 -2
- package/build/require/type/record/record.d.ts +0 -1
- package/build/require/type/record/record.js +1 -2
- package/build/require/type/recursive/recursive.d.ts +3 -2
- package/build/require/type/recursive/recursive.js +1 -5
- package/build/require/type/required/index.d.ts +1 -0
- package/build/require/type/required/index.js +1 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +13 -0
- package/build/require/type/required/required-from-mapped-result.js +18 -0
- package/build/require/type/required/required.d.ts +5 -2
- package/build/require/type/required/required.js +10 -5
- package/build/require/type/template-literal/syntax.d.ts +4 -4
- package/build/require/type/template-literal/template-literal.d.ts +4 -4
- package/build/require/type/transform/transform.d.ts +3 -2
- package/build/require/type/transform/transform.js +4 -4
- package/build/require/type/tuple/tuple.d.ts +3 -3
- package/build/require/type/type/json.d.ts +25 -20
- package/build/require/type/type/json.js +3 -3
- package/build/require/type/union/index.d.ts +2 -0
- package/build/require/type/union/index.js +2 -0
- package/build/require/type/union/union-create.d.ts +3 -0
- package/build/require/type/union/union-create.js +9 -0
- package/build/require/type/union/union-evaluated.d.ts +16 -0
- package/build/require/type/union/union-evaluated.js +35 -0
- package/build/require/type/union/union-type.d.ts +12 -0
- package/build/require/type/union/union-type.js +3 -0
- package/build/require/type/union/union.d.ts +3 -13
- package/build/require/type/union/union.js +3 -11
- package/build/require/value/delta/delta.d.ts +1 -1
- package/package.json +1 -1
- package/readme.md +97 -101
- package/build/import/type/extends/extends-mapped-result-from-result.d.mts +0 -13
- package/build/import/type/extends/extends-mapped-result-from-result.mjs +0 -14
- package/build/import/type/extends/extends-mapped-result.d.mts +0 -17
- package/build/import/type/extends/extends-mapped-result.mjs +0 -21
- package/build/import/type/indexed/indexed-mapped-result.mjs +0 -18
- package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +0 -21
- package/build/import/type/omit/omit-mapped-result.d.mts +0 -15
- package/build/import/type/omit/omit-mapped-result.mjs +0 -20
- package/build/import/type/pick/pick-mapped-result.d.mts +0 -15
- package/build/import/type/pick/pick-mapped-result.mjs +0 -20
- package/build/require/type/extends/extends-mapped-result-from-result.d.ts +0 -13
- package/build/require/type/extends/extends-mapped-result-from-result.js +0 -18
- package/build/require/type/extends/extends-mapped-result.d.ts +0 -17
- package/build/require/type/extends/extends-mapped-result.js +0 -25
- package/build/require/type/indexed/indexed-mapped-result.js +0 -22
- package/build/require/type/intrinsic/intrinsic-mapped-result.js +0 -25
- package/build/require/type/omit/omit-mapped-result.d.ts +0 -15
- package/build/require/type/omit/omit-mapped-result.js +0 -24
- package/build/require/type/pick/pick-mapped-result.d.ts +0 -15
- package/build/require/type/pick/pick-mapped-result.js +0 -24
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Required =
|
|
3
|
+
exports.Required = void 0;
|
|
4
4
|
const index_1 = require("../intersect/index");
|
|
5
5
|
const index_2 = require("../union/index");
|
|
6
6
|
const index_3 = require("../object/index");
|
|
7
7
|
const index_4 = require("../symbols/index");
|
|
8
8
|
const type_1 = require("../clone/type");
|
|
9
9
|
const index_5 = require("../discard/index");
|
|
10
|
+
const required_from_mapped_result_1 = require("./required-from-mapped-result");
|
|
10
11
|
const type_2 = require("../guard/type");
|
|
11
12
|
function FromIntersect(T) {
|
|
12
13
|
const [L, ...R] = T;
|
|
@@ -31,10 +32,14 @@ function RequiredResolve(T) {
|
|
|
31
32
|
(0, type_2.TObject)(T) ? (0, index_3.Object)(FromProperties(T.properties)) :
|
|
32
33
|
(0, index_3.Object)({}));
|
|
33
34
|
}
|
|
34
|
-
exports.RequiredResolve = RequiredResolve;
|
|
35
35
|
function Required(T, options = {}) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if ((0, type_2.TMappedResult)(T)) {
|
|
37
|
+
return (0, required_from_mapped_result_1.RequiredFromMappedResult)(T, options);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const D = (0, index_5.Discard)(T, [index_4.TransformKind, '$id', 'required']);
|
|
41
|
+
const R = (0, type_1.CloneType)(RequiredResolve(T), options);
|
|
42
|
+
return { ...D, ...R };
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
exports.Required = Required;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Assert, Trim } from '../helpers/index';
|
|
2
2
|
import type { TTemplateLiteralKind, TTemplateLiteral } from './index';
|
|
3
3
|
import { type TLiteral } from '../literal/index';
|
|
4
4
|
import { type TBoolean } from '../boolean/index';
|
|
5
5
|
import { type TBigInt } from '../bigint/index';
|
|
6
6
|
import { type TNumber } from '../number/index';
|
|
7
7
|
import { type TString } from '../string/index';
|
|
8
|
-
import {
|
|
8
|
+
import { UnionEvaluated } from '../union/index';
|
|
9
9
|
declare function FromUnion(syntax: string): IterableIterator<TTemplateLiteralKind>;
|
|
10
10
|
declare function FromTerminal(syntax: string): IterableIterator<TTemplateLiteralKind>;
|
|
11
11
|
type FromUnionLiteral<T extends string> = T extends `${infer L}|${infer R}` ? [TLiteral<Trim<L>>, ...FromUnionLiteral<R>] : T extends `${infer L}` ? [TLiteral<Trim<L>>] : [
|
|
12
12
|
];
|
|
13
|
-
type FromUnion<T extends string> =
|
|
13
|
+
type FromUnion<T extends string> = UnionEvaluated<FromUnionLiteral<T>>;
|
|
14
14
|
type FromTerminal<T extends string> = T extends 'boolean' ? TBoolean : T extends 'bigint' ? TBigInt : T extends 'number' ? TNumber : T extends 'string' ? TString : FromUnion<T>;
|
|
15
15
|
type FromString<T extends string> = T extends `{${infer L}}${infer R}` ? [FromTerminal<L>, ...FromString<R>] : T extends `${infer L}$${infer R}` ? [TLiteral<L>, ...FromString<R>] : T extends `${infer L}` ? [TLiteral<L>] : [
|
|
16
16
|
];
|
|
17
|
-
export type TemplateLiteralSyntax<T extends string> =
|
|
17
|
+
export type TemplateLiteralSyntax<T extends string> = (TTemplateLiteral<Assert<FromString<T>, TTemplateLiteralKind[]>>);
|
|
18
18
|
export declare function TemplateLiteralSyntax(syntax: string): TTemplateLiteralKind[];
|
|
19
19
|
export {};
|
|
@@ -12,14 +12,14 @@ import type { Static } from '../static/index';
|
|
|
12
12
|
import { TemplateLiteralSyntax } from './syntax';
|
|
13
13
|
import { EmptyString } from '../helpers/index';
|
|
14
14
|
import { Kind } from '../symbols/index';
|
|
15
|
-
type
|
|
16
|
-
[K in keyof U]:
|
|
15
|
+
type TemplateLiteralStaticKind<T, Acc extends string> = T extends TUnion<infer U> ? {
|
|
16
|
+
[K in keyof U]: TemplateLiteralStatic<Assert<[U[K]], TTemplateLiteralKind[]>, Acc>;
|
|
17
17
|
}[number] : T extends TTemplateLiteral ? `${Static<T>}` : T extends TLiteral<infer U> ? `${U}` : T extends TString ? `${string}` : T extends TNumber ? `${number}` : T extends TBigInt ? `${bigint}` : T extends TBoolean ? `${boolean}` : never;
|
|
18
|
-
|
|
18
|
+
type TemplateLiteralStatic<T extends TTemplateLiteralKind[], Acc extends string> = T extends [infer L, ...infer R] ? `${TemplateLiteralStaticKind<L, Acc>}${TemplateLiteralStatic<Assert<R, TTemplateLiteralKind[]>, Acc>}` : Acc;
|
|
19
19
|
export type TTemplateLiteralKind = TTemplateLiteral | TUnion | TLiteral | TInteger | TNumber | TBigInt | TString | TBoolean | TNever;
|
|
20
20
|
export interface TTemplateLiteral<T extends TTemplateLiteralKind[] = TTemplateLiteralKind[]> extends TSchema {
|
|
21
21
|
[Kind]: 'TemplateLiteral';
|
|
22
|
-
static:
|
|
22
|
+
static: TemplateLiteralStatic<T, EmptyString>;
|
|
23
23
|
type: 'string';
|
|
24
24
|
pattern: string;
|
|
25
25
|
}
|
|
@@ -14,15 +14,16 @@ export declare class TransformEncodeBuilder<T extends TSchema, D extends Transfo
|
|
|
14
14
|
private EncodeSchema;
|
|
15
15
|
Encode<E extends TransformFunction<ReturnType<D>, StaticDecode<T>>>(encode: E): TTransform<T, ReturnType<D>>;
|
|
16
16
|
}
|
|
17
|
+
type TransformStatic<T extends TSchema, P extends unknown[] = []> = T extends TTransform<infer _, infer S> ? S : Static<T, P>;
|
|
17
18
|
export type TransformFunction<T = any, U = any> = (value: T) => U;
|
|
18
19
|
export interface TransformOptions<I extends TSchema = TSchema, O extends unknown = unknown> {
|
|
19
20
|
Decode: TransformFunction<StaticDecode<I>, O>;
|
|
20
21
|
Encode: TransformFunction<O, StaticDecode<I>>;
|
|
21
22
|
}
|
|
22
|
-
export type TTransformResolve<T extends TSchema, P extends unknown[] = []> = T extends TTransform<infer _, infer S> ? S : Static<T, P>;
|
|
23
23
|
export interface TTransform<I extends TSchema = TSchema, O extends unknown = unknown> extends TSchema {
|
|
24
|
-
static:
|
|
24
|
+
static: TransformStatic<I, this['params']>;
|
|
25
25
|
[TransformKind]: TransformOptions<I, O>;
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
}
|
|
28
28
|
export declare function Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>;
|
|
29
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Transform = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = void 0;
|
|
4
|
-
const type_1 = require("../
|
|
5
|
-
const type_2 = require("../clone/type");
|
|
4
|
+
const type_1 = require("../clone/type");
|
|
6
5
|
const index_1 = require("../symbols/index");
|
|
6
|
+
const type_2 = require("../guard/type");
|
|
7
7
|
class TransformDecodeBuilder {
|
|
8
8
|
constructor(schema) {
|
|
9
9
|
this.schema = schema;
|
|
@@ -29,8 +29,8 @@ class TransformEncodeBuilder {
|
|
|
29
29
|
return { ...schema, [index_1.TransformKind]: Codec };
|
|
30
30
|
}
|
|
31
31
|
Encode(encode) {
|
|
32
|
-
const schema = (0,
|
|
33
|
-
return ((0,
|
|
32
|
+
const schema = (0, type_1.CloneType)(this.schema);
|
|
33
|
+
return ((0, type_2.TTransform)(schema) ? this.EncodeTransform(encode, schema) : this.EncodeSchema(encode, schema));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.TransformEncodeBuilder = TransformEncodeBuilder;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import { Kind } from '../symbols/index';
|
|
4
|
-
type
|
|
5
|
-
type
|
|
4
|
+
type TupleStaticRest<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TupleStaticRest<R, P>] : [];
|
|
5
|
+
type TupleStatic<T extends TSchema[], P extends unknown[], R extends unknown[] = TupleStaticRest<T, P>> = R;
|
|
6
6
|
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
7
7
|
[Kind]: 'Tuple';
|
|
8
|
-
static:
|
|
8
|
+
static: TupleStatic<T, this['params']>;
|
|
9
9
|
type: 'array';
|
|
10
10
|
items?: T;
|
|
11
11
|
additionalItems?: false;
|
|
@@ -5,14 +5,14 @@ import { type TComposite } from '../composite/index';
|
|
|
5
5
|
import { type TConst } from '../const/index';
|
|
6
6
|
import { type TDeref } from '../deref/index';
|
|
7
7
|
import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index';
|
|
8
|
-
import { type TExclude } from '../exclude/index';
|
|
9
|
-
import { type TExtends, type
|
|
10
|
-
import { type TExtract } from '../extract/index';
|
|
11
|
-
import { TIndex, type TIndexPropertyKeys, type
|
|
8
|
+
import { type TExclude, type TExcludeFromMappedResult } from '../exclude/index';
|
|
9
|
+
import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index';
|
|
10
|
+
import { type TExtract, type TExtractFromMappedResult } from '../extract/index';
|
|
11
|
+
import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from '../indexed/index';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index';
|
|
13
|
-
import {
|
|
13
|
+
import { Intersect, type IntersectOptions } from '../intersect/index';
|
|
14
14
|
import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index';
|
|
15
|
-
import { type TKeyOf } from '../keyof/index';
|
|
15
|
+
import { type TKeyOf, type TKeyOfFromMappedResult } from '../keyof/index';
|
|
16
16
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
17
17
|
import { type TMappedFunction, type TMapped, type TMappedResult } from '../mapped/index';
|
|
18
18
|
import { type TNever } from '../never/index';
|
|
@@ -21,23 +21,23 @@ import { type TNull } from '../null/index';
|
|
|
21
21
|
import { type TMappedKey } from '../mapped/index';
|
|
22
22
|
import { type TNumber, type NumberOptions } from '../number/index';
|
|
23
23
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
24
|
-
import { type TOmit, type
|
|
24
|
+
import { type TOmit, type TOmitFromMappedKey } from '../omit/index';
|
|
25
25
|
import { type TOptional } from '../optional/index';
|
|
26
|
-
import { type TPartial } from '../partial/index';
|
|
27
|
-
import { type TPick, type
|
|
26
|
+
import { type TPartial, type TPartialFromMappedResult } from '../partial/index';
|
|
27
|
+
import { type TPick, type TPickFromMappedKey } from '../pick/index';
|
|
28
28
|
import { type TReadonly } from '../readonly/index';
|
|
29
29
|
import { type TReadonlyOptional } from '../readonly-optional/index';
|
|
30
30
|
import { type RecordResolve } from '../record/index';
|
|
31
31
|
import { type TRecursive, type TThis } from '../recursive/index';
|
|
32
32
|
import { type TRef } from '../ref/index';
|
|
33
|
-
import { type TRequired } from '../required/index';
|
|
33
|
+
import { type TRequired, type TRequiredFromMappedResult } from '../required/index';
|
|
34
34
|
import { type TRest } from '../rest/index';
|
|
35
35
|
import { type TSchema, type SchemaOptions } from '../schema/index';
|
|
36
36
|
import { type TString, type StringOptions } from '../string/index';
|
|
37
37
|
import { type TTemplateLiteral, type TTemplateLiteralKind, type TemplateLiteralSyntax } from '../template-literal/index';
|
|
38
38
|
import { TransformDecodeBuilder } from '../transform/index';
|
|
39
39
|
import { type TTuple } from '../tuple/index';
|
|
40
|
-
import {
|
|
40
|
+
import { Union } from '../union/index';
|
|
41
41
|
import { type TUnknown } from '../unknown/index';
|
|
42
42
|
import { type TUnsafe, type UnsafeOptions } from '../unsafe/index';
|
|
43
43
|
export declare class JsonTypeBuilder {
|
|
@@ -53,16 +53,19 @@ export declare class JsonTypeBuilder {
|
|
|
53
53
|
Const<T>(value: T, options?: SchemaOptions): TConst<T>;
|
|
54
54
|
Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
|
|
55
55
|
Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
56
|
-
|
|
57
|
-
Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsMappedResult<L, R, T, F>;
|
|
58
|
-
Extends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtends<L, R, T, F>;
|
|
56
|
+
Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
59
57
|
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
58
|
+
Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
59
|
+
Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedKey<L, R, T, F>;
|
|
60
|
+
Extends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtends<L, R, T, F>;
|
|
61
|
+
Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
60
62
|
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
61
|
-
Index<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
63
|
+
Index<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedKey<T, K>;
|
|
62
64
|
Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
|
|
63
65
|
Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
64
66
|
Integer(options?: IntegerOptions): TInteger;
|
|
65
|
-
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions):
|
|
67
|
+
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): Intersect<T>;
|
|
68
|
+
KeyOf<T extends TMappedResult>(schema: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
|
|
66
69
|
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
67
70
|
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
68
71
|
Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TLowercase<T>;
|
|
@@ -73,18 +76,20 @@ export declare class JsonTypeBuilder {
|
|
|
73
76
|
Null(options?: SchemaOptions): TNull;
|
|
74
77
|
Number(options?: NumberOptions): TNumber;
|
|
75
78
|
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
76
|
-
Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
79
|
+
Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
|
|
77
80
|
Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
78
81
|
Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
|
|
82
|
+
Partial<T extends TMappedResult>(T: T, options?: ObjectOptions): TPartialFromMappedResult<T>;
|
|
79
83
|
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
80
|
-
Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
84
|
+
Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
|
|
81
85
|
Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
82
86
|
Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
83
87
|
Record<K extends TSchema, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): RecordResolve<K, T>;
|
|
84
88
|
Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
|
|
85
89
|
Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
|
|
86
90
|
Ref<T extends TSchema>($ref: string, options?: SchemaOptions): TRef<T>;
|
|
87
|
-
Required<T extends
|
|
91
|
+
Required<T extends TMappedResult>(T: T, options?: ObjectOptions): TRequiredFromMappedResult<T>;
|
|
92
|
+
Required<T extends TSchema>(schema: T, options?: ObjectOptions): TRequired<T>;
|
|
88
93
|
Rest<T extends TSchema>(schema: T): TRest<T>;
|
|
89
94
|
String(options?: StringOptions): TString;
|
|
90
95
|
TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TemplateLiteralSyntax<T>;
|
|
@@ -92,7 +97,7 @@ export declare class JsonTypeBuilder {
|
|
|
92
97
|
Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>;
|
|
93
98
|
Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
94
99
|
Uncapitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TUncapitalize<T>;
|
|
95
|
-
Union<T extends TSchema[]>(schemas: [...T], options?: SchemaOptions):
|
|
100
|
+
Union<T extends TSchema[]>(schemas: [...T], options?: SchemaOptions): Union<T>;
|
|
96
101
|
Unknown(options?: SchemaOptions): TUnknown;
|
|
97
102
|
Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
|
|
98
103
|
Uppercase<T extends TSchema>(schema: T, options?: SchemaOptions): TUppercase<T>;
|
|
@@ -79,12 +79,12 @@ class JsonTypeBuilder {
|
|
|
79
79
|
Enum(item, options = {}) {
|
|
80
80
|
return (0, index_7.Enum)(item, options);
|
|
81
81
|
}
|
|
82
|
-
Extends(L, R, T, F, options = {}) {
|
|
83
|
-
return (0, index_9.Extends)(L, R, T, F, options);
|
|
84
|
-
}
|
|
85
82
|
Exclude(unionType, excludedMembers, options = {}) {
|
|
86
83
|
return (0, index_8.Exclude)(unionType, excludedMembers, options);
|
|
87
84
|
}
|
|
85
|
+
Extends(L, R, T, F, options = {}) {
|
|
86
|
+
return (0, index_9.Extends)(L, R, T, F, options);
|
|
87
|
+
}
|
|
88
88
|
Extract(type, union, options = {}) {
|
|
89
89
|
return (0, index_10.Extract)(type, union, options);
|
|
90
90
|
}
|
|
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./union-evaluated"), exports);
|
|
18
|
+
__exportStar(require("./union-type"), exports);
|
|
17
19
|
__exportStar(require("./union"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionCreate = void 0;
|
|
4
|
+
const type_1 = require("../clone/type");
|
|
5
|
+
const index_1 = require("../symbols/index");
|
|
6
|
+
function UnionCreate(T, options) {
|
|
7
|
+
return { ...options, [index_1.Kind]: 'Union', anyOf: (0, type_1.CloneRest)(T) };
|
|
8
|
+
}
|
|
9
|
+
exports.UnionCreate = UnionCreate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaOptions, TSchema } from '../schema/index';
|
|
2
|
+
import { type TNever } from '../never/index';
|
|
3
|
+
import { type TOptional } from '../optional/index';
|
|
4
|
+
import type { TReadonly } from '../readonly/index';
|
|
5
|
+
import type { TUnion } from './union-type';
|
|
6
|
+
type IsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : IsUnionOptional<R> : false);
|
|
7
|
+
declare function IsUnionOptional<T extends TSchema[]>(T: T): IsUnionOptional<T>;
|
|
8
|
+
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
9
|
+
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
10
|
+
type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
|
|
11
|
+
declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
|
|
12
|
+
type ResolveUnion<T extends TSchema[], R extends TSchema[] = RemoveOptionalFromRest<T>> = (IsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
|
|
13
|
+
declare function ResolveUnion<T extends TSchema[]>(T: T, options: SchemaOptions): ResolveUnion<T>;
|
|
14
|
+
export type UnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveUnion<T>);
|
|
15
|
+
export declare function UnionEvaluated<T extends TSchema[], R = UnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionEvaluated = void 0;
|
|
4
|
+
const index_1 = require("../symbols/index");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
const index_2 = require("../discard/index");
|
|
7
|
+
const index_3 = require("../never/index");
|
|
8
|
+
const index_4 = require("../optional/index");
|
|
9
|
+
const union_create_1 = require("./union-create");
|
|
10
|
+
const type_2 = require("../guard/type");
|
|
11
|
+
function IsUnionOptional(T) {
|
|
12
|
+
const [L, ...R] = T;
|
|
13
|
+
return (T.length > 0
|
|
14
|
+
? (0, type_2.TOptional)(L)
|
|
15
|
+
? true
|
|
16
|
+
: IsUnionOptional(R)
|
|
17
|
+
: false);
|
|
18
|
+
}
|
|
19
|
+
function RemoveOptionalFromRest(T) {
|
|
20
|
+
return (T.map(T => RemoveOptionalFromType(T)));
|
|
21
|
+
}
|
|
22
|
+
function RemoveOptionalFromType(T) {
|
|
23
|
+
return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
|
|
24
|
+
}
|
|
25
|
+
function ResolveUnion(T, options) {
|
|
26
|
+
return (IsUnionOptional(T)
|
|
27
|
+
? (0, index_4.Optional)((0, union_create_1.UnionCreate)(RemoveOptionalFromRest(T), options))
|
|
28
|
+
: (0, union_create_1.UnionCreate)(RemoveOptionalFromRest(T), options));
|
|
29
|
+
}
|
|
30
|
+
function UnionEvaluated(T, options = {}) {
|
|
31
|
+
return (T.length === 0 ? (0, index_3.Never)(options) :
|
|
32
|
+
T.length === 1 ? (0, type_1.CloneType)(T[0], options) :
|
|
33
|
+
ResolveUnion(T, options));
|
|
34
|
+
}
|
|
35
|
+
exports.UnionEvaluated = UnionEvaluated;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
|
+
import type { Static } from '../static/index';
|
|
3
|
+
import { Kind } from '../symbols/index';
|
|
4
|
+
type UnionStatic<T extends TSchema[], P extends unknown[]> = {
|
|
5
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
|
|
6
|
+
}[number];
|
|
7
|
+
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
8
|
+
[Kind]: 'Union';
|
|
9
|
+
static: UnionStatic<T, this['params']>;
|
|
10
|
+
anyOf: T;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import type { Static } from '../static/index';
|
|
3
2
|
import { type TNever } from '../never/index';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export declare function UnionResolve<T extends TSchema[]>(T: [...T]): UnionResolve<T>;
|
|
8
|
-
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
9
|
-
[Kind]: 'Union';
|
|
10
|
-
static: {
|
|
11
|
-
[K in keyof T]: T[K] extends TSchema ? Static<T[K], this['params']> : never;
|
|
12
|
-
}[number];
|
|
13
|
-
anyOf: T;
|
|
14
|
-
}
|
|
15
|
-
export declare function Union<T extends TSchema[]>(T: [...T], options?: SchemaOptions): UnionResolve<T>;
|
|
3
|
+
import type { TUnion } from './union-type';
|
|
4
|
+
export type Union<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TUnion<T>);
|
|
5
|
+
export declare function Union<T extends TSchema[]>(T: [...T], options?: SchemaOptions): Union<T>;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Union =
|
|
3
|
+
exports.Union = void 0;
|
|
4
4
|
const index_1 = require("../never/index");
|
|
5
|
-
const index_2 = require("../modifiers/index");
|
|
6
5
|
const type_1 = require("../clone/type");
|
|
7
|
-
const
|
|
8
|
-
function UnionResolve(T) {
|
|
9
|
-
return (T.length === 0 ? (0, index_1.Never)() :
|
|
10
|
-
T.length === 1 ? T[0] :
|
|
11
|
-
(0, index_2.OptionalFromUnion)(T));
|
|
12
|
-
}
|
|
13
|
-
exports.UnionResolve = UnionResolve;
|
|
6
|
+
const union_create_1 = require("./union-create");
|
|
14
7
|
function Union(T, options = {}) {
|
|
15
8
|
return (T.length === 0 ? (0, index_1.Never)(options) :
|
|
16
9
|
T.length === 1 ? (0, type_1.CloneType)(T[0], options) :
|
|
17
|
-
|
|
18
|
-
});
|
|
10
|
+
(0, union_create_1.UnionCreate)(T, options));
|
|
19
11
|
}
|
|
20
12
|
exports.Union = Union;
|
|
@@ -17,7 +17,7 @@ export declare const Delete: import("../../type/object/object").TObject<{
|
|
|
17
17
|
path: import("../../type/string/string").TString;
|
|
18
18
|
}>;
|
|
19
19
|
export type Edit = Static<typeof Edit>;
|
|
20
|
-
export declare const Edit: import("../../type/union/union").TUnion<[import("../../type/object/object").TObject<{
|
|
20
|
+
export declare const Edit: import("../../type/union/union-type").TUnion<[import("../../type/object/object").TObject<{
|
|
21
21
|
type: import("../../type/literal/literal").TLiteral<"insert">;
|
|
22
22
|
path: import("../../type/string/string").TString;
|
|
23
23
|
value: import("../../type/unknown/unknown").TUnknown;
|