typebox 1.0.53 → 1.0.54
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/schema/static/additionalProperties.d.mts +2 -2
- package/build/schema/static/allOf.d.mts +1 -1
- package/build/schema/static/anyOf.d.mts +1 -1
- package/build/schema/static/items.d.mts +3 -3
- package/build/schema/static/oneOf.d.mts +1 -1
- package/build/schema/static/patternProperties.d.mts +2 -2
- package/build/schema/static/prefixItems.d.mts +1 -1
- package/build/schema/static/properties.d.mts +5 -5
- package/build/schema/static/ref.d.mts +15 -0
- package/build/schema/static/ref.mjs +2 -0
- package/build/schema/static/required.d.mts +3 -3
- package/build/schema/static/schema.d.mts +15 -12
- package/build/schema/static/static.d.mts +1 -1
- package/build/schema/static/unevaluatedProperties.d.mts +2 -2
- package/build/schema/static/~elements.d.mts +4 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticAdditionalProperties<Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
3
|
+
export type XStaticAdditionalProperties<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
4
4
|
[key: string]: unknown;
|
|
5
5
|
} : Schema extends false ? {} : {
|
|
6
|
-
[key: string]: XStaticSchema<Schema>;
|
|
6
|
+
[key: string]: XStaticSchema<Stack, Root, Schema>;
|
|
7
7
|
})> = Result;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticAllOf<Schemas extends XSchema[], Result extends unknown = unknown> = (Schemas extends readonly [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAllOf<Right, Result & XStaticSchema<Left>> : Result);
|
|
3
|
+
export type XStaticAllOf<Stack extends string[], Root extends XSchema, Schemas extends XSchema[], Result extends unknown = unknown> = (Schemas extends readonly [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAllOf<Stack, Root, Right, Result & XStaticSchema<Stack, Root, Left>> : Result);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticAnyOf<Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAnyOf<Right, XStaticSchema<Left> | Result> : Result);
|
|
3
|
+
export type XStaticAnyOf<Stack extends string[], Root extends XSchema, Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAnyOf<Stack, Root, Right, XStaticSchema<Stack, Root, Left> | Result> : Result);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
3
|
import type { XStaticElements } from './~elements.mjs';
|
|
4
|
-
type TFromSized<Schema extends XSchema, Items extends XSchema[]> = (XStaticElements<Schema, Items>);
|
|
5
|
-
type TFromUnsized<Schema extends XSchema> = (XStaticSchema<Schema>[]);
|
|
6
|
-
export type XStaticItems<Schema extends XSchema, Items extends XSchema[] | XSchema, Result extends unknown = (Items extends XSchema[] ? TFromSized<Schema, [...Items]> : Items extends XSchema ? TFromUnsized<Items> : never)> = Result;
|
|
4
|
+
type TFromSized<Stack extends string[], Root extends XSchema, Schema extends XSchema, Items extends XSchema[]> = (XStaticElements<Stack, Root, Schema, Items>);
|
|
5
|
+
type TFromUnsized<Stack extends string[], Root extends XSchema, Schema extends XSchema> = (XStaticSchema<Stack, Root, Schema>[]);
|
|
6
|
+
export type XStaticItems<Stack extends string[], Root extends XSchema, Schema extends XSchema, Items extends XSchema[] | XSchema, Result extends unknown = (Items extends XSchema[] ? TFromSized<Stack, Root, Schema, [...Items]> : Items extends XSchema ? TFromUnsized<Stack, Root, Items> : never)> = Result;
|
|
7
7
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticOneOf<Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticOneOf<Right, XStaticSchema<Left> | Result> : Result);
|
|
3
|
+
export type XStaticOneOf<Stack extends string[], Root extends XSchema, Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticOneOf<Stack, Root, Right, XStaticSchema<Stack, Root, Left> | Result> : Result);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticPatternProperties<Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>, InferredProperties extends Record<PropertyKey, unknown> = {
|
|
4
|
-
[Key in keyof Properties]: XStaticSchema<Properties[Key]>;
|
|
3
|
+
export type XStaticPatternProperties<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>, InferredProperties extends Record<PropertyKey, unknown> = {
|
|
4
|
+
[Key in keyof Properties]: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
5
5
|
}, EvaluatedProperties extends unknown = {
|
|
6
6
|
[key: string]: InferredProperties[keyof InferredProperties];
|
|
7
7
|
}> = EvaluatedProperties;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticElements } from './~elements.mjs';
|
|
3
|
-
export type XStaticPrefixItems<Schema extends XSchema, PrefixItems extends XSchema[], Result extends unknown[] = XStaticElements<Schema, PrefixItems>> = Result;
|
|
3
|
+
export type XStaticPrefixItems<Stack extends string[], Root extends XSchema, Schema extends XSchema, PrefixItems extends XSchema[], Result extends unknown[] = XStaticElements<Stack, Root, Schema, PrefixItems>> = Result;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
3
|
import type { TIsReadonly } from './~readonly.mjs';
|
|
4
|
-
type TReadonlyOptionalProperties<Properties extends Record<PropertyKey, XSchema>> = {
|
|
5
|
-
readonly [Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? Key : never]?: XStaticSchema<Properties[Key]>;
|
|
4
|
+
type TReadonlyOptionalProperties<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema>> = {
|
|
5
|
+
readonly [Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? Key : never]?: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
6
6
|
};
|
|
7
|
-
type TOptionalProperties<Properties extends Record<PropertyKey, XSchema>> = {
|
|
8
|
-
[Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? never : Key]?: XStaticSchema<Properties[Key]>;
|
|
7
|
+
type TOptionalProperties<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema>> = {
|
|
8
|
+
[Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? never : Key]?: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
9
9
|
};
|
|
10
|
-
export type XStaticProperties<Properties extends Record<PropertyKey, XSchema>, ReadonlyOptional extends Record<PropertyKey, unknown> = TReadonlyOptionalProperties<Properties>, Optional extends Record<PropertyKey, unknown> = TOptionalProperties<Properties>, Result extends Record<PropertyKey, unknown> = ReadonlyOptional & Optional> = Result;
|
|
10
|
+
export type XStaticProperties<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema>, ReadonlyOptional extends Record<PropertyKey, unknown> = TReadonlyOptionalProperties<Stack, Root, Properties>, Optional extends Record<PropertyKey, unknown> = TOptionalProperties<Stack, Root, Properties>, Result extends Record<PropertyKey, unknown> = ReadonlyOptional & Optional> = Result;
|
|
11
11
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { XSchema } from '../types/schema.mjs';
|
|
2
|
+
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
+
type CyclicStackLength<Stack extends unknown[], MaxLength extends number, Buffer extends unknown[] = []> = (Stack extends [infer Left, ...infer Right] ? Buffer['length'] extends MaxLength ? false : CyclicStackLength<Right, MaxLength, [...Buffer, Left]> : true);
|
|
4
|
+
type CyclicGuard<Stack extends unknown[], Ref extends string> = (Ref extends Stack[number] ? CyclicStackLength<Stack, 2> : true);
|
|
5
|
+
type TNormal<Pointer extends string> = (Pointer extends `#${infer Rest extends string}` ? Rest : Pointer);
|
|
6
|
+
type TEscape0<Index extends string> = (Index extends `${infer Left}~0${infer Right}` ? `${Left}~${TEscape<Right>}` : Index);
|
|
7
|
+
type TEscape1<Index extends string> = (Index extends `${infer Left}~1${infer Right}` ? `${Left}/${TEscape<Right>}` : Index);
|
|
8
|
+
type TEscape<Index extends string, Escaped0 extends string = TEscape0<Index>, Escaped1 extends string = TEscape1<Escaped0>> = Escaped1;
|
|
9
|
+
type IndicesReduce<Pointer extends string, Result extends string[] = []> = (Pointer extends `${infer Left extends string}/${infer Right extends string}` ? Left extends '' ? IndicesReduce<Right, Result> : IndicesReduce<Right, [...Result, TEscape<Left>]> : [...Result, TEscape<Pointer>]);
|
|
10
|
+
type TIndices<Pointer extends string, Normal extends string = TNormal<Pointer>, Result extends string[] = Normal extends '' ? [] : IndicesReduce<Normal>> = Result;
|
|
11
|
+
type TResolveReducer<Schema extends unknown, Indices extends string[]> = (Indices extends [infer Left extends string, ...infer Right extends string[]] ? Left extends keyof Schema ? TResolveReducer<Schema[Left], Right> : {} : Schema);
|
|
12
|
+
type TResolveRef<Schema extends unknown, Ref extends string, Indices extends string[] = TIndices<Ref>, // as pointer
|
|
13
|
+
Target extends unknown = TResolveReducer<Schema, Indices>, Result extends XSchema = Target extends XSchema ? Target : {}> = Result;
|
|
14
|
+
export type XStaticRef<Stack extends string[], Root extends XSchema, Ref extends string, Schema extends XSchema = TResolveRef<Root, Ref>, Result extends unknown = (CyclicGuard<Stack, Ref> extends true ? XStaticSchema<[...Stack, Ref], Root, Schema> : any)> = Result;
|
|
15
|
+
export {};
|
|
@@ -3,11 +3,11 @@ import type { XProperties } from '../types/properties.mjs';
|
|
|
3
3
|
import type { TIsReadonly } from './~readonly.mjs';
|
|
4
4
|
import type { XStaticSchema } from './schema.mjs';
|
|
5
5
|
type TResolveProperties<Schema extends XSchema, Result extends Record<PropertyKey, XSchema> = (Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? Properties : {})> = Result;
|
|
6
|
-
type TFromKey<Properties extends Record<PropertyKey, XSchema>, Key extends string, Readonly extends boolean = Key extends keyof Properties ? TIsReadonly<Properties[Key]> : false, Value extends unknown = Key extends keyof Properties ? XStaticSchema<Properties[Key]> : unknown, Result extends Record<PropertyKey, unknown> = (Readonly extends true ? {
|
|
6
|
+
type TFromKey<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema>, Key extends string, Readonly extends boolean = Key extends keyof Properties ? TIsReadonly<Properties[Key]> : false, Value extends unknown = Key extends keyof Properties ? XStaticSchema<Stack, Root, Properties[Key]> : unknown, Result extends Record<PropertyKey, unknown> = (Readonly extends true ? {
|
|
7
7
|
readonly [_ in Key]: Value;
|
|
8
8
|
} : {
|
|
9
9
|
[_ in Key]: Value;
|
|
10
10
|
})> = Result;
|
|
11
|
-
type TFromKeys<Properties extends Record<PropertyKey, XSchema>, Keys extends string[], Result extends Record<PropertyKey, unknown> = {}> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? TFromKeys<Properties, Right, Result & TFromKey<Properties, Left>> : Result);
|
|
12
|
-
export type XStaticRequired<Schema extends XSchema, Keys extends string[], Properties extends Record<PropertyKey, XSchema> = TResolveProperties<Schema>, Result extends Record<PropertyKey, unknown> = TFromKeys<Properties, Keys>> = Result;
|
|
11
|
+
type TFromKeys<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema>, Keys extends string[], Result extends Record<PropertyKey, unknown> = {}> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? TFromKeys<Stack, Root, Properties, Right, Result & TFromKey<Stack, Root, Properties, Left>> : Result);
|
|
12
|
+
export type XStaticRequired<Stack extends string[], Root extends XSchema, Schema extends XSchema, Keys extends string[], Properties extends Record<PropertyKey, XSchema> = TResolveProperties<Schema>, Result extends Record<PropertyKey, unknown> = TFromKeys<Stack, Root, Properties, Keys>> = Result;
|
|
13
13
|
export {};
|
|
@@ -8,6 +8,7 @@ import type { XOneOf } from '../types/oneOf.mjs';
|
|
|
8
8
|
import type { XPatternProperties } from '../types/patternProperties.mjs';
|
|
9
9
|
import type { XPrefixItems } from '../types/prefixItems.mjs';
|
|
10
10
|
import type { XProperties } from '../types/properties.mjs';
|
|
11
|
+
import type { XRef } from '../types/ref.mjs';
|
|
11
12
|
import type { XRequired } from '../types/required.mjs';
|
|
12
13
|
import type { XSchema } from '../types/schema.mjs';
|
|
13
14
|
import type { XType } from '../types/type.mjs';
|
|
@@ -22,27 +23,29 @@ import type { XStaticOneOf } from './oneOf.mjs';
|
|
|
22
23
|
import type { XStaticPatternProperties } from './patternProperties.mjs';
|
|
23
24
|
import type { XStaticPrefixItems } from './prefixItems.mjs';
|
|
24
25
|
import type { XStaticProperties } from './properties.mjs';
|
|
26
|
+
import type { XStaticRef } from './ref.mjs';
|
|
25
27
|
import type { XStaticRequired } from './required.mjs';
|
|
26
28
|
import type { XStaticType } from './type.mjs';
|
|
27
29
|
import type { XStaticUnevaluatedProperties } from './unevaluatedProperties.mjs';
|
|
28
|
-
type TFromKeywords<Schema, Result extends unknown[] = [
|
|
29
|
-
Schema extends XAdditionalProperties<infer Type extends XSchema> ? XStaticAdditionalProperties<Type> : unknown,
|
|
30
|
-
Schema extends XAllOf<infer Types extends XSchema[]> ? XStaticAllOf<Types> : unknown,
|
|
31
|
-
Schema extends XAnyOf<infer Types extends XSchema[]> ? XStaticAnyOf<Types> : unknown,
|
|
30
|
+
type TFromKeywords<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends unknown[] = [
|
|
31
|
+
Schema extends XAdditionalProperties<infer Type extends XSchema> ? XStaticAdditionalProperties<Stack, Root, Type> : unknown,
|
|
32
|
+
Schema extends XAllOf<infer Types extends XSchema[]> ? XStaticAllOf<Stack, Root, Types> : unknown,
|
|
33
|
+
Schema extends XAnyOf<infer Types extends XSchema[]> ? XStaticAnyOf<Stack, Root, Types> : unknown,
|
|
32
34
|
Schema extends XConst<infer Value extends unknown> ? XStaticConst<Value> : unknown,
|
|
33
35
|
Schema extends XEnum<infer Values extends unknown[]> ? XStaticEnum<Values> : unknown,
|
|
34
|
-
Schema extends XItems<infer Types extends XSchema[] | XSchema> ? XStaticItems<Schema, Types> : unknown,
|
|
35
|
-
Schema extends XOneOf<infer Types extends XSchema[]> ? XStaticOneOf<Types> : unknown,
|
|
36
|
-
Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticPatternProperties<Properties> : unknown,
|
|
37
|
-
Schema extends XPrefixItems<infer Types extends XSchema[]> ? XStaticPrefixItems<Schema, Types> : unknown,
|
|
38
|
-
Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticProperties<Properties> : unknown,
|
|
39
|
-
Schema extends
|
|
36
|
+
Schema extends XItems<infer Types extends XSchema[] | XSchema> ? XStaticItems<Stack, Root, Schema, Types> : unknown,
|
|
37
|
+
Schema extends XOneOf<infer Types extends XSchema[]> ? XStaticOneOf<Stack, Root, Types> : unknown,
|
|
38
|
+
Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticPatternProperties<Stack, Root, Properties> : unknown,
|
|
39
|
+
Schema extends XPrefixItems<infer Types extends XSchema[]> ? XStaticPrefixItems<Stack, Root, Schema, Types> : unknown,
|
|
40
|
+
Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticProperties<Stack, Root, Properties> : unknown,
|
|
41
|
+
Schema extends XRef<infer Ref extends string> ? XStaticRef<Stack, Root, Ref> : unknown,
|
|
42
|
+
Schema extends XRequired<infer Keys extends string[]> ? XStaticRequired<Stack, Root, Schema, Keys> : unknown,
|
|
40
43
|
Schema extends XType<infer TypeName extends string[] | string> ? XStaticType<TypeName> : unknown,
|
|
41
|
-
Schema extends XUnevaluatedProperties<infer Type extends XSchema> ? XStaticUnevaluatedProperties<Type> : unknown
|
|
44
|
+
Schema extends XUnevaluatedProperties<infer Type extends XSchema> ? XStaticUnevaluatedProperties<Stack, Root, Type> : unknown
|
|
42
45
|
]> = Result;
|
|
43
46
|
type TKeywordsIntersected<Schemas extends unknown[], Result extends unknown = unknown> = (Schemas extends [infer Left extends unknown, ...infer Right extends unknown[]] ? TKeywordsIntersected<Right, Result & Left> : Result);
|
|
44
47
|
type TKeywordsEvaluated<Schema extends unknown, Result extends unknown = Schema extends object ? {
|
|
45
48
|
[Key in keyof Schema]: Schema[Key];
|
|
46
49
|
} : Schema> = Result;
|
|
47
|
-
export type XStaticSchema<Schema extends XSchema, Keywords extends unknown[] = TFromKeywords<Schema>, Intersected extends unknown = TKeywordsIntersected<Keywords>, Evaluated extends unknown = TKeywordsEvaluated<Intersected>> = Evaluated;
|
|
50
|
+
export type XStaticSchema<Stack extends string[], Root extends XSchema, Schema extends XSchema, Keywords extends unknown[] = TFromKeywords<Stack, Root, Schema>, Intersected extends unknown = TKeywordsIntersected<Keywords>, Evaluated extends unknown = TKeywordsEvaluated<Intersected>> = Evaluated;
|
|
48
51
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XMutable } from './~mutable.mjs';
|
|
3
3
|
import type { XStaticSchema } from './schema.mjs';
|
|
4
|
-
export type XStatic<Value extends unknown, Schema extends XSchema = Value extends XSchema ? Value : {}, Mutable extends XSchema = XMutable<Schema>, Result extends unknown = XStaticSchema<Mutable>> = Result;
|
|
4
|
+
export type XStatic<Value extends unknown, Schema extends XSchema = Value extends XSchema ? Value : {}, Mutable extends XSchema = XMutable<Schema>, Result extends unknown = XStaticSchema<[], Mutable, Mutable>> = Result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XSchema } from '../types/schema.mjs';
|
|
2
2
|
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
-
export type XStaticUnevaluatedProperties<Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
3
|
+
export type XStaticUnevaluatedProperties<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
4
4
|
[key: string]: unknown;
|
|
5
5
|
} : Schema extends false ? {} : {
|
|
6
|
-
[key: string]: XStaticSchema<Schema>;
|
|
6
|
+
[key: string]: XStaticSchema<Stack, Root, Schema>;
|
|
7
7
|
})> = Result;
|
|
@@ -4,15 +4,15 @@ import type { XMaxItems } from '../types/maxItems.mjs';
|
|
|
4
4
|
import type { XAdditionalItems } from '../types/additionalItems.mjs';
|
|
5
5
|
import type { XStaticSchema } from './schema.mjs';
|
|
6
6
|
import type { XLessThan } from './~comparer.mjs';
|
|
7
|
-
type TElements<Schemas extends XSchema[], Result extends unknown[] = []> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? TElements<Right, [...Result, XStaticSchema<Left>]> : Result);
|
|
7
|
+
type TElements<Stack extends string[], Root extends XSchema, Schemas extends XSchema[], Result extends unknown[] = []> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? TElements<Stack, Root, Right, [...Result, XStaticSchema<Stack, Root, Left>]> : Result);
|
|
8
8
|
type TMaxItemsRemap<Elements extends unknown[], MaxItems extends number, Result extends unknown[] = []> = (Elements extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XLessThan<Result['length'], MaxItems> extends true ? TMaxItemsRemap<Right, MaxItems, [...Result, Left]> : Result : Result);
|
|
9
9
|
type TMaxItems<Schema extends XSchema, Elements extends unknown[], MaxItems extends number | null = Schema extends XMaxItems<infer MaxItems extends number> ? MaxItems : null, Result extends unknown[] = MaxItems extends number ? TMaxItemsRemap<Elements, MaxItems> : Elements> = Result;
|
|
10
10
|
type TNeedsAdditionalItems<Schema extends XSchema, Elements extends unknown[], MaxItems extends number | null = Schema extends XMaxItems<infer MaxItems extends number> ? MaxItems : null, Result extends boolean = MaxItems extends number ? XLessThan<Elements['length'], MaxItems> : true> = Result;
|
|
11
11
|
type TMinItemsRemap<Elements extends unknown[], MinItems extends number, Result extends unknown[] = []> = (Elements extends [infer Left, ...infer Right] ? XLessThan<Result['length'], MinItems> extends true ? TMinItemsRemap<Right, MinItems, [...Result, Left]> : TMinItemsRemap<Right, MinItems, [...Result, Left?]> : Result);
|
|
12
12
|
type TMinItems<Schema extends XSchema, Values extends unknown[], MinItems extends number = Schema extends XMinItems<infer MinItems extends number> ? MinItems : 0, Result extends unknown[] = TMinItemsRemap<Values, MinItems>> = Result;
|
|
13
|
-
type TAdditionalItems<Schema extends XSchema, Elements extends unknown[], Result extends unknown[] = Schema extends XAdditionalItems<infer Schema extends XSchema> ? (Schema extends true ? [...Elements, ...unknown[]] : Schema extends false ? [...Elements] : [
|
|
13
|
+
type TAdditionalItems<Stack extends string[], Root extends XSchema, Schema extends XSchema, Elements extends unknown[], Result extends unknown[] = Schema extends XAdditionalItems<infer Schema extends XSchema> ? (Schema extends true ? [...Elements, ...unknown[]] : Schema extends false ? [...Elements] : [
|
|
14
14
|
...Elements,
|
|
15
|
-
...XStaticSchema<Schema>[]
|
|
15
|
+
...XStaticSchema<Stack, Root, Schema>[]
|
|
16
16
|
]) : [...Elements, ...unknown[]]> = Result;
|
|
17
|
-
export type XStaticElements<Schema extends XSchema, PrefixItems extends XSchema[], Elements extends unknown[] = TElements<PrefixItems>, WithMaxItems extends unknown[] = TMaxItems<Schema, Elements>, NeedsAdditional extends boolean = TNeedsAdditionalItems<Schema, WithMaxItems>, WithMinItems extends unknown[] = TMinItems<Schema, WithMaxItems>, WithAdditionalItems extends unknown[] = NeedsAdditional extends true ? TAdditionalItems<Schema, WithMinItems> : WithMinItems> = WithAdditionalItems;
|
|
17
|
+
export type XStaticElements<Stack extends string[], Root extends XSchema, Schema extends XSchema, PrefixItems extends XSchema[], Elements extends unknown[] = TElements<Stack, Root, PrefixItems>, WithMaxItems extends unknown[] = TMaxItems<Schema, Elements>, NeedsAdditional extends boolean = TNeedsAdditionalItems<Schema, WithMaxItems>, WithMinItems extends unknown[] = TMinItems<Schema, WithMaxItems>, WithAdditionalItems extends unknown[] = NeedsAdditional extends true ? TAdditionalItems<Stack, Root, Schema, WithMinItems> : WithMinItems> = WithAdditionalItems;
|
|
18
18
|
export {};
|