dsh-opencode-go 0.1.22 → 0.1.24
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/LICENSE +1 -0
- package/README.en.md +70 -147
- package/README.md +70 -145
- package/THIRD_PARTY_NOTICES.md +6 -2
- package/docs/advanced.en.md +137 -0
- package/docs/advanced.md +135 -0
- package/docs/assets/accounts.png +0 -0
- package/docs/assets/advanced-settings.png +0 -0
- package/docs/assets/model-settings.png +0 -0
- package/docs/assets/usage-panel.png +0 -0
- package/docs/development.md +17 -3
- package/docs/verification.md +183 -0
- package/lib/build-info.json +1 -1
- package/lib/client.js +456 -410
- package/lib/index.js +50626 -5092
- package/lib/types/account-manager.d.ts +2 -0
- package/lib/types/accounts.d.ts +3 -1
- package/lib/types/adapter.d.ts +5 -3
- package/lib/types/catalog.d.ts +1 -1
- package/lib/types/client/accounts-controller.d.ts +2 -0
- package/lib/types/client/hint-mark.d.ts +17 -0
- package/lib/types/client/host-primitives.d.ts +11 -0
- package/lib/types/client/locales.d.ts +5 -3
- package/lib/types/client/section-controller.d.ts +0 -2
- package/lib/types/config-contract.d.ts +3 -2
- package/lib/types/config.d.ts +1 -1
- package/lib/types/conversion/stream.d.ts +2 -1
- package/lib/types/gateway-diagnostics.d.ts +1 -0
- package/lib/types/gateway-url.d.ts +6 -0
- package/lib/types/google-fetch.d.ts +6 -0
- package/lib/types/google-generative-ai.d.ts +3 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/model-metadata.d.ts +2 -2
- package/lib/types/request-budget.d.ts +12 -0
- package/lib/types/sdk-types.d.ts +1893 -305
- package/lib/vendor-licenses.txt +1760 -2
- package/package.json +3 -2
package/lib/types/sdk-types.d.ts
CHANGED
|
@@ -5,6 +5,1702 @@ import { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
|
|
|
5
5
|
|
|
6
6
|
interface TSchema {
|
|
7
7
|
}
|
|
8
|
+
interface TSchemaOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Allows for additional, unlisted properties to be included, typically for extensibility.
|
|
11
|
+
*/
|
|
12
|
+
[key: PropertyKey]: unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Specifies the URI of a JSON Schema that the current schema adheres to.
|
|
15
|
+
*/
|
|
16
|
+
$schema?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A URI that serves as a unique identifier for the schema.
|
|
19
|
+
*/
|
|
20
|
+
$id?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A short explanation about the purpose of the data described by the schema.
|
|
23
|
+
*/
|
|
24
|
+
title?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A detailed explanation of the data described by the schema.
|
|
27
|
+
*/
|
|
28
|
+
description?: string;
|
|
29
|
+
/**
|
|
30
|
+
* A default value for the data, used when no value is provided.
|
|
31
|
+
*/
|
|
32
|
+
default?: unknown;
|
|
33
|
+
/**
|
|
34
|
+
* Provides one or more examples of valid data conforming to the schema.
|
|
35
|
+
*/
|
|
36
|
+
examples?: unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates that the data should only be readable and not modified.
|
|
39
|
+
*/
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates that the data should only be writable and not read back.
|
|
43
|
+
*/
|
|
44
|
+
writeOnly?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A schema to apply conditionally: if the data validates against this schema, 'then' applies.
|
|
47
|
+
*/
|
|
48
|
+
if?: TSchema;
|
|
49
|
+
/**
|
|
50
|
+
* A schema to apply if the data validates against the 'if' schema.
|
|
51
|
+
*/
|
|
52
|
+
then?: TSchema;
|
|
53
|
+
/**
|
|
54
|
+
* A schema to apply if the data does not validate against the 'if' schema.
|
|
55
|
+
*/
|
|
56
|
+
else?: TSchema;
|
|
57
|
+
}
|
|
58
|
+
interface TObjectOptions extends TSchemaOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Defines whether additional properties are allowed beyond those explicitly defined in `properties`.
|
|
61
|
+
*/
|
|
62
|
+
additionalProperties?: TSchema | boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The minimum number of properties required in the object.
|
|
65
|
+
*/
|
|
66
|
+
minProperties?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The maximum number of properties allowed in the object.
|
|
69
|
+
*/
|
|
70
|
+
maxProperties?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Defines conditional requirements for properties.
|
|
73
|
+
*/
|
|
74
|
+
dependencies?: Record<string, boolean | TSchema | string[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Specifies properties that *must* be present if a given property is present.
|
|
77
|
+
*/
|
|
78
|
+
dependentRequired?: Record<string, string[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Defines schemas that apply if a specific property is present.
|
|
81
|
+
*/
|
|
82
|
+
dependentSchemas?: Record<string, TSchema>;
|
|
83
|
+
/**
|
|
84
|
+
* Maps regular expressions to schemas properties matching a pattern must validate against the schema.
|
|
85
|
+
*/
|
|
86
|
+
patternProperties?: Record<string, TSchema>;
|
|
87
|
+
/**
|
|
88
|
+
* A schema that all property names within the object must validate against.
|
|
89
|
+
*/
|
|
90
|
+
propertyNames?: TSchema;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Represents a deferred action. */
|
|
94
|
+
interface TDeferred<Action extends string = string, Types extends TSchema[] = TSchema[]> extends TSchema {
|
|
95
|
+
'~kind': 'Deferred';
|
|
96
|
+
type: 'deferred';
|
|
97
|
+
action: Action;
|
|
98
|
+
parameters: Types;
|
|
99
|
+
options: TSchemaOptions;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type StaticCodec<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema, Decoded extends unknown> = (Direction extends 'Decode' ? Decoded : StaticType<Stack, Direction, Context, This, Omit<Type, '~codec'>>);
|
|
103
|
+
type TDecodeCallback<Encoded extends unknown, Decoded = unknown> = (input: Encoded) => Decoded;
|
|
104
|
+
type TEncodeCallback<Encoded extends unknown, Decoded = unknown> = (input: Decoded) => Encoded;
|
|
105
|
+
type TCodec<Type extends TSchema = TSchema, Decoded extends unknown = unknown> = Type & {
|
|
106
|
+
'~codec': {
|
|
107
|
+
encode: TDecodeCallback<unknown, Decoded>;
|
|
108
|
+
decode: TEncodeCallback<unknown, Decoded>;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
type StaticAny = any;
|
|
113
|
+
/** Represents a Any type. */
|
|
114
|
+
interface TAny extends TSchema {
|
|
115
|
+
'~kind': 'Any';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type TImmutable<Type extends TSchema = TSchema> = (Type & {
|
|
119
|
+
'~immutable': true;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
type StaticArray<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Array extends TSchema, Item extends TSchema, Result extends readonly unknown[] = Array extends TImmutable ? readonly StaticType<Stack, Direction, Context, This, Item>[] : StaticType<Stack, Direction, Context, This, Item>[]> = Result;
|
|
123
|
+
/** Represents an Array type. */
|
|
124
|
+
interface TArray<Type extends TSchema = TSchema> extends TSchema {
|
|
125
|
+
'~kind': 'Array';
|
|
126
|
+
type: 'array';
|
|
127
|
+
items: Type;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare const BigIntPattern = "-?(?:0|[1-9][0-9]*)n";
|
|
131
|
+
type StaticBigInt = bigint;
|
|
132
|
+
/** Represents a BigInt type. */
|
|
133
|
+
interface TBigInt extends TSchema {
|
|
134
|
+
'~kind': 'BigInt';
|
|
135
|
+
type: 'bigint';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type StaticBoolean = boolean;
|
|
139
|
+
/** Represents a Boolean type. */
|
|
140
|
+
interface TBoolean extends TSchema {
|
|
141
|
+
'~kind': 'Boolean';
|
|
142
|
+
type: 'boolean';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Applies an AddReadonly action to a type. */
|
|
146
|
+
type TAddReadonly<Type extends TSchema> = (TAddReadonlyAction<Type>);
|
|
147
|
+
|
|
148
|
+
type TReadonly<Type extends TSchema = TSchema> = (Type & {
|
|
149
|
+
'~readonly': true;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
type TAddReadonlyOperation<Type extends TSchema, Result extends TSchema = `~readonly` extends keyof Type ? Type : TReadonly<Type>> = Result;
|
|
153
|
+
type TAddReadonlyAction<Type extends TSchema, Result extends TSchema = TAddReadonlyOperation<Type>> = Result;
|
|
154
|
+
type TAddReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddReadonlyAction<InstantiateType>;
|
|
155
|
+
|
|
156
|
+
type StaticUnknown = unknown;
|
|
157
|
+
/** Represents an Unknown type. */
|
|
158
|
+
interface TUnknown extends TSchema {
|
|
159
|
+
'~kind': 'Unknown';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Represents a Generic parameter. */
|
|
163
|
+
interface TParameter<Name extends string = string, Extends extends TSchema = TSchema, Equals extends TSchema = TSchema> extends TSchema {
|
|
164
|
+
'~kind': 'Parameter';
|
|
165
|
+
name: Name;
|
|
166
|
+
extends: Extends;
|
|
167
|
+
equals: Equals;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
type StaticObject<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, _This extends TProperties, Properties extends TProperties, Result = keyof Properties extends never ? object : StaticProperties<Stack, Direction, Context, Properties, Properties>> = Result;
|
|
171
|
+
/** Represents an Object type. */
|
|
172
|
+
interface TObject<Properties extends TProperties = TProperties> extends TSchema {
|
|
173
|
+
'~kind': 'Object';
|
|
174
|
+
type: 'object';
|
|
175
|
+
properties: Properties;
|
|
176
|
+
required: TRequiredArray<Properties>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
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);
|
|
180
|
+
type CyclicGuard<Stack extends unknown[], Ref extends string> = (Ref extends Stack[number] ? CyclicStackLength<Stack, 2> : true);
|
|
181
|
+
type StaticGuardedRef<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Ref extends string, Type extends TSchema> = (CyclicGuard<Stack, Ref> extends true ? StaticType<[...Stack, Ref], Direction, Context, This, Type> : any);
|
|
182
|
+
type StaticRef<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Ref extends string, Target extends TSchema = Ref extends keyof Context ? Context[Ref] : TUnknown, Result extends unknown = Target extends TObject ? StaticType<[], Direction, Context, This, Target> : StaticGuardedRef<Stack, Direction, Context, This, Ref, Target>> = Result;
|
|
183
|
+
/** Represents a type reference. */
|
|
184
|
+
interface TRef<Ref extends string = string> extends TSchema {
|
|
185
|
+
'~kind': 'Ref';
|
|
186
|
+
$ref: Ref;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Represents a callable Generic type. */
|
|
190
|
+
interface TGeneric<Parameters extends TParameter[] = TParameter[], Expression extends TSchema = TSchema> extends TSchema {
|
|
191
|
+
'~kind': 'Generic';
|
|
192
|
+
type: 'generic';
|
|
193
|
+
parameters: Parameters;
|
|
194
|
+
expression: Expression;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
declare const NeverPattern = "(?!)";
|
|
198
|
+
type StaticNever = never;
|
|
199
|
+
/** Represents a Never type. */
|
|
200
|
+
interface TNever extends TSchema {
|
|
201
|
+
'~kind': 'Never';
|
|
202
|
+
not: {};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
type StaticCyclic<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Defs extends TProperties, Ref extends string, Result extends unknown = (Ref extends keyof Defs ? StaticType<[...Stack, Ref], Direction, Defs, This, Defs[Ref]> : never)> = Result;
|
|
206
|
+
/** Represents a Cyclic type. */
|
|
207
|
+
interface TCyclic<Defs extends TProperties = TProperties, Ref extends string = string> extends TSchema {
|
|
208
|
+
'~kind': 'Cyclic';
|
|
209
|
+
$defs: Defs;
|
|
210
|
+
$ref: Ref;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type TUnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
|
|
214
|
+
type TUnionLast<U> = TUnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
|
|
215
|
+
type TUnionToTuple<U, Result extends unknown[] = [], R = TUnionLast<U>> = [U] extends [never] ? Result : TUnionToTuple<Exclude<U, R>, [Extract<U, R>, ...Result]>;
|
|
216
|
+
|
|
217
|
+
type StaticEnum<Values extends TEnumValue[]> = (Values[number]);
|
|
218
|
+
type TEnumValue = string | number;
|
|
219
|
+
/** Represents an Enum type. */
|
|
220
|
+
interface TEnum<Values extends TEnumValue[] = TEnumValue[]> extends TSchema {
|
|
221
|
+
'~kind': 'Enum';
|
|
222
|
+
enum: Values;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Represents a Identifier. */
|
|
226
|
+
interface TIdentifier<Name extends string = string> extends TSchema {
|
|
227
|
+
'~kind': 'Identifier';
|
|
228
|
+
type: 'identifier';
|
|
229
|
+
name: Name;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
type StaticDependent<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, If extends TSchema, Then extends TSchema, Else extends TSchema, StaticIf extends unknown = StaticType<Stack, Direction, Context, This, If>, StaticThen extends unknown = StaticType<Stack, Direction, Context, This, Then>, StaticElse extends unknown = StaticType<Stack, Direction, Context, This, Else>, Result extends unknown = (StaticIf & StaticThen) | Exclude<StaticElse, StaticIf>> = Result;
|
|
233
|
+
/** Represents a Dependent Type */
|
|
234
|
+
interface TDependent<If extends TSchema = TSchema, Then extends TSchema = TSchema, Else extends TSchema = TSchema> extends TSchema {
|
|
235
|
+
'~kind': 'Dependent';
|
|
236
|
+
if: If;
|
|
237
|
+
then: Then;
|
|
238
|
+
else: Else;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Represents an Infer instruction. */
|
|
242
|
+
interface TInfer<Name extends string = string, Extends extends TSchema = TSchema> extends TSchema {
|
|
243
|
+
'~kind': 'Infer';
|
|
244
|
+
type: 'infer';
|
|
245
|
+
name: Name;
|
|
246
|
+
extends: Extends;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare const IntegerPattern = "-?(?:0|[1-9][0-9]*)";
|
|
250
|
+
type StaticInteger = number;
|
|
251
|
+
/** Represents an integer type. */
|
|
252
|
+
interface TInteger extends TSchema {
|
|
253
|
+
'~kind': 'Integer';
|
|
254
|
+
type: 'integer';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
type StaticIntersect<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Types extends TSchema[], Result extends unknown = unknown> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? StaticIntersect<Stack, Direction, Context, This, Right, Result & StaticType<Stack, Direction, Context, This, Left>> : Result);
|
|
258
|
+
/** Represents a logical Intersect type. */
|
|
259
|
+
interface TIntersect<Types extends TSchema[] = TSchema[]> extends TSchema {
|
|
260
|
+
'~kind': 'Intersect';
|
|
261
|
+
allOf: Types;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
type StaticLiteral<Value extends TLiteralValue> = (Value);
|
|
265
|
+
type TLiteralTypeName<Value extends TLiteralValue> = (Value extends bigint ? 'bigint' : Value extends boolean ? 'boolean' : Value extends number ? 'number' : Value extends string ? 'string' : never);
|
|
266
|
+
type TLiteralValue = string | number | boolean | bigint;
|
|
267
|
+
/** Represents a Literal type. */
|
|
268
|
+
interface TLiteral<Value extends TLiteralValue = TLiteralValue> extends TSchema {
|
|
269
|
+
'~kind': 'Literal';
|
|
270
|
+
type: TLiteralTypeName<Value>;
|
|
271
|
+
const: Value;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
type StaticNull = null;
|
|
275
|
+
/** Represents a Null type. */
|
|
276
|
+
interface TNull extends TSchema {
|
|
277
|
+
'~kind': 'Null';
|
|
278
|
+
type: 'null';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare const NumberPattern = "-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";
|
|
282
|
+
type StaticNumber = number;
|
|
283
|
+
/** Represents a Number type. */
|
|
284
|
+
interface TNumber extends TSchema {
|
|
285
|
+
'~kind': 'Number';
|
|
286
|
+
type: 'number';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
type StaticSymbol = symbol;
|
|
290
|
+
/** Represents a Symbol type. */
|
|
291
|
+
interface TSymbol extends TSchema {
|
|
292
|
+
'~kind': 'Symbol';
|
|
293
|
+
type: 'symbol';
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
declare const StringPattern = ".*";
|
|
297
|
+
type StaticString = string;
|
|
298
|
+
/** Represents a String type. */
|
|
299
|
+
interface TString extends TSchema {
|
|
300
|
+
'~kind': 'String';
|
|
301
|
+
type: 'string';
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
type TUnreachable = never;
|
|
305
|
+
|
|
306
|
+
type ObjectLike = Record<PropertyKey, any>;
|
|
307
|
+
/**
|
|
308
|
+
* Performs an Object assign using the Left and Right object types. We track this operation as it
|
|
309
|
+
* creates a new GC handle per assignment.
|
|
310
|
+
*/
|
|
311
|
+
type TAssign<Left extends ObjectLike, Right extends ObjectLike, Assigned extends ObjectLike = Omit<Left, keyof Right> & Right> = {
|
|
312
|
+
[Key in keyof Assigned]: Assigned[Key];
|
|
313
|
+
} & {};
|
|
314
|
+
|
|
315
|
+
type TPatternBigIntMapping<Input extends '-?(?:0|[1-9][0-9]*)n'> = (TBigInt);
|
|
316
|
+
type TPatternStringMapping<Input extends '.*'> = (TString);
|
|
317
|
+
type TPatternNumberMapping<Input extends '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?'> = (TNumber);
|
|
318
|
+
type TPatternIntegerMapping<Input extends '-?(?:0|[1-9][0-9]*)'> = (TInteger);
|
|
319
|
+
type TPatternNeverMapping<Input extends '(?!)'> = (TNever);
|
|
320
|
+
type TPatternTextMapping<Input extends string, Result extends TSchema = TLiteral<Input>> = Result;
|
|
321
|
+
type TPatternBaseMapping<Input extends unknown> = (Input);
|
|
322
|
+
type TPatternGroupMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['(', infer Body extends TSchema[], ')'] ? TUnion<Body> : never);
|
|
323
|
+
type TPatternUnionMapping<Input extends [unknown, unknown, unknown] | [unknown] | []> = (Input extends [infer Term extends TSchema[], '|', infer Union extends TSchema[]] ? [...Term, ...Union] : Input extends [infer Term extends TSchema[]] ? [...Term] : [
|
|
324
|
+
]);
|
|
325
|
+
type TPatternTermMapping<Input extends [unknown, unknown]> = (Input extends [infer Left extends TSchema, infer Right extends TSchema[]] ? [Left, ...Right] : never);
|
|
326
|
+
type TPatternBodyMapping<Input extends unknown> = (Input);
|
|
327
|
+
type TPatternMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['^', infer Body extends TSchema[], '$'] ? Body : never);
|
|
328
|
+
|
|
329
|
+
type TTakeVariant<Variant extends string, Input extends string> = (Input extends `${Variant}${infer Rest extends string}` ? [Variant, Rest] : []);
|
|
330
|
+
/** Takes one of the given variants or fail */
|
|
331
|
+
type TTake<Variants extends string[], Input extends string> = (Variants extends [infer ValueLeft extends string, ...infer ValueRight extends string[]] ? TTakeVariant<ValueLeft, Input> extends [infer Take extends string, infer Rest extends string] ? [Take, Rest] : TTake<ValueRight, Input> : []);
|
|
332
|
+
|
|
333
|
+
declare const WhiteSpace = " ";
|
|
334
|
+
declare const NewLine = "\n";
|
|
335
|
+
declare const TabSpace = "\t";
|
|
336
|
+
type TWhiteSpace = typeof WhiteSpace;
|
|
337
|
+
type TNewLine = typeof NewLine;
|
|
338
|
+
type TTabSpace = typeof TabSpace;
|
|
339
|
+
|
|
340
|
+
type LineComment = typeof LineComment;
|
|
341
|
+
declare const LineComment = "//";
|
|
342
|
+
type OpenComment = typeof OpenComment;
|
|
343
|
+
declare const OpenComment = "/*";
|
|
344
|
+
type CloseComment = typeof CloseComment;
|
|
345
|
+
declare const CloseComment = "*/";
|
|
346
|
+
type TDiscardMultiLineComment<Input extends string> = (Input extends `${string}${CloseComment}${infer Rest extends string}` ? Rest : '');
|
|
347
|
+
type TDiscardLineComment<Input extends string> = (Input extends `${string}${TNewLine}${infer Rest extends string}` ? TTrimWhitespace<`${TNewLine}${Rest}`> : '');
|
|
348
|
+
type W4 = `${W3}${W3}`;
|
|
349
|
+
type W3 = `${W2}${W2}`;
|
|
350
|
+
type W2 = `${W1}${W1}`;
|
|
351
|
+
type W1 = `${W0}${W0}`;
|
|
352
|
+
type W0 = ` `;
|
|
353
|
+
type TTrimWhitespace<Input extends string> = (Input extends `${OpenComment}${infer Rest extends string}` ? TTrimWhitespace<TDiscardMultiLineComment<Rest>> : Input extends `${LineComment}${infer Rest extends string}` ? TTrimWhitespace<TDiscardLineComment<Rest>> : Input extends `${W4}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W3}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W1}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input extends `${W0}${infer Rest extends string}` ? TTrimWhitespace<Rest> : Input);
|
|
354
|
+
type TTrim<Input extends string> = (Input extends `${OpenComment}${infer Rest extends string}` ? TTrim<TDiscardMultiLineComment<Rest>> : Input extends `${LineComment}${infer Rest extends string}` ? TTrim<TDiscardLineComment<Rest>> : Input extends `${TNewLine}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${TTabSpace}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W4}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W3}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W1}${infer Rest extends string}` ? TTrim<Rest> : Input extends `${W0}${infer Rest extends string}` ? TTrim<Rest> : Input);
|
|
355
|
+
|
|
356
|
+
type TTakeConst<Const extends string, Input extends string> = (TTake<[Const], Input>);
|
|
357
|
+
/** Matches if next is the given Const value */
|
|
358
|
+
type TConst<Const extends string, Input extends string> = (Const extends '' ? ['', Input] : Const extends `${infer First extends string}${string}` ? (First extends TNewLine ? TTakeConst<Const, TTrimWhitespace<Input>> : First extends TWhiteSpace ? TTakeConst<Const, Input> : TTakeConst<Const, TTrim<Input>>) : never);
|
|
359
|
+
|
|
360
|
+
type TTakeOne<Input extends string> = (Input extends `${infer Left extends string}${infer Right extends string}` ? [Left, Right] : []);
|
|
361
|
+
type TIsInputMatchSentinal<End extends string[], Input extends string> = (End extends [infer Left extends string, ...infer Right extends string[]] ? Input extends `${Left}${string}` ? true : TIsInputMatchSentinal<Right, Input> : false);
|
|
362
|
+
/** Match Input until but not including End. No match if End not found. */
|
|
363
|
+
type TUntil<End extends string[], Input extends string, Result extends string = ''> = (TTakeOne<Input> extends [infer One extends string, infer Rest extends string] ? TIsInputMatchSentinal<End, Input> extends true ? [Result, Input] : TUntil<End, Rest, `${Result}${One}`> : []);
|
|
364
|
+
|
|
365
|
+
/** Match Input until but not including End. No match if End not found or match is zero-length. */
|
|
366
|
+
type TUntil_1<End extends string[], Input extends string> = (TUntil<End, Input> extends [infer Until extends string, infer UntilRest extends string] ? Until extends '' ? [] : [Until, UntilRest] : []);
|
|
367
|
+
|
|
368
|
+
type TPatternBigInt<Input extends string> = TConst<'-?(?:0|[1-9][0-9]*)n', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)n', infer Input extends string] ? [TPatternBigIntMapping<_0>, Input] : [];
|
|
369
|
+
type TPatternString<Input extends string> = TConst<'.*', Input> extends [infer _0 extends '.*', infer Input extends string] ? [TPatternStringMapping<_0>, Input] : [];
|
|
370
|
+
type TPatternNumber<Input extends string> = TConst<'-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', infer Input extends string] ? [TPatternNumberMapping<_0>, Input] : [];
|
|
371
|
+
type TPatternInteger<Input extends string> = TConst<'-?(?:0|[1-9][0-9]*)', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)', infer Input extends string] ? [TPatternIntegerMapping<_0>, Input] : [];
|
|
372
|
+
type TPatternNever<Input extends string> = TConst<'(?!)', Input> extends [infer _0 extends '(?!)', infer Input extends string] ? [TPatternNeverMapping<_0>, Input] : [];
|
|
373
|
+
type TPatternText<Input extends string> = TUntil_1<['-?(?:0|[1-9][0-9]*)n', '.*', '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', '-?(?:0|[1-9][0-9]*)', '(?!)', '(', ')', '$', '|'], Input> extends [infer _0 extends string, infer Input extends string] ? [TPatternTextMapping<_0>, Input] : [];
|
|
374
|
+
type TPatternBase<Input extends string> = (TPatternBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternInteger<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternNever<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternGroup<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternText<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [TPatternBaseMapping<_0>, Input] : [];
|
|
375
|
+
type TPatternGroup<Input extends string> = (TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? (TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [TPatternGroupMapping<_0>, Input] : [];
|
|
376
|
+
type TPatternUnion<Input extends string> = ((TPatternTerm<Input> extends [infer _0, infer Input extends string] ? (TConst<'|', Input> extends [infer _1, infer Input extends string] ? (TPatternUnion<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TPatternTerm<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [unknown] | [], infer Input extends string] ? [TPatternUnionMapping<_0>, Input] : [];
|
|
377
|
+
type TPatternTerm<Input extends string> = (TPatternBase<Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [TPatternTermMapping<_0>, Input] : [];
|
|
378
|
+
type TPatternBody<Input extends string> = (TPatternUnion<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternTerm<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [TPatternBodyMapping<_0>, Input] : [];
|
|
379
|
+
type TPattern<Input extends string> = (TConst<'^', Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? (TConst<'$', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [TPatternMapping<_0>, Input] : [];
|
|
380
|
+
|
|
381
|
+
type StaticUnion<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Types extends TSchema[], Result extends unknown = never> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? StaticUnion<Stack, Direction, Context, This, Right, Result | StaticType<Stack, Direction, Context, This, Left>> : Result);
|
|
382
|
+
/** Represents a logical Union type. */
|
|
383
|
+
interface TUnion<Types extends TSchema[] = TSchema[]> extends TSchema {
|
|
384
|
+
'~kind': 'Union';
|
|
385
|
+
anyOf: Types;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Parses a Pattern into a sequence of TemplateLiteral types. A result of [] indicates failure to parse. */
|
|
389
|
+
type TParsePatternIntoTypes<Pattern extends string, Parsed extends [TSchema[], string] | [] = TPattern<Pattern>, Result extends TSchema[] = Parsed extends [infer Types extends TSchema[], string] ? Types : []> = Result;
|
|
390
|
+
|
|
391
|
+
type TFromLiteral$5<Template extends string, Value extends TLiteralValue> = `${Template}${Value}`;
|
|
392
|
+
type TFromBigInt<Template extends string> = `${Template}${bigint}`;
|
|
393
|
+
type TFromString<Template extends string> = `${Template}${string}`;
|
|
394
|
+
type TFromNumber<Template extends string> = `${Template}${number}`;
|
|
395
|
+
type TFromInteger<Template extends string> = `${Template}${number}`;
|
|
396
|
+
type TFromUnion$8<Template extends string, Types extends TSchema[], Result extends string = never> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$8<Template, Right, Result | TFromType$i<'', Left>> : `${Template}${Result}`);
|
|
397
|
+
type TFromType$i<Template extends string, Type extends TSchema, Result extends string = (Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$8<Template, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral$5<Template, Value> : Type extends TBigInt ? TFromBigInt<Template> : Type extends TString ? TFromString<Template> : Type extends TNumber ? TFromNumber<Template> : Type extends TInteger ? TFromInteger<Template> : never)> = Result;
|
|
398
|
+
type TFromSpan<Template extends string, Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromSpan<TFromType$i<Template, Left>, Right> : Template);
|
|
399
|
+
type TTemplateLiteralStatic<Pattern extends string, Types extends TSchema[] = TParsePatternIntoTypes<Pattern>> = TFromSpan<'', Types>;
|
|
400
|
+
|
|
401
|
+
type TRemoveReadonlyOperation<Type extends TSchema, Result extends TSchema = Type extends TReadonly<infer Type extends TSchema> ? TRemoveReadonlyOperation<Type> : Type> = Result;
|
|
402
|
+
type TRemoveReadonlyAction<Type extends TSchema, Result extends TSchema = TRemoveReadonlyOperation<Type>> = Result;
|
|
403
|
+
type TRemoveReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TRemoveReadonlyAction<InstantiateType>;
|
|
404
|
+
|
|
405
|
+
/** Applies an RemoveReadonly action to a type. */
|
|
406
|
+
type TRemoveReadonly<Type extends TSchema> = (TRemoveReadonlyAction<Type>);
|
|
407
|
+
|
|
408
|
+
type TRemoveOptionalOperation<Type extends TSchema, Result extends TSchema = Type extends TOptional<infer Type extends TSchema> ? TRemoveOptionalOperation<Type> : Type> = Result;
|
|
409
|
+
type TRemoveOptionalAction<Type extends TSchema, Result extends TSchema = TRemoveOptionalOperation<Type>> = Result;
|
|
410
|
+
type TRemoveOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TRemoveOptionalAction<InstantiateType>;
|
|
411
|
+
|
|
412
|
+
/** Applies an RemoveOptional action to a type. */
|
|
413
|
+
type TRemoveOptional<Type extends TSchema> = (TRemoveOptionalAction<Type>);
|
|
414
|
+
|
|
415
|
+
type TTupleElementsToProperties<Types extends TSchema[], Result extends TProperties = {}> = (Types extends [...infer Left extends TSchema[], infer Right extends TSchema] ? TTupleElementsToProperties<Left, {
|
|
416
|
+
[_ in Left['length']]: Right;
|
|
417
|
+
} & Result> : {
|
|
418
|
+
[Key in keyof Result]: Result[Key];
|
|
419
|
+
});
|
|
420
|
+
type TTupleToObject<Type extends TTuple, Properties extends TProperties = TTupleElementsToProperties<Type['items']>, Result extends TSchema = TObject<Properties>> = Result;
|
|
421
|
+
|
|
422
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
423
|
+
type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
|
|
424
|
+
type TIsReadonlyProperty<Left extends TSchema, Right extends TSchema> = (Left extends TReadonly<Left> ? Right extends TReadonly<Right> ? true : false : false);
|
|
425
|
+
type TIsOptionalProperty<Left extends TSchema, Right extends TSchema> = (Left extends TOptional<Left> ? Right extends TOptional<Right> ? true : false : false);
|
|
426
|
+
type TCompositeProperty<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = TIsReadonlyProperty<Left, Right>, IsOptional extends boolean = TIsOptionalProperty<Left, Right>, Evaluated extends TSchema = TEvaluateIntersect<[Left, Right]>, Property extends TSchema = TRemoveReadonly<TRemoveOptional<Evaluated>>> = ([
|
|
427
|
+
IsReadonly,
|
|
428
|
+
IsOptional
|
|
429
|
+
] extends [true, true] ? TAddReadonly<TAddOptional<Property>> : [
|
|
430
|
+
IsReadonly,
|
|
431
|
+
IsOptional
|
|
432
|
+
] extends [true, false] ? TAddReadonly<Property> : [
|
|
433
|
+
IsReadonly,
|
|
434
|
+
IsOptional
|
|
435
|
+
] extends [false, true] ? TAddOptional<Property> : Property);
|
|
436
|
+
type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TCompositeProperty<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
|
|
437
|
+
type TCompositeProperties<Left extends TProperties, Right extends TProperties, Keys extends PropertyKey = keyof (Left & Right), Result extends TProperties = {
|
|
438
|
+
[Key in Keys]: TCompositePropertyKey<Left, Right, Key>;
|
|
439
|
+
}> = Result;
|
|
440
|
+
type TGetProperties<Type extends TSchema, Result extends TProperties = (Type extends TObject<infer Properties extends TProperties> ? Properties : Type extends TTuple<infer Types extends TSchema[]> ? TTupleElementsToProperties<Types> : {})> = Result;
|
|
441
|
+
type TComposite<Left extends TSchema, Right extends TSchema, LeftProperties extends TProperties = TGetProperties<Left>, RightProperties extends TProperties = TGetProperties<Right>, Properties extends TProperties = TCompositeProperties<LeftProperties, RightProperties>, Result extends TSchema = TObject<Properties>> = Result;
|
|
442
|
+
|
|
443
|
+
type TNarrowCompareRule<Left extends TSchema, Right extends TSchema, Result extends TCompareResult = TCompare<Left, Right>> = (Result extends typeof CompareResultLeftInside ? Left : Result extends typeof CompareResultRightInside ? Right : Result extends typeof CompareResultEqual ? Right : TNever);
|
|
444
|
+
type TNarrowCompositeRule<Left extends TSchema, Right extends TSchema, CanCompositeLeft extends boolean = TCanComposite<Left>, CanCompositeRight extends boolean = TCanComposite<Right>> = ([
|
|
445
|
+
CanCompositeLeft,
|
|
446
|
+
CanCompositeRight
|
|
447
|
+
] extends [true, true] ? TComposite<Left, Right> : [
|
|
448
|
+
CanCompositeLeft,
|
|
449
|
+
CanCompositeRight
|
|
450
|
+
] extends [true, false] ? Left : [
|
|
451
|
+
CanCompositeLeft,
|
|
452
|
+
CanCompositeRight
|
|
453
|
+
] extends [false, true] ? Right : TNarrowCompareRule<Left, Right>);
|
|
454
|
+
type TNarrow<Left extends TSchema, Right extends TSchema> = (Left extends TNever ? TNever : Left extends TAny ? TAny : Left extends TUnknown ? Right : Right extends TNever ? TNever : Right extends TAny ? TAny : Right extends TUnknown ? Left : TNarrowCompositeRule<Left, Right>);
|
|
455
|
+
|
|
456
|
+
type TShouldEvaluate<Left extends TSchema, Right extends TSchema, IsUnionLeft extends boolean = Left extends TUnion ? true : false, IsUnionRight extends boolean = Right extends TUnion ? true : false, Result extends boolean = IsUnionLeft extends true ? true : IsUnionRight extends true ? true : false> = Result;
|
|
457
|
+
type TDistributeOperation<Left extends TSchema, Right extends TSchema, EvaluatedLeft extends TSchema = TEvaluateType<Left>, EvaluatedRight extends TSchema = TEvaluateType<Right>, ShouldEvaluate extends boolean = TShouldEvaluate<EvaluatedLeft, EvaluatedRight>, Result extends TSchema = [ShouldEvaluate] extends [true] ? TEvaluateIntersect<[EvaluatedLeft, EvaluatedRight]> : TNarrow<EvaluatedLeft, EvaluatedRight>> = Result;
|
|
458
|
+
type TDistributeType<Type extends TSchema, Distribution extends TSchema[], Result extends TSchema[] = []> = (Distribution extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDistributeType<Type, Right, [...Result, TDistributeOperation<Left, Type>]> : Result extends [] ? [Type] : Result);
|
|
459
|
+
type TDistributeUnion<Types extends TSchema[], Distribution extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDistributeUnion<Right, Distribution, [...Result, ...TDistribute$1<[Left], Distribution>]> : Result);
|
|
460
|
+
type TDistribute$1<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TUnion<infer UnionTypes extends TSchema[]> ? TDistribute$1<Right, TDistributeUnion<UnionTypes, Result>> : TDistribute$1<Right, TDistributeType<Left, Result>> : Result);
|
|
461
|
+
|
|
462
|
+
type StaticUnsafe<Type extends unknown> = Type;
|
|
463
|
+
/** Represents an Unsafe type. */
|
|
464
|
+
interface TUnsafe<Type extends unknown = unknown> extends TSchema {
|
|
465
|
+
'~unsafe': Type;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
type TResult = TExtendsUnion$1 | TExtendsTrue | TExtendsFalse;
|
|
469
|
+
interface TExtendsUnion$1<Inferred extends TProperties = TProperties> {
|
|
470
|
+
'~kind': 'ExtendsUnion';
|
|
471
|
+
inferred: Inferred;
|
|
472
|
+
}
|
|
473
|
+
interface TExtendsTrue<Inferred extends TProperties = TProperties> {
|
|
474
|
+
'~kind': 'ExtendsTrue';
|
|
475
|
+
inferred: Inferred;
|
|
476
|
+
}
|
|
477
|
+
interface TExtendsFalse {
|
|
478
|
+
type: 'ExtendsFalse';
|
|
479
|
+
}
|
|
480
|
+
type TExtendsTrueLike<Inferred extends TProperties = TProperties> = TExtendsUnion$1<Inferred> | TExtendsTrue<Inferred>;
|
|
481
|
+
|
|
482
|
+
type TExtendsRightInfer<Inferred extends TProperties, Name extends string, Left extends TSchema, Right extends TSchema, Result extends TResult = (TExtendsLeft<Inferred, Left, Right> extends TExtendsTrueLike<infer CheckInferred extends TProperties> ? TExtendsTrue<TAssign<TAssign<Inferred, CheckInferred>, {
|
|
483
|
+
[_ in Name]: Left;
|
|
484
|
+
}>> : TExtendsFalse)> = Result;
|
|
485
|
+
type TExtendsRightAny<Inferred extends TProperties, _Left extends TSchema, Result extends TResult = TExtendsTrue<Inferred>> = Result;
|
|
486
|
+
type TExtendsRightDependent<Inferred extends TProperties, Left extends TSchema, If extends TSchema, Then extends TSchema, Else extends TSchema, Result extends TResult = TExtendsLeft<Inferred, Left, If> extends TExtendsTrueLike<infer Inferred extends TProperties> ? (TExtendsLeft<Inferred, Left, Then> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTrue<Inferred> : TExtendsFalse) : (TExtendsLeft<Inferred, Left, Else> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTrue<Inferred> : TExtendsFalse)> = Result;
|
|
487
|
+
type TExtendsRightEnum<Inferred extends TProperties, Left extends TSchema, Right extends TEnumValue[], Evaluated extends TSchema = TEvaluateEnum<Right>> = TExtendsLeft<Inferred, Left, Evaluated>;
|
|
488
|
+
type TExtendsRightIntersect<Inferred extends TProperties, Left extends TSchema, Right extends TSchema[]> = (Right extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Left, Head> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsRightIntersect<Inferred, Left, Tail> : TExtendsFalse : TExtendsTrue<Inferred>);
|
|
489
|
+
type TExtendsRightTemplateLiteral<Inferred extends TProperties, Left extends TSchema, Right extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Right>> = TExtendsLeft<Inferred, Left, Evaluated>;
|
|
490
|
+
type TExtendsRightUnion<Inferred extends TProperties, Left extends TSchema, Right extends TSchema[]> = (Right extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Left, Head> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTrue<Inferred> : TExtendsRightUnion<Inferred, Left, Tail> : TExtendsFalse);
|
|
491
|
+
type TExtendsRight<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TAny ? TExtendsRightAny<Inferred, Left> : Right extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TExtendsRightDependent<Inferred, Left, If, Then, Else> : Right extends TEnum<infer Values extends TEnumValue[]> ? TExtendsRightEnum<Inferred, Left, Values> : Right extends TInfer<infer Name extends string, infer Type extends TSchema> ? TExtendsRightInfer<Inferred, Name, Left, Type> : Right extends TTemplateLiteral<infer Pattern extends string> ? TExtendsRightTemplateLiteral<Inferred, Left, Pattern> : Right extends TIntersect<infer Types extends TSchema[]> ? TExtendsRightIntersect<Inferred, Left, Types> : Right extends TUnion<infer Types extends TSchema[]> ? TExtendsRightUnion<Inferred, Left, Types> : Right extends TUnknown ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
492
|
+
|
|
493
|
+
type TExtendsAny<Inferred extends TProperties, Left extends TAny, Right extends TSchema> = (Right extends TInfer ? TExtendsRight<Inferred, Left, Right> : Right extends TAny ? TExtendsTrue<Inferred> : Right extends TUnknown ? TExtendsTrue<Inferred> : TExtendsUnion$1<Inferred>);
|
|
494
|
+
|
|
495
|
+
type TExtendsImmutable<Left extends TSchema, Right extends TSchema, IsImmutableLeft extends boolean = Left extends TImmutable ? true : false, IsImmutableRight extends boolean = Right extends TImmutable ? true : false, Result extends boolean = [
|
|
496
|
+
IsImmutableLeft,
|
|
497
|
+
IsImmutableRight
|
|
498
|
+
] extends [true, true] ? true : [
|
|
499
|
+
IsImmutableLeft,
|
|
500
|
+
IsImmutableRight
|
|
501
|
+
] extends [false, true] ? true : [
|
|
502
|
+
IsImmutableLeft,
|
|
503
|
+
IsImmutableRight
|
|
504
|
+
] extends [true, false] ? false : true> = Result;
|
|
505
|
+
type TExtendsArray<Inferred extends TProperties, ArrayLeft extends TSchema, Left extends TSchema, Right extends TSchema> = (Right extends TArray<infer Type extends TSchema> ? TExtendsImmutable<ArrayLeft, Right> extends true ? TExtendsLeft<Inferred, Left, Type> : TExtendsFalse : TExtendsRight<Inferred, ArrayLeft, Right>);
|
|
506
|
+
|
|
507
|
+
type TExtendsBigInt<Inferred extends TProperties, Left extends TBigInt, Right extends TSchema> = (Right extends TBigInt ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
508
|
+
|
|
509
|
+
type TExtendsBoolean<Inferred extends TProperties, Left extends TBoolean, Right extends TSchema> = (Right extends TBoolean ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
510
|
+
|
|
511
|
+
type TParameterCompare<Inferred extends TProperties, Left extends TSchema, LeftRest extends TSchema[], Right extends TSchema, RightRest extends TSchema[], CheckLeft extends TSchema = Right extends TInfer ? Left : Right, CheckRight extends TSchema = Right extends TInfer ? Right : Left, IsLeftOptional extends boolean = Left extends TOptional ? true : false, IsRightOptional extends boolean = Right extends TOptional ? true : false> = ([
|
|
512
|
+
IsLeftOptional,
|
|
513
|
+
IsRightOptional
|
|
514
|
+
] extends [false, true] ? TExtendsFalse : TExtendsLeft<Inferred, CheckLeft, CheckRight> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsParameters<Inferred, LeftRest, RightRest> : TExtendsFalse);
|
|
515
|
+
type TParameterRight<Inferred extends TProperties, Left extends TSchema, LeftRest extends TSchema[], RightRest extends TSchema[]> = (RightRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TParameterCompare<Inferred, Left, LeftRest, Head, Tail> : Left extends TOptional ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
516
|
+
type TParameterLeft<Inferred extends TProperties, LeftRest extends TSchema[], RightRest extends TSchema[]> = (LeftRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TParameterRight<Inferred, Head, Tail, RightRest> : TExtendsTrue<Inferred>);
|
|
517
|
+
type TExtendsParameters<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[]> = TParameterLeft<Inferred, Left, Right>;
|
|
518
|
+
|
|
519
|
+
type StaticVoid = void;
|
|
520
|
+
/** Represents a Void type. */
|
|
521
|
+
interface TVoid extends TSchema {
|
|
522
|
+
'~kind': 'Void';
|
|
523
|
+
type: 'void';
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
type TExtendsReturnType<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TVoid ? TExtendsTrue<Inferred> : TExtendsLeft<Inferred, Left, Right>);
|
|
527
|
+
|
|
528
|
+
type TExtendsConstructor<Inferred extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema, Right extends TSchema> = (Right extends TAny ? TExtendsTrue<Inferred> : Right extends TUnknown ? TExtendsTrue<Inferred> : Right extends TConstructor ? TExtendsParameters<Inferred, Parameters, Right['parameters']> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsReturnType<Inferred, InstanceType, Right['instanceType']> : TExtendsFalse : TExtendsFalse);
|
|
529
|
+
|
|
530
|
+
type TExtendsDependent<Inferred extends TProperties, If extends TSchema, Then extends TSchema, Else extends TSchema, Right extends TSchema> = (TExtendsLeft<Inferred, If, Right> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsLeft<Inferred, Then, Right> : TExtendsLeft<Inferred, Else, Right>);
|
|
531
|
+
|
|
532
|
+
type TExtendsEnum<Inferred extends TProperties, Left extends TEnumValue[], Right extends TSchema, Evaluated extends TSchema = TEvaluateEnum<Left>> = TExtendsLeft<Inferred, Evaluated, Right>;
|
|
533
|
+
|
|
534
|
+
type TExtendsFunction<Inferred extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema, Right extends TSchema> = (Right extends TAny ? TExtendsTrue<Inferred> : Right extends TUnknown ? TExtendsTrue<Inferred> : Right extends TFunction ? TExtendsParameters<Inferred, Parameters, Right['parameters']> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsReturnType<Inferred, ReturnType, Right['returnType']> : TExtendsFalse : TExtendsFalse);
|
|
535
|
+
|
|
536
|
+
type TExtendsInteger<Inferred extends TProperties, Left extends TInteger, Right extends TSchema> = (Right extends TInteger ? TExtendsTrue<Inferred> : Right extends TNumber ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
537
|
+
|
|
538
|
+
type TExtendsIntersect<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, Evaluated extends TSchema = TEvaluateIntersect<Left>> = TExtendsLeft<Inferred, Evaluated, Right>;
|
|
539
|
+
|
|
540
|
+
type TExtendsLiteralValue<Inferred extends TProperties, Left extends TLiteralValue, Right extends TLiteralValue> = (Left extends Right ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
541
|
+
type TExtendsLiteralBigInt<Inferred extends TProperties, Left extends bigint, Right extends TSchema> = (Right extends TLiteral<infer Value extends bigint> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TBigInt ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
|
|
542
|
+
type TExtendsLiteralBoolean<Inferred extends TProperties, Left extends boolean, Right extends TSchema> = (Right extends TLiteral<infer Value extends boolean> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TBoolean ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
|
|
543
|
+
type TExtendsLiteralNumber<Inferred extends TProperties, Left extends number, Right extends TSchema> = (Right extends TLiteral<infer Value extends number> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TNumber ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
|
|
544
|
+
type TExtendsLiteralString<Inferred extends TProperties, Left extends string, Right extends TSchema> = (Right extends TLiteral<infer Value extends string> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TString ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
|
|
545
|
+
type TExtendsLiteral<Inferred extends TProperties, Left extends TLiteral, Right extends TSchema> = (Left extends TLiteral<infer Value extends bigint> ? TExtendsLiteralBigInt<Inferred, Value, Right> : Left extends TLiteral<infer Value extends boolean> ? TExtendsLiteralBoolean<Inferred, Value, Right> : Left extends TLiteral<infer Value extends number> ? TExtendsLiteralNumber<Inferred, Value, Right> : Left extends TLiteral<infer Value extends string> ? TExtendsLiteralString<Inferred, Value, Right> : TUnreachable);
|
|
546
|
+
|
|
547
|
+
type TExtendsNever<Inferred extends TProperties, Left extends TNever, Right extends TSchema> = (Right extends TInfer ? TExtendsRight<Inferred, Left, Right> : TExtendsTrue<Inferred>);
|
|
548
|
+
|
|
549
|
+
type TExtendsNull<Inferred extends TProperties, Left extends TNull, Right extends TSchema> = (Right extends TNull ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
550
|
+
|
|
551
|
+
type TExtendsNumber<Inferred extends TProperties, Left extends TNumber, Right extends TSchema> = (Right extends TNumber ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
552
|
+
|
|
553
|
+
type TExtendsPropertyOptional<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TOptional<Left> ? Right extends TOptional<Right> ? TExtendsTrue<Inferred> : TExtendsFalse : TExtendsTrue<Inferred>);
|
|
554
|
+
type TExtendsProperty<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TInfer<string, TNever> ? TExtendsFalse : TExtendsLeft<Inferred, Left, Right> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsPropertyOptional<Inferred, Left, Right> : TExtendsFalse);
|
|
555
|
+
type TExtractInferredProperties<Keys extends PropertyKey[], Properties extends Record<PropertyKey, TResult>, Result extends TProperties = {}> = (Keys extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Left extends keyof Properties ? Properties[Left] extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtractInferredProperties<Right, Properties, Result & Inferred> : TExtractInferredProperties<Right, Properties, Result> : TUnreachable : Result);
|
|
556
|
+
type TExtendsPropertiesComparer<Inferred extends TProperties, Left extends TProperties, Right extends TProperties, Properties extends Record<PropertyKey, TExtendsTrue | TExtendsFalse> = {
|
|
557
|
+
[RightKey in keyof Right]: (RightKey extends keyof Left ? TExtendsProperty<{}, Left[RightKey], Right[RightKey]> : Right[RightKey] extends TOptional<Right[RightKey]> ? Right[RightKey] extends TInfer ? TExtendsTrue<TAssign<Inferred, {
|
|
558
|
+
[_ in Right[RightKey]['name']]: Right[RightKey]['extends'];
|
|
559
|
+
}>> : TExtendsTrue<Inferred> : TExtendsFalse);
|
|
560
|
+
}, Checked extends boolean = Properties[keyof Right] extends TExtendsTrueLike ? true : false, Extracted extends TProperties = Checked extends true ? TExtractInferredProperties<TUnionToTuple<keyof Properties>, Properties> : {}> = (Checked extends true ? TExtendsTrue<Extracted> : TExtendsFalse);
|
|
561
|
+
type TExtendsProperties<Inferred extends TProperties, Left extends TProperties, Right extends TProperties, Compared extends TResult = TExtendsPropertiesComparer<Inferred, Left, Right>> = (Compared extends TExtendsTrueLike<infer ComparedInferred extends TProperties> ? TExtendsTrue<TAssign<Inferred, ComparedInferred>> : TExtendsFalse);
|
|
562
|
+
type TExtendsObjectToObject<Inferred extends TProperties, Left extends TProperties, Right extends TProperties> = (TExtendsProperties<Inferred, Left, Right>);
|
|
563
|
+
type TRecordMergeInferred<Left extends TProperties, Right extends TProperties, Result extends TProperties = {
|
|
564
|
+
[Key in keyof Right]: Key extends keyof Left ? Left[Key] extends TUnion<infer Types extends TSchema[]> ? TUnion<[...Types, Right[Key]]> : TUnion<[Left[Key], Right[Key]]> : Right[Key];
|
|
565
|
+
}> = Result;
|
|
566
|
+
type TExtendsRecordComparer<Properties extends TProperties, Keys extends (keyof Properties)[], Type extends TSchema, Result extends TProperties> = (Keys extends [infer Left extends (keyof Properties), ...infer Right extends (keyof Properties)[]] ? TExtendsLeft<{}, Properties[Left], Type> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsRecordComparer<Properties, Right, Type, TRecordMergeInferred<Result, Inferred>> : Result.TExtendsFalse : Result.TExtendsTrue<Result>);
|
|
567
|
+
type TExtendsObjectToRecord<Inferred extends TProperties, Properties extends TProperties, _Pattern extends string, Value extends TSchema, Keys extends (keyof Properties)[] = TUnionToTuple<keyof Properties>, Result extends TResult = TExtendsRecordComparer<Properties, Keys, Value, Inferred>> = Result;
|
|
568
|
+
type TExtendsObject<Inferred extends TProperties, Left extends TProperties, Right extends TSchema> = (Right extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TExtendsObjectToRecord<Inferred, Left, Pattern, Value> : Right extends TObject<infer Properties extends TProperties> ? TExtendsObjectToObject<Inferred, Left, Properties> : TExtendsRight<Inferred, TObject<Left>, Right>);
|
|
569
|
+
|
|
570
|
+
type TFromObject$6<Inferred extends TProperties, Properties extends TProperties> = keyof Properties extends never ? TExtendsTrue<Inferred> : TExtendsFalse;
|
|
571
|
+
type TFromRecord$1<Inferred extends TProperties, _LeftKey extends TSchema, LeftValue extends TSchema, _RightKey extends TSchema, RightValue extends TSchema> = (TExtendsLeft<Inferred, LeftValue, RightValue>);
|
|
572
|
+
type TExtendsRecord<Inferred extends TProperties, LeftPattern extends string, LeftValue extends TSchema, Right extends TSchema> = (Right extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TFromRecord$1<Inferred, TRecordPatternToType<LeftPattern>, LeftValue, TRecordPatternToType<Pattern>, Value> : Right extends TObject<infer Properties extends TProperties> ? TFromObject$6<Inferred, Properties> : Right extends TAny ? TExtendsTrue<Inferred> : Right extends TUnknown ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
573
|
+
|
|
574
|
+
type TExtendsString<Inferred extends TProperties, Left extends TString, Right extends TSchema> = (Right extends TString ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
575
|
+
|
|
576
|
+
type TExtendsSymbol<Inferred extends TProperties, Left extends TSymbol, Right extends TSchema> = (Right extends TSymbol ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
577
|
+
|
|
578
|
+
type TExtendsTemplateLiteral<Inferred extends TProperties, Pattern extends string, Right extends TSchema, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>> = TExtendsLeft<Inferred, Evaluated, Right>;
|
|
579
|
+
|
|
580
|
+
/** Represents a Rest instruction. */
|
|
581
|
+
interface TRest<Type extends TSchema = TSchema> extends TSchema {
|
|
582
|
+
'~kind': 'Rest';
|
|
583
|
+
type: 'rest';
|
|
584
|
+
items: Type;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
interface TInferable<Name extends string = string, Type extends TSchema = TSchema> {
|
|
588
|
+
'~kind': 'Inferrable';
|
|
589
|
+
name: Name;
|
|
590
|
+
type: Type;
|
|
591
|
+
}
|
|
592
|
+
type TTryRestInferable<Type extends TSchema, Result extends TInferable | undefined = (Type extends TRest<infer RestType extends TSchema> ? RestType extends TInfer<infer Name extends string, infer Type extends TSchema> ? Type extends TArray<infer Type extends TSchema> ? TInferable<Name, Type> : Type extends TUnknown ? TInferable<Name, Type> : undefined : TUnreachable : undefined)> = Result;
|
|
593
|
+
type TTryInferable<Type extends TSchema, Result extends TInferable | undefined = (Type extends TInfer<infer Name extends string, infer Type extends TSchema> ? TInferable<Name, Type> : undefined)> = Result;
|
|
594
|
+
type TryInferResults<Rest extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Rest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<{}, Head, Right> extends Result.TExtendsTrueLike ? TryInferResults<Tail, Right, [...Result, Head]> : undefined : Result);
|
|
595
|
+
declare function TryInferResults<Rest extends TSchema[], Right extends TSchema>(rest: [...Rest], right: Right, result?: TSchema[]): TryInferResults<Rest, Right>;
|
|
596
|
+
type TInferTupleResult<Inferred extends TProperties, Name extends string, Left extends TSchema[], Right extends TSchema, Results extends TSchema[] | undefined = TryInferResults<Left, Right>> = (Results extends [...infer Results extends TSchema[]] ? TExtendsTrue<TAssign<Inferred, {
|
|
597
|
+
[_ in Name]: TTuple<Results>;
|
|
598
|
+
}>> : TExtendsFalse);
|
|
599
|
+
type TInferUnionResult<Inferred extends TProperties, Name extends string, Left extends TSchema[], Right extends TSchema, Results extends TSchema[] | undefined = TryInferResults<Left, Right>> = (Results extends [...infer Results extends TSchema[]] ? TExtendsTrue<TAssign<Inferred, {
|
|
600
|
+
[_ in Name]: TUnion<Results>;
|
|
601
|
+
}>> : TExtendsFalse);
|
|
602
|
+
|
|
603
|
+
type TReverse<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReverse<Right, [Left, ...Result]> : Result);
|
|
604
|
+
type TApplyReverse<Types extends TSchema[], Reversed extends boolean> = Reversed extends true ? TReverse<Types> : Types;
|
|
605
|
+
type TReversed<Types extends TSchema[], First extends TSchema | undefined = Types extends [infer Left extends TSchema, ...infer _ extends TSchema[]] ? Left : undefined, Inferable extends TSchema | undefined = First extends TSchema ? TTryRestInferable<First> : undefined, Result extends boolean = Inferable extends TSchema ? true : false> = Result;
|
|
606
|
+
type TElementsCompare<Inferred extends TProperties, Reversed extends boolean, Left extends TSchema, LeftRest extends TSchema[], Right extends TSchema, RightRest extends TSchema[]> = (TExtendsLeft<Inferred, Left, Right> extends TExtendsTrueLike<infer CheckInferred extends TProperties> ? TElements<CheckInferred, Reversed, LeftRest, RightRest> : TExtendsFalse);
|
|
607
|
+
type TElementsLeft<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], Right extends TSchema, RightRest extends TSchema[], Inferable extends TInferable | undefined = TTryRestInferable<Right>> = (Inferable extends TInferable ? TInferTupleResult<Inferred, Inferable['name'], TApplyReverse<LeftRest, Reversed>, Inferable['type']> : LeftRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TElementsCompare<Inferred, Reversed, Head, Tail, Right, RightRest> : TExtendsFalse);
|
|
608
|
+
type TElementsRight<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], RightRest extends TSchema[]> = (RightRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TElementsLeft<Inferred, Reversed, LeftRest, Head, Tail> : LeftRest['length'] extends 0 ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
609
|
+
type TElements<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], RightRest extends TSchema[]> = TElementsRight<Inferred, Reversed, LeftRest, RightRest>;
|
|
610
|
+
type TExtendsTupleToTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[], InstantiatedRight extends TSchema[] = TInstantiateElements<Inferred, TState<[], []>, Right>, Reversed extends boolean = TReversed<InstantiatedRight>> = TElements<Inferred, Reversed, TApplyReverse<Left, Reversed>, TApplyReverse<InstantiatedRight, Reversed>>;
|
|
611
|
+
type TExtendsTupleToArray<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, Inferrable extends TInferable | undefined = TTryInferable<Right>> = (Inferrable extends TInferable ? TInferUnionResult<Inferred, Inferrable['name'], Left, Inferrable['type']> : Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Head, Right> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTupleToArray<Inferred, Tail, Right> : TExtendsFalse : TExtendsTrue<Inferred>);
|
|
612
|
+
type TExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, InstantiatedLeft extends TSchema[] = TInstantiateElements<Inferred, TState<[], []>, Left>> = (Right extends TTuple<infer Types extends TSchema[]> ? TExtendsTupleToTuple<Inferred, InstantiatedLeft, Types> : Right extends TArray<infer Type extends TSchema> ? TExtendsTupleToArray<Inferred, InstantiatedLeft, Type> : TExtendsRight<Inferred, TTuple<InstantiatedLeft>, Right>);
|
|
613
|
+
|
|
614
|
+
type StaticUndefined = undefined;
|
|
615
|
+
/** Represents a Undefined type. */
|
|
616
|
+
interface TUndefined extends TSchema {
|
|
617
|
+
'~kind': 'Undefined';
|
|
618
|
+
type: 'undefined';
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
type TExtendsUndefined<Inferred extends TProperties, Left extends TUndefined, Right extends TSchema> = (Right extends TVoid ? TExtendsTrue<Inferred> : Right extends TUndefined ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
622
|
+
|
|
623
|
+
type TExtendsUnionSome<Inferred extends TProperties, Type extends TSchema, UnionTypes extends TSchema[]> = (UnionTypes extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Type, Head> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTrue<Inferred> : TExtendsUnionSome<Inferred, Type, Tail> : TExtendsFalse);
|
|
624
|
+
type TExtendsUnionLeft<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[]> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsUnionSome<Inferred, Head, Right> extends TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsUnionLeft<Inferred, Tail, Right> : TExtendsFalse : TExtendsTrue<Inferred>);
|
|
625
|
+
type TExtendsUnion<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, Inferrable extends TInferable | undefined = TTryInferable<Right>> = (Inferrable extends TInferable<infer Name extends string, infer Type extends TSchema> ? TInferUnionResult<Inferred, Name, Left, Type> : Right extends TUnion<infer Types extends TSchema[]> ? TExtendsUnionLeft<Inferred, Left, Types> : TExtendsUnionLeft<Inferred, Left, [Right]>);
|
|
626
|
+
|
|
627
|
+
type TExtendsUnknown<Inferred extends TProperties, Left extends TUnknown, Right extends TSchema> = (Right extends TInfer ? TExtendsRight<Inferred, Left, Right> : Right extends TAny ? TExtendsTrue<Inferred> : Right extends TUnknown ? TExtendsTrue<Inferred> : TExtendsFalse);
|
|
628
|
+
|
|
629
|
+
type TExtendsVoid<Inferred extends TProperties, Left extends TVoid, Right extends TSchema> = (Right extends TVoid ? TExtendsTrue<Inferred> : TExtendsRight<Inferred, Left, Right>);
|
|
630
|
+
|
|
631
|
+
type TExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TAny ? TExtendsAny<Inferred, Left, Right> : Left extends TArray<infer Items extends TSchema> ? TExtendsArray<Inferred, Left, Items, Right> : Left extends TBigInt ? TExtendsBigInt<Inferred, Left, Right> : Left extends TBoolean ? TExtendsBoolean<Inferred, Left, Right> : Left extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TExtendsConstructor<Inferred, Parameters, InstanceType, Right> : Left extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TExtendsDependent<Inferred, If, Then, Else, Right> : Left extends TEnum<infer Values extends TEnumValue[]> ? TExtendsEnum<Inferred, Values, Right> : Left extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TExtendsFunction<Inferred, Parameters, ReturnType, Right> : Left extends TInteger ? TExtendsInteger<Inferred, Left, Right> : Left extends TIntersect<infer Types extends TSchema[]> ? TExtendsIntersect<Inferred, Types, Right> : Left extends TLiteral ? TExtendsLiteral<Inferred, Left, Right> : Left extends TNever ? TExtendsNever<Inferred, Left, Right> : Left extends TNull ? TExtendsNull<Inferred, Left, Right> : Left extends TNumber ? TExtendsNumber<Inferred, Left, Right> : Left extends TObject<infer Properties extends TProperties> ? TExtendsObject<Inferred, Properties, Right> : Left extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TExtendsRecord<Inferred, Pattern, Value, Right> : Left extends TString ? TExtendsString<Inferred, Left, Right> : Left extends TSymbol ? TExtendsSymbol<Inferred, Left, Right> : Left extends TTemplateLiteral<infer Pattern extends string> ? TExtendsTemplateLiteral<Inferred, Pattern, Right> : Left extends TTuple<infer Types extends TSchema[]> ? TExtendsTuple<Inferred, Types, Right> : Left extends TUndefined ? TExtendsUndefined<Inferred, Left, Right> : Left extends TUnion<infer Types extends TSchema[]> ? TExtendsUnion<Inferred, Types, Right> : Left extends TUnknown ? TExtendsUnknown<Inferred, Left, Right> : Left extends TVoid ? TExtendsVoid<Inferred, Left, Right> : TExtendsFalse);
|
|
632
|
+
|
|
633
|
+
type TInterfaceOperation<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TEvaluateIntersect<[...Heritage, TObject<Properties>]>> = Result;
|
|
634
|
+
type TInterfaceAction<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TCanInstantiate<Heritage> extends true ? TInterfaceOperation<Heritage, Properties> : TInterfaceDeferred<Heritage, Properties>> = Result;
|
|
635
|
+
type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, State, Heritage>, InstantiatedProperties extends TProperties = TInstantiateProperties<Context, State, Properties>> = TInterfaceAction<InstantiatedHeritage, InstantiatedProperties>;
|
|
636
|
+
|
|
637
|
+
/** Creates a deferred Interface action. */
|
|
638
|
+
type TInterfaceDeferred<Heritage extends TSchema[] = TSchema[], Properties extends TProperties = TProperties> = (TDeferred<'Interface', [Heritage, Properties]>);
|
|
639
|
+
|
|
640
|
+
type TFromRef$3<Stack extends (keyof Context)[], Context extends TProperties, Ref extends (keyof Context)> = Ref extends Stack[number] ? true : TFromType$h<[...Stack, Ref], Context, Context[Ref]>;
|
|
641
|
+
type TFromProperties$2<Stack extends (keyof Context)[], Context extends TProperties, Properties extends TProperties, Types extends TSchema[] = TPropertyValues<Properties>> = TFromTypes$4<Stack, Context, Types>;
|
|
642
|
+
type TFromTypes$4<Stack extends (keyof Context)[], Context extends TProperties, Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromType$h<Stack, Context, Left> extends true ? true : TFromTypes$4<Stack, Context, Right> : false;
|
|
643
|
+
type TFromType$h<Stack extends (keyof Context)[], Context extends TProperties, Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef$3<Stack, Context, Ref> : Type extends TArray<infer Type extends TSchema> ? TFromType$h<Stack, Context, Type> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromTypes$4<Stack, Context, [...Parameters, InstanceType]> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromTypes$4<Stack, Context, [...Parameters, ReturnType]> : Type extends TInterfaceDeferred<TSchema[], infer Properties extends TProperties> ? TFromProperties$2<Stack, Context, Properties> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromTypes$4<Stack, Context, Types> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties$2<Stack, Context, Properties> : Type extends TUnion<infer Types extends TSchema[]> ? TFromTypes$4<Stack, Context, Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTypes$4<Stack, Context, Types> : Type extends TRecord<string, infer Type extends TSchema> ? TFromType$h<Stack, Context, Type> : false);
|
|
644
|
+
/** Performs a cyclic check on the given type. Initial key stack can be empty, but faster if specified */
|
|
645
|
+
type TCyclicCheck<Stack extends (keyof Context)[], Context extends TProperties, Type extends TSchema, Result extends boolean = TFromType$h<Stack, Context, Type>> = Result;
|
|
646
|
+
|
|
647
|
+
type TResolveCandidateKeys<Context extends TProperties, Keys extends (keyof Context)[], Result extends (keyof Context)[] = []> = (Keys extends [infer Left extends keyof Context, ...infer Right extends (keyof Context)[]] ? TCyclicCheck<[Left], Context, Context[Left]> extends true ? TResolveCandidateKeys<Context, Right, [...Result, Left]> : TResolveCandidateKeys<Context, Right, Result> : Result);
|
|
648
|
+
/** Returns keys for context types that need to be transformed to TCyclic. */
|
|
649
|
+
type TCyclicCandidates<Context extends TProperties, Keys extends (keyof Context)[] = TPropertyKeys<Context>, Result extends (keyof Context)[] = TResolveCandidateKeys<Context, Keys>> = Result;
|
|
650
|
+
|
|
651
|
+
type TFromRef$2<Context extends TProperties, Ref extends string, Dependencies extends string[]> = Ref extends Dependencies[number] ? Dependencies : Ref extends keyof Context ? TFromType$g<Context, Context[Ref], [...Dependencies, Ref]> : TUnreachable;
|
|
652
|
+
type TFromProperties$1<Context extends TProperties, Properties extends TProperties, Dependencies extends string[], Types extends TSchema[] = TPropertyValues<Properties>> = TFromTypes$3<Context, Types, Dependencies>;
|
|
653
|
+
type TFromTypes$3<Context extends TProperties, Types extends TSchema[], Dependencies extends string[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes$3<Context, Right, TFromType$g<Context, Left, Dependencies>> : Dependencies;
|
|
654
|
+
type TFromType$g<Context extends TProperties, Type extends TSchema, Result extends string[]> = (Type extends TRef<infer Ref extends string> ? TFromRef$2<Context, Ref, Result> : Type extends TArray<infer Type extends TSchema> ? TFromType$g<Context, Type, Result> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromTypes$3<Context, [...Parameters, InstanceType], Result> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromTypes$3<Context, [...Parameters, ReturnType], Result> : Type extends TInterfaceDeferred<TSchema[], infer Properties extends TProperties> ? TFromProperties$1<Context, Properties, Result> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromTypes$3<Context, Types, Result> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties$1<Context, Properties, Result> : Type extends TUnion<infer Types extends TSchema[]> ? TFromTypes$3<Context, Types, Result> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTypes$3<Context, Types, Result> : Type extends TRecord<string, infer Type extends TSchema> ? TFromType$g<Context, Type, Result> : Result);
|
|
655
|
+
/** Returns dependent cyclic keys for the given type. This function is used to dead-type-eliminate (DTE) for initializing TCyclic types. */
|
|
656
|
+
type TCyclicDependencies<Context extends TProperties, Key extends string, Type extends TSchema, Result extends string[] = TFromType$g<Context, Type, [Key]>> = Result;
|
|
657
|
+
|
|
658
|
+
type TFromRef$1<_Ref extends string> = (TAny);
|
|
659
|
+
type TFromProperties<Properties extends TProperties, Result extends TProperties = {
|
|
660
|
+
[Key in keyof Properties]: TFromType$f<Properties[Key]>;
|
|
661
|
+
}> = {
|
|
662
|
+
[Key in keyof Result]: Result[Key];
|
|
663
|
+
};
|
|
664
|
+
type TFromTypes$2<Types extends TSchema[], Result extends TSchema[] = []> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes$2<Right, [...Result, TFromType$f<Left>]> : Result;
|
|
665
|
+
type TFromType$f<Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef$1<Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TFromType$f<Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFunction<TFromTypes$2<Parameters>, TFromType$f<InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TFromTypes$2<Parameters>, TFromType$f<ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromTypes$2<Types>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TFromProperties<Properties>> : Type extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TRecord<Pattern, TFromType$f<Value>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromTypes$2<Types>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TFromTypes$2<Types>> : Type);
|
|
666
|
+
type TCyclicAnyFromParameters<Defs extends TProperties, Ref extends string> = (Ref extends keyof Defs ? TFromType$f<Defs[Ref]> : TUnknown);
|
|
667
|
+
/** Transforms TCyclic TRef's into TAny's. This function is used prior to TExtends checks to enable cyclics to be structurally checked and terminated (with TAny) at first point of recursion, what would otherwise be a recursive TRef.*/
|
|
668
|
+
type TCyclicExtends<Type extends TCyclic, Result extends TSchema = TCyclicAnyFromParameters<Type['$defs'], Type['$ref']>> = Result;
|
|
669
|
+
|
|
670
|
+
type TCyclicInterface<Context extends TProperties, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, TState<[], []>, Heritage>, instantiatedProperties extends TProperties = TInstantiateProperties<{}, TState<[], []>, Properties>, EvaluatedInterface extends TSchema = TEvaluateIntersect<[...InstantiatedHeritage, TObject<instantiatedProperties>]>> = EvaluatedInterface;
|
|
671
|
+
type TCyclicDefinitions<Context extends TProperties, Dependencies extends string[], Result extends TProperties = {
|
|
672
|
+
[Key in Extract<keyof Context, Dependencies[number]>]: Context[Key] extends TInterfaceDeferred<infer Heritage extends TSchema[], infer Properties extends TProperties> ? TCyclicInterface<Context, Heritage, Properties> : Context[Key];
|
|
673
|
+
}> = Result;
|
|
674
|
+
type TInstantiateCyclic<Context extends TProperties, Ref extends string, Type extends TSchema, Dependencies extends string[] = TCyclicDependencies<Context, Ref, Type>, Definitions extends TProperties = TCyclicDefinitions<Context, Dependencies>, Result extends TSchema = TCyclic<Definitions, Ref>> = Result;
|
|
675
|
+
|
|
676
|
+
type TResolve$1<Defs extends TProperties, Ref extends string> = (Ref extends keyof Defs ? Defs[Ref] extends TRef<infer Ref extends string> ? TResolve$1<Defs, Ref> : Defs[Ref] : TNever);
|
|
677
|
+
/** Returns the target Type from the Defs or Never if target is non-resolvable */
|
|
678
|
+
type TCyclicTarget<Defs extends TProperties, Ref extends string, Result extends TSchema = TResolve$1<Defs, Ref>> = Result;
|
|
679
|
+
|
|
680
|
+
type TCanonical<Type extends TSchema> = (Type extends TCyclic ? TCyclicExtends<Type> : Type extends TUnsafe ? TUnknown : Type);
|
|
681
|
+
/** Performs a structural extends check on left and right types and yields inferred types on right if specified. */
|
|
682
|
+
type TExtends<Inferred extends TProperties, Left extends TSchema, Right extends TSchema, CanonicalLeft extends TSchema = TCanonical<Left>, CanonicalRight extends TSchema = TCanonical<Right>> = TExtendsLeft<Inferred, CanonicalLeft, CanonicalRight>;
|
|
683
|
+
|
|
684
|
+
type TExcludeType<Left extends TSchema, Right extends TSchema, Check extends TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends TExtendsTrueLike ? [] : [Left]> = Result;
|
|
685
|
+
type TExcludeUnion<Left extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExcludeUnion<Tail, Right, [...Result, ...TExcludeType<Head, Right>]> : Result);
|
|
686
|
+
type TExcludeOperation<Left extends TSchema, Right extends TSchema, Evaluated extends TSchema = TEvaluateType<Left>, Canonical extends TSchema[] = Evaluated extends TUnion<infer Types extends TSchema[]> ? Types : [Evaluated], Remaining extends TSchema[] = TExcludeUnion<Canonical, Right>, Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
687
|
+
|
|
688
|
+
type TEvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema, Intersected extends TSchema = TEvaluateIntersect<[If, Then]>, Excluded extends TSchema = TExcludeOperation<Else, If>, Result extends TSchema = TEvaluateUnion<[Intersected, Excluded]>> = Result;
|
|
689
|
+
type TEvaluateEnum<Values extends TEnumValue[], Result extends TSchema[] = []> = (Values extends [infer Left extends TEnumValue, ...infer Right extends TEnumValue[]] ? TEvaluateEnum<Right, [...Result, TLiteral<Left>]> : TEvaluateUnion<Result>);
|
|
690
|
+
type TEvaluateIntersect<Types extends TSchema[], Distribution extends TSchema[] = TDistribute$1<Types>, Broadend extends TSchema[] = TBroaden<Distribution>, Result extends TSchema = TEvaluateUnion<Broadend>> = Result;
|
|
691
|
+
type TEvaluateTemplateLiteral<Pattern extends string, Evaluated extends TSchema = TTemplateLiteralDecode<Pattern>, Result extends TSchema = TEvaluateType<Evaluated>> = Result;
|
|
692
|
+
type TEvaluateUnion<Types extends TSchema[], Broadend extends TSchema[] = TBroaden<Types>, Result extends TSchema = TEvaluateUnionFast<Broadend>> = Result;
|
|
693
|
+
type TEvaluateType<Type extends TSchema, Result extends TSchema = (Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TEvaluateDependent<If, Then, Else> : Type extends TEnum<infer Values extends TEnumValue[]> ? TEvaluateEnum<Values> : Type extends TIntersect<infer Types extends TSchema[]> ? TEvaluateIntersect<Types> : Type extends TTemplateLiteral<infer Pattern extends string> ? TEvaluateTemplateLiteral<Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEvaluateUnion<Types> : Type)> = Result;
|
|
694
|
+
type TEvaluateUnionFast<Types extends TSchema[], Result extends TSchema = (Types extends [infer Type extends TSchema] ? Type : Types extends [] ? TNever : TUnion<Types>)> = Result;
|
|
695
|
+
|
|
696
|
+
type TJoinString<Input extends string[], Result extends string = ''> = (Input extends [infer Left extends string, ...infer Right extends string[]] ? Result extends '' ? TJoinString<Right, Left> : TJoinString<Right, `${Result}|${Left}`> : Result);
|
|
697
|
+
type TUnwrapTemplateLiteralPattern<Pattern extends string> = (Pattern extends `^${infer Pattern extends string}$` ? Pattern : never);
|
|
698
|
+
type TEncodeLiteral<Value extends TLiteralValue, Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${Value}`>);
|
|
699
|
+
type TEncodeBigInt<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof BigIntPattern}`>);
|
|
700
|
+
type TEncodeInteger<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof IntegerPattern}`>);
|
|
701
|
+
type TEncodeNumber<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof NumberPattern}`>);
|
|
702
|
+
type TEncodeBoolean<Right extends TSchema[], Pattern extends string> = (TEncodeType<TUnion<[TLiteral<'false'>, TLiteral<'true'>]>, Right, Pattern>);
|
|
703
|
+
type TEncodeString<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof StringPattern}`>);
|
|
704
|
+
type TEncodeTemplateLiteral<TemplatePattern extends string, Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${TUnwrapTemplateLiteralPattern<TemplatePattern>}`>);
|
|
705
|
+
type TEncodeTemplateLiteralDeferred<Types extends TSchema[], Right extends TSchema[], Pattern extends string, TemplateLiteral extends TSchema = TTemplateLiteralAction<Types>, Result extends TSchema = TEncodeType<TemplateLiteral, Right, Pattern>> = Result;
|
|
706
|
+
type TEncodeEnum<Values extends TEnumValue[], Right extends TSchema[], Pattern extends string, Evaluated extends TSchema = TEvaluateEnum<Values>> = TEncodeType<Evaluated, Right, Pattern>;
|
|
707
|
+
type TEncodeUnion<Types extends TSchema[], Right extends TSchema[], Pattern extends string, Result extends string[] = []> = Types extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TEncodeUnion<Tail, Right, Pattern, [...Result, TEncodeType<Head, [], ''>]> : TEncodeTypes<Right, `${Pattern}(${TJoinString<Result>})`>;
|
|
708
|
+
type TEncodeType<Type extends TSchema, Right extends TSchema[], Pattern extends string> = (Type extends TEnum<infer Values extends TEnumValue[]> ? TEncodeEnum<Values, Right, Pattern> : Type extends TInteger ? TEncodeInteger<Right, Pattern> : Type extends TLiteral<infer Value extends TLiteralValue> ? TEncodeLiteral<Value, Right, Pattern> : Type extends TBigInt ? TEncodeBigInt<Right, Pattern> : Type extends TBoolean ? TEncodeBoolean<Right, Pattern> : Type extends TNumber ? TEncodeNumber<Right, Pattern> : Type extends TString ? TEncodeString<Right, Pattern> : Type extends TTemplateLiteral<infer TemplatePattern extends string> ? TEncodeTemplateLiteral<TemplatePattern, Right, Pattern> : Type extends TTemplateLiteralDeferred<infer Types extends TSchema[]> ? TEncodeTemplateLiteralDeferred<Types, Right, Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEncodeUnion<Types, Right, Pattern> : typeof NeverPattern);
|
|
709
|
+
type TEncodeTypes<Types extends TSchema[], Pattern extends string> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TEncodeType<Left, Right, Pattern> : Pattern);
|
|
710
|
+
type TEncodePattern<Types extends TSchema[], Encoded extends string = TEncodeTypes<Types, ''>, Result extends string = `^${Encoded}$`> = Result;
|
|
711
|
+
/** Encodes a TemplateLiteral type sequence into a TemplateLiteral */
|
|
712
|
+
type TTemplateLiteralEncode<Types extends TSchema[], Pattern extends string = TEncodePattern<Types>, Result extends TSchema = TTemplateLiteral<Pattern>> = Result;
|
|
713
|
+
|
|
714
|
+
type TTemplateLiteralAction<Types extends TSchema[], Result extends TSchema = TCanInstantiate<Types> extends true ? TTemplateLiteralEncode<Types> : TTemplateLiteralDeferred<Types>> = Result;
|
|
715
|
+
type TTemplateLiteralInstantiate<Context extends TProperties, State extends TState, Types extends TSchema[], InstantiatedTypes extends TSchema[] = TInstantiateTypes<Context, State, Types>> = TTemplateLiteralAction<InstantiatedTypes>;
|
|
716
|
+
|
|
717
|
+
type StaticTemplateLiteral<Pattern extends string> = (TTemplateLiteralStatic<Pattern>);
|
|
718
|
+
/** Represents a TemplateLiteral type. */
|
|
719
|
+
interface TTemplateLiteral<Pattern extends string = string> extends TSchema {
|
|
720
|
+
'~kind': 'TemplateLiteral';
|
|
721
|
+
type: 'string';
|
|
722
|
+
pattern: Pattern;
|
|
723
|
+
}
|
|
724
|
+
/** Creates a deferred TemplateLiteral action. */
|
|
725
|
+
type TTemplateLiteralDeferred<Types extends TSchema[] = TSchema[]> = (TDeferred<'TemplateLiteral', [Types]>);
|
|
726
|
+
|
|
727
|
+
type TFromLiteral$4<_Value extends TLiteralValue> = true;
|
|
728
|
+
type TFromTypesReduce<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromType$e<Left> extends true ? TFromTypesReduce<Right> : false : true);
|
|
729
|
+
type TFromTypes$1<Types extends TSchema[], Result extends boolean = Types extends [] ? false : TFromTypesReduce<Types>> = Result;
|
|
730
|
+
type TFromType$e<Type extends TSchema> = Type extends TUnion<infer Types extends TSchema[]> ? TFromTypes$1<Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral$4<Value> : false;
|
|
731
|
+
/** Returns true if the given TemplateLiteral types yields a finite variant set */
|
|
732
|
+
type TIsTemplateLiteralFinite<Types extends TSchema[], Result extends boolean = TFromTypes$1<Types>> = Result;
|
|
733
|
+
|
|
734
|
+
type TFromLiteralPush<Variants extends string[], Value extends TLiteralValue, Result extends string[] = []> = Variants extends [infer Left extends string, ...infer Right extends string[]] ? TFromLiteralPush<Right, Value, [...Result, `${Left}${Value}`]> : Result;
|
|
735
|
+
type TFromLiteral$3<Variants extends string[], Value extends TLiteralValue> = Variants extends [] ? [`${Value}`] : TFromLiteralPush<Variants, Value>;
|
|
736
|
+
type TFromUnion$7<Variants extends string[], Types extends TSchema[], Result extends string[] = []> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$7<Variants, Right, [...Result, ...TFromType$d<Variants, Left>]> : Result;
|
|
737
|
+
type TFromType$d<Variants extends string[], Type extends TSchema, Result extends string[] = (Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$7<Variants, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral$3<Variants, Value> : TUnreachable)> = Result;
|
|
738
|
+
type TDecodeFromSpan<Variants extends string[], Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDecodeFromSpan<TFromType$d<Variants, Left>, Right> : Variants;
|
|
739
|
+
type TVariantsToLiterals<Variants extends string[], Result extends TSchema[] = []> = Variants extends [infer Left extends string, ...infer Right extends string[]] ? TVariantsToLiterals<Right, [...Result, TLiteral<Left>]> : Result;
|
|
740
|
+
type TDecodeTypesAsUnion<Types extends TSchema[], Variants extends string[] = TDecodeFromSpan<[], Types>, Literals extends TSchema[] = TVariantsToLiterals<Variants>, Result extends TSchema = TUnion<Literals>> = Result;
|
|
741
|
+
type TDecodeTypes<Types extends TSchema[], Result extends TSchema = (Types extends [] ? TUnreachable : Types extends [infer Type extends TLiteral] ? Type : TDecodeTypesAsUnion<Types>)> = Result;
|
|
742
|
+
/** Decodes a TemplateLiteral into a Type. */
|
|
743
|
+
type TTemplateLiteralDecodeUnsafe<Pattern extends string, Types extends TSchema[] = TParsePatternIntoTypes<Pattern>, Result extends TSchema = (Types extends [] ? TString : TIsTemplateLiteralFinite<Types> extends true ? TDecodeTypes<Types> : TTemplateLiteral<Pattern>)> = Result;
|
|
744
|
+
/** Decodes a TemplateLiteral pattern but returns TString if the pattern in non-finite. */
|
|
745
|
+
type TTemplateLiteralDecode<Pattern extends string, Decoded extends TSchema = TTemplateLiteralDecodeUnsafe<Pattern>, Result extends TSchema = Decoded extends TTemplateLiteral ? TString : Decoded> = Result;
|
|
746
|
+
|
|
747
|
+
type TFromAnyKey<Value extends TSchema, Result extends TSchema = TRecord<typeof StringKey, Value>> = Result;
|
|
748
|
+
|
|
749
|
+
type TFromBooleanKey<Value extends TSchema, Result extends TSchema = TObject<{
|
|
750
|
+
true: Value;
|
|
751
|
+
false: Value;
|
|
752
|
+
}>> = Result;
|
|
753
|
+
|
|
754
|
+
type TFromEnumKey<Values extends TEnumValue[], Value extends TSchema, UnionKey extends TSchema = TEvaluateEnum<Values>, Result extends TSchema = TFromKey<UnionKey, Value>> = Result;
|
|
755
|
+
|
|
756
|
+
type TFromIntegerKey<_Key extends TInteger, Value extends TSchema, Result extends TSchema = TRecord<typeof IntegerKey, Value>> = Result;
|
|
757
|
+
|
|
758
|
+
type TFromIntersectKey<Types extends TSchema[], Value extends TSchema, EvaluatedKey extends TSchema = TEvaluateIntersect<Types>, Result extends TSchema = TFromKey<EvaluatedKey, Value>> = Result;
|
|
759
|
+
|
|
760
|
+
type TFromLiteralKey<Key extends TLiteralValue, Value extends TSchema, Result extends TSchema = (Key extends string | number ? TObject<{
|
|
761
|
+
[_ in Key]: Value;
|
|
762
|
+
}> : Key extends false ? TObject<{
|
|
763
|
+
false: Value;
|
|
764
|
+
}> : Key extends true ? TObject<{
|
|
765
|
+
true: Value;
|
|
766
|
+
}> : TObject<{}>)> = Result;
|
|
767
|
+
|
|
768
|
+
type TFromNumberKey<Key extends TNumber, Value extends TSchema, Result extends TSchema = TRecord<typeof NumberKey, Value>> = Result;
|
|
769
|
+
|
|
770
|
+
type TFromStringKey<_Key extends TSchema, Value extends TSchema, Result extends TSchema = TRecord<typeof StringKey, Value>> = Result;
|
|
771
|
+
|
|
772
|
+
type TFromTemplateKey<Pattern extends string, Value extends TSchema, Types extends TSchema[] = TParsePatternIntoTypes<Pattern>, Finite extends boolean = TIsTemplateLiteralFinite<Types>, Result extends TSchema = Finite extends true ? TFromKey<TEvaluateTemplateLiteral<Pattern>, Value> : TRecord<Pattern, Value>> = Result;
|
|
773
|
+
|
|
774
|
+
type TFlattenType<Type extends TSchema, Result extends TSchema[] = Type extends TUnion<infer Types extends TSchema[]> ? TFlatten<Types> : [Type]> = Result;
|
|
775
|
+
type TFlatten<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFlatten<Right, [...Result, ...TFlattenType<Left>]> : Result);
|
|
776
|
+
|
|
777
|
+
type TStringOrNumberCheck<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TString | TNumber | TInteger ? true : TStringOrNumberCheck<Right> : false);
|
|
778
|
+
type TTryBuildRecord<Types extends TSchema[], Value extends TSchema, Result extends TSchema | undefined = (TStringOrNumberCheck<Types> extends true ? TRecord<typeof StringKey, Value> : undefined)> = Result;
|
|
779
|
+
type TCreateProperties<Variants extends TSchema[], Value extends TSchema, Result extends TProperties = {}> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TLiteral<string | number> ? TCreateProperties<Right, Value, Result & {
|
|
780
|
+
[_ in Left['const']]: Value;
|
|
781
|
+
}> : TCreateProperties<Right, Value, Result> : {
|
|
782
|
+
[Key in keyof Result]: Result[Key];
|
|
783
|
+
});
|
|
784
|
+
type TCreateObject<Variants extends TSchema[], Value extends TSchema, Properties extends TProperties = TCreateProperties<Variants, Value>, Result extends TSchema = TObject<Properties>> = Result;
|
|
785
|
+
type TFromUnionKey<Types extends TSchema[], Value extends TSchema, Flattened extends TSchema[] = TFlatten<Types>, Record extends TSchema | undefined = TTryBuildRecord<Flattened, Value>, Result extends TSchema = (Record extends TSchema ? Record : TCreateObject<Flattened, Value>)> = Result;
|
|
786
|
+
|
|
787
|
+
type TFromKey<Key extends TSchema, Value extends TSchema, Result extends TSchema = (Key extends TAny ? TFromAnyKey<Value> : Key extends TBoolean ? TFromBooleanKey<Value> : Key extends TEnum<infer Values extends TEnumValue[]> ? TFromEnumKey<Values, Value> : Key extends TInteger ? TFromIntegerKey<Key, Value> : Key extends TIntersect<infer Types extends TSchema[]> ? TFromIntersectKey<Types, Value> : Key extends TLiteral<infer LiteralValue extends TLiteralValue> ? TFromLiteralKey<LiteralValue, Value> : Key extends TNumber ? TFromNumberKey<Key, Value> : Key extends TString ? TFromStringKey<Key, Value> : Key extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateKey<Pattern, Value> : Key extends TUnion<infer Types extends TSchema[]> ? TFromUnionKey<Types, Value> : TObject<{}>)> = Result;
|
|
788
|
+
|
|
789
|
+
type TRecordAction<Key extends TSchema, Value extends TSchema, Result extends TSchema = TCanInstantiate<[Key]> extends true ? TFromKey<Key, Value> : TRecordDeferred<Key, Value>> = Result;
|
|
790
|
+
type TRecordInstantiate<Context extends TProperties, State extends TState, Key extends TSchema, Value extends TSchema, InstantiatedKey extends TSchema = TInstantiateType<Context, State, Key>, InstantiatedValue extends TSchema = TInstantiateType<Context, State, Value>> = TRecordAction<InstantiatedKey, InstantiatedValue>;
|
|
791
|
+
|
|
792
|
+
type StaticPropertyKey<Key extends string, Result extends PropertyKey = (Key extends TStringKey ? string : Key extends TIntegerKey ? number : Key extends TNumberKey ? number : Key extends `^${string}$` ? TTemplateLiteralStatic<Key> : string)> = Result;
|
|
793
|
+
type StaticRecord<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Key extends string, Value extends TSchema, StaticKey extends PropertyKey = StaticPropertyKey<Key>, StaticValue extends unknown = StaticType<Stack, Direction, Context, This, Value>, Result extends Record$1<PropertyKey, unknown> = Record$1<StaticKey, StaticValue>> = Result;
|
|
794
|
+
type TStringKey = typeof StringKey;
|
|
795
|
+
type TIntegerKey = typeof IntegerKey;
|
|
796
|
+
type TNumberKey = typeof NumberKey;
|
|
797
|
+
declare const IntegerKey = "^-?(?:0|[1-9][0-9]*)$";
|
|
798
|
+
declare const NumberKey = "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$";
|
|
799
|
+
declare const StringKey = "^.*$";
|
|
800
|
+
interface TRecord<Key extends string = string, Value extends TSchema = TSchema> extends TSchema {
|
|
801
|
+
'~kind': 'Record';
|
|
802
|
+
type: 'object';
|
|
803
|
+
patternProperties: {
|
|
804
|
+
[_ in Key]: Value;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
/** Represents a deferred Record action. */
|
|
808
|
+
type TRecordDeferred<Key extends TSchema = TSchema, Value extends TSchema = TSchema> = (TDeferred<'Record', [Key, Value]>);
|
|
809
|
+
/** Creates a Record type. */
|
|
810
|
+
declare function Record$1<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions): TRecordAction<Key, Value>;
|
|
811
|
+
/** Transforms a Record Pattern to a Type */
|
|
812
|
+
type TRecordPatternToType<Pattern extends string, Result extends TSchema = (Pattern extends typeof StringKey ? TString : Pattern extends typeof IntegerKey ? TInteger : Pattern extends typeof NumberKey ? TNumber : TTemplateLiteralDecodeUnsafe<Pattern>)> = Result;
|
|
813
|
+
/** Extracts the Pattern from a Record type */
|
|
814
|
+
type TRecordPattern<Type extends TRecord, Result extends string = Extract<keyof Type['patternProperties'], string>> = Result;
|
|
815
|
+
/** Extracts the Key from a Record type */
|
|
816
|
+
type TRecordKey<Type extends TRecord, Pattern extends string = TRecordPattern<Type>, Result extends TSchema = TRecordPatternToType<Pattern>> = Result;
|
|
817
|
+
|
|
818
|
+
type StaticThis<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties> = (StaticType<Stack, Direction, Context, This, TObject<This>>);
|
|
819
|
+
/** Represents a This type. */
|
|
820
|
+
interface TThis extends TSchema {
|
|
821
|
+
'~kind': 'This';
|
|
822
|
+
$ref: '#';
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
declare const CompareResultEqual = 0;
|
|
826
|
+
declare const CompareResultDisjoint = 1;
|
|
827
|
+
declare const CompareResultLeftInside = 2;
|
|
828
|
+
declare const CompareResultRightInside = 3;
|
|
829
|
+
type TCompareResult = (typeof CompareResultEqual | typeof CompareResultDisjoint | typeof CompareResultLeftInside | typeof CompareResultRightInside);
|
|
830
|
+
/** Compares left and right types and determines their set relationship */
|
|
831
|
+
type TCompare<Left extends TSchema, Right extends TSchema, Extends extends [TResult, TResult] = [TExtends<{}, Left, Right>, TExtends<{}, Right, Left>]> = (Extends extends [TExtendsTrueLike, TExtendsTrueLike] ? typeof CompareResultEqual : Extends extends [TExtendsTrueLike, TExtendsFalse] ? typeof CompareResultLeftInside : Extends extends [TExtendsFalse, TExtendsTrueLike] ? typeof CompareResultRightInside : typeof CompareResultDisjoint);
|
|
832
|
+
|
|
833
|
+
type TBroadenFilter<Type extends TSchema, Types extends TSchema[], Result extends TSchema[] = [], All extends TSchema[] = Types> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCompare<Type, Left> extends typeof CompareResultLeftInside | typeof CompareResultEqual ? All : TCompare<Type, Left> extends typeof CompareResultDisjoint ? TBroadenFilter<Type, Right, [...Result, Left], All> : TBroadenFilter<Type, Right, Result, All> : [...Result, Type]);
|
|
834
|
+
type TBroadenType<Type extends TSchema, Types extends TSchema[], Result extends TSchema[], Evaluated extends TSchema = TEvaluateType<Type>> = (Evaluated extends TAny ? [Evaluated] : Evaluated extends TUnknown ? [Evaluated] : Evaluated extends TNever ? TBroadenTypes<Types, Result> : Evaluated extends TObject ? TBroadenTypes<Types, [...Result, Evaluated]> : TBroadenTypes<Types, TBroadenFilter<Evaluated, Result>>);
|
|
835
|
+
type TBroadenTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TBroadenType<Left, Right, Result> : Result);
|
|
836
|
+
type TBroaden<Types extends TSchema[], Broadened extends TSchema[] = TBroadenTypes<Types>, Flattened extends TSchema[] = TFlatten<Broadened>> = Flattened;
|
|
837
|
+
|
|
838
|
+
type TEvaluateAction<Type extends TSchema, Result extends TSchema = TEvaluateType<Type>> = Result;
|
|
839
|
+
type TEvaluateInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TEvaluateAction<InstantiatedType>;
|
|
840
|
+
|
|
841
|
+
type TCollectDistributionNames<Expression extends TSchema, Result extends string[] = []> = (Expression extends TDeferred<'Conditional', [infer Left extends TSchema, infer _Right extends TSchema, infer True extends TSchema, infer False extends TSchema]> ? Left extends TRef ? TCollectDistributionNames<True, TCollectDistributionNames<False, [...Result, Left['$ref']]>> : TCollectDistributionNames<True, TCollectDistributionNames<False, Result>> : Expression extends TDeferred<'Mapped', [infer _Identifier extends TSchema, infer Type extends TSchema, infer _As extends TSchema, infer _Property extends TSchema]> ? (Type extends TDeferred<'KeyOf', [infer Ref extends TRef]> ? [...Result, Ref['$ref']] : Result) : Result);
|
|
842
|
+
type TBuildDistributionArray<Parameters extends TParameter[], Names extends string[], Result extends boolean[] = []> = (Parameters extends [infer Left extends TParameter, ...infer Right extends TParameter[]] ? Left['name'] extends Names[number] ? TBuildDistributionArray<Right, Names, [...Result, true]> : TBuildDistributionArray<Right, Names, [...Result, false]> : Result);
|
|
843
|
+
type TZipDistributionArray<Arguments extends TSchema[], DistributionArray extends boolean[], Result extends [boolean, TSchema][] = []> = (Arguments extends [infer ArgumentLeft extends TSchema, ...infer ArgumentRight extends TSchema[]] ? DistributionArray extends [infer BooleanLeft extends boolean, ...infer BooleanRight extends boolean[]] ? TZipDistributionArray<ArgumentRight, BooleanRight, [...Result, [BooleanLeft, ArgumentLeft]]> : Result : Result);
|
|
844
|
+
type TCanonicalArgument<Type extends TSchema> = (Type extends TTemplateLiteral<infer Pattern extends string> ? TEvaluateTemplateLiteral<Pattern> : Type extends TEnum<infer Values extends TEnumValue[]> ? TEvaluateEnum<Values> : Type);
|
|
845
|
+
type TExpand<Argument extends TSchema, CanonicalArgument extends TSchema = TCanonicalArgument<Argument>> = (CanonicalArgument extends TUnion<infer Types extends TSchema[]> ? [...Types] : [CanonicalArgument]);
|
|
846
|
+
type TAppend<Current extends TSchema[][], Type extends TSchema, Result extends TSchema[][] = []> = (Current extends [infer Left extends TSchema[], ...infer Right extends TSchema[][]] ? TAppend<Right, Type, [...Result, [...Left, Type]]> : Result);
|
|
847
|
+
type TCross<Current extends TSchema[][], Variants extends TSchema[], Result extends TSchema[][] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCross<Current, Right, [...Result, ...TAppend<Current, Left>]> : Result);
|
|
848
|
+
type TDistribute<ZippedArguments extends [boolean, TSchema][], Result extends TSchema[][] = [[]]> = (ZippedArguments extends [infer Left extends [boolean, TSchema], ...infer Right extends [boolean, TSchema][]] ? Left[0] extends true ? TDistribute<Right, TCross<Result, TExpand<Left[1]>>> : TDistribute<Right, TCross<Result, [Left[1]]>> : Result);
|
|
849
|
+
type TDistributeArguments<Parameters extends TParameter[], Arguments extends TSchema[], Expression extends TSchema, DistributionNames extends string[] = TCollectDistributionNames<Expression>, DistributionArray extends boolean[] = TBuildDistributionArray<Parameters, DistributionNames>, ZippedArguments extends [boolean, TSchema][] = TZipDistributionArray<Arguments, DistributionArray>, Result extends TSchema[][] = (Expression extends TDeferred<'Conditional', TSchema[]> ? TDistribute<ZippedArguments> : Expression extends TDeferred<'Mapped', TSchema[]> ? TDistribute<ZippedArguments> : [Arguments])> = Result;
|
|
850
|
+
|
|
851
|
+
type TFromNotResolvable = ([
|
|
852
|
+
'(not-resolvable)',
|
|
853
|
+
TNever
|
|
854
|
+
]);
|
|
855
|
+
type TFromNotGeneric = ([
|
|
856
|
+
'(not-generic)',
|
|
857
|
+
TNever
|
|
858
|
+
]);
|
|
859
|
+
type TFromGeneric<Name extends string, Parameters extends TParameter[], Expression extends TSchema> = ([
|
|
860
|
+
Name,
|
|
861
|
+
TGeneric<Parameters, Expression>
|
|
862
|
+
]);
|
|
863
|
+
type TFromRef<Context extends TProperties, Ref extends string, Arguments extends TSchema[]> = (Ref extends keyof Context ? TFromType$c<Context, Ref, Context[Ref], Arguments> : TFromNotResolvable);
|
|
864
|
+
type TFromType$c<Context extends TProperties, Name extends string, Type extends TSchema, Arguments extends TSchema[]> = (Type extends TGeneric<infer Parameters extends TParameter[], infer Expression extends TSchema> ? TFromGeneric<Name, Parameters, Expression> : Type extends TRef<infer Ref extends string> ? TFromRef<Context, Ref, Arguments> : TFromNotGeneric);
|
|
865
|
+
/** Resolves a named generic target from the context, or returns TNever if it cannot be resolved or is not generic. */
|
|
866
|
+
type TResolveTarget<Context extends TProperties, Target extends TSchema, Arguments extends TSchema[], Result extends [string, TSchema] = TFromType$c<Context, '(anonymous)', Target, Arguments>> = Result;
|
|
867
|
+
|
|
868
|
+
type TBindArgument<Context extends TProperties, State extends TState, Name extends string, Extends extends TSchema, Type extends TSchema, InstantiatedArgument extends TSchema = TInstantiateType<Context, State, Type>> = TAssign<Context, {
|
|
869
|
+
[_ in Name]: InstantiatedArgument;
|
|
870
|
+
}>;
|
|
871
|
+
type TBindArguments<Context extends TProperties, State extends TState, ParameterLeft extends TParameter, ParameterRight extends TParameter[], Arguments extends TSchema[], InstantiatedExtends extends TSchema = TInstantiateType<Context, State, ParameterLeft['extends']>, InstantiatedEquals extends TSchema = TInstantiateType<Context, State, ParameterLeft['equals']>> = (Arguments extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TBindParameters<TBindArgument<Context, State, ParameterLeft['name'], InstantiatedExtends, Left>, State, ParameterRight, Right> : TBindParameters<TBindArgument<Context, State, ParameterLeft['name'], InstantiatedExtends, InstantiatedEquals>, State, ParameterRight, []>);
|
|
872
|
+
type TBindParameters<Context extends TProperties, State extends TState, Parameters extends TParameter[], Arguments extends TSchema[]> = (Parameters extends [infer Left extends TParameter, ...infer Right extends TParameter[]] ? TBindArguments<Context, State, Left, Right, Arguments> : Context);
|
|
873
|
+
type TResolveArgumentsContext<Context extends TProperties, State extends TState, Parameters extends TParameter[], Arguments extends TSchema[], Result extends TProperties = TBindParameters<Context, State, Parameters, Arguments>> = Result;
|
|
874
|
+
|
|
875
|
+
type TPeek<State extends TState, Result extends string = State['callstack'] extends [...infer _ extends string[], infer Top extends string] ? Top : ''> = Result;
|
|
876
|
+
type TIsTailCall<State extends TState, Name extends string, Result extends boolean = TPeek<State> extends Name ? true : false> = Result;
|
|
877
|
+
type TCallDispatch<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, Arguments extends TSchema[], ArgumentsContext extends TProperties = TResolveArgumentsContext<Context, State, Parameters, Arguments>, ReturnType extends TSchema = TInstantiateType<ArgumentsContext, TState<[...State['callstack'], Target['$ref']], State['visited']>, Expression>> = TInstantiateType<ArgumentsContext, TState<[], []>, ReturnType>;
|
|
878
|
+
type TCallDistributed<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, DistributedArguments extends TSchema[][], Result extends TSchema[] = []> = (DistributedArguments extends [infer Arguments extends TSchema[], ...infer DistributedArguments extends TSchema[][]] ? TCallDispatch<Context, State, Target, Parameters, Expression, Arguments> extends infer ReturnType extends TSchema ? TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments, [...Result, ReturnType]> : never : Result);
|
|
879
|
+
type TCallImmediate<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, InstantiatedArguments extends TSchema[], DistributedArguments extends TSchema[][] = TDistributeArguments<Parameters, InstantiatedArguments, Expression>, ReturnTypes extends TSchema[] = TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments>, Result extends TSchema = ReturnTypes['length'] extends 1 ? ReturnTypes[0] : TEvaluateUnion<ReturnTypes>> = Result;
|
|
880
|
+
type TCallInstantiate<Context extends TProperties, State extends TState, Target extends TSchema, Arguments extends TSchema[], InstantiatedArguments extends TSchema[] = TInstantiateTypes<Context, State, Arguments>, Resolved extends [string, TSchema] = TResolveTarget<Context, Target, Arguments>, Name extends string = Resolved[0], Type extends TSchema = Resolved[1], Result extends TSchema = (Type extends TGeneric<infer Parameters extends TParameter[], infer Expression extends TSchema> ? TIsTailCall<State, Name> extends true ? TCallConstruct<TRef<Name>, InstantiatedArguments> : TCallImmediate<Context, State, TRef<Name>, Parameters, Expression, InstantiatedArguments> : TCallConstruct<Target, InstantiatedArguments>)> = Result;
|
|
881
|
+
|
|
882
|
+
/** Represents a deferred generic Call */
|
|
883
|
+
interface TCall<Target extends TSchema = TSchema, Arguments extends TSchema[] = TSchema[]> extends TSchema {
|
|
884
|
+
'~kind': 'Call';
|
|
885
|
+
type: 'call';
|
|
886
|
+
target: Target;
|
|
887
|
+
arguments: Arguments;
|
|
888
|
+
}
|
|
889
|
+
type TCallConstruct<Target extends TSchema, Arguments extends TSchema[], Result extends TSchema = TCall<Target, Arguments>> = Result;
|
|
890
|
+
|
|
891
|
+
type TRemoveImmutableOperation<Type extends TSchema, Result extends TSchema = Type extends TImmutable<infer Type extends TSchema> ? TRemoveImmutableOperation<Type> : Type> = Result;
|
|
892
|
+
type TRemoveImmutableAction<Type extends TSchema, Result extends TSchema = TRemoveImmutableOperation<Type>> = Result;
|
|
893
|
+
type TRemoveImmutableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TRemoveImmutableAction<InstantiateType>;
|
|
894
|
+
|
|
895
|
+
interface TMappingType {
|
|
896
|
+
input: string;
|
|
897
|
+
output: string;
|
|
898
|
+
}
|
|
899
|
+
type TApplyMapping<Mapping extends TMappingType, Value extends string> = ((Mapping & {
|
|
900
|
+
input: Value;
|
|
901
|
+
})['output']);
|
|
902
|
+
|
|
903
|
+
type TFromLiteral$2<Mapping extends TMappingType, Value extends TLiteralValue> = (Value extends string ? TLiteral<TApplyMapping<Mapping, Value>> : TLiteral<Value>);
|
|
904
|
+
|
|
905
|
+
type TFromTemplateLiteral$2<Mapping extends TMappingType, Pattern extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>, Result extends TSchema = TFromType$b<Mapping, Evaluated>> = Result;
|
|
906
|
+
|
|
907
|
+
type TFromUnion$6<Mapping extends TMappingType, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$6<Mapping, Right, [...Result, TFromType$b<Mapping, Left>]> : TUnion<Result>);
|
|
908
|
+
|
|
909
|
+
type TFromType$b<Mapping extends TMappingType, Type extends TSchema> = (Type extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral$2<Mapping, Value> : Type extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateLiteral$2<Mapping, Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$6<Mapping, Types> : Type);
|
|
910
|
+
|
|
911
|
+
/** Creates a deferred Capitalize action. */
|
|
912
|
+
type TCapitalizeDeferred<Type extends TSchema> = (TDeferred<'Capitalize', [Type]>);
|
|
913
|
+
|
|
914
|
+
/** Creates a deferred Lowercase action. */
|
|
915
|
+
type TLowercaseDeferred<Type extends TSchema> = (TDeferred<'Lowercase', [Type]>);
|
|
916
|
+
|
|
917
|
+
/** Creates a deferred Uncapitalize action. */
|
|
918
|
+
type TUncapitalizeDeferred<Type extends TSchema> = (TDeferred<'Uncapitalize', [Type]>);
|
|
919
|
+
|
|
920
|
+
/** Creates a deferred Uppercase action. */
|
|
921
|
+
type TUppercaseDeferred<Type extends TSchema> = (TDeferred<'Uppercase', [Type]>);
|
|
922
|
+
|
|
923
|
+
interface TCapitalizeMapping extends TMappingType {
|
|
924
|
+
output: Capitalize<this['input']>;
|
|
925
|
+
}
|
|
926
|
+
interface TLowercaseMapping extends TMappingType {
|
|
927
|
+
output: Lowercase<this['input']>;
|
|
928
|
+
}
|
|
929
|
+
interface TUncapitalizeMapping extends TMappingType {
|
|
930
|
+
output: Uncapitalize<this['input']>;
|
|
931
|
+
}
|
|
932
|
+
interface TUppercaseMapping extends TMappingType {
|
|
933
|
+
output: Uppercase<this['input']>;
|
|
934
|
+
}
|
|
935
|
+
type TCapitalizeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$b<TCapitalizeMapping, Type> : TCapitalizeDeferred<Type>> = Result;
|
|
936
|
+
type TLowercaseAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$b<TLowercaseMapping, Type> : TLowercaseDeferred<Type>> = Result;
|
|
937
|
+
type TUncapitalizeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$b<TUncapitalizeMapping, Type> : TUncapitalizeDeferred<Type>> = Result;
|
|
938
|
+
type TUppercaseAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$b<TUppercaseMapping, Type> : TUppercaseDeferred<Type>> = Result;
|
|
939
|
+
type TCapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TCapitalizeAction<InstantiatedType>;
|
|
940
|
+
type TLowercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TLowercaseAction<InstantiatedType>;
|
|
941
|
+
type TUncapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TUncapitalizeAction<InstantiatedType>;
|
|
942
|
+
type TUppercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TUppercaseAction<InstantiatedType>;
|
|
943
|
+
|
|
944
|
+
/** Creates a deferred Conditional action. */
|
|
945
|
+
type TConditionalDeferred<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TDeferred<'Conditional', [Left, Right, True, False]>);
|
|
946
|
+
|
|
947
|
+
type TConditionalOperation<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema, ExtendsResult extends TResult = TExtends<Context, Left, Right>> = (ExtendsResult extends ExtendsResult.TExtendsUnion<infer InferredContext extends TProperties> ? TUnion<[TInstantiateType<InferredContext, State, True>, TInstantiateType<Context, State, False>]> : ExtendsResult extends ExtendsResult.TExtendsTrue<infer InferredContext extends TProperties> ? TInstantiateType<InferredContext, State, True> : TInstantiateType<Context, State, False>);
|
|
948
|
+
type TConditionalAction<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema, Result extends TSchema = TCanInstantiate<[Left, Right]> extends true ? TConditionalOperation<Context, State, Left, Right, True, False> : TConditionalDeferred<Left, Right, True, False>> = Result;
|
|
949
|
+
type TConditionalInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema, InstaniatedLeft extends TSchema = TInstantiateType<Context, State, Left>, InstaniatedRight extends TSchema = TInstantiateType<Context, State, Right>> = TConditionalAction<Context, State, InstaniatedLeft, InstaniatedRight, True, False>;
|
|
950
|
+
|
|
951
|
+
/** Creates a deferred ConstructorParameters action. */
|
|
952
|
+
type TConstructorParametersDeferred<Type extends TSchema> = (TDeferred<'ConstructorParameters', [Type]>);
|
|
953
|
+
|
|
954
|
+
type TConstructorParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TConstructor ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, TState<[], []>, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
955
|
+
type TConstructorParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TConstructorParametersOperation<Type> : TConstructorParametersDeferred<Type>> = Result;
|
|
956
|
+
type TConstructorParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TConstructorParametersAction<InstantiatedType>;
|
|
957
|
+
|
|
958
|
+
/** Creates a deferred Exclude action. */
|
|
959
|
+
type TExcludeDeferred<Left extends TSchema, Right extends TSchema> = (TDeferred<'Exclude', [Left, Right]>);
|
|
960
|
+
|
|
961
|
+
type TExcludeAction<Left extends TSchema, Right extends TSchema, Result extends TSchema = TCanInstantiate<[Left, Right]> extends true ? TExcludeOperation<Left, Right> : TExcludeDeferred<Left, Right>> = Result;
|
|
962
|
+
type TExcludeInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, InstantiatedLeft extends TSchema = TInstantiateType<Context, State, Left>, InstantiatedRight extends TSchema = TInstantiateType<Context, State, Right>> = TExcludeAction<InstantiatedLeft, InstantiatedRight>;
|
|
963
|
+
|
|
964
|
+
/** Creates a deferred Extract action. */
|
|
965
|
+
type TExtractDeferred<Left extends TSchema, Right extends TSchema> = (TDeferred<'Extract', [Left, Right]>);
|
|
966
|
+
|
|
967
|
+
type TExtractType<Left extends TSchema, Right extends TSchema, Check extends TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends TExtendsTrueLike ? [Left] : []> = Result;
|
|
968
|
+
type TExtractUnion<Left extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtractUnion<Tail, Right, [...Result, ...TExtractType<Head, Right>]> : Result);
|
|
969
|
+
type TExtractOperation<Left extends TSchema, Right extends TSchema, Evaluated extends TSchema = TEvaluateType<Left>, Canonical extends TSchema[] = Evaluated extends TUnion<infer Types extends TSchema[]> ? Types : [Evaluated], Remaining extends TSchema[] = TExtractUnion<Canonical, Right>, Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
970
|
+
|
|
971
|
+
type TExtractAction<Left extends TSchema, Right extends TSchema, Result extends TSchema = TCanInstantiate<[Left, Right]> extends true ? TExtractOperation<Left, Right> : TExtractDeferred<Left, Right>> = Result;
|
|
972
|
+
type TExtractInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, InstantiatedLeft extends TSchema = TInstantiateType<Context, State, Left>, InstantiatedRight extends TSchema = TInstantiateType<Context, State, Right>> = TExtractAction<InstantiatedLeft, InstantiatedRight>;
|
|
973
|
+
|
|
974
|
+
/** Creates a deferred Index action. */
|
|
975
|
+
type TIndexDeferred<Type extends TSchema, Indexer extends TSchema> = (TDeferred<'Index', [Type, Indexer]>);
|
|
976
|
+
|
|
977
|
+
type TFromCyclic$4<Defs extends TProperties, Ref extends string, Target extends TSchema = TCyclicTarget<Defs, Ref>, Result extends TProperties = TFromType$a<Target>> = Result;
|
|
978
|
+
|
|
979
|
+
type TFromDependent$4<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends TSchema = TFromType$a<Evaluated>> = Result;
|
|
980
|
+
|
|
981
|
+
type TCollapseIntersectProperties<Left extends TProperties, Right extends TProperties, LeftKeys extends keyof Left = Exclude<keyof Left, keyof Right>, RightKeys extends keyof Right = Exclude<keyof Right, keyof Left>, SharedKeys extends keyof Left & keyof Right = Extract<keyof Left, keyof Right>, LeftProperties extends TProperties = {
|
|
982
|
+
[Key in LeftKeys]: Left[Key];
|
|
983
|
+
}, RightProperties extends TProperties = {
|
|
984
|
+
[Key in RightKeys]: Right[Key];
|
|
985
|
+
}, SharedProperties extends TProperties = {
|
|
986
|
+
[Key in SharedKeys]: TEvaluateIntersect<[Left[Key], Right[Key]]>;
|
|
987
|
+
}, Unique extends TProperties = TAssign<LeftProperties, RightProperties>, Shared extends TProperties = TAssign<Unique, SharedProperties>> = Shared;
|
|
988
|
+
type TFromIntersect$4<Types extends TSchema[], Result extends TProperties = {}> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromIntersect$4<Right, TCollapseIntersectProperties<Result, TFromType$a<Left>>> : {
|
|
989
|
+
[Key in keyof Result]: Result[Key];
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
type TFromObject$5<Properties extends TProperties> = (Properties);
|
|
993
|
+
|
|
994
|
+
type TFromTuple$3<Types extends TSchema[], Object extends TSchema = TTupleToObject<TTuple<Types>>, Result extends TSchema = TFromType$a<Object>> = Result;
|
|
995
|
+
|
|
996
|
+
type TCollapseUnionProperties<Left extends TProperties, Right extends TProperties, SharedKeys extends PropertyKey = keyof Left & keyof Right, Result extends TProperties = {
|
|
997
|
+
[Key in SharedKeys]: TEvaluateUnion<[Left[Key], Right[Key]]>;
|
|
998
|
+
}> = Result;
|
|
999
|
+
type TReduceVariants<Types extends TSchema[], Result extends TProperties> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReduceVariants<Right, TCollapseUnionProperties<Result, TFromType$a<Left>>> : Result);
|
|
1000
|
+
type TFromUnion$5<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReduceVariants<Right, TFromType$a<Left>> : TUnreachable);
|
|
1001
|
+
|
|
1002
|
+
type TFromType$a<Type extends TSchema, Result extends TProperties = (Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic$4<Defs, Ref> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent$4<If, Then, Else> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$4<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$5<Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$3<Types> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$5<Properties> : {})> = Result;
|
|
1003
|
+
|
|
1004
|
+
type TCollapseToObject<Type extends TSchema, Properties extends TProperties = TFromType$a<Type>, Result extends TSchema = TObject<Properties>> = Result;
|
|
1005
|
+
|
|
1006
|
+
type TConvertToIntegerKey<Value extends TLiteralValue, Normal extends string = `${Value}`, Result extends TLiteralValue = (Normal extends ` ${infer _ extends number}` ? Normal : Normal extends `${infer _ extends number} ` ? Normal : Normal extends `0${infer _ extends number}` ? Normal : Normal extends `-${infer _ extends number}` ? Normal : Normal extends `${infer Value extends number}` ? Value : Value)> = Result;
|
|
1007
|
+
|
|
1008
|
+
type TNormalizeLiteral<Value extends TLiteralValue, Result extends TSchema = TLiteral<TConvertToIntegerKey<Value>>> = Result;
|
|
1009
|
+
type TNormalizeIndexerTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TNormalizeIndexerTypes<Right, [...Result, TNormalizeIndexer<Left>]> : Result);
|
|
1010
|
+
type TNormalizeIndexer<Type extends TSchema, Result extends TSchema = (Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TNormalizeIndexerTypes<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TNormalizeIndexerTypes<Types>> : Type extends TLiteral<infer Value extends TLiteralValue> ? TNormalizeLiteral<Value> : Type)> = Result;
|
|
1011
|
+
type TFromArray$2<Type extends TSchema, Indexer extends TSchema, NormalizedIndexer extends TSchema = TNormalizeIndexer<Indexer>, Check extends TResult = TExtends<{}, NormalizedIndexer, TNumber>, Result extends TSchema = (Check extends TExtendsTrueLike ? Type : Indexer extends TLiteral<infer _ extends 'length'> ? TNumber : TNever)> = Result;
|
|
1012
|
+
|
|
1013
|
+
type TFromCyclic$3<Defs extends TProperties, Ref extends string, Target extends TSchema = TCyclicTarget<Defs, Ref>, Result extends string[] = TFromType$9<Target>> = Result;
|
|
1014
|
+
|
|
1015
|
+
type TFromDependent$3<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends string[] = TFromType$9<Evaluated>> = Result;
|
|
1016
|
+
|
|
1017
|
+
type TFromEnum$1<Values extends TEnumValue[], Evaluated extends TSchema = TEvaluateEnum<Values>, Result extends string[] = TFromType$9<Evaluated>> = Result;
|
|
1018
|
+
|
|
1019
|
+
type TFromIntersect$3<Types extends TSchema[], Evaluated extends TSchema = TEvaluateIntersect<Types>, Result extends string[] = TFromType$9<Evaluated>> = Result;
|
|
1020
|
+
|
|
1021
|
+
type TFromLiteral$1<Value extends TLiteralValue, Result extends string[] = [`${Value}`]> = Result;
|
|
1022
|
+
|
|
1023
|
+
type TFromTemplateLiteral$1<Pattern extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>, Result extends string[] = TFromType$9<Evaluated>> = Result;
|
|
1024
|
+
|
|
1025
|
+
type TFromUnion$4<Types extends TSchema[], Result extends string[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$4<Right, [...Result, ...TFromType$9<Left>]> : Result);
|
|
1026
|
+
|
|
1027
|
+
type TFromType$9<Indexer extends TSchema, Result extends string[] = (Indexer extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic$3<Defs, Ref> : Indexer extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent$3<If, Then, Else> : Indexer extends TEnum<infer Values extends TEnumValue[]> ? TFromEnum$1<Values> : Indexer extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$3<Types> : Indexer extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral$1<Value> : Indexer extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateLiteral$1<Pattern> : Indexer extends TUnion<infer Types extends TSchema[]> ? TFromUnion$4<Types> : [
|
|
1028
|
+
])> = Result;
|
|
1029
|
+
|
|
1030
|
+
type TToIndexableKeys<Indexer extends TSchema, Result extends string[] = TFromType$9<Indexer>> = Result;
|
|
1031
|
+
|
|
1032
|
+
type TFromTypes<Properties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes<Properties, Right, [...Result, TFromType$8<Properties, Left>]> : Result);
|
|
1033
|
+
type TFromType$8<Properties extends TProperties, Type extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TArray<TFromType$8<Properties, Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TFromTypes<Properties, Parameters>, TFromType$8<Properties, InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TFromTypes<Properties, Parameters>, TFromType$8<Properties, ReturnType>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TFromTypes<Properties, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromTypes<Properties, Types>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromTypes<Properties, Types>> : Type extends TThis ? TObject<Properties> : Type);
|
|
1034
|
+
type TExpandThis<Properties extends TProperties, Type extends TSchema, Result extends TSchema = TFromType$8<Properties, Type>> = Result;
|
|
1035
|
+
|
|
1036
|
+
type TIndexProperty<Properties extends TProperties, Key extends string, CanonicalKey extends string = keyof Properties extends string | number ? `${keyof Properties}` : never, SelectedType extends TSchema = Key extends CanonicalKey ? Properties[Key] : TNever, Result extends TSchema = TExpandThis<Properties, SelectedType>> = Result;
|
|
1037
|
+
type TIndexProperties<Properties extends TProperties, Keys extends string[], Result extends TSchema[] = []> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? TIndexProperties<Properties, Right, [...Result, TIndexProperty<Properties, Left>]> : Result);
|
|
1038
|
+
type TFromIndexer<Properties extends TProperties, Indexer extends TSchema, Keys extends string[] = TToIndexableKeys<Indexer>, Variants extends TSchema[] = TIndexProperties<Properties, Keys>, Result extends TSchema = TEvaluateUnion<Variants>> = Result;
|
|
1039
|
+
type TNumericKeys<Keys extends string[], Result extends string[] = []> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? Left extends `${infer _ extends number}` ? TNumericKeys<Right, [...Result, Left]> : TNumericKeys<Right, Result> : Result);
|
|
1040
|
+
type TFromIndexerNumber<Properties extends TProperties, Keys extends string[] = TPropertyKeys<Properties>, NumericKeys extends string[] = TNumericKeys<Keys>, Variants extends TSchema[] = TIndexProperties<Properties, NumericKeys>, Result extends TSchema = TEvaluateUnion<Variants>> = Result;
|
|
1041
|
+
type TFromObject$4<Properties extends TProperties, Indexer extends TSchema, Result extends TSchema = Indexer extends TNumber ? TFromIndexerNumber<Properties> : TFromIndexer<Properties, Indexer>> = Result;
|
|
1042
|
+
|
|
1043
|
+
type TConvertLiteral<Value extends TLiteralValue, Result extends TSchema = TLiteral<TConvertToIntegerKey<Value>>> = Result;
|
|
1044
|
+
type TArrayIndexerTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TArrayIndexerTypes<Right, [...Result, TFormatArrayIndexer<Left>]> : Result);
|
|
1045
|
+
/** Formats embedded integer-like strings on an Indexer to be number values inline with TS indexing | coercion behaviors. */
|
|
1046
|
+
type TFormatArrayIndexer<Type extends TSchema, Result extends TSchema = (Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TArrayIndexerTypes<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TArrayIndexerTypes<Types>> : Type extends TLiteral<infer Value extends TLiteralValue> ? TConvertLiteral<Value> : Type)> = Result;
|
|
1047
|
+
|
|
1048
|
+
type TIndexElementsWithIndexer<Types extends TSchema[], Indexer extends TSchema, Result extends TSchema[] = []> = (Types extends [...infer Left extends TSchema[], infer Right extends TSchema] ? TExtends<{}, TLiteral<Left['length']>, Indexer> extends TExtendsTrueLike ? TIndexElementsWithIndexer<Left, Indexer, [Right, ...Result]> : TIndexElementsWithIndexer<Left, Indexer, Result> : Result);
|
|
1049
|
+
type TFromTupleWithIndexer<Types extends TSchema[], Indexer extends TSchema, ArrayIndexer extends TSchema = TFormatArrayIndexer<Indexer>, Elements extends TSchema[] = TIndexElementsWithIndexer<Types, ArrayIndexer>, Result extends TSchema = TEvaluateUnionFast<Elements>> = Result;
|
|
1050
|
+
type TFromTupleWithoutIndexer<Types extends TSchema[], Result extends TSchema = TEvaluateUnionFast<Types>> = Result;
|
|
1051
|
+
type TFromTuple$2<Types extends TSchema[], Indexer extends TSchema, Result extends TSchema = (Indexer extends TLiteral<infer _ extends 'length'> ? TLiteral<Types['length']> : Indexer extends TNumber | TInteger ? TFromTupleWithoutIndexer<Types> : TFromTupleWithIndexer<Types, Indexer>)> = Result;
|
|
1052
|
+
|
|
1053
|
+
type TFromType$7<Type extends TSchema, Indexer extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TFromArray$2<Type, Indexer> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$4<Properties, Indexer> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$2<Types, Indexer> : TNever);
|
|
1054
|
+
|
|
1055
|
+
type TNormalizeType$1<Type extends TSchema, Result extends TSchema = (Type extends TCyclic ? TCollapseToObject<Type> : Type extends TDependent ? TCollapseToObject<Type> : Type extends TIntersect ? TCollapseToObject<Type> : Type extends TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
1056
|
+
type TIndexAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType$7<TNormalizeType$1<Type>, Indexer> : TIndexDeferred<Type, Indexer>> = Result;
|
|
1057
|
+
type TIndexInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TIndexAction<InstantiatedType, InstantiatedIndexer>;
|
|
1058
|
+
|
|
1059
|
+
/** Creates a deferred InstanceType action. */
|
|
1060
|
+
type TInstanceTypeDeferred<Type extends TSchema> = (TDeferred<'InstanceType', [Type]>);
|
|
1061
|
+
|
|
1062
|
+
type TInstanceTypeOperation<Type extends TSchema> = (Type extends TConstructor ? Type['instanceType'] : TNever);
|
|
1063
|
+
type TInstanceTypeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TInstanceTypeOperation<Type> : TInstanceTypeDeferred<Type>> = Result;
|
|
1064
|
+
type TInstanceTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TInstanceTypeAction<InstantiatedType>;
|
|
1065
|
+
|
|
1066
|
+
/** Creates a deferred KeyOf action. */
|
|
1067
|
+
type TKeyOfDeferred<Type extends TSchema> = (TDeferred<'KeyOf', [Type]>);
|
|
1068
|
+
|
|
1069
|
+
type TFromAny<Result = TUnion<[TNumber, TString, TSymbol]>> = Result;
|
|
1070
|
+
|
|
1071
|
+
type TFromArray$1<_Type extends TSchema> = TNumber;
|
|
1072
|
+
|
|
1073
|
+
type TFromPropertyKeys<Keys extends PropertyKey[], Result extends TSchema[] = []> = (Keys extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Left extends TLiteralValue ? TFromPropertyKeys<Right, [...Result, TLiteral<Left>]> : TUnreachable : Result);
|
|
1074
|
+
type TFromObject$3<Properties extends TProperties, PropertyKeys extends PropertyKey[] = TUnionToTuple<keyof Properties>, Variants extends TSchema[] = TFromPropertyKeys<PropertyKeys>, Result extends TSchema = TEvaluateUnionFast<Variants>> = Result;
|
|
1075
|
+
|
|
1076
|
+
type TFromRecord<Type extends TRecord, Result extends TSchema = TRecordKey<Type>> = Result;
|
|
1077
|
+
|
|
1078
|
+
type TFromTuple$1<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [...infer Left extends TSchema[], infer _ extends TSchema] ? TFromTuple$1<Left, [TLiteral<Left['length']>, ...Result]> : TEvaluateUnionFast<Result>);
|
|
1079
|
+
|
|
1080
|
+
type TFromType$6<Type extends TSchema> = (Type extends TAny ? TFromAny : Type extends TArray<infer Type extends TSchema> ? TFromArray$1<Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$3<Properties> : Type extends TRecord ? TFromRecord<Type> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$1<Types> : TNever);
|
|
1081
|
+
|
|
1082
|
+
type TNormalizeType<Type extends TSchema, Result extends TSchema = (Type extends TCyclic ? TCollapseToObject<Type> : Type extends TDependent ? TCollapseToObject<Type> : Type extends TIntersect ? TCollapseToObject<Type> : Type extends TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
1083
|
+
type TKeyOfAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$6<TNormalizeType<Type>> : TKeyOfDeferred<Type>> = Result;
|
|
1084
|
+
type TKeyOfInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TKeyOfAction<InstantiatedType>;
|
|
1085
|
+
|
|
1086
|
+
/** Creates a deferred Mapped action. */
|
|
1087
|
+
type TMappedDeferred<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TDeferred<'Mapped', [Identifier, Type, As, Property]>);
|
|
1088
|
+
|
|
1089
|
+
type TFromTemplateLiteral<Pattern extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>, Result extends TSchema[] = TFromType$5<Evaluated>> = Result;
|
|
1090
|
+
type TFromUnion$3<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$3<Right, [...Result, ...TFromType$5<Left>]> : Result);
|
|
1091
|
+
type TFromEnum<Values extends TEnumValue[], Evaluated extends TSchema = TEvaluateEnum<Values>, Result extends TSchema[] = TFromType$5<Evaluated>> = Result;
|
|
1092
|
+
type TFromLiteral<Value extends TLiteralValue, Result extends TSchema[] = Value extends number ? [TLiteral<`${Value}`>] : [TLiteral<Value>]> = Result;
|
|
1093
|
+
type TFromType$5<Type extends TSchema, Result extends TSchema[] = (Type extends TEnum<infer Values extends TEnumValue[]> ? TFromEnum<Values> : Type extends TLiteral<infer Value extends number> ? TFromLiteral<Value> : Type extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateLiteral<Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$3<Types> : [
|
|
1094
|
+
Type
|
|
1095
|
+
])> = Result;
|
|
1096
|
+
type TMappedVariants<Type extends TSchema, Result extends TSchema[] = TFromType$5<Type>> = Result;
|
|
1097
|
+
|
|
1098
|
+
type TCanonicalAs<InstantiatedAs extends TSchema, Result extends TSchema = InstantiatedAs extends TTemplateLiteral<infer Pattern extends string> ? TEvaluateTemplateLiteral<Pattern> : InstantiatedAs> = Result;
|
|
1099
|
+
type TMappedVariant<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Variant extends TSchema, As extends TSchema, Property extends TSchema, VariantContext extends TProperties = TAssign<Context, {
|
|
1100
|
+
[_ in Identifier['name']]: Variant;
|
|
1101
|
+
}>, InstantiatedAs extends TSchema = TInstantiateType<VariantContext, State, As>, CanonicalAs extends TSchema = TCanonicalAs<InstantiatedAs>, InstantiatedProperty extends TSchema = TInstantiateType<VariantContext, State, Property>, Result extends TProperties = CanonicalAs extends TLiteral<string | number> ? {
|
|
1102
|
+
[_ in CanonicalAs['const']]: InstantiatedProperty;
|
|
1103
|
+
} : {}> = Result;
|
|
1104
|
+
type TMappedProperties<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Variants extends TSchema[], As extends TSchema, Property extends TSchema, Result extends TProperties[] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TMappedProperties<Context, State, Identifier, Right, As, Property, [...Result, TMappedVariant<Context, State, Identifier, Left, As, Property>]> : Result);
|
|
1105
|
+
type TReduceProperties<Properties extends TProperties[], Result extends TSchema[] = []> = (Properties extends [infer Left extends TProperties, ...infer Right extends TProperties[]] ? TReduceProperties<Right, [...Result, TObject<Left>]> : Result);
|
|
1106
|
+
type TMappedOperation<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, Variants extends TSchema[] = TMappedVariants<Type>, MappedProperties extends TProperties[] = TMappedProperties<Context, State, Identifier, Variants, As, Property>, MappedObjects extends TSchema[] = TReduceProperties<MappedProperties>, Result extends TSchema = TEvaluateIntersect<MappedObjects>> = Result;
|
|
1107
|
+
|
|
1108
|
+
type TMappedAction<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TMappedOperation<Context, State, Identifier, Type, As, Property> : TMappedDeferred<Identifier, Type, As, Property>> = Result;
|
|
1109
|
+
type TMappedInstantiate<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, InstaniatedType extends TSchema = TInstantiateType<Context, State, Type>> = TMappedAction<Context, State, Identifier, InstaniatedType, As, Property>;
|
|
1110
|
+
|
|
1111
|
+
type TInstantiateCyclics<Context extends TProperties, Declarations extends TProperties, CyclicKeys extends string[], DeclarationContext extends TProperties = TAssign<Context, Declarations>, Result extends TProperties = {
|
|
1112
|
+
[Key in Extract<keyof Declarations, CyclicKeys[number]>]: TInstantiateCyclic<DeclarationContext, Key, Declarations[Key]>;
|
|
1113
|
+
}> = Result;
|
|
1114
|
+
type TInstantiateNonCyclics<Context extends TProperties, Declarations extends TProperties, CyclicKeys extends string[], DeclarationContext extends TProperties = TAssign<Context, Declarations>, Result extends TProperties = {
|
|
1115
|
+
[Key in Exclude<keyof Declarations, CyclicKeys[number]>]: TInstantiateType<DeclarationContext, TState<[], []>, Declarations[Key]>;
|
|
1116
|
+
}> = Result;
|
|
1117
|
+
type TInstantiateModule<Context extends TProperties, Declarations extends TProperties, CyclicCandidates extends string[] = TCyclicCandidates<Declarations>, InstantiatedCyclics extends TProperties = TInstantiateCyclics<Context, Declarations, CyclicCandidates>, InstantiatedNonCyclics extends TProperties = TInstantiateNonCyclics<Context, Declarations, CyclicCandidates>, InstantiatedModule extends TProperties = InstantiatedCyclics & InstantiatedNonCyclics> = {
|
|
1118
|
+
[Key in keyof InstantiatedModule]: InstantiatedModule[Key];
|
|
1119
|
+
} & {};
|
|
1120
|
+
type TModuleInstantiate<Context extends TProperties, _State extends TState, Declarations extends TProperties, InstantiatedModule extends TProperties = TInstantiateModule<Context, Declarations>> = InstantiatedModule;
|
|
1121
|
+
|
|
1122
|
+
/** Creates a deferred NonNullable action. */
|
|
1123
|
+
type TNonNullableDeferred<Type extends TSchema> = (TDeferred<'NonNullable', [Type]>);
|
|
1124
|
+
|
|
1125
|
+
type TNonNullableOperation<Type extends TSchema, Excluded extends TSchema = TUnion<[TNull, TUndefined]>> = TExcludeAction<Type, Excluded>;
|
|
1126
|
+
type TNonNullableAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TNonNullableOperation<Type> : TNonNullableDeferred<Type>> = Result;
|
|
1127
|
+
type TNonNullableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TNonNullableAction<InstantiatedType>;
|
|
1128
|
+
|
|
1129
|
+
/** Creates a deferred Omit action. */
|
|
1130
|
+
type TOmitDeferred<Type extends TSchema, Indexer extends TSchema> = (TDeferred<'Omit', [Type, Indexer]>);
|
|
1131
|
+
|
|
1132
|
+
/** Transforms a type into a TProperties used for indexing operations */
|
|
1133
|
+
type TToIndexable<Type extends TSchema, Collapsed extends TSchema = TCollapseToObject<Type>, Result extends TProperties = (Collapsed extends TObject<infer Properties extends TProperties> ? Properties : TUnreachable)> = Result;
|
|
1134
|
+
|
|
1135
|
+
type TNormalKeys<Keys extends string[], UnionKeys extends string = Keys[number], Result extends string | number = (UnionKeys extends `${infer Value extends number}` ? UnionKeys | Value : UnionKeys)> = Result;
|
|
1136
|
+
type TFromKeys$1<Properties extends TProperties, Keys extends string[], Omitted extends TProperties = Omit<Properties, TNormalKeys<Keys>>, Result extends TProperties = {
|
|
1137
|
+
[Key in keyof Omitted]: Omitted[Key];
|
|
1138
|
+
}> = Result;
|
|
1139
|
+
type TFromType$4<Type extends TSchema, Indexer extends TSchema, Indexable extends TProperties = TToIndexable<Type>, IndexableKeys extends string[] = TToIndexableKeys<Indexer>, Omitted extends TProperties = TFromKeys$1<Indexable, IndexableKeys>, Result extends TSchema = TObject<Omitted>> = Result;
|
|
1140
|
+
|
|
1141
|
+
type TOmitAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType$4<Type, Indexer> : TOmitDeferred<Type, Indexer>> = Result;
|
|
1142
|
+
type TOmitInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TOmitAction<InstantiatedType, InstantiatedIndexer>;
|
|
1143
|
+
|
|
1144
|
+
/** Creates a deferred Parameters action. */
|
|
1145
|
+
type TParametersDeferred<Type extends TSchema> = (TDeferred<'Parameters', [Type]>);
|
|
1146
|
+
|
|
1147
|
+
type TParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TFunction ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, TState<[], []>, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
1148
|
+
type TParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TParametersOperation<Type> : TParametersDeferred<Type>> = Result;
|
|
1149
|
+
type TParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TParametersAction<InstantiatedType>;
|
|
1150
|
+
|
|
1151
|
+
/** Creates a deferred Partial action. */
|
|
1152
|
+
type TPartialDeferred<Type extends TSchema> = (TDeferred<'Partial', [Type]>);
|
|
1153
|
+
|
|
1154
|
+
type TFromCyclic$2<Defs extends TProperties, Ref extends string, Target extends TSchema = TCyclicTarget<Defs, Ref>, Partial extends TSchema = TFromType$3<Target>, Result extends TSchema = TCyclic<TAssign<Defs, {
|
|
1155
|
+
[_ in Ref]: Partial;
|
|
1156
|
+
}>, Ref>> = Result;
|
|
1157
|
+
|
|
1158
|
+
type TFromDependent$2<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends TSchema = TFromType$3<Evaluated>> = Result;
|
|
1159
|
+
|
|
1160
|
+
type TFromIntersect$2<Types extends TSchema[], Evaluated extends TSchema = TEvaluateIntersect<Types>, Result extends TSchema = TFromType$3<Evaluated>> = Result;
|
|
1161
|
+
|
|
1162
|
+
type TFromUnion$2<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$2<Right, [...Result, TFromType$3<Left>]> : TUnion<Result>);
|
|
1163
|
+
|
|
1164
|
+
type TFromObject$2<Properties extends TProperties, Mapped extends TProperties = {
|
|
1165
|
+
[Key in keyof Properties]: TAddOptional<Properties[Key]>;
|
|
1166
|
+
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
1167
|
+
|
|
1168
|
+
type TFromType$3<Type extends TSchema> = (Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic$2<Defs, Ref> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent$2<If, Then, Else> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$2<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$2<Types> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$2<Properties> : TObject<{}>);
|
|
1169
|
+
|
|
1170
|
+
type TPartialAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$3<Type> : TPartialDeferred<Type>> = Result;
|
|
1171
|
+
type TPartialInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TPartialAction<InstantiatedType>;
|
|
1172
|
+
|
|
1173
|
+
/** Creates a deferred Pick action. */
|
|
1174
|
+
type TPickDeferred<Type extends TSchema, Indexer extends TSchema> = (TDeferred<'Pick', [Type, Indexer]>);
|
|
1175
|
+
|
|
1176
|
+
type TComparable<Indexable extends TProperties> = (keyof Indexable extends string | number ? `${keyof Indexable}` : never);
|
|
1177
|
+
type TFromKeys<Indexable extends TProperties, Keys extends string[], Result extends TProperties = {}> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? Left extends TComparable<Indexable> ? TFromKeys<Indexable, Right, TAssign<Result, {
|
|
1178
|
+
[_ in Left]: Indexable[Left];
|
|
1179
|
+
}>> : TFromKeys<Indexable, Right, Result> : Result);
|
|
1180
|
+
type TFromType$2<Type extends TSchema, Indexer extends TSchema, Indexable extends TProperties = TToIndexable<Type>, Keys extends string[] = TToIndexableKeys<Indexer>, Applied extends TProperties = TFromKeys<Indexable, Keys>, Result extends TSchema = TObject<Applied>> = Result;
|
|
1181
|
+
|
|
1182
|
+
type TPickAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType$2<Type, Indexer> : TPickDeferred<Type, Indexer>> = Result;
|
|
1183
|
+
type TPickInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TPickAction<InstantiatedType, InstantiatedIndexer>;
|
|
1184
|
+
|
|
1185
|
+
/** Creates a deferred ReadonlyType action. */
|
|
1186
|
+
type TReadonlyObjectDeferred<Type extends TSchema> = (TDeferred<'ReadonlyObject', [Type]>);
|
|
1187
|
+
|
|
1188
|
+
type TFromArray<Type extends TSchema, Result extends TSchema = TAddImmutable<TArray<Type>>> = Result;
|
|
1189
|
+
|
|
1190
|
+
type TFromCyclic$1<Defs extends TProperties, Ref extends string, Target extends TSchema = TCyclicTarget<Defs, Ref>, Partial extends TSchema = TFromType$1<Target>, Result extends TSchema = TCyclic<TAssign<Defs, {
|
|
1191
|
+
[_ in Ref]: Partial;
|
|
1192
|
+
}>, Ref>> = Result;
|
|
1193
|
+
|
|
1194
|
+
type TFromDependent$1<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends TSchema = TFromType$1<Evaluated>> = Result;
|
|
1195
|
+
|
|
1196
|
+
type TFromIntersect$1<Types extends TSchema[], Evaluated extends TSchema = TEvaluateIntersect<Types>, Result extends TSchema = TFromType$1<Evaluated>> = Result;
|
|
1197
|
+
|
|
1198
|
+
type TFromObject$1<Properties extends TProperties, Mapped extends TProperties = {
|
|
1199
|
+
[Key in keyof Properties]: TAddReadonly<Properties[Key]>;
|
|
1200
|
+
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
1201
|
+
|
|
1202
|
+
type TFromTuple<Types extends TSchema[], Result extends TSchema = TAddImmutable<TTuple<Types>>> = Result;
|
|
1203
|
+
|
|
1204
|
+
type TFromUnion$1<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion$1<Right, [...Result, TFromType$1<Left>]> : TUnion<Result>);
|
|
1205
|
+
|
|
1206
|
+
type TFromType$1<Type extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TFromArray<Type> : Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic$1<Defs, Ref> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent$1<If, Then, Else> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$1<Types> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$1<Properties> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$1<Types> : Type);
|
|
1207
|
+
|
|
1208
|
+
type TReadonlyObjectAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType$1<Type> : TReadonlyObjectDeferred<Type>> = Result;
|
|
1209
|
+
type TReadonlyObjectInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TReadonlyObjectAction<InstantiateType>;
|
|
1210
|
+
|
|
1211
|
+
type TRefInstantiate<Context extends TProperties, State extends TState, Type extends TRef, Ref extends string> = (Ref extends State['visited'][number] ? Type : Ref extends keyof Context ? TInstantiateType<Context, TState<State['callstack'], [...State['visited'], Ref]>, Context[Ref]> : Type);
|
|
1212
|
+
|
|
1213
|
+
type TFromCyclic<Defs extends TProperties, Ref extends string, Target extends TSchema = TCyclicTarget<Defs, Ref>, Partial extends TSchema = TFromType<Target>, Result extends TSchema = TCyclic<TAssign<Defs, {
|
|
1214
|
+
[_ in Ref]: Partial;
|
|
1215
|
+
}>, Ref>> = Result;
|
|
1216
|
+
|
|
1217
|
+
type TFromDependent<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends TSchema = TFromType<Evaluated>> = Result;
|
|
1218
|
+
|
|
1219
|
+
type TFromIntersect<Types extends TSchema[], Evaluated extends TSchema = TEvaluateIntersect<Types>, Result extends TSchema = TFromType<Evaluated>> = Result;
|
|
1220
|
+
|
|
1221
|
+
type TFromUnion<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromUnion<Right, [...Result, TFromType<Left>]> : TUnion<Result>);
|
|
1222
|
+
|
|
1223
|
+
type TFromObject<Properties extends TProperties, Mapped extends TProperties = {
|
|
1224
|
+
[Key in keyof Properties]: TRemoveOptional<Properties[Key]>;
|
|
1225
|
+
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
1226
|
+
|
|
1227
|
+
type TFromType<Type extends TSchema> = (Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic<Defs, Ref> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent<If, Then, Else> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<Types> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<Properties> : TObject<{}>);
|
|
1228
|
+
|
|
1229
|
+
/** Creates a deferred Required action. */
|
|
1230
|
+
type TRequiredDeferred<Type extends TSchema> = (TDeferred<'Required', [Type]>);
|
|
1231
|
+
|
|
1232
|
+
type TRequiredAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<Type> : TRequiredDeferred<Type>> = Result;
|
|
1233
|
+
type TRequiredInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TRequiredAction<InstantiatedType>;
|
|
1234
|
+
|
|
1235
|
+
/** Creates a deferred ReturnType action. */
|
|
1236
|
+
type TReturnTypeDeferred<Type extends TSchema> = (TDeferred<'ReturnType', [Type]>);
|
|
1237
|
+
|
|
1238
|
+
type TReturnTypeOperation<Type extends TSchema> = (Type extends TFunction ? Type['returnType'] : TNever);
|
|
1239
|
+
type TReturnTypeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TReturnTypeOperation<Type> : TReturnTypeDeferred<Type>> = Result;
|
|
1240
|
+
type TReturnTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TReturnTypeAction<InstantiatedType>;
|
|
1241
|
+
|
|
1242
|
+
/** Creates a deferred With action. */
|
|
1243
|
+
type TWithDeferred<Type extends TSchema, Options extends TSchema> = (TDeferred<'With', [Type, Options]>);
|
|
1244
|
+
/** Applies annotation options to the given type. */
|
|
1245
|
+
type TWith<Type extends TSchema, Options extends TSchema> = (Type & Options);
|
|
1246
|
+
|
|
1247
|
+
type TWithAction<Type extends TSchema, Options extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TWith<Type, Options> : TWithDeferred<Type, Options>> = Result;
|
|
1248
|
+
type TWithInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Options extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TWithAction<InstantiatedType, Options>;
|
|
1249
|
+
|
|
1250
|
+
type TSpreadElement<Type extends TSchema, Result extends TSchema[] = (Type extends TRest<infer Rest extends TSchema> ? (Rest extends TTuple<infer Elements extends TSchema[]> ? TRestSpread<Elements> : Rest extends TInfer<string, TSchema> ? [Type] : Rest extends TRef<string> ? [Type] : [
|
|
1251
|
+
TNever
|
|
1252
|
+
]) : [Type])> = Result;
|
|
1253
|
+
type TRestSpread<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TRestSpread<Right, [...Result, ...TSpreadElement<Left>]> : Result);
|
|
1254
|
+
|
|
1255
|
+
interface TState<CallStack extends string[] = string[], Visited extends string[] = string[]> {
|
|
1256
|
+
callstack: CallStack;
|
|
1257
|
+
visited: Visited;
|
|
1258
|
+
}
|
|
1259
|
+
type TCanInstantiate<Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef ? false : TCanInstantiate<Right> : true;
|
|
1260
|
+
type TInstantiateProperties<Context extends TProperties, State extends TState, Properties extends TProperties, Result extends TProperties = {
|
|
1261
|
+
[Key in keyof Properties]: TInstantiateType<Context, State, Properties[Key]>;
|
|
1262
|
+
}> = Result;
|
|
1263
|
+
type TInstantiateElements<Context extends TProperties, State extends TState, Types extends TSchema[], Elements extends TSchema[] = TInstantiateTypes<Context, State, Types>, Result extends TSchema[] = TRestSpread<Elements>> = Result;
|
|
1264
|
+
type TInstantiateTypes<Context extends TProperties, State extends TState, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TInstantiateTypes<Context, State, Right, [...Result, TInstantiateType<Context, State, Left>]> : Result);
|
|
1265
|
+
type TWithModifiers<Type extends TSchema, InstantiatedType extends TSchema, WithOptional extends TSchema = Type extends TOptional ? TAddOptionalAction<InstantiatedType> : InstantiatedType, WithReadonly extends TSchema = Type extends TReadonly ? TAddReadonlyAction<WithOptional> : WithOptional, WithImmutable extends TSchema = Type extends TImmutable ? TAddImmutableAction<WithReadonly> : WithReadonly> = WithImmutable;
|
|
1266
|
+
type TInstantiateDeferred<Context extends TProperties, State extends TState, Action extends string, Parameters extends TSchema[]> = ([
|
|
1267
|
+
Action,
|
|
1268
|
+
Parameters
|
|
1269
|
+
] extends ['AddImmutable', [infer Type extends TSchema]] ? TAddImmutableInstantiate<Context, State, Type> : [
|
|
1270
|
+
Action,
|
|
1271
|
+
Parameters
|
|
1272
|
+
] extends ['RemoveImmutable', [infer Type extends TSchema]] ? TRemoveImmutableInstantiate<Context, State, Type> : [
|
|
1273
|
+
Action,
|
|
1274
|
+
Parameters
|
|
1275
|
+
] extends ['AddReadonly', [infer Type extends TSchema]] ? TAddReadonlyInstantiate<Context, State, Type> : [
|
|
1276
|
+
Action,
|
|
1277
|
+
Parameters
|
|
1278
|
+
] extends ['RemoveReadonly', [infer Type extends TSchema]] ? TRemoveReadonlyInstantiate<Context, State, Type> : [
|
|
1279
|
+
Action,
|
|
1280
|
+
Parameters
|
|
1281
|
+
] extends ['AddOptional', [infer Type extends TSchema]] ? TAddOptionalInstantiate<Context, State, Type> : [
|
|
1282
|
+
Action,
|
|
1283
|
+
Parameters
|
|
1284
|
+
] extends ['RemoveOptional', [infer Type extends TSchema]] ? TRemoveOptionalInstantiate<Context, State, Type> : [
|
|
1285
|
+
Action,
|
|
1286
|
+
Parameters
|
|
1287
|
+
] extends ['Capitalize', [infer Type extends TSchema]] ? TCapitalizeInstantiate<Context, State, Type> : [
|
|
1288
|
+
Action,
|
|
1289
|
+
Parameters
|
|
1290
|
+
] extends ['Conditional', [infer Left extends TSchema, infer Right extends TSchema, infer True extends TSchema, infer False extends TSchema]] ? TConditionalInstantiate<Context, State, Left, Right, True, False> : [
|
|
1291
|
+
Action,
|
|
1292
|
+
Parameters
|
|
1293
|
+
] extends ['ConstructorParameters', [infer Type extends TSchema]] ? TConstructorParametersInstantiate<Context, State, Type> : [
|
|
1294
|
+
Action,
|
|
1295
|
+
Parameters
|
|
1296
|
+
] extends ['Evaluate', [infer Type extends TSchema]] ? TEvaluateInstantiate<Context, State, Type> : [
|
|
1297
|
+
Action,
|
|
1298
|
+
Parameters
|
|
1299
|
+
] extends ['Exclude', [infer Left extends TSchema, infer Right extends TSchema]] ? TExcludeInstantiate<Context, State, Left, Right> : [
|
|
1300
|
+
Action,
|
|
1301
|
+
Parameters
|
|
1302
|
+
] extends ['Extract', [infer Left extends TSchema, infer Right extends TSchema]] ? TExtractInstantiate<Context, State, Left, Right> : [
|
|
1303
|
+
Action,
|
|
1304
|
+
Parameters
|
|
1305
|
+
] extends ['Index', [infer Type extends TSchema, infer Indexer extends TSchema]] ? TIndexInstantiate<Context, State, Type, Indexer> : [
|
|
1306
|
+
Action,
|
|
1307
|
+
Parameters
|
|
1308
|
+
] extends ['InstanceType', [infer Type extends TSchema]] ? TInstanceTypeInstantiate<Context, State, Type> : [
|
|
1309
|
+
Action,
|
|
1310
|
+
Parameters
|
|
1311
|
+
] extends ['Interface', [infer Heritage extends TSchema[], infer Properties extends TProperties]] ? TInterfaceInstantiate<Context, State, Heritage, Properties> : [
|
|
1312
|
+
Action,
|
|
1313
|
+
Parameters
|
|
1314
|
+
] extends ['KeyOf', [infer Type extends TSchema]] ? TKeyOfInstantiate<Context, State, Type> : [
|
|
1315
|
+
Action,
|
|
1316
|
+
Parameters
|
|
1317
|
+
] extends ['Lowercase', [infer Type extends TSchema]] ? TLowercaseInstantiate<Context, State, Type> : [
|
|
1318
|
+
Action,
|
|
1319
|
+
Parameters
|
|
1320
|
+
] extends ['Mapped', [infer Name extends TIdentifier, infer Key extends TSchema, infer As extends TSchema, infer Property extends TSchema]] ? TMappedInstantiate<Context, State, Name, Key, As, Property> : [
|
|
1321
|
+
Action,
|
|
1322
|
+
Parameters
|
|
1323
|
+
] extends ['Module', [infer Declarations extends TProperties]] ? TModuleInstantiate<Context, State, Declarations> : [
|
|
1324
|
+
Action,
|
|
1325
|
+
Parameters
|
|
1326
|
+
] extends ['NonNullable', [infer Type extends TSchema]] ? TNonNullableInstantiate<Context, State, Type> : [
|
|
1327
|
+
Action,
|
|
1328
|
+
Parameters
|
|
1329
|
+
] extends ['Pick', [infer Type extends TSchema, infer Indexer extends TSchema]] ? TPickInstantiate<Context, State, Type, Indexer> : [
|
|
1330
|
+
Action,
|
|
1331
|
+
Parameters
|
|
1332
|
+
] extends ['Parameters', [infer Type extends TSchema]] ? TParametersInstantiate<Context, State, Type> : [
|
|
1333
|
+
Action,
|
|
1334
|
+
Parameters
|
|
1335
|
+
] extends ['Partial', [infer Type extends TSchema]] ? TPartialInstantiate<Context, State, Type> : [
|
|
1336
|
+
Action,
|
|
1337
|
+
Parameters
|
|
1338
|
+
] extends ['Omit', [infer Type extends TSchema, infer Indexer extends TSchema]] ? TOmitInstantiate<Context, State, Type, Indexer> : [
|
|
1339
|
+
Action,
|
|
1340
|
+
Parameters
|
|
1341
|
+
] extends ['ReadonlyObject', [infer Type extends TSchema]] ? TReadonlyObjectInstantiate<Context, State, Type> : [
|
|
1342
|
+
Action,
|
|
1343
|
+
Parameters
|
|
1344
|
+
] extends ['Record', [infer Key extends TSchema, infer Value extends TSchema]] ? TRecordInstantiate<Context, State, Key, Value> : [
|
|
1345
|
+
Action,
|
|
1346
|
+
Parameters
|
|
1347
|
+
] extends ['Required', [infer Type extends TSchema]] ? TRequiredInstantiate<Context, State, Type> : [
|
|
1348
|
+
Action,
|
|
1349
|
+
Parameters
|
|
1350
|
+
] extends ['ReturnType', [infer Type extends TSchema]] ? TReturnTypeInstantiate<Context, State, Type> : [
|
|
1351
|
+
Action,
|
|
1352
|
+
Parameters
|
|
1353
|
+
] extends ['TemplateLiteral', [infer Types extends TSchema[]]] ? TTemplateLiteralInstantiate<Context, State, Types> : [
|
|
1354
|
+
Action,
|
|
1355
|
+
Parameters
|
|
1356
|
+
] extends ['Uncapitalize', [infer Type extends TSchema]] ? TUncapitalizeInstantiate<Context, State, Type> : [
|
|
1357
|
+
Action,
|
|
1358
|
+
Parameters
|
|
1359
|
+
] extends ['Uppercase', [infer Type extends TSchema]] ? TUppercaseInstantiate<Context, State, Type> : [
|
|
1360
|
+
Action,
|
|
1361
|
+
Parameters
|
|
1362
|
+
] extends ['With', [infer Type extends TSchema, infer Options extends TSchema]] ? TWithInstantiate<Context, State, Type, Options> : TDeferred<Action, Parameters>);
|
|
1363
|
+
type TInstantiateImmediate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Type, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TDependent<TInstantiateType<Context, State, If>, TInstantiateType<Context, State, Then>, TInstantiateType<Context, State, Else>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithModifiers extends TSchema = TWithModifiers<Type, InstantiatedType>> = WithModifiers;
|
|
1364
|
+
type TInstantiateType<Context extends TProperties, State extends TState, Type extends TSchema, Result extends TSchema = Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : TInstantiateImmediate<Context, State, Type>> = Result;
|
|
1365
|
+
/** Instantiates computed schematics using the given context and type. */
|
|
1366
|
+
type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, TState<[], []>, Type>);
|
|
1367
|
+
|
|
1368
|
+
type TAddOptionalOperation<Type extends TSchema, Result extends TSchema = `~optional` extends keyof Type ? Type : TOptional<Type>> = Result;
|
|
1369
|
+
type TAddOptionalAction<Type extends TSchema, Result extends TSchema = TAddOptionalOperation<Type>> = Result;
|
|
1370
|
+
type TAddOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddOptionalAction<InstantiateType>;
|
|
1371
|
+
|
|
1372
|
+
/** Applies an AddOptional action to a type. */
|
|
1373
|
+
type TAddOptional<Type extends TSchema> = (TAddOptionalAction<Type>);
|
|
1374
|
+
|
|
1375
|
+
type TOptional<Type extends TSchema = TSchema> = (Type & {
|
|
1376
|
+
'~optional': true;
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
type StaticLast<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema, Result extends unknown[]> = (Type extends TRest<infer RestType extends TSchema> ? RestType extends TArray<infer ArrayType extends TSchema> ? [...Result, ...TStaticElement<Stack, Direction, Context, This, ArrayType>[0][]] : [...Result, never] : [...Result, ...TStaticElement<Stack, Direction, Context, This, Type>]);
|
|
1380
|
+
type TStaticElement<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema, IsReadonly extends boolean = Type extends TReadonly ? true : false, IsOptional extends boolean = Type extends TOptional ? true : false, Inferred extends unknown = StaticType<Stack, Direction, Context, This, Type>, Result extends [unknown?] = ([
|
|
1381
|
+
IsReadonly,
|
|
1382
|
+
IsOptional
|
|
1383
|
+
] extends [true, true] ? [Readonly<Inferred>?] : [
|
|
1384
|
+
IsReadonly,
|
|
1385
|
+
IsOptional
|
|
1386
|
+
] extends [false, true] ? [Inferred?] : [
|
|
1387
|
+
IsReadonly,
|
|
1388
|
+
IsOptional
|
|
1389
|
+
] extends [true, false] ? [Readonly<Inferred>] : [
|
|
1390
|
+
Inferred
|
|
1391
|
+
])> = Result;
|
|
1392
|
+
type TStaticElements<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Types extends TSchema[], Result extends unknown[] = []> = (Types extends [infer Last extends TSchema] ? StaticLast<Stack, Direction, Context, This, Last, Result> : Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TStaticElements<Stack, Direction, Context, This, Right, [...Result, ...TStaticElement<Stack, Direction, Context, This, Left>]> : Result);
|
|
1393
|
+
type StaticTuple<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Tuple extends TSchema, Items extends TSchema[], Elements extends unknown[] = TStaticElements<Stack, Direction, Context, This, Items>, Result extends readonly unknown[] = (Tuple extends TImmutable ? readonly [...Elements] : Elements)> = Result;
|
|
1394
|
+
/** Represents a Tuple type. */
|
|
1395
|
+
interface TTuple<Types extends TSchema[] = TSchema[]> extends TSchema {
|
|
1396
|
+
'~kind': 'Tuple';
|
|
1397
|
+
type: 'array';
|
|
1398
|
+
additionalItems: false;
|
|
1399
|
+
items: Types;
|
|
1400
|
+
minItems: Types['length'];
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
type StaticInstantiatedParameters<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], Evaluated extends TSchema = TInstantiate<Context, TTuple<Parameters>>, Static extends unknown = StaticType<Stack, Direction, Context, This, Evaluated>, Result extends unknown[] = Static extends unknown[] ? Static : []> = Result;
|
|
1404
|
+
type StaticFunction<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema, StaticParameters extends unknown[] = StaticInstantiatedParameters<Stack, Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Stack, Direction, Context, This, ReturnType>, Result = (...args: StaticParameters) => StaticReturnType> = Result;
|
|
1405
|
+
/** Represents a Function type. */
|
|
1406
|
+
interface TFunction<Parameters extends TSchema[] = TSchema[], ReturnType extends TSchema = TSchema> extends TSchema {
|
|
1407
|
+
'~kind': 'Function';
|
|
1408
|
+
type: 'function';
|
|
1409
|
+
parameters: Parameters;
|
|
1410
|
+
returnType: ReturnType;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
type StaticConstructor<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema, StaticParameters extends unknown[] = StaticInstantiatedParameters<Stack, Direction, Context, This, Parameters>, StaticReturnType extends unknown = StaticType<Stack, Direction, Context, This, InstanceType>, Result = new (...args: StaticParameters) => StaticReturnType> = Result;
|
|
1414
|
+
/** Represents a Constructor type. */
|
|
1415
|
+
interface TConstructor<Parameters extends TSchema[] = TSchema[], InstanceType extends TSchema = TSchema> extends TSchema {
|
|
1416
|
+
'~kind': 'Constructor';
|
|
1417
|
+
type: 'constructor';
|
|
1418
|
+
parameters: Parameters;
|
|
1419
|
+
instanceType: InstanceType;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
type XSchemaObject = object;
|
|
1423
|
+
type XSchemaBoolean = boolean;
|
|
1424
|
+
type XSchema = XSchemaObject | XSchemaBoolean;
|
|
1425
|
+
|
|
1426
|
+
type XCanonicalTuple<Value extends readonly unknown[]> = (Value extends [infer Left, ...infer Right extends unknown[]] ? [XCanonical<Left>, ...XCanonicalTuple<Right>] : []);
|
|
1427
|
+
type XCanonicalArray<Value extends unknown, Result extends unknown[] = XCanonical<Value>[]> = Result;
|
|
1428
|
+
type XCanonicalObject<Value extends object, Result extends Record<PropertyKey, unknown> = {
|
|
1429
|
+
-readonly [Key in keyof Value]: XCanonical<Value[Key]>;
|
|
1430
|
+
}> = Result;
|
|
1431
|
+
type XCanonical<Schema extends unknown> = (Schema extends readonly [...infer Schemas extends unknown[]] ? XCanonicalTuple<Schemas> : Schema extends readonly (infer Schema)[] ? XCanonicalArray<Schema> : Schema extends object ? XCanonicalObject<Schema> : Schema);
|
|
1432
|
+
|
|
1433
|
+
interface XAdditionalProperties<AdditionalProperties extends XSchema = XSchema> {
|
|
1434
|
+
additionalProperties: AdditionalProperties;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
interface XAnyOf<AnyOf extends XSchema[] = XSchema[]> {
|
|
1438
|
+
anyOf: AnyOf;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
interface XAllOf<AllOf extends XSchema[] = XSchema[]> {
|
|
1442
|
+
allOf: AllOf;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
interface XConst<Const extends unknown = unknown> {
|
|
1446
|
+
const: Const;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
interface XEnum<Enum extends unknown[] = unknown[]> {
|
|
1450
|
+
enum: Enum;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
interface XIf<If extends XSchema = XSchema> {
|
|
1454
|
+
if: If;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
interface XItems<Items extends (XSchema | XSchema[]) = (XSchema | XSchema[])> {
|
|
1458
|
+
items: Items;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
interface XOneOf<OneOf extends XSchema[] = XSchema[]> {
|
|
1462
|
+
oneOf: OneOf;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
interface XPatternProperties<PatternProperties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>> {
|
|
1466
|
+
patternProperties: PatternProperties;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
interface XPrefixItems<PrefixItems extends XSchema[] = XSchema[]> {
|
|
1470
|
+
prefixItems: PrefixItems;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
interface XProperties<Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>> {
|
|
1474
|
+
properties: Properties;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
interface XPropertyNames<PropertyNames extends XSchema = XSchema> {
|
|
1478
|
+
propertyNames: PropertyNames;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
interface XRef<Ref extends string = string> {
|
|
1482
|
+
$ref: Ref;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
interface XRequired<Required extends string[] = string[]> {
|
|
1486
|
+
required: Required;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
interface XType<Type extends string | string[] = string | string[]> {
|
|
1490
|
+
type: Type;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
interface XUnevaluatedProperties<UnevaluatedProperties extends XSchema = XSchema> {
|
|
1494
|
+
unevaluatedProperties: UnevaluatedProperties;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
type XStaticAdditionalProperties<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
1498
|
+
[key: string]: unknown;
|
|
1499
|
+
} : Schema extends false ? {} : {
|
|
1500
|
+
[key: string]: XStaticSchema<Stack, Root, Schema>;
|
|
1501
|
+
})> = Result;
|
|
1502
|
+
|
|
1503
|
+
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);
|
|
1504
|
+
|
|
1505
|
+
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);
|
|
1506
|
+
|
|
1507
|
+
type XStaticConst<Value extends unknown> = Value;
|
|
1508
|
+
|
|
1509
|
+
type XStaticEnum<Values extends unknown[], Result extends unknown = never> = (Values extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XStaticEnum<Right, Left | Result> : Result);
|
|
1510
|
+
|
|
1511
|
+
interface XElse<Else extends XSchema = XSchema> {
|
|
1512
|
+
else: Else;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
interface XThen<Then extends XSchema = XSchema> {
|
|
1516
|
+
then: Then;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
type XStaticIf<Stack extends string[], Root extends XSchema, Schema extends XIf, IfSchema extends XSchema, If extends unknown = XStaticSchema<Stack, Root, IfSchema>, Then extends unknown = Schema extends XThen<infer ThenSchema extends XSchema> ? XStaticSchema<Stack, Root, ThenSchema> : never, Else extends unknown = Schema extends XElse<infer ElseSchema extends XSchema> ? XStaticSchema<Stack, Root, ElseSchema> : never, IsThen extends boolean = Schema extends XThen ? true : false, IsElse extends boolean = Schema extends XElse ? true : false, Result extends unknown = ([
|
|
1520
|
+
IsThen,
|
|
1521
|
+
IsElse
|
|
1522
|
+
] extends [true, true] ? (If & Then) | Exclude<Else, If> : [
|
|
1523
|
+
IsThen,
|
|
1524
|
+
IsElse
|
|
1525
|
+
] extends [true, false] ? (If & Then) : [
|
|
1526
|
+
IsThen,
|
|
1527
|
+
IsElse
|
|
1528
|
+
] extends [false, true] ? Exclude<Else, If> : unknown)> = Result;
|
|
1529
|
+
|
|
1530
|
+
interface XMinItems<MinItems extends number = number> {
|
|
1531
|
+
minItems: MinItems;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
interface XMaxItems<MaxItems extends number = number> {
|
|
1535
|
+
maxItems: MaxItems;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
interface XAdditionalItems<AdditionalItems extends XSchema = XSchema> {
|
|
1539
|
+
additionalItems: AdditionalItems;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
type XBuildTuple<Size extends number, Tuple extends unknown[] = []> = (Tuple['length'] extends Size ? Tuple : XBuildTuple<Size, [...Tuple, unknown]>);
|
|
1543
|
+
type XLessThan<Left extends number, Right extends number> = Left extends Right ? false : XBuildTuple<Left> extends [...XBuildTuple<Right>, ...infer _Rest] ? false : true;
|
|
1544
|
+
|
|
1545
|
+
type XWithElements<Stack extends string[], Root extends XSchema, Schemas extends XSchema[], Result extends unknown[] = []> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XWithElements<Stack, Root, Right, [...Result, XStaticSchema<Stack, Root, Left>]> : Result);
|
|
1546
|
+
type XWithMaxItemsRemap<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 ? XWithMaxItemsRemap<Right, MaxItems, [...Result, Left]> : Result : Result);
|
|
1547
|
+
type XWithMaxItems<Schema extends XSchema, Elements extends unknown[], Result extends unknown[] = Schema extends XMaxItems<infer MaxItems extends number> ? XWithMaxItemsRemap<Elements, MaxItems> : Elements> = Result;
|
|
1548
|
+
type XNeedsAdditionalItems<Schema extends XSchema, Elements extends unknown[], Result extends boolean = (Schema extends XMaxItems<infer MaxItems extends number> ? XLessThan<Elements['length'], MaxItems> : true)> = Result;
|
|
1549
|
+
type XWithMinItemsRemap<Elements extends unknown[], MinItems extends number, Result extends unknown[] = []> = (Elements extends [infer Left, ...infer Right] ? XLessThan<Result['length'], MinItems> extends true ? XWithMinItemsRemap<Right, MinItems, [...Result, Left]> : XWithMinItemsRemap<Right, MinItems, [...Result, Left?]> : Result);
|
|
1550
|
+
type XWithMinItems<Schema extends XSchema, Values extends unknown[], MinItems extends number = Schema extends XMinItems<infer MinItems extends number> ? MinItems : 0, Result extends unknown[] = XWithMinItemsRemap<Values, MinItems>> = Result;
|
|
1551
|
+
type XWithAdditionalItems<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] : [
|
|
1552
|
+
...Elements,
|
|
1553
|
+
...XStaticSchema<Stack, Root, Schema>[]
|
|
1554
|
+
]) : [...Elements, ...unknown[]]> = Result;
|
|
1555
|
+
type XStaticElements<Stack extends string[], Root extends XSchema, Schema extends XSchema, PrefixItems extends XSchema[], WithElements extends unknown[] = XWithElements<Stack, Root, PrefixItems>, WithMaxItems extends unknown[] = XWithMaxItems<Schema, WithElements>, NeedsAdditional extends boolean = XNeedsAdditionalItems<Schema, WithMaxItems>, WithMinItems extends unknown[] = XWithMinItems<Schema, WithMaxItems>, WithAdditionalItems extends unknown[] = NeedsAdditional extends true ? XWithAdditionalItems<Stack, Root, Schema, WithMinItems> : WithMinItems> = WithAdditionalItems;
|
|
1556
|
+
|
|
1557
|
+
type XFromSized<Stack extends string[], Root extends XSchema, Schema extends XSchema, Items extends XSchema[]> = (XStaticElements<Stack, Root, Schema, Items>);
|
|
1558
|
+
type XFromUnsized<Stack extends string[], Root extends XSchema, Schema extends XSchema> = (XStaticSchema<Stack, Root, Schema>[]);
|
|
1559
|
+
type XStaticItems<Stack extends string[], Root extends XSchema, Schema extends XSchema, Items extends XSchema[] | XSchema, Result extends unknown = (Items extends XSchema[] ? XFromSized<Stack, Root, Schema, [...Items]> : Items extends XSchema ? XFromUnsized<Stack, Root, Items> : never)> = Result;
|
|
1560
|
+
|
|
1561
|
+
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);
|
|
1562
|
+
|
|
1563
|
+
type XStaticPatternProperties<Stack extends string[], Root extends XSchema, Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>, InferredProperties extends Record<PropertyKey, unknown> = {
|
|
1564
|
+
[Key in keyof Properties]: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
1565
|
+
}, EvaluatedProperties extends unknown = {
|
|
1566
|
+
[key: string]: InferredProperties[keyof InferredProperties];
|
|
1567
|
+
}> = EvaluatedProperties;
|
|
1568
|
+
|
|
1569
|
+
type XStaticPrefixItems<Stack extends string[], Root extends XSchema, Schema extends XSchema, PrefixItems extends XSchema[], Result extends unknown[] = XStaticElements<Stack, Root, Schema, PrefixItems>> = Result;
|
|
1570
|
+
|
|
1571
|
+
type XIsReadonly<Schema extends XSchema> = (Schema extends {
|
|
1572
|
+
readOnly: true;
|
|
1573
|
+
} ? true : Schema extends {
|
|
1574
|
+
'~readonly': true;
|
|
1575
|
+
} ? true : false);
|
|
1576
|
+
type XRequiredArray<Schema extends XSchema, Result extends PropertyKey[] = Schema extends XRequired<infer Keys extends string[]> ? Keys : []> = Result;
|
|
1577
|
+
type XReadonlyKeys<Properties extends Record<PropertyKey, XSchema>, ReadonlyProperties extends Record<PropertyKey, unknown> = {
|
|
1578
|
+
[Key in keyof Properties as XIsReadonly<Properties[Key]> extends true ? Key : never]: unknown;
|
|
1579
|
+
}, Result extends PropertyKey = keyof ReadonlyProperties> = Result;
|
|
1580
|
+
type XRequiredKeys<Properties extends Record<PropertyKey, XSchema>, RequiredArray extends string[], Result extends PropertyKey = RequiredArray extends [] ? never : Extract<keyof Properties, RequiredArray[number]>> = Result;
|
|
1581
|
+
type XUnknownKeys<Properties extends Record<PropertyKey, XSchema>, RequiredArray extends string[], Result extends PropertyKey = Exclude<RequiredArray[number], keyof Properties>> = Result;
|
|
1582
|
+
type XOptionalKeys<Properties extends Record<PropertyKey, XSchema>, RequiredArray extends string[], Result extends PropertyKey = RequiredArray extends [] ? keyof Properties : Exclude<keyof Properties, RequiredArray[number]>> = Result;
|
|
1583
|
+
type XReadonlyOptionalProperties<Stack extends string[], Root extends XSchema, OptionalKeys extends PropertyKey, Properties extends Record<PropertyKey, XSchema>> = {
|
|
1584
|
+
readonly [Key in Extract<keyof Properties, OptionalKeys>]?: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
1585
|
+
};
|
|
1586
|
+
type XReadonlyRequiredProperties<Stack extends string[], Root extends XSchema, RequiredKeys extends PropertyKey, Properties extends Record<PropertyKey, XSchema>> = {
|
|
1587
|
+
readonly [Key in Extract<keyof Properties, RequiredKeys>]: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
1588
|
+
};
|
|
1589
|
+
type XOptionalProperties<Stack extends string[], Root extends XSchema, OptionalKeys extends PropertyKey, Properties extends Record<PropertyKey, XSchema>> = {
|
|
1590
|
+
[Key in Extract<keyof Properties, OptionalKeys>]?: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
1591
|
+
};
|
|
1592
|
+
type XRequiredProperties<Stack extends string[], Root extends XSchema, RequiredKeys extends PropertyKey, Properties extends Record<PropertyKey, XSchema>> = {
|
|
1593
|
+
[Key in Extract<keyof Properties, RequiredKeys>]: XStaticSchema<Stack, Root, Properties[Key]>;
|
|
1594
|
+
};
|
|
1595
|
+
type XUnknownProperties<UnknownKeys extends PropertyKey> = {
|
|
1596
|
+
[Key in UnknownKeys]: unknown;
|
|
1597
|
+
};
|
|
1598
|
+
type XStaticProperties<Stack extends string[], Root extends XSchema, Schema extends XSchema, Properties extends Record<PropertyKey, XSchema>, RequiredArray extends string[] = XRequiredArray<Schema>, ReadonlyKeys extends PropertyKey = XReadonlyKeys<Properties>, OptionalKeys extends PropertyKey = XOptionalKeys<Properties, RequiredArray>, RequiredKeys extends PropertyKey = XRequiredKeys<Properties, RequiredArray>, UnknownKeys extends PropertyKey = XUnknownKeys<Properties, RequiredArray>, ReadonlyOptionalProperties extends Record<PropertyKey, unknown> = XReadonlyOptionalProperties<Stack, Root, Extract<OptionalKeys, ReadonlyKeys>, Properties>, ReadonlyRequiredProperties extends Record<PropertyKey, unknown> = XReadonlyRequiredProperties<Stack, Root, Extract<RequiredKeys, ReadonlyKeys>, Properties>, OptionalProperties extends Record<PropertyKey, unknown> = XOptionalProperties<Stack, Root, Exclude<OptionalKeys, ReadonlyKeys>, Properties>, RequiredProperties extends Record<PropertyKey, unknown> = XRequiredProperties<Stack, Root, Exclude<RequiredKeys, ReadonlyKeys>, Properties>, UnknownProperties extends Record<PropertyKey, unknown> = XUnknownProperties<UnknownKeys>, Result extends Record<PropertyKey, unknown> = (ReadonlyOptionalProperties & ReadonlyRequiredProperties & OptionalProperties & RequiredProperties & UnknownProperties)> = Result;
|
|
1599
|
+
|
|
1600
|
+
type XStaticPropertyNames<Stack extends string[], Root extends XSchema, Schema extends XSchema, StaticKey extends unknown = XStaticSchema<Stack, Root, Schema>, Result extends Record<string, unknown> = [StaticKey] extends [PropertyKey] ? {
|
|
1601
|
+
[Key in StaticKey]?: unknown;
|
|
1602
|
+
} : {}> = Result;
|
|
1603
|
+
|
|
1604
|
+
type TEscape0<Index extends string> = Index extends `${infer Left}~0${infer Right}` ? `${Left}~${TEscape<Right>}` : Index;
|
|
1605
|
+
type TEscape1<Index extends string> = Index extends `${infer Left}~1${infer Right}` ? `${Left}/${TEscape<Right>}` : Index;
|
|
1606
|
+
type TEscape<Index extends string, Escaped0 extends string = TEscape0<Index>, Escaped1 extends string = TEscape1<Escaped0>> = Escaped1;
|
|
1607
|
+
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>]);
|
|
1608
|
+
type TIndices<Pointer extends string, Result extends string[] = Pointer extends '' ? [] : IndicesReduce<Pointer>> = Result;
|
|
1609
|
+
type TResolve<Value extends unknown, Indices extends string[]> = (Indices extends [infer Left extends string, ...infer Right extends string[]] ? Left extends keyof Value ? TResolve<Value[Left], Right> : undefined : Value);
|
|
1610
|
+
/** Type Level RFC 6901 Json Pointer Resolver */
|
|
1611
|
+
type XPointerGet<Value extends unknown, Pointer extends string, Indices extends string[] = TIndices<Pointer>, Result extends unknown = TResolve<Value, Indices>> = Result;
|
|
1612
|
+
|
|
1613
|
+
type XCyclicCheck<Stack extends unknown[], MaxLength extends number, Buffer extends unknown[] = []> = (Stack extends [infer Left, ...infer Right] ? Buffer['length'] extends MaxLength ? false : XCyclicCheck<Right, MaxLength, [...Buffer, Left]> : true);
|
|
1614
|
+
type XCyclicGuard<Stack extends unknown[], Ref extends string> = (Ref extends Stack[number] ? XCyclicCheck<Stack, 2> : true);
|
|
1615
|
+
type XNormal<Pointer extends string, Result extends string = (Pointer extends `#${infer Rest extends string}` ? Rest : Pointer)> = Result;
|
|
1616
|
+
type XStaticRef<Stack extends string[], Root extends XSchema, Ref extends string, Normal extends string = XNormal<Ref>, Target extends unknown = XPointerGet<Root, Normal>, Schema extends XSchema = Target extends XSchema ? Target : {}, Result extends unknown = (XCyclicGuard<Stack, Ref> extends true ? XStaticSchema<[...Stack, Ref], Root, Schema> : any)> = Result;
|
|
1617
|
+
|
|
1618
|
+
type XStaticRequired<_Stack extends string[], _Root extends XSchema, Schema extends XSchema, Keys extends string[], Result extends Record<PropertyKey, unknown> = Schema extends XProperties ? {} : Record<Keys[number], unknown>> = Result;
|
|
1619
|
+
|
|
1620
|
+
type XFromTypeNames<TypeNames extends string[], Result extends unknown = never> = (TypeNames extends readonly [infer Left extends string, ...infer Right extends string[]] ? XFromTypeNames<Right, Result | XFromTypeName<Left>> : Result);
|
|
1621
|
+
type XFromTypeName<TypeName extends string> = (TypeName extends 'object' ? object : TypeName extends 'array' ? {} : TypeName extends 'boolean' ? boolean : TypeName extends 'integer' ? number : TypeName extends 'number' ? number : TypeName extends 'null' ? null : TypeName extends 'string' ? string : TypeName extends 'bigint' ? bigint : TypeName extends 'symbol' ? symbol : TypeName extends 'undefined' ? undefined : TypeName extends 'void' ? void : TypeName extends 'asyncIterator' ? {} : TypeName extends 'constructor' ? {} : TypeName extends 'function' ? {} : TypeName extends 'iterator' ? {} : unknown);
|
|
1622
|
+
type XStaticType<TypeName extends string[] | string> = (TypeName extends string[] ? XFromTypeNames<TypeName> : TypeName extends string ? XFromTypeName<TypeName> : unknown);
|
|
1623
|
+
|
|
1624
|
+
type XStaticUnevaluatedProperties<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
|
|
1625
|
+
[key: string]: unknown;
|
|
1626
|
+
} : Schema extends false ? {} : {
|
|
1627
|
+
[key: string]: XStaticSchema<Stack, Root, Schema>;
|
|
1628
|
+
})> = Result;
|
|
1629
|
+
|
|
1630
|
+
type XFromKeywords<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends unknown[] = [
|
|
1631
|
+
Schema extends XAdditionalProperties<infer Type extends XSchema> ? XStaticAdditionalProperties<Stack, Root, Type> : unknown,
|
|
1632
|
+
Schema extends XAllOf<infer Types extends XSchema[]> ? XStaticAllOf<Stack, Root, Types> : unknown,
|
|
1633
|
+
Schema extends XAnyOf<infer Types extends XSchema[]> ? XStaticAnyOf<Stack, Root, Types> : unknown,
|
|
1634
|
+
Schema extends XConst<infer Value extends unknown> ? XStaticConst<Value> : unknown,
|
|
1635
|
+
Schema extends XIf<infer Type extends XSchema> ? XStaticIf<Stack, Root, Schema, Type> : unknown,
|
|
1636
|
+
Schema extends XEnum<infer Values extends unknown[]> ? XStaticEnum<Values> : unknown,
|
|
1637
|
+
Schema extends XItems<infer Types extends XSchema[] | XSchema> ? XStaticItems<Stack, Root, Schema, Types> : unknown,
|
|
1638
|
+
Schema extends XOneOf<infer Types extends XSchema[]> ? XStaticOneOf<Stack, Root, Types> : unknown,
|
|
1639
|
+
Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticPatternProperties<Stack, Root, Properties> : unknown,
|
|
1640
|
+
Schema extends XPrefixItems<infer Types extends XSchema[]> ? XStaticPrefixItems<Stack, Root, Schema, Types> : unknown,
|
|
1641
|
+
Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticProperties<Stack, Root, Schema, Properties> : unknown,
|
|
1642
|
+
Schema extends XPropertyNames<infer Type extends XSchema> ? XStaticPropertyNames<Stack, Root, Type> : unknown,
|
|
1643
|
+
Schema extends XRef<infer Ref extends string> ? XStaticRef<Stack, Root, Ref> : unknown,
|
|
1644
|
+
Schema extends XRequired<infer Keys extends string[]> ? XStaticRequired<Stack, Root, Schema, Keys> : unknown,
|
|
1645
|
+
Schema extends XType<infer TypeName extends string[] | string> ? XStaticType<TypeName> : unknown,
|
|
1646
|
+
Schema extends XUnevaluatedProperties<infer Type extends XSchema> ? XStaticUnevaluatedProperties<Stack, Root, Type> : unknown
|
|
1647
|
+
]> = Result;
|
|
1648
|
+
type XKeywordsIntersected<Schemas extends unknown[], Result extends unknown = unknown> = (Schemas extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XKeywordsIntersected<Right, Result & Left> : Result);
|
|
1649
|
+
type XKeywordsEvaluated<Schema extends unknown, Result extends unknown = Schema extends object ? {
|
|
1650
|
+
[Key in keyof Schema]: Schema[Key];
|
|
1651
|
+
} : Schema> = Result;
|
|
1652
|
+
type XStaticObject<Stack extends string[], Root extends XSchema, Schema extends XSchema, Keywords extends unknown[] = XFromKeywords<Stack, Root, Schema>, Intersected extends unknown = XKeywordsIntersected<Keywords>, Evaluated extends unknown = XKeywordsEvaluated<Intersected>> = Evaluated;
|
|
1653
|
+
type XStaticBoolean<Schema extends boolean, Result extends unknown = Schema extends false ? never : unknown> = Result;
|
|
1654
|
+
type XStaticSchema<Stack extends string[], Root extends XSchema, Schema extends XSchema, Result extends unknown = Schema extends boolean ? XStaticBoolean<Schema> : XStaticObject<Stack, Root, Schema>> = Result;
|
|
1655
|
+
|
|
1656
|
+
type XStatic<Value extends unknown, Schema extends XSchema = Value extends XSchema ? Value : {}, Canonical extends XSchema = XCanonical<Schema>, Result extends unknown = XStaticSchema<[], Canonical, Canonical>> = Result;
|
|
1657
|
+
|
|
1658
|
+
type StaticEvaluate<T> = {
|
|
1659
|
+
[K in keyof T]: T[K];
|
|
1660
|
+
} & {};
|
|
1661
|
+
type StaticDirection = 'Encode' | 'Decode';
|
|
1662
|
+
type StaticType<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema> = (Type extends TCodec<infer Type extends TSchema, infer Decoded extends unknown> ? StaticCodec<Stack, Direction, Context, This, Type, Decoded> : Type extends TAny ? StaticAny : Type extends TArray<infer Items extends TSchema> ? StaticArray<Stack, Direction, Context, This, Type, Items> : Type extends TBigInt ? StaticBigInt : Type extends TBoolean ? StaticBoolean : Type extends TConstructor<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticConstructor<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TEnum<infer Values extends TEnumValue[]> ? StaticEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticFunction<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? StaticDependent<Stack, Direction, Context, This, If, Then, Else> : Type extends TInteger ? StaticInteger : Type extends TIntersect<infer Types extends TSchema[]> ? StaticIntersect<Stack, Direction, Context, This, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? StaticLiteral<Value> : Type extends TNever ? StaticNever : Type extends TNull ? StaticNull : Type extends TNumber ? StaticNumber : Type extends TObject<infer Properties extends TProperties> ? StaticObject<Stack, Direction, Context, This, Properties> : Type extends TRecord<infer Key extends string, infer Value extends TSchema> ? StaticRecord<Stack, Direction, Context, This, Key, Value> : Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? StaticCyclic<Stack, Direction, Context, This, Defs, Ref> : Type extends TRef<infer Ref extends string> ? StaticRef<Stack, Direction, Context, This, Ref> : Type extends TString ? StaticString : Type extends TSymbol ? StaticSymbol : Type extends TTemplateLiteral<infer Pattern extends string> ? StaticTemplateLiteral<Pattern> : Type extends TThis ? StaticThis<Stack, Direction, Context, This> : Type extends TTuple<infer Items extends TSchema[]> ? StaticTuple<Stack, Direction, Context, This, Type, Items> : Type extends TUndefined ? StaticUndefined : Type extends TUnion<infer Types extends TSchema[]> ? StaticUnion<Stack, Direction, Context, This, Types> : Type extends TUnknown ? StaticUnknown : Type extends TUnsafe<infer Type extends unknown> ? StaticUnsafe<Type> : Type extends TVoid ? StaticVoid : XStatic<Type>);
|
|
1663
|
+
/** Infers a static type from a TypeBox type. */
|
|
1664
|
+
type Static<Type extends TSchema, Context extends TProperties = {}, Result extends unknown = StaticType<[], 'Encode', Context, {}, Type>> = Result;
|
|
1665
|
+
|
|
1666
|
+
type ReadonlyOptionalKeys<Properties extends TProperties, Result extends PropertyKey = {
|
|
1667
|
+
[Key in keyof Properties]: Properties[Key] extends TReadonly<TSchema> ? (Properties[Key] extends TOptional<Properties[Key]> ? Key : never) : never;
|
|
1668
|
+
}[keyof Properties]> = Result;
|
|
1669
|
+
type ReadonlyKeys<Properties extends TProperties, Result extends PropertyKey = {
|
|
1670
|
+
[Key in keyof Properties]: Properties[Key] extends TReadonly<TSchema> ? (Properties[Key] extends TOptional<Properties[Key]> ? never : Key) : never;
|
|
1671
|
+
}[keyof Properties]> = Result;
|
|
1672
|
+
type OptionalKeys<Properties extends TProperties, Result extends PropertyKey = {
|
|
1673
|
+
[Key in keyof Properties]: Properties[Key] extends TOptional<TSchema> ? (Properties[Key] extends TReadonly<Properties[Key]> ? never : Key) : never;
|
|
1674
|
+
}[keyof Properties]> = Result;
|
|
1675
|
+
type RequiredKeys<Properties extends TProperties, Result extends PropertyKey = keyof Omit<Properties, ReadonlyOptionalKeys<Properties> | ReadonlyKeys<Properties> | OptionalKeys<Properties>>> = Result;
|
|
1676
|
+
type StaticPropertiesWithModifiers<Properties extends TProperties, PropertiesWithoutModifiers extends Record<PropertyKey, unknown>> = StaticEvaluate<Readonly<Partial<Pick<PropertiesWithoutModifiers, ReadonlyOptionalKeys<Properties>>>> & Readonly<Pick<PropertiesWithoutModifiers, ReadonlyKeys<Properties>>> & Partial<Pick<PropertiesWithoutModifiers, OptionalKeys<Properties>>> & Required<Pick<PropertiesWithoutModifiers, RequiredKeys<Properties>>>>;
|
|
1677
|
+
type StaticPropertiesWithoutModifiers<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Properties extends TProperties, Result extends Record<PropertyKey, unknown> = {
|
|
1678
|
+
[Key in keyof Properties]: StaticType<Stack, Direction, Context, This, Properties[Key]>;
|
|
1679
|
+
}> = Result;
|
|
1680
|
+
type StaticProperties<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Properties extends TProperties, PropertiesWithoutModifiers extends Record<PropertyKey, unknown> = StaticPropertiesWithoutModifiers<Stack, Direction, Context, This, Properties>, PropertiesWithModifiers extends Record<PropertyKey, unknown> = StaticPropertiesWithModifiers<Properties, PropertiesWithoutModifiers>, Result extends Record<PropertyKey, unknown> = {
|
|
1681
|
+
[Key in keyof PropertiesWithModifiers]: PropertiesWithModifiers[Key];
|
|
1682
|
+
}> = Result;
|
|
1683
|
+
/** Represents a Record<PropertyKey, TSchema> structure. */
|
|
1684
|
+
interface TProperties extends TSchema {
|
|
1685
|
+
[key: PropertyKey]: TSchema;
|
|
1686
|
+
}
|
|
1687
|
+
/** Creates a RequiredArray derived from the given TProperties value. */
|
|
1688
|
+
type TRequiredArray<Properties extends TProperties, RequiredProperties extends TProperties = {
|
|
1689
|
+
[Key in keyof Properties as Properties[Key] extends TOptional<Properties[Key]> ? never : Key]: Properties[Key];
|
|
1690
|
+
}, RequiredKeys extends string[] = TUnionToTuple<Extract<keyof RequiredProperties, string>>, Result extends string[] | undefined = RequiredKeys extends [] ? undefined : RequiredKeys> = Result;
|
|
1691
|
+
type TKeyToString<Key extends number | string> = `${Key}`;
|
|
1692
|
+
/** Extracts a tuple of keys from a TProperties value. */
|
|
1693
|
+
type TPropertyKeys<Properties extends TProperties, ExtractKey extends number | string = Extract<keyof Properties, number | string>, StringKey extends string = TKeyToString<ExtractKey>, Result extends string[] = TUnionToTuple<StringKey>> = Result;
|
|
1694
|
+
type TPropertyValuesReduce<Properties extends TProperties, Keys extends string[], Result extends TSchema[] = []> = Keys extends [infer Left extends string, ...infer Right extends string[]] ? Left extends keyof Properties ? TPropertyValuesReduce<Properties, Right, [...Result, Properties[Left]]> : TPropertyValuesReduce<Properties, Right, Result> : Result;
|
|
1695
|
+
/** Extracts a tuple of property values from a TProperties value. */
|
|
1696
|
+
type TPropertyValues<Properties extends TProperties, Keys extends string[] = TPropertyKeys<Properties>, Result extends TSchema[] = TPropertyValuesReduce<Properties, Keys>> = Result;
|
|
1697
|
+
|
|
1698
|
+
type TAddImmutableOperation<Type extends TSchema, Result extends TSchema = '~immutable' extends keyof Type ? Type : TImmutable<Type>> = Result;
|
|
1699
|
+
type TAddImmutableAction<Type extends TSchema, Result extends TSchema = TAddImmutableOperation<Type>> = Result;
|
|
1700
|
+
type TAddImmutableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddImmutableAction<InstantiateType>;
|
|
1701
|
+
|
|
1702
|
+
/** Applies an AddImmutable action to a type. */
|
|
1703
|
+
type TAddImmutable<Type extends TSchema> = (TAddImmutableAction<Type>);
|
|
8
1704
|
|
|
9
1705
|
type AttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
10
1706
|
interface SpanAttributes {
|
|
@@ -171,6 +1867,194 @@ interface PiMessagesOptions extends StreamOptions {
|
|
|
171
1867
|
debug?: boolean;
|
|
172
1868
|
}
|
|
173
1869
|
|
|
1870
|
+
declare const OpenAICompletionsCompatSchema: TObject<{
|
|
1871
|
+
supportsStore: TOptional<TBoolean>;
|
|
1872
|
+
supportsDeveloperRole: TOptional<TBoolean>;
|
|
1873
|
+
supportsReasoningEffort: TOptional<TBoolean>;
|
|
1874
|
+
supportsUsageInStreaming: TOptional<TBoolean>;
|
|
1875
|
+
supportsFinishReason: TOptional<TBoolean>;
|
|
1876
|
+
maxTokensField: TOptional<TUnion<[TLiteral<"max_completion_tokens">, TLiteral<"max_tokens">]>>;
|
|
1877
|
+
requiresToolResultName: TOptional<TBoolean>;
|
|
1878
|
+
requiresAssistantAfterToolResult: TOptional<TBoolean>;
|
|
1879
|
+
requiresThinkingAsText: TOptional<TBoolean>;
|
|
1880
|
+
requiresReasoningContentOnAssistantMessages: TOptional<TBoolean>;
|
|
1881
|
+
thinkingFormat: TOptional<TUnion<[TLiteral<"openai">, TLiteral<"openrouter">, TLiteral<"deepseek">, TLiteral<"together">, TLiteral<"baseten">, TLiteral<"zai">, TLiteral<"qwen">, TLiteral<"chat-template">, TLiteral<"qwen-chat-template">, TLiteral<"string-thinking">, TLiteral<"ant-ling">]>>;
|
|
1882
|
+
chatTemplateKwargs: TOptional<TRecord<"^.*$", TUnion<[TString, TNumber, TBoolean, TNull, TObject<{
|
|
1883
|
+
$var: TUnion<[TLiteral<"thinking.enabled">, TLiteral<"thinking.effort">, TLiteral<"thinking.budget">]>;
|
|
1884
|
+
omitWhenOff: TOptional<TBoolean>;
|
|
1885
|
+
}>]>>>;
|
|
1886
|
+
chatTemplateArgs: TOptional<TRecord<"^.*$", TUnion<[TString, TNumber, TBoolean, TNull, TObject<{
|
|
1887
|
+
$var: TUnion<[TLiteral<"thinking.enabled">, TLiteral<"thinking.effort">, TLiteral<"thinking.budget">]>;
|
|
1888
|
+
omitWhenOff: TOptional<TBoolean>;
|
|
1889
|
+
}>]>>>;
|
|
1890
|
+
openRouterRouting: TOptional<TObject<{
|
|
1891
|
+
allow_fallbacks: TOptional<TBoolean>;
|
|
1892
|
+
require_parameters: TOptional<TBoolean>;
|
|
1893
|
+
data_collection: TOptional<TUnion<[TLiteral<"deny">, TLiteral<"allow">]>>;
|
|
1894
|
+
zdr: TOptional<TBoolean>;
|
|
1895
|
+
enforce_distillable_text: TOptional<TBoolean>;
|
|
1896
|
+
order: TOptional<TArray<TString>>;
|
|
1897
|
+
only: TOptional<TArray<TString>>;
|
|
1898
|
+
ignore: TOptional<TArray<TString>>;
|
|
1899
|
+
quantizations: TOptional<TArray<TString>>;
|
|
1900
|
+
sort: TOptional<TUnion<[TString, TObject<{
|
|
1901
|
+
by: TOptional<TString>;
|
|
1902
|
+
partition: TOptional<TUnion<[TString, TNull]>>;
|
|
1903
|
+
}>]>>;
|
|
1904
|
+
max_price: TOptional<TObject<{
|
|
1905
|
+
prompt: TOptional<TUnion<[TNumber, TString]>>;
|
|
1906
|
+
completion: TOptional<TUnion<[TNumber, TString]>>;
|
|
1907
|
+
image: TOptional<TUnion<[TNumber, TString]>>;
|
|
1908
|
+
audio: TOptional<TUnion<[TNumber, TString]>>;
|
|
1909
|
+
request: TOptional<TUnion<[TNumber, TString]>>;
|
|
1910
|
+
}>>;
|
|
1911
|
+
preferred_min_throughput: TOptional<TUnion<[TNumber, TObject<{
|
|
1912
|
+
p50: TOptional<TNumber>;
|
|
1913
|
+
p75: TOptional<TNumber>;
|
|
1914
|
+
p90: TOptional<TNumber>;
|
|
1915
|
+
p99: TOptional<TNumber>;
|
|
1916
|
+
}>]>>;
|
|
1917
|
+
preferred_max_latency: TOptional<TUnion<[TNumber, TObject<{
|
|
1918
|
+
p50: TOptional<TNumber>;
|
|
1919
|
+
p75: TOptional<TNumber>;
|
|
1920
|
+
p90: TOptional<TNumber>;
|
|
1921
|
+
p99: TOptional<TNumber>;
|
|
1922
|
+
}>]>>;
|
|
1923
|
+
}>>;
|
|
1924
|
+
vercelGatewayRouting: TOptional<TObject<{
|
|
1925
|
+
only: TOptional<TArray<TString>>;
|
|
1926
|
+
order: TOptional<TArray<TString>>;
|
|
1927
|
+
}>>;
|
|
1928
|
+
zaiToolStream: TOptional<TBoolean>;
|
|
1929
|
+
thinkingTokenBudgetField: TOptional<TUnion<[TLiteral<"thinking_token_budget">, TLiteral<"thinking_budget">, TLiteral<"thinking_budget_tokens">]>>;
|
|
1930
|
+
supportsThinkingTokenBudget: TOptional<TBoolean>;
|
|
1931
|
+
supportsOpenAIGrammarTools: TOptional<TBoolean>;
|
|
1932
|
+
supportsMidConvoSystemMessages: TOptional<TBoolean>;
|
|
1933
|
+
supportsMidConvoToolAdditions: TOptional<TBoolean>;
|
|
1934
|
+
supportsStrictMode: TOptional<TBoolean>;
|
|
1935
|
+
cacheControlFormat: TOptional<TLiteral<"anthropic">>;
|
|
1936
|
+
sendSessionAffinityHeaders: TOptional<TBoolean>;
|
|
1937
|
+
sessionAffinityFormat: TOptional<TUnion<[TLiteral<"openai">, TLiteral<"openai-nosession">, TLiteral<"openrouter">]>>;
|
|
1938
|
+
supportsLongCacheRetention: TOptional<TBoolean>;
|
|
1939
|
+
vllmPriority: TOptional<TNumber>;
|
|
1940
|
+
}>;
|
|
1941
|
+
declare const OpenAIResponsesCompatSchema: TObject<{
|
|
1942
|
+
supportsDeveloperRole: TOptional<TBoolean>;
|
|
1943
|
+
supportsMidConvoSystemMessages: TOptional<TBoolean>;
|
|
1944
|
+
sessionAffinityFormat: TOptional<TUnion<[TLiteral<"openai">, TLiteral<"openai-nosession">, TLiteral<"openrouter">]>>;
|
|
1945
|
+
supportsLongCacheRetention: TOptional<TBoolean>;
|
|
1946
|
+
supportsStrictMode: TOptional<TBoolean>;
|
|
1947
|
+
supportsOpenAIGrammarTools: TOptional<TBoolean>;
|
|
1948
|
+
supportsAdditionalTools: TOptional<TBoolean>;
|
|
1949
|
+
supportsToolSearch: TOptional<TBoolean>;
|
|
1950
|
+
supportsExplicitPromptCacheMode: TOptional<TBoolean>;
|
|
1951
|
+
supportsMaxOutputTokens: TOptional<TBoolean>;
|
|
1952
|
+
}>;
|
|
1953
|
+
declare const AnthropicMessagesCompatSchema: TObject<{
|
|
1954
|
+
supportsEagerToolInputStreaming: TOptional<TBoolean>;
|
|
1955
|
+
supportsLongCacheRetention: TOptional<TBoolean>;
|
|
1956
|
+
sendSessionAffinityHeaders: TOptional<TBoolean>;
|
|
1957
|
+
sessionAffinityFormat: TOptional<TLiteral<"openrouter">>;
|
|
1958
|
+
supportsCacheControlOnTools: TOptional<TBoolean>;
|
|
1959
|
+
supportsTemperature: TOptional<TBoolean>;
|
|
1960
|
+
forceAdaptiveThinking: TOptional<TBoolean>;
|
|
1961
|
+
allowEmptySignature: TOptional<TBoolean>;
|
|
1962
|
+
supportsStrictTools: TOptional<TBoolean>;
|
|
1963
|
+
supportsMidConvoEffort: TOptional<TBoolean>;
|
|
1964
|
+
supportsMidConvoSystemMessages: TOptional<TBoolean>;
|
|
1965
|
+
supportsMidConvoToolChanges: TOptional<TBoolean>;
|
|
1966
|
+
allowedFallbackModels: TOptional<TArray<TObject<{
|
|
1967
|
+
provider: TString;
|
|
1968
|
+
model: TString;
|
|
1969
|
+
cost: TObject<{
|
|
1970
|
+
input: TNumber;
|
|
1971
|
+
output: TNumber;
|
|
1972
|
+
cacheRead: TNumber;
|
|
1973
|
+
cacheWrite: TNumber;
|
|
1974
|
+
tiers: TOptional<TArray<TObject<{
|
|
1975
|
+
input: TNumber;
|
|
1976
|
+
output: TNumber;
|
|
1977
|
+
cacheRead: TNumber;
|
|
1978
|
+
cacheWrite: TNumber;
|
|
1979
|
+
inputTokensAbove: TNumber;
|
|
1980
|
+
}>>>;
|
|
1981
|
+
}>;
|
|
1982
|
+
}>>>;
|
|
1983
|
+
}>;
|
|
1984
|
+
declare const BedrockCompatSchema: TObject<{
|
|
1985
|
+
supportsStrictMode: TOptional<TBoolean>;
|
|
1986
|
+
}>;
|
|
1987
|
+
declare const MistralConversationsCompatSchema: TObject<{
|
|
1988
|
+
supportsMidConvoSystemMessages: TOptional<TBoolean>;
|
|
1989
|
+
}>;
|
|
1990
|
+
/** Compatibility settings for OpenAI-compatible completions APIs. */
|
|
1991
|
+
interface OpenAICompletionsCompat extends Static<typeof OpenAICompletionsCompatSchema> {
|
|
1992
|
+
}
|
|
1993
|
+
/** Compatibility settings for OpenAI Responses APIs. */
|
|
1994
|
+
interface OpenAIResponsesCompat extends Static<typeof OpenAIResponsesCompatSchema> {
|
|
1995
|
+
}
|
|
1996
|
+
/** Compatibility settings for Anthropic Messages-compatible APIs. */
|
|
1997
|
+
interface AnthropicMessagesCompat extends Static<typeof AnthropicMessagesCompatSchema> {
|
|
1998
|
+
}
|
|
1999
|
+
/** Compatibility settings for Amazon Bedrock models. */
|
|
2000
|
+
interface BedrockCompat extends Static<typeof BedrockCompatSchema> {
|
|
2001
|
+
}
|
|
2002
|
+
/** Compatibility settings for the Mistral chat API. */
|
|
2003
|
+
interface MistralConversationsCompat extends Static<typeof MistralConversationsCompatSchema> {
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
declare const ThinkingLevelSchema: TEnum<["minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
2007
|
+
declare const ModelThinkingLevelSchema: TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
2008
|
+
declare const ModelInputModalitySchema: TEnum<["text", "image"]>;
|
|
2009
|
+
declare const CacheRetentionSchema: TEnum<["none", "short", "long"]>;
|
|
2010
|
+
declare const ThinkingLevelMapSchema: TObject<{
|
|
2011
|
+
high: TOptional<TUnion<[TString, TNull]>>;
|
|
2012
|
+
low: TOptional<TUnion<[TString, TNull]>>;
|
|
2013
|
+
max: TOptional<TUnion<[TString, TNull]>>;
|
|
2014
|
+
medium: TOptional<TUnion<[TString, TNull]>>;
|
|
2015
|
+
minimal: TOptional<TUnion<[TString, TNull]>>;
|
|
2016
|
+
off: TOptional<TUnion<[TString, TNull]>>;
|
|
2017
|
+
xhigh: TOptional<TUnion<[TString, TNull]>>;
|
|
2018
|
+
}>;
|
|
2019
|
+
declare const ModelPromptCacheSchema: TObject<{
|
|
2020
|
+
long: TOptional<TNumber>;
|
|
2021
|
+
short: TOptional<TNumber>;
|
|
2022
|
+
}>;
|
|
2023
|
+
declare const ModelCostSchema: TObject<{
|
|
2024
|
+
input: TNumber;
|
|
2025
|
+
output: TNumber;
|
|
2026
|
+
cacheRead: TNumber;
|
|
2027
|
+
cacheWrite: TNumber;
|
|
2028
|
+
tiers: TOptional<TArray<TObject<{
|
|
2029
|
+
input: TNumber;
|
|
2030
|
+
output: TNumber;
|
|
2031
|
+
cacheRead: TNumber;
|
|
2032
|
+
cacheWrite: TNumber;
|
|
2033
|
+
inputTokensAbove: TNumber;
|
|
2034
|
+
}>>>;
|
|
2035
|
+
}>;
|
|
2036
|
+
declare const ModelInputLimitsSchema: TObject<{
|
|
2037
|
+
maxRequestBytes: TOptional<TInteger>;
|
|
2038
|
+
images: TOptional<TObject<{
|
|
2039
|
+
resize: TOptional<TObject<{
|
|
2040
|
+
maxWidth: TOptional<TInteger>;
|
|
2041
|
+
maxHeight: TOptional<TInteger>;
|
|
2042
|
+
maxBytes: TOptional<TInteger>;
|
|
2043
|
+
jpegQuality: TOptional<TInteger>;
|
|
2044
|
+
}>>;
|
|
2045
|
+
maxPerMessage: TOptional<TInteger>;
|
|
2046
|
+
maxPerRequest: TOptional<TInteger>;
|
|
2047
|
+
}>>;
|
|
2048
|
+
}>;
|
|
2049
|
+
type ThinkingLevel = Static<typeof ThinkingLevelSchema>;
|
|
2050
|
+
type ModelThinkingLevel = Static<typeof ModelThinkingLevelSchema>;
|
|
2051
|
+
type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;
|
|
2052
|
+
type ModelInputModality = Static<typeof ModelInputModalitySchema>;
|
|
2053
|
+
type CacheRetention = Static<typeof CacheRetentionSchema>;
|
|
2054
|
+
type ModelPromptCache = Static<typeof ModelPromptCacheSchema>;
|
|
2055
|
+
type ModelCost = Static<typeof ModelCostSchema>;
|
|
2056
|
+
type ModelInputLimits = Static<typeof ModelInputLimitsSchema>;
|
|
2057
|
+
|
|
174
2058
|
interface DiagnosticErrorInfo {
|
|
175
2059
|
name?: string;
|
|
176
2060
|
message: string;
|
|
@@ -220,17 +2104,8 @@ type ClassifierApi = KnownClassifierApi | (string & {});
|
|
|
220
2104
|
type KnownProvider = "amazon-bedrock" | "ant-ling" | "anthropic" | "google" | "google-vertex" | "openai" | "azure" | "openai-codex" | "radius" | "typesafe" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "meta" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
|
|
221
2105
|
type ProviderId = KnownProvider | string;
|
|
222
2106
|
type ToolChoice = "auto" | "none";
|
|
223
|
-
type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
224
|
-
type ModelThinkingLevel = "off" | ThinkingLevel;
|
|
225
|
-
type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;
|
|
226
2107
|
type SamplingParams = Record<string, unknown>;
|
|
227
2108
|
type SamplingParamsByThinkingLevel = Partial<Record<ModelThinkingLevel, SamplingParams>>;
|
|
228
|
-
type ChatTemplateKwargValue = string | number | boolean | null | {
|
|
229
|
-
$var: "thinking.enabled" | "thinking.effort" | "thinking.budget";
|
|
230
|
-
omitWhenOff?: boolean;
|
|
231
|
-
};
|
|
232
|
-
/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */
|
|
233
|
-
type ThinkingTokenBudgetField = "thinking_token_budget" | "thinking_budget" | "thinking_budget_tokens";
|
|
234
2109
|
/** Token budgets for each thinking level (token-based providers only) */
|
|
235
2110
|
interface ThinkingBudgets {
|
|
236
2111
|
minimal?: number;
|
|
@@ -238,18 +2113,11 @@ interface ThinkingBudgets {
|
|
|
238
2113
|
medium?: number;
|
|
239
2114
|
high?: number;
|
|
240
2115
|
}
|
|
241
|
-
type CacheRetention = "none" | "short" | "long";
|
|
242
|
-
/**
|
|
243
|
-
* Best-effort prompt cache lifetime in seconds for each retention tier a request can ask for.
|
|
244
|
-
* A missing tier means the lifetime is unknown; pi does not warm such caches.
|
|
245
|
-
*/
|
|
246
|
-
type ModelPromptCache = Partial<Record<Exclude<CacheRetention, "none">, number>>;
|
|
247
2116
|
type Transport = "sse" | "websocket" | "websocket-cached" | "auto";
|
|
248
2117
|
/** Provider-scoped environment overrides. Values take precedence over process.env. */
|
|
249
2118
|
type ProviderEnv = Record<string, string>;
|
|
250
2119
|
type ProviderHeaders = Record<string, string | null>;
|
|
251
2120
|
type FetchFunction = typeof globalThis.fetch;
|
|
252
|
-
type SessionAffinityFormat = "openai" | "openai-nosession" | "openrouter";
|
|
253
2121
|
interface ProviderResponse {
|
|
254
2122
|
status: number;
|
|
255
2123
|
headers: Record<string, string>;
|
|
@@ -406,11 +2274,6 @@ interface ImagesOptions extends ProviderRequestOptions<ImageModel<ImageApi>> {
|
|
|
406
2274
|
*/
|
|
407
2275
|
metadata?: Record<string, unknown>;
|
|
408
2276
|
}
|
|
409
|
-
interface AnthropicAllowedFallbackModel {
|
|
410
|
-
provider: ProviderId;
|
|
411
|
-
model: string;
|
|
412
|
-
cost: ModelCost;
|
|
413
|
-
}
|
|
414
2277
|
interface SimpleStreamOptions extends StreamOptions {
|
|
415
2278
|
/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */
|
|
416
2279
|
toolChoice?: ToolChoice;
|
|
@@ -422,6 +2285,7 @@ interface SimpleStreamOptions extends StreamOptions {
|
|
|
422
2285
|
/** Custom token budgets for thinking levels (token-based providers only) */
|
|
423
2286
|
thinkingBudgets?: ThinkingBudgets;
|
|
424
2287
|
}
|
|
2288
|
+
type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (model: Model$1<TApi>, context: TranscriptContext, options?: TOptions) => AssistantMessageEventStream;
|
|
425
2289
|
interface TextContent {
|
|
426
2290
|
type: "text";
|
|
427
2291
|
text: string;
|
|
@@ -708,7 +2572,7 @@ interface ToolReference {
|
|
|
708
2572
|
* system message; `normalizeContext()` folds them into one before the request
|
|
709
2573
|
* reaches a provider.
|
|
710
2574
|
*/
|
|
711
|
-
interface Context {
|
|
2575
|
+
interface Context$1 {
|
|
712
2576
|
systemPrompt?: string;
|
|
713
2577
|
messages: Message[];
|
|
714
2578
|
tools?: Tool[];
|
|
@@ -794,287 +2658,6 @@ type AssistantMessageEvent = {
|
|
|
794
2658
|
reason: Extract<StopReason, "aborted" | "error">;
|
|
795
2659
|
error: AssistantMessage;
|
|
796
2660
|
};
|
|
797
|
-
/**
|
|
798
|
-
* Compatibility settings for OpenAI-compatible completions APIs.
|
|
799
|
-
* Use this to override URL-based auto-detection for custom providers.
|
|
800
|
-
*/
|
|
801
|
-
interface OpenAICompletionsCompat {
|
|
802
|
-
/** Whether the provider supports the `store` field. Default: auto-detected from URL. */
|
|
803
|
-
supportsStore?: boolean;
|
|
804
|
-
/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */
|
|
805
|
-
supportsDeveloperRole?: boolean;
|
|
806
|
-
/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
|
|
807
|
-
supportsReasoningEffort?: boolean;
|
|
808
|
-
/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
|
|
809
|
-
supportsUsageInStreaming?: boolean;
|
|
810
|
-
/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */
|
|
811
|
-
supportsFinishReason?: boolean;
|
|
812
|
-
/** Which field to use for max tokens. Default: auto-detected from URL. */
|
|
813
|
-
maxTokensField?: "max_completion_tokens" | "max_tokens";
|
|
814
|
-
/** Whether tool results require the `name` field. Default: auto-detected from URL. */
|
|
815
|
-
requiresToolResultName?: boolean;
|
|
816
|
-
/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */
|
|
817
|
-
requiresAssistantAfterToolResult?: boolean;
|
|
818
|
-
/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */
|
|
819
|
-
requiresThinkingAsText?: boolean;
|
|
820
|
-
/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */
|
|
821
|
-
requiresReasoningContentOnAssistantMessages?: boolean;
|
|
822
|
-
/** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "openrouter" uses reasoning: { effort }, "deepseek" uses thinking: { type } plus reasoning_effort when supported, "together" uses reasoning: { enabled } plus reasoning_effort when supported, "baseten" uses configurable chat_template_args plus reasoning_effort when supported, "zai" uses thinking: { type }, "qwen" uses top-level enable_thinking: boolean, "qwen-chat-template" uses chat_template_kwargs.enable_thinking and preserve_thinking, "chat-template" uses configurable chat_template_kwargs, "string-thinking" uses top-level thinking: string, and "ant-ling" uses reasoning: { effort } only when the mapped effort is non-null. Default: "openai". */
|
|
823
|
-
thinkingFormat?: "openai" | "openrouter" | "deepseek" | "together" | "baseten" | "zai" | "qwen" | "chat-template" | "qwen-chat-template" | "string-thinking" | "ant-ling";
|
|
824
|
-
/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ "$var": "thinking.enabled" }`, `{ "$var": "thinking.effort" }`, or `{ "$var": "thinking.budget" }` for pi-controlled thinking values. */
|
|
825
|
-
chatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;
|
|
826
|
-
/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ "$var": "thinking.enabled" }`, `{ "$var": "thinking.effort" }`, or `{ "$var": "thinking.budget" }` for pi-controlled thinking values. */
|
|
827
|
-
chatTemplateArgs?: Record<string, ChatTemplateKwargValue>;
|
|
828
|
-
/** OpenRouter-compatible routing preferences sent as the `provider` request field. */
|
|
829
|
-
openRouterRouting?: OpenRouterRouting;
|
|
830
|
-
/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */
|
|
831
|
-
vercelGatewayRouting?: VercelGatewayRouting;
|
|
832
|
-
/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */
|
|
833
|
-
zaiToolStream?: boolean;
|
|
834
|
-
/**
|
|
835
|
-
* Top-level request field used to cap reasoning tokens from `thinkingBudgets`.
|
|
836
|
-
* Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a
|
|
837
|
-
* reasoning-heavy turn can consume the whole response and emit no answer.
|
|
838
|
-
* `"thinking_token_budget"` is vLLM, `"thinking_budget"` is Qwen/DashScope/SGLang,
|
|
839
|
-
* `"thinking_budget_tokens"` is llama.cpp. Off by default; not set on the generated catalog.
|
|
840
|
-
*/
|
|
841
|
-
thinkingTokenBudgetField?: ThinkingTokenBudgetField;
|
|
842
|
-
/** Alias for `thinkingTokenBudgetField: "thinking_token_budget"` (vLLM). Prefer `thinkingTokenBudgetField`. Default: false. */
|
|
843
|
-
supportsThinkingTokenBudget?: boolean;
|
|
844
|
-
/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */
|
|
845
|
-
supportsOpenAIGrammarTools?: boolean;
|
|
846
|
-
/** Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message. Default: false; the generated model catalog enables it for verified models. */
|
|
847
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
848
|
-
/** Whether system messages can introduce additional tools mid-conversation. Requires `supportsMidConvoSystemMessages`. Default: false; the generated model catalog enables it for capable models. */
|
|
849
|
-
supportsMidConvoToolAdditions?: boolean;
|
|
850
|
-
/** Whether the provider supports the `strict` field in tool definitions. Default: false; generated capable models enable it explicitly. */
|
|
851
|
-
supportsStrictMode?: boolean;
|
|
852
|
-
/** Cache control convention for prompt caching. "anthropic" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */
|
|
853
|
-
cacheControlFormat?: "anthropic";
|
|
854
|
-
/** Whether to send session-affinity data from `options.sessionId`. Default: true for OpenRouter endpoints, false otherwise. */
|
|
855
|
-
sendSessionAffinityHeaders?: boolean;
|
|
856
|
-
/** Session-affinity header format: `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` sends `x-client-request-id` and `x-session-affinity`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */
|
|
857
|
-
sessionAffinityFormat?: SessionAffinityFormat;
|
|
858
|
-
/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: "24h"` or Anthropic-style `cache_control.ttl: "1h"`, depending on format). Default: true. */
|
|
859
|
-
supportsLongCacheRetention?: boolean;
|
|
860
|
-
/**
|
|
861
|
-
* vLLM scheduler priority sent as the top-level `priority` request field (lower values are
|
|
862
|
-
* handled earlier; server default 0). Only meaningful when vLLM runs with
|
|
863
|
-
* `--scheduling-policy priority`; useful for keeping background/batch work from stalling
|
|
864
|
-
* interactive sessions. Off by default; not set on the generated catalog.
|
|
865
|
-
*/
|
|
866
|
-
vllmPriority?: number;
|
|
867
|
-
}
|
|
868
|
-
/** Compatibility settings for OpenAI Responses APIs. */
|
|
869
|
-
interface OpenAIResponsesCompat {
|
|
870
|
-
/** Whether the provider supports the `developer` role (vs `system`). Default: true. */
|
|
871
|
-
supportsDeveloperRole?: boolean;
|
|
872
|
-
/** Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. Default: false; the generated model catalog enables it for verified models. */
|
|
873
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
874
|
-
/** Session-affinity header format: `openai` sends `session_id` and `x-client-request-id`; `openai-nosession` sends `x-client-request-id`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */
|
|
875
|
-
sessionAffinityFormat?: SessionAffinityFormat;
|
|
876
|
-
/** Whether the provider supports long prompt cache retention. This uses `prompt_cache_options.ttl: "30m"` on GPT-5.6+ and `prompt_cache_retention: "24h"` on earlier models. Default: true. */
|
|
877
|
-
supportsLongCacheRetention?: boolean;
|
|
878
|
-
/** Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly. */
|
|
879
|
-
supportsStrictMode?: boolean;
|
|
880
|
-
/** Whether to emit OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */
|
|
881
|
-
supportsOpenAIGrammarTools?: boolean;
|
|
882
|
-
/** Whether the model supports message-anchored `additional_tools` input items. Default: false. */
|
|
883
|
-
supportsAdditionalTools?: boolean;
|
|
884
|
-
/** Whether the model supports client-executed tool search for transcript-anchored additions. Default: false. */
|
|
885
|
-
supportsToolSearch?: boolean;
|
|
886
|
-
/** Whether the model accepts `prompt_cache_options` (OpenAI GPT-5.6+ prompt caching). Older OpenAI models reject the parameter. Default: false. */
|
|
887
|
-
supportsExplicitPromptCacheMode?: boolean;
|
|
888
|
-
/** Whether the provider accepts the `max_output_tokens` parameter. Some Codex-protocol gateways reject it. Default: true. */
|
|
889
|
-
supportsMaxOutputTokens?: boolean;
|
|
890
|
-
}
|
|
891
|
-
/** Compatibility settings for Anthropic Messages-compatible APIs. */
|
|
892
|
-
interface AnthropicMessagesCompat {
|
|
893
|
-
/**
|
|
894
|
-
* Whether the provider accepts per-tool `eager_input_streaming`.
|
|
895
|
-
* When false, the Anthropic provider omits `tools[].eager_input_streaming`
|
|
896
|
-
* and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header
|
|
897
|
-
* for tool-enabled requests.
|
|
898
|
-
* Default: true.
|
|
899
|
-
*/
|
|
900
|
-
supportsEagerToolInputStreaming?: boolean;
|
|
901
|
-
/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: "1h"`). Default: true. */
|
|
902
|
-
supportsLongCacheRetention?: boolean;
|
|
903
|
-
/**
|
|
904
|
-
* Whether to send the `x-session-affinity` header from `options.sessionId`
|
|
905
|
-
* when caching is enabled. Required for providers like Fireworks that use
|
|
906
|
-
* session affinity for prompt cache routing (requests to the same replica
|
|
907
|
-
* maximize cache hits).
|
|
908
|
-
* Default: false.
|
|
909
|
-
*/
|
|
910
|
-
sendSessionAffinityHeaders?: boolean;
|
|
911
|
-
/** Session-affinity format. `"openrouter"` sends `x-session-id`; when unset, sends `x-session-affinity`. */
|
|
912
|
-
sessionAffinityFormat?: "openrouter";
|
|
913
|
-
/**
|
|
914
|
-
* Whether the provider supports Anthropic-style `cache_control` markers on
|
|
915
|
-
* tool definitions. When false, `cache_control` is omitted from tool params.
|
|
916
|
-
* Some Anthropic-compatible providers (e.g., Fireworks) do not support this
|
|
917
|
-
* field on tools and may reject or ignore it.
|
|
918
|
-
* Default: true.
|
|
919
|
-
*/
|
|
920
|
-
supportsCacheControlOnTools?: boolean;
|
|
921
|
-
/**
|
|
922
|
-
* Whether the model accepts the Anthropic `temperature` request field.
|
|
923
|
-
* Claude Opus 4.7+ rejects non-default temperature values.
|
|
924
|
-
* Default: true.
|
|
925
|
-
*/
|
|
926
|
-
supportsTemperature?: boolean;
|
|
927
|
-
/**
|
|
928
|
-
* Whether to force adaptive thinking (`thinking.type: "adaptive"` plus
|
|
929
|
-
* `output_config.effort`) regardless of the model id. Built-in models that
|
|
930
|
-
* require adaptive thinking set this in generated metadata. Custom
|
|
931
|
-
* Anthropic-compatible providers can set this to `true` for any model whose
|
|
932
|
-
* upstream requires the adaptive format. Set to `false` to
|
|
933
|
-
* opt out on overridden built-in models.
|
|
934
|
-
* Default: false.
|
|
935
|
-
*/
|
|
936
|
-
forceAdaptiveThinking?: boolean;
|
|
937
|
-
/** Whether to replay empty thinking signatures as `signature: ""` instead of converting thinking to text. Default: false. */
|
|
938
|
-
allowEmptySignature?: boolean;
|
|
939
|
-
/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */
|
|
940
|
-
supportsStrictTools?: boolean;
|
|
941
|
-
/** Whether the exact model transport supports effort-only system messages and thinking binding controls. Default: false. */
|
|
942
|
-
supportsMidConvoEffort?: boolean;
|
|
943
|
-
/** Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt. Default: false. */
|
|
944
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
945
|
-
/** Whether the exact model accepts mid-conversation `tool_addition` blocks with inline tool definitions (`inline-tools-2026-09-15`) and `tool_removal` blocks. Requires `supportsMidConvoSystemMessages`. Default: false. */
|
|
946
|
-
supportsMidConvoToolChanges?: boolean;
|
|
947
|
-
/**
|
|
948
|
-
* Models Anthropic accepts in `fallbacks` for server-side refusal fallback,
|
|
949
|
-
* with local pricing metadata for returned fallback responses. When absent or
|
|
950
|
-
* empty, callers must omit `fallbacks`; Anthropic rejects the field for models
|
|
951
|
-
* with no permitted fallback targets.
|
|
952
|
-
*/
|
|
953
|
-
allowedFallbackModels?: AnthropicAllowedFallbackModel[];
|
|
954
|
-
}
|
|
955
|
-
/** Compatibility settings for Amazon Bedrock models. */
|
|
956
|
-
interface BedrockCompat {
|
|
957
|
-
/** Whether the model supports Bedrock strict tool schemas. Default: false. */
|
|
958
|
-
supportsStrictMode?: boolean;
|
|
959
|
-
}
|
|
960
|
-
/** Compatibility settings for the Mistral chat API. */
|
|
961
|
-
interface MistralConversationsCompat {
|
|
962
|
-
/** Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message. Default: false. */
|
|
963
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* OpenRouter provider routing preferences.
|
|
967
|
-
* Controls which upstream providers OpenRouter routes requests to.
|
|
968
|
-
* Sent as the `provider` field in the OpenRouter API request body.
|
|
969
|
-
* @see https://openrouter.ai/docs/guides/routing/provider-selection
|
|
970
|
-
*/
|
|
971
|
-
interface OpenRouterRouting {
|
|
972
|
-
/** Whether to allow backup providers to serve requests. Default: true. */
|
|
973
|
-
allow_fallbacks?: boolean;
|
|
974
|
-
/** Whether to filter providers to only those that support all parameters in the request. Default: false. */
|
|
975
|
-
require_parameters?: boolean;
|
|
976
|
-
/** Data collection setting. "allow" (default): allow providers that may store/train on data. "deny": only use providers that don't collect user data. */
|
|
977
|
-
data_collection?: "deny" | "allow";
|
|
978
|
-
/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */
|
|
979
|
-
zdr?: boolean;
|
|
980
|
-
/** Whether to restrict routing to only models that allow text distillation. */
|
|
981
|
-
enforce_distillable_text?: boolean;
|
|
982
|
-
/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */
|
|
983
|
-
order?: string[];
|
|
984
|
-
/** List of provider names/slugs to exclusively allow for this request. */
|
|
985
|
-
only?: string[];
|
|
986
|
-
/** List of provider names/slugs to skip for this request. */
|
|
987
|
-
ignore?: string[];
|
|
988
|
-
/** A list of quantization levels to filter providers by (e.g., ["fp16", "bf16", "fp8", "fp6", "int8", "int4", "fp4", "fp32"]). */
|
|
989
|
-
quantizations?: string[];
|
|
990
|
-
/** Sorting strategy. Can be a string (e.g., "price", "throughput", "latency") or an object with `by` and `partition`. */
|
|
991
|
-
sort?: string | {
|
|
992
|
-
/** The sorting metric: "price", "throughput", "latency". */
|
|
993
|
-
by?: string;
|
|
994
|
-
/** Partitioning strategy: "model" (default) or "none". */
|
|
995
|
-
partition?: string | null;
|
|
996
|
-
};
|
|
997
|
-
/** Maximum price per million tokens (USD). */
|
|
998
|
-
max_price?: {
|
|
999
|
-
/** Price per million prompt tokens. */
|
|
1000
|
-
prompt?: number | string;
|
|
1001
|
-
/** Price per million completion tokens. */
|
|
1002
|
-
completion?: number | string;
|
|
1003
|
-
/** Price per image. */
|
|
1004
|
-
image?: number | string;
|
|
1005
|
-
/** Price per audio unit. */
|
|
1006
|
-
audio?: number | string;
|
|
1007
|
-
/** Price per request. */
|
|
1008
|
-
request?: number | string;
|
|
1009
|
-
};
|
|
1010
|
-
/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */
|
|
1011
|
-
preferred_min_throughput?: number | {
|
|
1012
|
-
/** Minimum tokens/second at the 50th percentile. */
|
|
1013
|
-
p50?: number;
|
|
1014
|
-
/** Minimum tokens/second at the 75th percentile. */
|
|
1015
|
-
p75?: number;
|
|
1016
|
-
/** Minimum tokens/second at the 90th percentile. */
|
|
1017
|
-
p90?: number;
|
|
1018
|
-
/** Minimum tokens/second at the 99th percentile. */
|
|
1019
|
-
p99?: number;
|
|
1020
|
-
};
|
|
1021
|
-
/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */
|
|
1022
|
-
preferred_max_latency?: number | {
|
|
1023
|
-
/** Maximum latency in seconds at the 50th percentile. */
|
|
1024
|
-
p50?: number;
|
|
1025
|
-
/** Maximum latency in seconds at the 75th percentile. */
|
|
1026
|
-
p75?: number;
|
|
1027
|
-
/** Maximum latency in seconds at the 90th percentile. */
|
|
1028
|
-
p90?: number;
|
|
1029
|
-
/** Maximum latency in seconds at the 99th percentile. */
|
|
1030
|
-
p99?: number;
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Vercel AI Gateway routing preferences.
|
|
1035
|
-
* Controls which upstream providers the gateway routes requests to.
|
|
1036
|
-
* @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
|
|
1037
|
-
*/
|
|
1038
|
-
interface VercelGatewayRouting {
|
|
1039
|
-
/** List of provider slugs to exclusively use for this request (e.g., ["bedrock", "anthropic"]). */
|
|
1040
|
-
only?: string[];
|
|
1041
|
-
/** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
|
|
1042
|
-
order?: string[];
|
|
1043
|
-
}
|
|
1044
|
-
interface ModelCostRates {
|
|
1045
|
-
input: number;
|
|
1046
|
-
output: number;
|
|
1047
|
-
cacheRead: number;
|
|
1048
|
-
cacheWrite: number;
|
|
1049
|
-
}
|
|
1050
|
-
interface ModelCostTier extends ModelCostRates {
|
|
1051
|
-
/** Use this tier for requests whose total input usage exceeds this token count. */
|
|
1052
|
-
inputTokensAbove: number;
|
|
1053
|
-
}
|
|
1054
|
-
interface ModelCost extends ModelCostRates {
|
|
1055
|
-
/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */
|
|
1056
|
-
tiers?: ModelCostTier[];
|
|
1057
|
-
}
|
|
1058
|
-
interface ModelImageResizeOptions {
|
|
1059
|
-
maxWidth?: number;
|
|
1060
|
-
maxHeight?: number;
|
|
1061
|
-
/** Maximum base64-encoded payload size in bytes. */
|
|
1062
|
-
maxBytes?: number;
|
|
1063
|
-
jpegQuality?: number;
|
|
1064
|
-
}
|
|
1065
|
-
interface ModelImageInputLimits {
|
|
1066
|
-
/** Cache-safe resize profile applied before a new image enters conversation history. */
|
|
1067
|
-
resize?: ModelImageResizeOptions;
|
|
1068
|
-
/** Maximum images accepted in one provider message. */
|
|
1069
|
-
maxPerMessage?: number;
|
|
1070
|
-
/** Maximum images accepted across one provider request. */
|
|
1071
|
-
maxPerRequest?: number;
|
|
1072
|
-
}
|
|
1073
|
-
interface ModelInputLimits {
|
|
1074
|
-
/** Maximum serialized provider request size in bytes. */
|
|
1075
|
-
maxRequestBytes?: number;
|
|
1076
|
-
images?: ModelImageInputLimits;
|
|
1077
|
-
}
|
|
1078
2661
|
/** Fields shared by every catalog entry, regardless of what you can do with it. */
|
|
1079
2662
|
interface BaseModel<TApi extends string> {
|
|
1080
2663
|
id: string;
|
|
@@ -1082,7 +2665,7 @@ interface BaseModel<TApi extends string> {
|
|
|
1082
2665
|
api: TApi;
|
|
1083
2666
|
provider: ProviderId;
|
|
1084
2667
|
baseUrl: string;
|
|
1085
|
-
input:
|
|
2668
|
+
input: ModelInputModality[];
|
|
1086
2669
|
/** Provider input limits and cache-safe preprocessing metadata. */
|
|
1087
2670
|
inputLimits?: ModelInputLimits;
|
|
1088
2671
|
cost: ModelCost;
|
|
@@ -1434,6 +3017,11 @@ interface RefreshModelsContext {
|
|
|
1434
3017
|
force?: boolean;
|
|
1435
3018
|
/** Always present, including when the public refresh caller omits its optional signal. */
|
|
1436
3019
|
signal: AbortSignal;
|
|
3020
|
+
/**
|
|
3021
|
+
* Base URL of the registered provider, including configuration overrides that wrappers apply
|
|
3022
|
+
* outside the provider receiving this context.
|
|
3023
|
+
*/
|
|
3024
|
+
baseUrl?: string;
|
|
1437
3025
|
}
|
|
1438
3026
|
/** Any model a provider with chat APIs `TApi` can list. */
|
|
1439
3027
|
type ProviderModel<TApi extends Api> = Model$1<TApi> | ImageModel<ImageApi> | ClassifierModel<ClassifierApi>;
|
|
@@ -1565,4 +3153,4 @@ type Model<TApi extends Api> = Model$1<TApi> & {
|
|
|
1565
3153
|
reasoningBudgetPresets?: readonly number[];
|
|
1566
3154
|
};
|
|
1567
3155
|
|
|
1568
|
-
export type { Api, AssistantMessage, AssistantMessageEvent, Context, ImageContent, Message, Model, ModelCost, ModelThinkingLevel, Provider, TextContent, ThinkingBudgets, ThinkingLevelMap, Tool, ToolCall, Usage };
|
|
3156
|
+
export type { Api, AssistantMessage, AssistantMessageEvent, Context$1 as Context, ImageContent, Message, Model, ModelCost, ModelThinkingLevel, Provider, SimpleStreamOptions, StreamFunction, TextContent, ThinkingBudgets, ThinkingLevelMap, Tool, ToolCall, Usage };
|