@bonsae/nrg 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/server.d.ts CHANGED
@@ -1,1715 +1,11 @@
1
+ /// <reference path="./shims/typebox.d.ts" />
1
2
  // Generated by dts-bundle-generator v9.5.1
2
3
 
4
+ import { Kind, ObjectOptions, SchemaOptions, Static, TArray, TBoolean, TConst, TEnum, TFunction, TInteger, TIntersect, TLiteral, TNull, TNumber, TObject, TOptional, TProperties, TRecord, TRef, TSchema, TString, TTuple, TUnion } from '@sinclair/typebox';
3
5
  import { EventEmitter } from 'events';
4
6
  import { Express as Express$1 } from 'express';
5
7
  import { Http2ServerRequest } from 'http2';
6
8
 
7
- declare const TransformKind: unique symbol;
8
- declare const ReadonlyKind: unique symbol;
9
- declare const OptionalKind: unique symbol;
10
- declare const Hint: unique symbol;
11
- declare const Kind: unique symbol;
12
- export interface TAny extends TSchema {
13
- [Kind]: "Any";
14
- static: any;
15
- }
16
- export interface TMappedKey<T extends PropertyKey[] = PropertyKey[]> extends TSchema {
17
- [Kind]: "MappedKey";
18
- static: T[number];
19
- keys: T;
20
- }
21
- export interface TMappedResult<T extends TProperties = TProperties> extends TSchema {
22
- [Kind]: "MappedResult";
23
- properties: T;
24
- static: unknown;
25
- }
26
- export interface TAsyncIterator<T extends TSchema = TSchema> extends TSchema {
27
- [Kind]: "AsyncIterator";
28
- static: AsyncIterableIterator<Static<T, this["params"]>>;
29
- type: "AsyncIterator";
30
- items: T;
31
- }
32
- export type TRemoveReadonly<T extends TSchema> = T extends TReadonly<infer S> ? S : T;
33
- export type TAddReadonly<T extends TSchema> = T extends TReadonly<infer S> ? TReadonly<S> : Ensure<TReadonly<T>>;
34
- export type TReadonlyWithFlag<T extends TSchema, F extends boolean> = F extends false ? TRemoveReadonly<T> : TAddReadonly<T>;
35
- export type TReadonly<T extends TSchema> = T & {
36
- [ReadonlyKind]: "Readonly";
37
- };
38
- export type TFromProperties<P extends TProperties, F extends boolean> = ({
39
- [K2 in keyof P]: TReadonlyWithFlag<P[K2], F>;
40
- });
41
- export type TFromMappedResult<R extends TMappedResult, F extends boolean> = (TFromProperties<R["properties"], F>);
42
- export type TReadonlyFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<R, F>> = (TMappedResult<P>);
43
- export type TReadonlyOptional<T extends TSchema> = TOptional<T> & TReadonly<T>;
44
- export type StaticReturnType<U extends TSchema, P extends unknown[]> = Static<U, P>;
45
- export type StaticParameter<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [
46
- Readonly<Static<T, P>>?
47
- ] : T extends TReadonly<T> ? [
48
- Readonly<Static<T, P>>
49
- ] : T extends TOptional<T> ? [
50
- Static<T, P>?
51
- ] : [
52
- Static<T, P>
53
- ];
54
- export type StaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = [
55
- ]> = (T extends [
56
- infer L extends TSchema,
57
- ...infer R extends TSchema[]
58
- ] ? StaticParameters<R, P, [
59
- ...Acc,
60
- ...StaticParameter<L, P>
61
- ]> : Acc);
62
- export type StaticConstructor<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<new (...param: StaticParameters<T, P>) => StaticReturnType<U, P>>;
63
- export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
64
- [Kind]: "Constructor";
65
- static: StaticConstructor<T, U, this["params"]>;
66
- type: "Constructor";
67
- parameters: T;
68
- returns: U;
69
- }
70
- export type TLiteralValue = boolean | number | string;
71
- export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
72
- [Kind]: "Literal";
73
- static: T;
74
- const: T;
75
- }
76
- export type TEnumRecord = Record<TEnumKey, TEnumValue>;
77
- export type TEnumValue = string | number;
78
- export type TEnumKey = string;
79
- export interface TEnum<T extends Record<string, string | number> = Record<string, string | number>> extends TSchema {
80
- [Kind]: "Union";
81
- [Hint]: "Enum";
82
- static: T[keyof T];
83
- anyOf: TLiteral<T[keyof T]>[];
84
- }
85
- type StaticReturnType$1<U extends TSchema, P extends unknown[]> = Static<U, P>;
86
- type StaticParameter$1<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [
87
- Readonly<Static<T, P>>?
88
- ] : T extends TReadonly<T> ? [
89
- Readonly<Static<T, P>>
90
- ] : T extends TOptional<T> ? [
91
- Static<T, P>?
92
- ] : [
93
- Static<T, P>
94
- ];
95
- type StaticParameters$1<T extends TSchema[], P extends unknown[], Acc extends unknown[] = [
96
- ]> = (T extends [
97
- infer L extends TSchema,
98
- ...infer R extends TSchema[]
99
- ] ? StaticParameters$1<R, P, [
100
- ...Acc,
101
- ...StaticParameter$1<L, P>
102
- ]> : Acc);
103
- export type StaticFunction<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<(...param: StaticParameters$1<T, P>) => StaticReturnType$1<U, P>>;
104
- export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
105
- [Kind]: "Function";
106
- static: StaticFunction<T, U, this["params"]>;
107
- type: "Function";
108
- parameters: T;
109
- returns: U;
110
- }
111
- export interface TComputed<Target extends string = string, Parameters extends TSchema[] = [
112
- ]> extends TSchema {
113
- [Kind]: "Computed";
114
- target: Target;
115
- parameters: Parameters;
116
- }
117
- export interface TNever extends TSchema {
118
- [Kind]: "Never";
119
- static: never;
120
- not: {};
121
- }
122
- export type TIntersectStatic<T extends TSchema[], P extends unknown[], Acc extends unknown = unknown> = T extends [
123
- infer L extends TSchema,
124
- ...infer R extends TSchema[]
125
- ] ? TIntersectStatic<R, P, Acc & Static<L, P>> : Acc;
126
- export type TUnevaluatedProperties = undefined | TSchema | boolean;
127
- export interface IntersectOptions extends SchemaOptions {
128
- unevaluatedProperties?: TUnevaluatedProperties;
129
- }
130
- export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
131
- [Kind]: "Intersect";
132
- static: TIntersectStatic<T, this["params"]>;
133
- type?: "object";
134
- allOf: [
135
- ...T
136
- ];
137
- }
138
- export type TIsIntersectOptional<Types extends TSchema[]> = (Types extends [
139
- infer Left extends TSchema,
140
- ...infer Right extends TSchema[]
141
- ] ? Left extends TOptional<TSchema> ? TIsIntersectOptional<Right> : false : true);
142
- export type TRemoveOptionalFromType<Type extends TSchema> = (Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TRemoveOptionalFromType<Type>> : Type extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromType<Type> : Type);
143
- export type TRemoveOptionalFromRest<Types extends TSchema[], Result extends TSchema[] = [
144
- ]> = (Types extends [
145
- infer Left extends TSchema,
146
- ...infer Right extends TSchema[]
147
- ] ? Left extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromRest<Right, [
148
- ...Result,
149
- TRemoveOptionalFromType<Type>
150
- ]> : TRemoveOptionalFromRest<Right, [
151
- ...Result,
152
- Left
153
- ]> : Result);
154
- export type TResolveIntersect<Types extends TSchema[]> = (TIsIntersectOptional<Types> extends true ? TOptional<TIntersect<TRemoveOptionalFromRest<Types>>> : TIntersect<TRemoveOptionalFromRest<Types>>);
155
- export type TIntersectEvaluated<Types extends TSchema[]> = (Types extends [
156
- TSchema
157
- ] ? Types[0] : Types extends [
158
- ] ? TNever : TResolveIntersect<Types>);
159
- export type Intersect<Types extends TSchema[]> = (Types extends [
160
- TSchema
161
- ] ? Types[0] : Types extends [
162
- ] ? TNever : TIntersect<Types>);
163
- declare function Intersect<Types extends TSchema[]>(types: [
164
- ...Types
165
- ], options?: IntersectOptions): Intersect<Types>;
166
- export type UnionStatic<T extends TSchema[], P extends unknown[]> = {
167
- [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
168
- }[number];
169
- export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
170
- [Kind]: "Union";
171
- static: UnionStatic<T, this["params"]>;
172
- anyOf: T;
173
- }
174
- export type TIsUnionOptional<Types extends TSchema[]> = (Types extends [
175
- infer Left extends TSchema,
176
- ...infer Right extends TSchema[]
177
- ] ? Left extends TOptional<TSchema> ? true : TIsUnionOptional<Right> : false);
178
- type TRemoveOptionalFromRest$1<Types extends TSchema[], Result extends TSchema[] = [
179
- ]> = (Types extends [
180
- infer Left extends TSchema,
181
- ...infer Right extends TSchema[]
182
- ] ? Left extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest$1<Right, [
183
- ...Result,
184
- TRemoveOptionalFromType$1<S>
185
- ]> : TRemoveOptionalFromRest$1<Right, [
186
- ...Result,
187
- Left
188
- ]> : Result);
189
- type TRemoveOptionalFromType$1<Type extends TSchema> = (Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TRemoveOptionalFromType$1<Type>> : Type extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromType$1<Type> : Type);
190
- export type TResolveUnion<Types extends TSchema[], Result extends TSchema[] = TRemoveOptionalFromRest$1<Types>, IsOptional extends boolean = TIsUnionOptional<Types>> = (IsOptional extends true ? TOptional<TUnion<Result>> : TUnion<Result>);
191
- export type TUnionEvaluated<Types extends TSchema[]> = (Types extends [
192
- TSchema
193
- ] ? Types[0] : Types extends [
194
- ] ? TNever : TResolveUnion<Types>);
195
- export type Union<T extends TSchema[]> = (T extends [
196
- ] ? TNever : T extends [
197
- TSchema
198
- ] ? T[0] : TUnion<T>);
199
- declare function Union<Types extends TSchema[]>(types: [
200
- ...Types
201
- ], options?: SchemaOptions): Union<Types>;
202
- export interface TThis extends TSchema {
203
- [Kind]: "This";
204
- static: this["params"][0];
205
- $ref: string;
206
- }
207
- export type RecursiveStatic<T extends TSchema> = Static<T, [
208
- RecursiveStatic<T>
209
- ]>;
210
- export interface TRecursive<T extends TSchema> extends TSchema {
211
- [Hint]: "Recursive";
212
- static: RecursiveStatic<T>;
213
- }
214
- export interface UnsafeOptions extends SchemaOptions {
215
- [Kind]?: string;
216
- }
217
- export interface TUnsafe<T> extends TSchema {
218
- [Kind]: string;
219
- static: T;
220
- }
221
- export interface TRef<Ref extends string = string> extends TSchema {
222
- [Kind]: "Ref";
223
- static: unknown;
224
- $ref: Ref;
225
- }
226
- export type TRefUnsafe<Type extends TSchema> = TUnsafe<Static<Type>>;
227
- export type TupleStatic<T extends TSchema[], P extends unknown[], Acc extends unknown[] = [
228
- ]> = T extends [
229
- infer L extends TSchema,
230
- ...infer R extends TSchema[]
231
- ] ? TupleStatic<R, P, [
232
- ...Acc,
233
- Static<L, P>
234
- ]> : Acc;
235
- export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
236
- [Kind]: "Tuple";
237
- static: TupleStatic<T, this["params"]>;
238
- type: "array";
239
- items: T;
240
- additionalItems?: false;
241
- minItems: T["length"];
242
- maxItems: T["length"];
243
- }
244
- export type StringFormatOption = "date-time" | "time" | "date" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "uuid" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | "regex" | ({} & string);
245
- export type StringContentEncodingOption = "7bit" | "8bit" | "binary" | "quoted-printable" | "base64" | ({} & string);
246
- export interface StringOptions extends SchemaOptions {
247
- /** The maximum string length */
248
- maxLength?: number;
249
- /** The minimum string length */
250
- minLength?: number;
251
- /** A regular expression pattern this string should match */
252
- pattern?: string;
253
- /** A format this string should match */
254
- format?: StringFormatOption;
255
- /** The content encoding for this string */
256
- contentEncoding?: StringContentEncodingOption;
257
- /** The content media type for this string */
258
- contentMediaType?: string;
259
- }
260
- export interface TString extends TSchema, StringOptions {
261
- [Kind]: "String";
262
- static: string;
263
- type: "string";
264
- }
265
- export interface TBoolean extends TSchema {
266
- [Kind]: "Boolean";
267
- static: boolean;
268
- type: "boolean";
269
- }
270
- export interface NumberOptions extends SchemaOptions {
271
- exclusiveMaximum?: number;
272
- exclusiveMinimum?: number;
273
- maximum?: number;
274
- minimum?: number;
275
- multipleOf?: number;
276
- }
277
- export interface TNumber extends TSchema, NumberOptions {
278
- [Kind]: "Number";
279
- static: number;
280
- type: "number";
281
- }
282
- export interface IntegerOptions extends SchemaOptions {
283
- exclusiveMaximum?: number;
284
- exclusiveMinimum?: number;
285
- maximum?: number;
286
- minimum?: number;
287
- multipleOf?: number;
288
- }
289
- export interface TInteger extends TSchema, IntegerOptions {
290
- [Kind]: "Integer";
291
- static: number;
292
- type: "integer";
293
- }
294
- export interface BigIntOptions extends SchemaOptions {
295
- exclusiveMaximum?: bigint;
296
- exclusiveMinimum?: bigint;
297
- maximum?: bigint;
298
- minimum?: bigint;
299
- multipleOf?: bigint;
300
- }
301
- export interface TBigInt extends TSchema, BigIntOptions {
302
- [Kind]: "BigInt";
303
- static: bigint;
304
- type: "bigint";
305
- }
306
- export type TFromTemplateLiteralKind<T> = T extends TTemplateLiteral<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TUnion<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TString ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TBoolean ? true : T extends TLiteral ? true : false;
307
- export type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[]> = T extends [
308
- infer L extends TTemplateLiteralKind,
309
- ...infer R extends TTemplateLiteralKind[]
310
- ] ? TFromTemplateLiteralKind<L> extends false ? false : TFromTemplateLiteralKinds<R> : true;
311
- export type TIsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ? TFromTemplateLiteralKinds<U> : false;
312
- export type TStringReduceUnary<L extends string, R extends string[], Acc extends string[] = [
313
- ]> = R extends [
314
- infer A extends string,
315
- ...infer B extends string[]
316
- ] ? TStringReduceUnary<L, B, [
317
- ...Acc,
318
- `${L}${A}`
319
- ]> : Acc;
320
- export type TStringReduceBinary<L extends string[], R extends string[], Acc extends string[] = [
321
- ]> = L extends [
322
- infer A extends string,
323
- ...infer B extends string[]
324
- ] ? TStringReduceBinary<B, R, [
325
- ...Acc,
326
- ...TStringReduceUnary<A, R>
327
- ]> : Acc;
328
- export type TStringReduceMany<T extends string[][]> = T extends [
329
- infer L extends string[],
330
- infer R extends string[],
331
- ...infer Rest extends string[][]
332
- ] ? TStringReduceMany<[
333
- TStringReduceBinary<L, R>,
334
- ...Rest
335
- ]> : T;
336
- export type TStringReduce<T extends string[][], O = TStringReduceMany<T>> = 0 extends keyof O ? Assert<O[0], string[]> : [
337
- ];
338
- export type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [
339
- infer L extends TLiteral,
340
- ...infer R extends TLiteral[]
341
- ] ? [
342
- `${L["const"]}`,
343
- ...TFromTemplateLiteralUnionKinds<R>
344
- ] : [
345
- ];
346
- type TFromTemplateLiteralKinds$1<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = [
347
- ]> = T extends [
348
- infer L extends TTemplateLiteralKind,
349
- ...infer R extends TTemplateLiteralKind[]
350
- ] ? (L extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds$1<[
351
- ...S,
352
- ...R
353
- ], Acc> : L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds$1<R, [
354
- ...Acc,
355
- [
356
- S
357
- ]
358
- ]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds$1<R, [
359
- ...Acc,
360
- TFromTemplateLiteralUnionKinds<S>
361
- ]> : L extends TBoolean ? TFromTemplateLiteralKinds$1<R, [
362
- ...Acc,
363
- [
364
- "true",
365
- "false"
366
- ]
367
- ]> : Acc) : Acc;
368
- export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds$1<S> extends infer R extends string[][] ? TStringReduce<R> : [
369
- ] : [
370
- ]) : [
371
- ];
372
- declare function FromUnion(syntax: string): IterableIterator<TTemplateLiteralKind>;
373
- declare function FromTerminal(syntax: string): IterableIterator<TTemplateLiteralKind>;
374
- export type FromUnionLiteral<T extends string> = T extends `${infer L}|${infer R}` ? [
375
- TLiteral<Trim<L>>,
376
- ...FromUnionLiteral<R>
377
- ] : T extends `${infer L}` ? [
378
- TLiteral<Trim<L>>
379
- ] : [
380
- ];
381
- export type FromUnion<T extends string> = TUnionEvaluated<FromUnionLiteral<T>>;
382
- export type FromTerminal<T extends string> = T extends "boolean" ? TBoolean : T extends "bigint" ? TBigInt : T extends "number" ? TNumber : T extends "string" ? TString : FromUnion<T>;
383
- export type FromString<T extends string> = T extends `{${infer L}}${infer R}` ? [
384
- FromTerminal<L>,
385
- ...FromString<R>
386
- ] : T extends `${infer L}$\{${infer R1}\}${infer R2}` ? [
387
- TLiteral<L>,
388
- ...FromString<`{${R1}}`>,
389
- ...FromString<R2>
390
- ] : T extends `${infer L}$\{${infer R1}\}` ? [
391
- TLiteral<L>,
392
- ...FromString<`{${R1}}`>
393
- ] : T extends `${infer L}` ? [
394
- TLiteral<L>
395
- ] : [
396
- ];
397
- export type TTemplateLiteralSyntax<T extends string> = (TTemplateLiteral<Assert<FromString<T>, TTemplateLiteralKind[]>>);
398
- export type TemplateLiteralStaticKind<T, Acc extends string> = T extends TUnion<infer U> ? {
399
- [K in keyof U]: TemplateLiteralStatic<Assert<[
400
- U[K]
401
- ], TTemplateLiteralKind[]>, Acc>;
402
- }[number] : T extends TTemplateLiteral ? `${Static<T>}` : T extends TLiteral<infer U> ? `${U}` : T extends TString ? `${string}` : T extends TNumber ? `${number}` : T extends TBigInt ? `${bigint}` : T extends TBoolean ? `${boolean}` : never;
403
- export type TemplateLiteralStatic<T extends TTemplateLiteralKind[], Acc extends string> = T extends [
404
- infer L,
405
- ...infer R
406
- ] ? `${TemplateLiteralStaticKind<L, Acc>}${TemplateLiteralStatic<Assert<R, TTemplateLiteralKind[]>, Acc>}` : Acc;
407
- export type TTemplateLiteralKind = TTemplateLiteral | TUnion | TLiteral | TInteger | TNumber | TBigInt | TString | TBoolean | TNever;
408
- export interface TTemplateLiteral<T extends TTemplateLiteralKind[] = TTemplateLiteralKind[]> extends TSchema {
409
- [Kind]: "TemplateLiteral";
410
- static: TemplateLiteralStatic<T, EmptyString>;
411
- type: "string";
412
- pattern: string;
413
- }
414
- export type TTemplateLiteralToUnionLiteralArray<T extends string[], Acc extends TLiteral[] = [
415
- ]> = (T extends [
416
- infer L extends string,
417
- ...infer R extends string[]
418
- ] ? TTemplateLiteralToUnionLiteralArray<R, [
419
- ...Acc,
420
- TLiteral<L>
421
- ]> : Acc);
422
- export type TTemplateLiteralToUnion<T extends TTemplateLiteral, U extends string[] = UnionToTuple<Static<T>>> = TUnionEvaluated<TTemplateLiteralToUnionLiteralArray<U>>;
423
- export type TFromTemplateLiteral<TemplateLiteral extends TTemplateLiteral, Keys extends string[] = TTemplateLiteralGenerate<TemplateLiteral>> = (Keys);
424
- export type TFromUnion<Types extends TSchema[], Result extends string[] = [
425
- ]> = (Types extends [
426
- infer Left extends TSchema,
427
- ...infer Right extends TSchema[]
428
- ] ? TFromUnion<Right, [
429
- ...Result,
430
- ...TIndexPropertyKeys<Left>
431
- ]> : Result);
432
- export type TFromLiteral<LiteralValue extends TLiteralValue> = (LiteralValue extends PropertyKey ? [
433
- `${LiteralValue}`
434
- ] : [
435
- ]);
436
- export type TIndexPropertyKeys<Type extends TSchema> = (Type extends TTemplateLiteral ? TFromTemplateLiteral<Type> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral<Value> : Type extends TNumber ? [
437
- "[number]"
438
- ] : Type extends TInteger ? [
439
- "[number]"
440
- ] : [
441
- ]);
442
- type TFromProperties$1<Type extends TSchema, Properties extends TProperties> = ({
443
- [K2 in keyof Properties]: TIndex<Type, TIndexPropertyKeys<Properties[K2]>>;
444
- });
445
- type TFromMappedResult$1<Type extends TSchema, MappedResult extends TMappedResult> = (TFromProperties$1<Type, MappedResult["properties"]>);
446
- export type TIndexFromMappedResult<Type extends TSchema, MappedResult extends TMappedResult, Properties extends TProperties = TFromMappedResult$1<Type, MappedResult>> = (TMappedResult<Properties>);
447
- export type TFromRest<Types extends TSchema[], Key extends PropertyKey, Result extends TSchema[] = [
448
- ]> = (Types extends [
449
- infer Left extends TSchema,
450
- ...infer Right extends TSchema[]
451
- ] ? TFromRest<Right, Key, [
452
- ...Result,
453
- Assert<TIndexFromPropertyKey<Left, Key>, TSchema>
454
- ]> : Result);
455
- export type TFromIntersectRest<Types extends TSchema[], Result extends TSchema[] = [
456
- ]> = (Types extends [
457
- infer Left extends TSchema,
458
- ...infer Right extends TSchema[]
459
- ] ? Left extends TNever ? TFromIntersectRest<Right, [
460
- ...Result
461
- ]> : TFromIntersectRest<Right, [
462
- ...Result,
463
- Left
464
- ]> : Result);
465
- export type TFromIntersect<Types extends TSchema[], Key extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<Types, Key>>>);
466
- export type TFromUnionRest<Types extends TSchema[], Result extends TSchema[] = [
467
- ]> = Types extends [
468
- infer Left extends TSchema,
469
- ...infer Right extends TSchema[]
470
- ] ? Left extends TNever ? [
471
- ] : TFromUnionRest<Right, [
472
- Left,
473
- ...Result
474
- ]> : Result;
475
- type TFromUnion$1<Types extends TSchema[], Key extends PropertyKey> = (TUnionEvaluated<TFromUnionRest<TFromRest<Types, Key>>>);
476
- export type TFromTuple<Types extends TSchema[], Key extends PropertyKey> = (Key extends keyof Types ? Types[Key] : Key extends "[number]" ? TUnionEvaluated<Types> : TNever);
477
- export type TFromArray<Type extends TSchema, Key extends PropertyKey> = (Key extends "[number]" ? Type : TNever);
478
- export type AssertPropertyKey<T> = Assert<T, string | number>;
479
- export type TFromProperty<Properties extends TProperties, Key extends PropertyKey> = (Key extends keyof Properties ? Properties[Key] : `${AssertPropertyKey<Key>}` extends `${AssertPropertyKey<keyof Properties>}` ? Properties[AssertPropertyKey<Key>] : TNever);
480
- export type TIndexFromPropertyKey<Type extends TSchema, Key extends PropertyKey> = (Type extends TRecursive<infer Type extends TSchema> ? TIndexFromPropertyKey<Type, Key> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<Types, Key> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$1<Types, Key> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<Types, Key> : Type extends TArray<infer Type extends TSchema> ? TFromArray<Type, Key> : Type extends TObject<infer Properties extends TProperties> ? TFromProperty<Properties, Key> : TNever);
481
- export type TIndexFromPropertyKeys<Type extends TSchema, PropertyKeys extends PropertyKey[], Result extends TSchema[] = [
482
- ]> = (PropertyKeys extends [
483
- infer Left extends PropertyKey,
484
- ...infer Right extends PropertyKey[]
485
- ] ? TIndexFromPropertyKeys<Type, Right, [
486
- ...Result,
487
- Assert<TIndexFromPropertyKey<Type, Left>, TSchema>
488
- ]> : Result);
489
- export type FromSchema<Type extends TSchema, PropertyKeys extends PropertyKey[]> = (TUnionEvaluated<TIndexFromPropertyKeys<Type, PropertyKeys>>);
490
- declare function FromSchema<Type extends TSchema, PropertyKeys extends PropertyKey[]>(type: Type, propertyKeys: [
491
- ...PropertyKeys
492
- ]): FromSchema<Type, PropertyKeys>;
493
- export type TIndexFromComputed<Type extends TSchema, Key extends TSchema> = (TComputed<"Index", [
494
- Type,
495
- Key
496
- ]>);
497
- export type TIndex<Type extends TSchema, PropertyKeys extends PropertyKey[]> = (FromSchema<Type, PropertyKeys>);
498
- export type TMappedIndexPropertyKey<Type extends TSchema, Key extends PropertyKey> = {
499
- [_ in Key]: TIndex<Type, [
500
- Key
501
- ]>;
502
- };
503
- export type TMappedIndexPropertyKeys<Type extends TSchema, PropertyKeys extends PropertyKey[], Result extends TProperties = {}> = (PropertyKeys extends [
504
- infer Left extends PropertyKey,
505
- ...infer Right extends PropertyKey[]
506
- ] ? TMappedIndexPropertyKeys<Type, Right, Result & TMappedIndexPropertyKey<Type, Left>> : Result);
507
- export type TMappedIndexProperties<Type extends TSchema, MappedKey extends TMappedKey> = Evaluate<TMappedIndexPropertyKeys<Type, MappedKey["keys"]>>;
508
- export type TIndexFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey, Properties extends TProperties = TMappedIndexProperties<Type, MappedKey>> = (Ensure<TMappedResult<Properties>>);
509
- export interface TIterator<T extends TSchema = TSchema> extends TSchema {
510
- [Kind]: "Iterator";
511
- static: IterableIterator<Static<T, this["params"]>>;
512
- type: "Iterator";
513
- items: T;
514
- }
515
- export interface TPromise<T extends TSchema = TSchema> extends TSchema {
516
- [Kind]: "Promise";
517
- static: Promise<Static<T, this["params"]>>;
518
- type: "Promise";
519
- item: TSchema;
520
- }
521
- export type TSetIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [
522
- infer L extends PropertyKey,
523
- ...infer R extends PropertyKey[]
524
- ] ? S extends L ? true : TSetIncludes<R, S> : false);
525
- export type TSetDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = [
526
- ]> = T extends [
527
- infer L extends PropertyKey,
528
- ...infer R extends PropertyKey[]
529
- ] ? TSetIncludes<Acc, L> extends false ? TSetDistinct<R, [
530
- ...Acc,
531
- L
532
- ]> : TSetDistinct<R, [
533
- ...Acc
534
- ]> : Acc;
535
- export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = [
536
- ]> = (T extends [
537
- infer L extends PropertyKey,
538
- ...infer R extends PropertyKey[]
539
- ] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [
540
- ...Acc,
541
- L
542
- ]> : TSetIntersect<R, S, [
543
- ...Acc
544
- ]> : Acc);
545
- export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[]> = ([
546
- ...T,
547
- ...S
548
- ]);
549
- export type TSetIntersectManyResolve<T extends PropertyKey[][], Acc extends PropertyKey[]> = (T extends [
550
- infer L extends PropertyKey[],
551
- ...infer R extends PropertyKey[][]
552
- ] ? TSetIntersectManyResolve<R, TSetIntersect<Acc, L>> : Acc);
553
- export type TSetIntersectMany<T extends PropertyKey[][]> = (T extends [
554
- infer L extends PropertyKey[]
555
- ] ? L : T extends [
556
- infer L extends PropertyKey[],
557
- ...infer R extends PropertyKey[][]
558
- ] ? TSetIntersectManyResolve<R, L> : [
559
- ]);
560
- export type TSetUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = [
561
- ]> = (T extends [
562
- infer L extends PropertyKey[],
563
- ...infer R extends PropertyKey[][]
564
- ] ? TSetUnionMany<R, TSetUnion<Acc, L>> : Acc);
565
- type TFromMappedResult$2<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> : TMappedResult<P>);
566
- export type TMappedKeyToKnownMappedResultProperties<K extends PropertyKey> = {
567
- [_ in K]: TLiteral<Assert<K, TLiteralValue>>;
568
- };
569
- export type TMappedKeyToUnknownMappedResultProperties<P extends PropertyKey[], Acc extends TProperties = {}> = (P extends [
570
- infer L extends PropertyKey,
571
- ...infer R extends PropertyKey[]
572
- ] ? TMappedKeyToUnknownMappedResultProperties<R, Acc & {
573
- [_ in L]: TLiteral<Assert<L, TLiteralValue>>;
574
- }> : Acc);
575
- export type TMappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]> = (TSetIncludes<P, K> extends true ? TMappedKeyToKnownMappedResultProperties<K> : TMappedKeyToUnknownMappedResultProperties<P>);
576
- export type TFromMappedKey<K extends PropertyKey, P extends PropertyKey[], R extends TProperties = TMappedKeyToMappedResultProperties<K, P>> = (TFromMappedResult$2<K, R>);
577
- type TFromRest$1<K extends PropertyKey, T extends TSchema[], Acc extends TSchema[] = [
578
- ]> = (T extends [
579
- infer L extends TSchema,
580
- ...infer R extends TSchema[]
581
- ] ? TFromRest$1<K, R, [
582
- ...Acc,
583
- FromSchemaType<K, L>
584
- ]> : Acc);
585
- export type FromProperties<K extends PropertyKey, T extends TProperties, R extends TProperties = Evaluate<{
586
- [K2 in keyof T]: FromSchemaType<K, T[K2]>;
587
- }>> = R;
588
- declare function FromProperties<K extends PropertyKey, T extends TProperties>(K: K, T: T): FromProperties<K, T>;
589
- export type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S extends TSchema> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P extends TProperties> ? TFromMappedResult$2<K, P> : T extends TMappedKey<infer P extends PropertyKey[]> ? TFromMappedKey<K, P> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest$1<K, S>, FromSchemaType<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest$1<K, S>, FromSchemaType<K, R>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<FromSchemaType<K, S>> : T extends TIterator<infer S extends TSchema> ? TIterator<FromSchemaType<K, S>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest$1<K, S>> : T extends TEnum<infer S extends TEnumRecord> ? TEnum<S> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest$1<K, S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest$1<K, S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<K, S>> : T extends TArray<infer S extends TSchema> ? TArray<FromSchemaType<K, S>> : T extends TPromise<infer S extends TSchema> ? TPromise<FromSchemaType<K, S>> : T);
590
- declare function FromSchemaType<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromSchemaType<K, T>;
591
- export type TMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [
592
- infer L extends PropertyKey,
593
- ...infer R extends PropertyKey[]
594
- ] ? TMappedFunctionReturnType<R, T, Acc & {
595
- [_ in L]: FromSchemaType<L, T>;
596
- }> : Acc);
597
- export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
598
- export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<TMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
599
- export type TRemoveOptional<T extends TSchema> = T extends TOptional<infer S> ? S : T;
600
- export type TAddOptional<T extends TSchema> = T extends TOptional<infer S> ? TOptional<S> : Ensure<TOptional<T>>;
601
- export type TOptionalWithFlag<T extends TSchema, F extends boolean> = F extends false ? TRemoveOptional<T> : TAddOptional<T>;
602
- export type TOptional<T extends TSchema> = T & {
603
- [OptionalKind]: "Optional";
604
- };
605
- type TFromProperties$2<P extends TProperties, F extends boolean> = ({
606
- [K2 in keyof P]: TOptionalWithFlag<P[K2], F>;
607
- });
608
- type TFromMappedResult$3<R extends TMappedResult, F extends boolean> = (TFromProperties$2<R["properties"], F>);
609
- export type TOptionalFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult$3<R, F>> = (TMappedResult<P>);
610
- export type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<(TComputed<"Awaited", [
611
- TComputed<Target, Parameters>
612
- ]>)>;
613
- export type TFromRef<Ref extends string> = Ensure<TComputed<"Awaited", [
614
- TRef<Ref>
615
- ]>>;
616
- type TFromRest$2<Types extends TSchema[], Result extends TSchema[] = [
617
- ]> = (Types extends [
618
- infer Left extends TSchema,
619
- ...infer Right extends TSchema[]
620
- ] ? TFromRest$2<Right, [
621
- ...Result,
622
- TAwaited<Left>
623
- ]> : Result);
624
- export type TAwaited<Type extends TSchema> = (Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest$2<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest$2<Types>> : Type extends TPromise<infer Type extends TSchema> ? TAwaited<Type> : Type);
625
- type TFromRest$3<Types extends TSchema[], Result extends PropertyKey[][] = [
626
- ]> = (Types extends [
627
- infer L extends TSchema,
628
- ...infer R extends TSchema[]
629
- ] ? TFromRest$3<R, [
630
- ...Result,
631
- TKeyOfPropertyKeys<L>
632
- ]> : Result);
633
- type TFromIntersect$1<Types extends TSchema[], PropertyKeysArray extends PropertyKey[][] = TFromRest$3<Types>, PropertyKeys extends PropertyKey[] = TSetUnionMany<PropertyKeysArray>> = PropertyKeys;
634
- type TFromUnion$2<Types extends TSchema[], PropertyKeysArray extends PropertyKey[][] = TFromRest$3<Types>, PropertyKeys extends PropertyKey[] = TSetIntersectMany<PropertyKeysArray>> = PropertyKeys;
635
- type TFromTuple$1<Types extends TSchema[], Indexer extends string = ZeroString, Acc extends PropertyKey[] = [
636
- ]> = Types extends [
637
- infer _ extends TSchema,
638
- ...infer R extends TSchema[]
639
- ] ? TFromTuple$1<R, TIncrement<Indexer>, [
640
- ...Acc,
641
- Indexer
642
- ]> : Acc;
643
- type TFromArray$1<_ extends TSchema> = ([
644
- "[number]"
645
- ]);
646
- type TFromProperties$3<Properties extends TProperties> = (UnionToTuple<keyof Properties>);
647
- export type TKeyOfPropertyKeys<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TKeyOfPropertyKeys<Type> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$1<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$2<Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$1<Types> : Type extends TArray<infer Type extends TSchema> ? TFromArray$1<Type> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties$3<Properties> : [
648
- ]);
649
- type TFromComputed$1<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<"KeyOf", [
650
- TComputed<Target, Parameters>
651
- ]>>;
652
- type TFromRef$1<Ref extends string> = Ensure<TComputed<"KeyOf", [
653
- TRef<Ref>
654
- ]>>;
655
- /** `[Internal]` Used by KeyOfFromMappedResult */
656
- export type TKeyOfFromType<Type extends TSchema, PropertyKeys extends PropertyKey[] = TKeyOfPropertyKeys<Type>, PropertyKeyTypes extends TSchema[] = TKeyOfPropertyKeysToRest<PropertyKeys>, Result = TUnionEvaluated<PropertyKeyTypes>> = Ensure<Result>;
657
- export type TKeyOfPropertyKeysToRest<PropertyKeys extends PropertyKey[], Result extends TSchema[] = [
658
- ]> = (PropertyKeys extends [
659
- infer L extends PropertyKey,
660
- ...infer R extends PropertyKey[]
661
- ] ? L extends "[number]" ? TKeyOfPropertyKeysToRest<R, [
662
- ...Result,
663
- TNumber
664
- ]> : TKeyOfPropertyKeysToRest<R, [
665
- ...Result,
666
- TLiteral<Assert<L, TLiteralValue>>
667
- ]> : Result);
668
- export type TKeyOf<Type extends TSchema> = (Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed$1<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef$1<Ref> : Type extends TMappedResult ? TKeyOfFromMappedResult<Type> : TKeyOfFromType<Type>);
669
- type TFromProperties$4<Properties extends TProperties> = ({
670
- [K2 in keyof Properties]: TKeyOfFromType<Properties[K2]>;
671
- });
672
- type TFromMappedResult$4<MappedResult extends TMappedResult> = (Evaluate<TFromProperties$4<MappedResult["properties"]>>);
673
- export type TKeyOfFromMappedResult<MappedResult extends TMappedResult, Properties extends TProperties = TFromMappedResult$4<MappedResult>> = (Ensure<TMappedResult<Properties>>);
674
- type TFromProperties$5<Properties extends TProperties, PropertyKeys extends PropertyKey[]> = ({
675
- [K2 in keyof Properties]: TOmit<Properties[K2], PropertyKeys>;
676
- });
677
- type TFromMappedResult$5<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[]> = (Evaluate<TFromProperties$5<MappedResult["properties"], PropertyKeys>>);
678
- export type TOmitFromMappedResult<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[], Properties extends TProperties = TFromMappedResult$5<MappedResult, PropertyKeys>> = (Ensure<TMappedResult<Properties>>);
679
- type TFromIntersect$2<Types extends TSchema[], PropertyKeys extends PropertyKey[], Result extends TSchema[] = [
680
- ]> = (Types extends [
681
- infer L extends TSchema,
682
- ...infer R extends TSchema[]
683
- ] ? TFromIntersect$2<R, PropertyKeys, [
684
- ...Result,
685
- TOmit<L, PropertyKeys>
686
- ]> : Result);
687
- type TFromUnion$3<T extends TSchema[], K extends PropertyKey[], Result extends TSchema[] = [
688
- ]> = (T extends [
689
- infer L extends TSchema,
690
- ...infer R extends TSchema[]
691
- ] ? TFromUnion$3<R, K, [
692
- ...Result,
693
- TOmit<L, K>
694
- ]> : Result);
695
- type TFromProperties$6<Properties extends TProperties, PropertyKeys extends PropertyKey[], UnionKey extends PropertyKey = TupleToUnion<PropertyKeys>> = (Evaluate<Omit<Properties, UnionKey>>);
696
- export type TFromObject<_Type extends TObject, PropertyKeys extends PropertyKey[], Properties extends TProperties, MappedProperties extends TProperties = TFromProperties$6<Properties, PropertyKeys>, Result extends TSchema = TObject<MappedProperties>> = Result;
697
- export type TUnionFromPropertyKeys<PropertyKeys extends PropertyKey[], Result extends TLiteral[] = [
698
- ]> = (PropertyKeys extends [
699
- infer Key extends PropertyKey,
700
- ...infer Rest extends PropertyKey[]
701
- ] ? Key extends TLiteralValue ? TUnionFromPropertyKeys<Rest, [
702
- ...Result,
703
- TLiteral<Key>
704
- ]> : TUnionFromPropertyKeys<Rest, [
705
- ...Result
706
- ]> : TUnion<Result>);
707
- export type TOmitResolve<Properties extends TProperties, PropertyKeys extends PropertyKey[]> = (Properties extends TRecursive<infer Types extends TSchema> ? TRecursive<TOmitResolve<Types, PropertyKeys>> : Properties extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromIntersect$2<Types, PropertyKeys>> : Properties extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromUnion$3<Types, PropertyKeys>> : Properties extends TObject<infer Properties extends TProperties> ? TFromObject<TObject, PropertyKeys, Properties> : TObject<{}>);
708
- export type TResolvePropertyKeys<Key extends TSchema | PropertyKey[]> = Key extends TSchema ? TIndexPropertyKeys<Key> : Key;
709
- export type TResolveTypeKey<Key extends TSchema | PropertyKey[]> = Key extends PropertyKey[] ? TUnionFromPropertyKeys<Key> : Key;
710
- export type TOmit<Type extends TSchema, Key extends TSchema | PropertyKey[], IsTypeRef extends boolean = Type extends TRef ? true : false, IsKeyRef extends boolean = Key extends TRef ? true : false> = (Type extends TMappedResult ? TOmitFromMappedResult<Type, TResolvePropertyKeys<Key>> : Key extends TMappedKey ? TOmitFromMappedKey<Type, Key> : [
711
- IsTypeRef,
712
- IsKeyRef
713
- ] extends [
714
- true,
715
- true
716
- ] ? TComputed<"Omit", [
717
- Type,
718
- TResolveTypeKey<Key>
719
- ]> : [
720
- IsTypeRef,
721
- IsKeyRef
722
- ] extends [
723
- false,
724
- true
725
- ] ? TComputed<"Omit", [
726
- Type,
727
- TResolveTypeKey<Key>
728
- ]> : [
729
- IsTypeRef,
730
- IsKeyRef
731
- ] extends [
732
- true,
733
- false
734
- ] ? TComputed<"Omit", [
735
- Type,
736
- TResolveTypeKey<Key>
737
- ]> : TOmitResolve<Type, TResolvePropertyKeys<Key>>);
738
- export type TFromPropertyKey<Type extends TSchema, Key extends PropertyKey> = {
739
- [_ in Key]: TOmit<Type, [
740
- Key
741
- ]>;
742
- };
743
- export type TFromPropertyKeys<Type extends TSchema, PropertyKeys extends PropertyKey[], Result extends TProperties = {}> = (PropertyKeys extends [
744
- infer LK extends PropertyKey,
745
- ...infer RK extends PropertyKey[]
746
- ] ? TFromPropertyKeys<Type, RK, Result & TFromPropertyKey<Type, LK>> : Result);
747
- type TFromMappedKey$1<Type extends TSchema, MappedKey extends TMappedKey> = (TFromPropertyKeys<Type, MappedKey["keys"]>);
748
- export type TOmitFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey, Properties extends TProperties = TFromMappedKey$1<Type, MappedKey>> = (TMappedResult<Properties>);
749
- type TFromProperties$7<Properties extends TProperties, PropertyKeys extends PropertyKey[]> = ({
750
- [K2 in keyof Properties]: TPick<Properties[K2], PropertyKeys>;
751
- });
752
- type TFromMappedResult$6<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[]> = (Evaluate<TFromProperties$7<MappedResult["properties"], PropertyKeys>>);
753
- export type TPickFromMappedResult<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[], Properties extends TProperties = TFromMappedResult$6<MappedResult, PropertyKeys>> = (Ensure<TMappedResult<Properties>>);
754
- type TFromIntersect$3<Types extends TSchema[], PropertyKeys extends PropertyKey[], Result extends TSchema[] = [
755
- ]> = Types extends [
756
- infer L extends TSchema,
757
- ...infer R extends TSchema[]
758
- ] ? TFromIntersect$3<R, PropertyKeys, [
759
- ...Result,
760
- TPick<L, PropertyKeys>
761
- ]> : Result;
762
- type TFromUnion$4<Types extends TSchema[], PropertyKeys extends PropertyKey[], Result extends TSchema[] = [
763
- ]> = Types extends [
764
- infer L extends TSchema,
765
- ...infer R extends TSchema[]
766
- ] ? TFromUnion$4<R, PropertyKeys, [
767
- ...Result,
768
- TPick<L, PropertyKeys>
769
- ]> : Result;
770
- type TFromProperties$8<Properties extends TProperties, PropertyKeys extends PropertyKey[], UnionKeys extends PropertyKey = TupleToUnion<PropertyKeys>> = (Evaluate<Pick<Properties, UnionKeys & keyof Properties>>);
771
- type TFromObject$1<_Type extends TObject, Keys extends PropertyKey[], Properties extends TProperties, MappedProperties extends TProperties = TFromProperties$8<Properties, Keys>, Result extends TSchema = TObject<MappedProperties>> = Result;
772
- type TUnionFromPropertyKeys$1<PropertyKeys extends PropertyKey[], Result extends TLiteral[] = [
773
- ]> = (PropertyKeys extends [
774
- infer Key extends PropertyKey,
775
- ...infer Rest extends PropertyKey[]
776
- ] ? Key extends TLiteralValue ? TUnionFromPropertyKeys$1<Rest, [
777
- ...Result,
778
- TLiteral<Key>
779
- ]> : TUnionFromPropertyKeys$1<Rest, [
780
- ...Result
781
- ]> : TUnion<Result>);
782
- export type TPickResolve<Type extends TProperties, PropertyKeys extends PropertyKey[]> = (Type extends TRecursive<infer Types extends TSchema> ? TRecursive<TPickResolve<Types, PropertyKeys>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromIntersect$3<Types, PropertyKeys>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromUnion$4<Types, PropertyKeys>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$1<TObject, PropertyKeys, Properties> : TObject<{}>);
783
- type TResolvePropertyKeys$1<Key extends TSchema | PropertyKey[]> = Key extends TSchema ? TIndexPropertyKeys<Key> : Key;
784
- type TResolveTypeKey$1<Key extends TSchema | PropertyKey[]> = Key extends PropertyKey[] ? TUnionFromPropertyKeys$1<Key> : Key;
785
- export type TPick<Type extends TSchema, Key extends TSchema | PropertyKey[], IsTypeRef extends boolean = Type extends TRef ? true : false, IsKeyRef extends boolean = Key extends TRef ? true : false> = (Type extends TMappedResult ? TPickFromMappedResult<Type, TResolvePropertyKeys$1<Key>> : Key extends TMappedKey ? TPickFromMappedKey<Type, Key> : [
786
- IsTypeRef,
787
- IsKeyRef
788
- ] extends [
789
- true,
790
- true
791
- ] ? TComputed<"Pick", [
792
- Type,
793
- TResolveTypeKey$1<Key>
794
- ]> : [
795
- IsTypeRef,
796
- IsKeyRef
797
- ] extends [
798
- false,
799
- true
800
- ] ? TComputed<"Pick", [
801
- Type,
802
- TResolveTypeKey$1<Key>
803
- ]> : [
804
- IsTypeRef,
805
- IsKeyRef
806
- ] extends [
807
- true,
808
- false
809
- ] ? TComputed<"Pick", [
810
- Type,
811
- TResolveTypeKey$1<Key>
812
- ]> : TPickResolve<Type, TResolvePropertyKeys$1<Key>>);
813
- type TFromPropertyKey$1<Type extends TSchema, Key extends PropertyKey> = {
814
- [_ in Key]: TPick<Type, [
815
- Key
816
- ]>;
817
- };
818
- type TFromPropertyKeys$1<Type extends TSchema, PropertyKeys extends PropertyKey[], Result extends TProperties = {}> = (PropertyKeys extends [
819
- infer LeftKey extends PropertyKey,
820
- ...infer RightKeys extends PropertyKey[]
821
- ] ? TFromPropertyKeys$1<Type, RightKeys, Result & TFromPropertyKey$1<Type, LeftKey>> : Result);
822
- type TFromMappedKey$2<Type extends TSchema, MappedKey extends TMappedKey> = (TFromPropertyKeys$1<Type, MappedKey["keys"]>);
823
- export type TPickFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey, Properties extends TProperties = TFromMappedKey$2<Type, MappedKey>> = (TMappedResult<Properties>);
824
- export interface TNull extends TSchema {
825
- [Kind]: "Null";
826
- static: null;
827
- type: "null";
828
- }
829
- export interface TSymbol extends TSchema, SchemaOptions {
830
- [Kind]: "Symbol";
831
- static: symbol;
832
- type: "symbol";
833
- }
834
- export interface TUndefined extends TSchema {
835
- [Kind]: "Undefined";
836
- static: undefined;
837
- type: "undefined";
838
- }
839
- type TFromComputed$2<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<"Partial", [
840
- TComputed<Target, Parameters>
841
- ]>>;
842
- type TFromRef$2<Ref extends string> = Ensure<TComputed<"Partial", [
843
- TRef<Ref>
844
- ]>>;
845
- type TFromProperties$9<Properties extends TProperties> = Evaluate<{
846
- [K in keyof Properties]: Properties[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : Properties[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : Properties[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<Properties[K]>;
847
- }>;
848
- type TFromObject$2<_Type extends TObject, Properties extends TProperties, MappedProperties extends TProperties = TFromProperties$9<Properties>, Result extends TSchema = TObject<MappedProperties>> = Result;
849
- type TFromRest$4<Types extends TSchema[], Result extends TSchema[] = [
850
- ]> = (Types extends [
851
- infer L extends TSchema,
852
- ...infer R extends TSchema[]
853
- ] ? TFromRest$4<R, [
854
- ...Result,
855
- TPartial<L>
856
- ]> : Result);
857
- export type TPartial<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TPartial<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed$2<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef$2<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest$4<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest$4<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$2<TObject, Properties> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
858
- type TFromProperties$10<P extends TProperties> = ({
859
- [K2 in keyof P]: TPartial<P[K2]>;
860
- });
861
- type TFromMappedResult$7<R extends TMappedResult> = (Evaluate<TFromProperties$10<R["properties"]>>);
862
- export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult$7<R>> = (Ensure<TMappedResult<P>>);
863
- export interface RegExpOptions extends SchemaOptions {
864
- /** The maximum length of the string */
865
- maxLength?: number;
866
- /** The minimum length of the string */
867
- minLength?: number;
868
- }
869
- export interface TRegExp extends TSchema {
870
- [Kind]: "RegExp";
871
- static: `${string}`;
872
- type: "RegExp";
873
- source: string;
874
- flags: string;
875
- }
876
- export type TFromTemplateLiteralKeyInfinite<Key extends TTemplateLiteral, Type extends TSchema> = Ensure<TRecord<Key, Type>>;
877
- export type TFromTemplateLiteralKeyFinite<Key extends TTemplateLiteral, Type extends TSchema, I extends string = Static<Key>> = (Ensure<TObject<Evaluate<{
878
- [_ in I]: Type;
879
- }>>>);
880
- export type TFromTemplateLiteralKey<Key extends TTemplateLiteral, Type extends TSchema> = TIsTemplateLiteralFinite<Key> extends false ? TFromTemplateLiteralKeyInfinite<Key, Type> : TFromTemplateLiteralKeyFinite<Key, Type>;
881
- export type TFromEnumKey<Key extends Record<string, string | number>, Type extends TSchema> = Ensure<TObject<{
882
- [_ in Key[keyof Key]]: Type;
883
- }>>;
884
- export type TFromUnionKeyLiteralString<Key extends TLiteral<string>, Type extends TSchema> = {
885
- [_ in Key["const"]]: Type;
886
- };
887
- export type TFromUnionKeyLiteralNumber<Key extends TLiteral<number>, Type extends TSchema> = {
888
- [_ in Key["const"]]: Type;
889
- };
890
- export type TFromUnionKeyVariants<Keys extends TSchema[], Type extends TSchema, Result extends TProperties = {}> = Keys extends [
891
- infer Left extends TSchema,
892
- ...infer Right extends TSchema[]
893
- ] ? (Left extends TUnion<infer Types extends TSchema[]> ? TFromUnionKeyVariants<Right, Type, Result & TFromUnionKeyVariants<Types, Type>> : Left extends TLiteral<string> ? TFromUnionKeyVariants<Right, Type, Result & TFromUnionKeyLiteralString<Left, Type>> : Left extends TLiteral<number> ? TFromUnionKeyVariants<Right, Type, Result & TFromUnionKeyLiteralNumber<Left, Type>> : {}) : Result;
894
- export type TFromUnionKey<Key extends TSchema[], Type extends TSchema, Properties extends TProperties = TFromUnionKeyVariants<Key, Type>> = (Ensure<TObject<Evaluate<Properties>>>);
895
- export type TFromLiteralKey<Key extends TLiteralValue, Type extends TSchema> = (Ensure<TObject<{
896
- [_ in Assert<Key, PropertyKey>]: Type;
897
- }>>);
898
- export type TFromRegExpKey<_Key extends TRegExp, Type extends TSchema> = (Ensure<TRecord<TRegExp, Type>>);
899
- export type TFromStringKey<_Key extends TString, Type extends TSchema> = (Ensure<TRecord<TString, Type>>);
900
- export type TFromAnyKey<_Key extends TAny, Type extends TSchema> = (Ensure<TRecord<TAny, Type>>);
901
- export type TFromNeverKey<_Key extends TNever, Type extends TSchema> = (Ensure<TRecord<TNever, Type>>);
902
- export type TFromBooleanKey<_Key extends TBoolean, Type extends TSchema> = (Ensure<TObject<{
903
- true: Type;
904
- false: Type;
905
- }>>);
906
- export type TFromIntegerKey<_Key extends TSchema, Type extends TSchema> = (Ensure<TRecord<TNumber, Type>>);
907
- export type TFromNumberKey<_Key extends TSchema, Type extends TSchema> = (Ensure<TRecord<TNumber, Type>>);
908
- export type RecordStatic<Key extends TSchema, Type extends TSchema, P extends unknown[]> = (Evaluate<{
909
- [_ in Assert<Static<Key>, PropertyKey>]: Static<Type, P>;
910
- }>);
911
- export interface TRecord<Key extends TSchema = TSchema, Type extends TSchema = TSchema> extends TSchema {
912
- [Kind]: "Record";
913
- static: RecordStatic<Key, Type, this["params"]>;
914
- type: "object";
915
- patternProperties: {
916
- [pattern: string]: Type;
917
- };
918
- additionalProperties: TAdditionalProperties;
919
- }
920
- export type TRecordOrObject<Key extends TSchema, Type extends TSchema> = (Key extends TTemplateLiteral ? TFromTemplateLiteralKey<Key, Type> : Key extends TEnum<infer Enum extends TEnumRecord> ? TFromEnumKey<Enum, Type> : Key extends TUnion<infer Types extends TSchema[]> ? TFromUnionKey<Types, Type> : Key extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteralKey<Value, Type> : Key extends TBoolean ? TFromBooleanKey<Key, Type> : Key extends TInteger ? TFromIntegerKey<Key, Type> : Key extends TNumber ? TFromNumberKey<Key, Type> : Key extends TRegExp ? TFromRegExpKey<Key, Type> : Key extends TString ? TFromStringKey<Key, Type> : Key extends TAny ? TFromAnyKey<Key, Type> : Key extends TNever ? TFromNeverKey<Key, Type> : TNever);
921
- type TFromComputed$3<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<"Required", [
922
- TComputed<Target, Parameters>
923
- ]>>;
924
- type TFromRef$3<Ref extends string> = Ensure<TComputed<"Required", [
925
- TRef<Ref>
926
- ]>>;
927
- type TFromProperties$11<Properties extends TProperties> = Evaluate<{
928
- [K in keyof Properties]: Properties[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : Properties[K] extends (TReadonly<infer S>) ? TReadonly<S> : Properties[K] extends (TOptional<infer S>) ? S : Properties[K];
929
- }>;
930
- type TFromObject$3<_Type extends TObject, Properties extends TProperties, MappedProperties extends TProperties = TFromProperties$11<Properties>, Result extends TSchema = TObject<MappedProperties>> = Result;
931
- type TFromRest$5<Types extends TSchema[], Result extends TSchema[] = [
932
- ]> = (Types extends [
933
- infer L extends TSchema,
934
- ...infer R extends TSchema[]
935
- ] ? TFromRest$5<R, [
936
- ...Result,
937
- TRequired<L>
938
- ]> : Result);
939
- export type TRequired<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TRequired<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed$3<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef$3<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest$5<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest$5<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$3<TObject, Properties> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
940
- type TFromProperties$12<P extends TProperties> = ({
941
- [K2 in keyof P]: TRequired<P[K2]>;
942
- });
943
- type TFromMappedResult$8<R extends TMappedResult> = (Evaluate<TFromProperties$12<R["properties"]>>);
944
- export type TRequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult$8<R>> = (Ensure<TMappedResult<P>>);
945
- declare class TransformDecodeBuilder<T extends TSchema> {
946
- private readonly schema;
947
- constructor(schema: T);
948
- Decode<U extends unknown, D extends TransformFunction<StaticDecode<T>, U>>(decode: D): TransformEncodeBuilder<T, D>;
949
- }
950
- declare class TransformEncodeBuilder<T extends TSchema, D extends TransformFunction> {
951
- private readonly schema;
952
- private readonly decode;
953
- constructor(schema: T, decode: D);
954
- private EncodeTransform;
955
- private EncodeSchema;
956
- Encode<E extends TransformFunction<ReturnType<D>, StaticDecode<T>>>(encode: E): TTransform<T, ReturnType<D>>;
957
- }
958
- export type TransformStatic<T extends TSchema, P extends unknown[] = [
959
- ]> = T extends TTransform<infer _, infer S> ? S : Static<T, P>;
960
- export type TransformFunction<T = any, U = any> = (value: T) => U;
961
- export interface TransformOptions<I extends TSchema = TSchema, O extends unknown = unknown> {
962
- Decode: TransformFunction<StaticDecode<I>, O>;
963
- Encode: TransformFunction<O, StaticDecode<I>>;
964
- }
965
- export interface TTransform<I extends TSchema = TSchema, O extends unknown = unknown> extends TSchema {
966
- static: TransformStatic<I, this["params"]>;
967
- [TransformKind]: TransformOptions<I, O>;
968
- [key: string]: any;
969
- }
970
- export type TDereferenceParameters<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = [
971
- ]> = (Types extends [
972
- infer Left extends TSchema,
973
- ...infer Right extends TSchema[]
974
- ] ? Left extends TRef<infer Key extends string> ? TDereferenceParameters<ModuleProperties, Right, [
975
- ...Result,
976
- TDereference<ModuleProperties, Key>
977
- ]> : TDereferenceParameters<ModuleProperties, Right, [
978
- ...Result,
979
- TFromType<ModuleProperties, Left>
980
- ]> : Result);
981
- export type TDereference<ModuleProperties extends TProperties, Ref extends string, Result extends TSchema = (Ref extends keyof ModuleProperties ? ModuleProperties[Ref] extends TRef<infer Ref2 extends string> ? TDereference<ModuleProperties, Ref2> : TFromType<ModuleProperties, ModuleProperties[Ref]> : TNever)> = Result;
982
- export type TFromAwaited<Parameters extends TSchema[]> = (Parameters extends [
983
- infer T0 extends TSchema
984
- ] ? TAwaited<T0> : never);
985
- export type TFromIndex<Parameters extends TSchema[]> = (Parameters extends [
986
- infer T0 extends TSchema,
987
- infer T1 extends TSchema
988
- ] ? TIndex<T0, TIndexPropertyKeys<T1>> extends infer Result extends TSchema ? Result : never : never);
989
- export type TFromKeyOf<Parameters extends TSchema[]> = (Parameters extends [
990
- infer T0 extends TSchema
991
- ] ? TKeyOf<T0> : never);
992
- export type TFromPartial<Parameters extends TSchema[]> = (Parameters extends [
993
- infer T0 extends TSchema
994
- ] ? TPartial<T0> : never);
995
- export type TFromOmit<Parameters extends TSchema[]> = (Parameters extends [
996
- infer T0 extends TSchema,
997
- infer T1 extends TSchema
998
- ] ? TOmit<T0, T1> : never);
999
- export type TFromPick<Parameters extends TSchema[]> = (Parameters extends [
1000
- infer T0 extends TSchema,
1001
- infer T1 extends TSchema
1002
- ] ? TPick<T0, T1> : never);
1003
- export type TFromRequired<Parameters extends TSchema[]> = (Parameters extends [
1004
- infer T0 extends TSchema
1005
- ] ? TRequired<T0> : never);
1006
- type TFromComputed$4<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] = TDereferenceParameters<ModuleProperties, Parameters>> = (Target extends "Awaited" ? TFromAwaited<Dereferenced> : Target extends "Index" ? TFromIndex<Dereferenced> : Target extends "KeyOf" ? TFromKeyOf<Dereferenced> : Target extends "Partial" ? TFromPartial<Dereferenced> : Target extends "Omit" ? TFromOmit<Dereferenced> : Target extends "Pick" ? TFromPick<Dereferenced> : Target extends "Required" ? TFromRequired<Dereferenced> : TNever);
1007
- type TFromArray$2<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<TArray<TFromType<ModuleProperties, Type>>>);
1008
- export type TFromAsyncIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TAsyncIterator<TFromType<ModuleProperties, Type>>);
1009
- export type TFromConstructor<ModuleProperties extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema> = (TConstructor<TFromTypes<ModuleProperties, Parameters>, TFromType<ModuleProperties, InstanceType>>);
1010
- export type TFromFunction<ModuleProperties extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema> = Ensure<Ensure<TFunction<TFromTypes<ModuleProperties, Parameters>, TFromType<ModuleProperties, ReturnType>>>>;
1011
- type TFromIntersect$4<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TIntersectEvaluated<TFromTypes<ModuleProperties, Types>>>);
1012
- export type TFromIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TIterator<TFromType<ModuleProperties, Type>>);
1013
- type TFromObject$4<ModuleProperties extends TProperties, Properties extends TProperties> = Ensure<TObject<Evaluate<{
1014
- [Key in keyof Properties]: TFromType<ModuleProperties, Properties[Key]>;
1015
- }>>>;
1016
- export type TFromRecord<ModuleProperties extends TProperties, Key extends TSchema, Value extends TSchema, Result extends TSchema = TRecordOrObject<Key, TFromType<ModuleProperties, Value>>> = Result;
1017
- export type TFromTransform<ModuleProperties extends TProperties, Input extends TSchema, Output extends unknown, Result extends TSchema = Input extends TRef<infer Key extends string> ? TTransform<TDereference<ModuleProperties, Key>, Output> : TTransform<Input, Output>> = Result;
1018
- type TFromTuple$2<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TTuple<TFromTypes<ModuleProperties, Types>>>);
1019
- type TFromUnion$5<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TUnionEvaluated<TFromTypes<ModuleProperties, Types>>>);
1020
- export type TFromTypes<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = [
1021
- ]> = (Types extends [
1022
- infer Left extends TSchema,
1023
- ...infer Right extends TSchema[]
1024
- ] ? TFromTypes<ModuleProperties, Right, [
1025
- ...Result,
1026
- TFromType<ModuleProperties, Left>
1027
- ]> : Result);
1028
- export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TFromType<ModuleProperties, Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TFromType<ModuleProperties, Type>> : Type extends TTransform<infer Input extends TSchema, infer Output extends unknown> ? TFromTransform<ModuleProperties, Input, Output> : Type extends TArray<infer Type extends TSchema> ? TFromArray$2<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator<ModuleProperties, Type> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed$4<ModuleProperties, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$4<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$4<ModuleProperties, Properties> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TFromRecord<ModuleProperties, Key, Value> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$2<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Type : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$5<ModuleProperties, Types> : Type);
1029
- export type TComputeType<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TFromType<ModuleProperties, ModuleProperties[Key]> : TNever);
1030
- export type TComputeModuleProperties<ModuleProperties extends TProperties> = Evaluate<{
1031
- [Key in keyof ModuleProperties]: TComputeType<ModuleProperties, Key>;
1032
- }>;
1033
- export type TInferArray<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<Array<TInfer<ModuleProperties, Type>>>);
1034
- export type TInferAsyncIterator<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<AsyncIterableIterator<TInfer<ModuleProperties, Type>>>);
1035
- export type TInferConstructor<ModuleProperties extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema> = Ensure<new (...args: TInferTuple<ModuleProperties, Parameters>) => TInfer<ModuleProperties, InstanceType>>;
1036
- export type TInferFunction<ModuleProperties extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema> = Ensure<(...args: TInferTuple<ModuleProperties, Parameters>) => TInfer<ModuleProperties, ReturnType>>;
1037
- export type TInferIterator<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<IterableIterator<TInfer<ModuleProperties, Type>>>);
1038
- export type TInferIntersect<ModuleProperties extends TProperties, Types extends TSchema[], Result extends unknown = unknown> = (Types extends [
1039
- infer Left extends TSchema,
1040
- ...infer Right extends TSchema[]
1041
- ] ? TInferIntersect<ModuleProperties, Right, Result & TInfer<ModuleProperties, Left>> : Result);
1042
- export type ReadonlyOptionalPropertyKeys<Properties extends TProperties> = {
1043
- [Key in keyof Properties]: Properties[Key] extends TReadonly<TSchema> ? (Properties[Key] extends TOptional<Properties[Key]> ? Key : never) : never;
1044
- }[keyof Properties];
1045
- export type ReadonlyPropertyKeys<Source extends TProperties> = {
1046
- [Key in keyof Source]: Source[Key] extends TReadonly<TSchema> ? (Source[Key] extends TOptional<Source[Key]> ? never : Key) : never;
1047
- }[keyof Source];
1048
- export type OptionalPropertyKeys<Source extends TProperties> = {
1049
- [Key in keyof Source]: Source[Key] extends TOptional<TSchema> ? (Source[Key] extends TReadonly<Source[Key]> ? never : Key) : never;
1050
- }[keyof Source];
1051
- export type RequiredPropertyKeys<Source extends TProperties> = keyof Omit<Source, ReadonlyOptionalPropertyKeys<Source> | ReadonlyPropertyKeys<Source> | OptionalPropertyKeys<Source>>;
1052
- export type InferPropertiesWithModifiers<Properties extends TProperties, Source extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<Source, ReadonlyOptionalPropertyKeys<Properties>>>> & Readonly<Pick<Source, ReadonlyPropertyKeys<Properties>>> & Partial<Pick<Source, OptionalPropertyKeys<Properties>>> & Required<Pick<Source, RequiredPropertyKeys<Properties>>>)>;
1053
- export type InferProperties<ModuleProperties extends TProperties, Properties extends TProperties> = InferPropertiesWithModifiers<Properties, {
1054
- [K in keyof Properties]: TInfer<ModuleProperties, Properties[K]>;
1055
- }>;
1056
- export type TInferObject<ModuleProperties extends TProperties, Properties extends TProperties> = (InferProperties<ModuleProperties, Properties>);
1057
- export type TInferTuple<ModuleProperties extends TProperties, Types extends TSchema[], Result extends unknown[] = [
1058
- ]> = (Types extends [
1059
- infer L extends TSchema,
1060
- ...infer R extends TSchema[]
1061
- ] ? TInferTuple<ModuleProperties, R, [
1062
- ...Result,
1063
- TInfer<ModuleProperties, L>
1064
- ]> : Result);
1065
- export type TInferRecord<ModuleProperties extends TProperties, Key extends TSchema, Type extends TSchema, InferredKey extends PropertyKey = TInfer<ModuleProperties, Key> extends infer Key extends PropertyKey ? Key : never, InferedType extends unknown = TInfer<ModuleProperties, Type>> = Ensure<{
1066
- [_ in InferredKey]: InferedType;
1067
- }>;
1068
- export type TInferRef<ModuleProperties extends TProperties, Ref extends string> = (Ref extends keyof ModuleProperties ? TInfer<ModuleProperties, ModuleProperties[Ref]> : unknown);
1069
- export type TInferUnion<ModuleProperties extends TProperties, Types extends TSchema[], Result extends unknown = never> = (Types extends [
1070
- infer L extends TSchema,
1071
- ...infer R extends TSchema[]
1072
- ] ? TInferUnion<ModuleProperties, R, Result | TInfer<ModuleProperties, L>> : Result);
1073
- export type TInfer<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TInferArray<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TInferAsyncIterator<ModuleProperties, Type> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TInferConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TInferFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TInferIntersect<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TInferIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TInferObject<ModuleProperties, Properties> : Type extends TRecord<infer Key extends TSchema, infer Type extends TSchema> ? TInferRecord<ModuleProperties, Key, Type> : Type extends TRef<infer Ref extends string> ? TInferRef<ModuleProperties, Ref> : Type extends TTuple<infer Types extends TSchema[]> ? TInferTuple<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Static<Type> : Type extends TUnion<infer Types extends TSchema[]> ? TInferUnion<ModuleProperties, Types> : Type extends TRecursive<infer Schema extends TSchema> ? TInfer<ModuleProperties, Schema> : Static<Type>);
1074
- /** Inference Path for Imports. This type is used to compute TImport `static` */
1075
- export type TInferFromModuleKey<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TInfer<ModuleProperties, ModuleProperties[Key]> : never);
1076
- export interface TImport<ModuleProperties extends TProperties = {}, Key extends keyof ModuleProperties = keyof ModuleProperties> extends TSchema {
1077
- [Kind]: "Import";
1078
- static: TInferFromModuleKey<ModuleProperties, Key>;
1079
- $defs: ModuleProperties;
1080
- $ref: Key;
1081
- }
1082
- declare class TModule<ModuleProperties extends TProperties, ComputedModuleProperties extends TProperties = TComputeModuleProperties<ModuleProperties>> {
1083
- private readonly $defs;
1084
- constructor($defs: ModuleProperties);
1085
- /** `[Json]` Imports a Type by Key. */
1086
- Import<Key extends keyof ComputedModuleProperties>(key: Key, options?: SchemaOptions): TImport<ComputedModuleProperties, Key>;
1087
- private WithIdentifiers;
1088
- }
1089
- export interface TNot<T extends TSchema = TSchema> extends TSchema {
1090
- [Kind]: "Not";
1091
- static: T extends TNot<infer U> ? Static<U> : unknown;
1092
- not: T;
1093
- }
1094
- export type TDecodeImport<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TDecodeType<ModuleProperties[Key]> extends infer Type extends TSchema ? Type extends TRef<infer Ref extends string> ? TDecodeImport<ModuleProperties, Ref> : Type : TNever : TNever);
1095
- export type TDecodeProperties<Properties extends TProperties> = {
1096
- [Key in keyof Properties]: TDecodeType<Properties[Key]>;
1097
- };
1098
- export type TDecodeTypes<Types extends TSchema[], Result extends TSchema[] = [
1099
- ]> = (Types extends [
1100
- infer Left extends TSchema,
1101
- ...infer Right extends TSchema[]
1102
- ] ? TDecodeTypes<Right, [
1103
- ...Result,
1104
- TDecodeType<Left>
1105
- ]> : Result);
1106
- export type TDecodeType<Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TDecodeType<Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TDecodeType<Type>> : Type extends TTransform<infer _Input extends TSchema, infer Output> ? TUnsafe<Output> : Type extends TArray<infer Type extends TSchema> ? TArray<TDecodeType<Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TDecodeType<Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TDecodeTypes<Parameters>, TDecodeType<InstanceType>> : Type extends TEnum<infer Values> ? TEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TDecodeTypes<Parameters>, TDecodeType<ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TDecodeTypes<Types>> : Type extends TImport<infer ModuleProperties extends TProperties, infer Key> ? TDecodeImport<ModuleProperties, Key> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TDecodeType<Type>> : Type extends TNot<infer Type extends TSchema> ? TNot<TDecodeType<Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<Evaluate<TDecodeProperties<Properties>>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TDecodeType<Type>> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TRecord<Key, TDecodeType<Value>> : Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TDecodeType<Type>> : Type extends TRef<infer Ref extends string> ? TRef<Ref> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TDecodeTypes<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TDecodeTypes<Types>> : Type);
1107
- export type StaticDecodeIsAny<Type> = boolean extends (Type extends TSchema ? true : false) ? true : false;
1108
- /** Creates an decoded static type from a TypeBox type */
1109
- export type StaticDecode<Type extends TSchema, Params extends unknown[] = [
1110
- ], Result = StaticDecodeIsAny<Type> extends true ? unknown : Static<TDecodeType<Type>, Params>> = Result;
1111
- /** Creates a static type from a TypeBox type */
1112
- export type Static<Type extends TSchema, Params extends unknown[] = [
1113
- ], Result = (Type & {
1114
- params: Params;
1115
- })["static"]> = Result;
1116
- type ReadonlyOptionalPropertyKeys$1<T extends TProperties> = {
1117
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
1118
- }[keyof T];
1119
- type ReadonlyPropertyKeys$1<T extends TProperties> = {
1120
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
1121
- }[keyof T];
1122
- type OptionalPropertyKeys$1<T extends TProperties> = {
1123
- [K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
1124
- }[keyof T];
1125
- type RequiredPropertyKeys$1<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys$1<T> | ReadonlyPropertyKeys$1<T> | OptionalPropertyKeys$1<T>>;
1126
- export type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys$1<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys$1<T>>> & Partial<Pick<R, OptionalPropertyKeys$1<T>>> & Required<Pick<R, RequiredPropertyKeys$1<T>>>)>;
1127
- export type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
1128
- [K in keyof T]: Static<T[K], P>;
1129
- }>;
1130
- export type TPropertyKey = string | number;
1131
- export type TProperties = Record<TPropertyKey, TSchema>;
1132
- export type TIsLiteralString<Type extends string> = ([
1133
- Type
1134
- ] extends [
1135
- string
1136
- ] ? [
1137
- string
1138
- ] extends [
1139
- Type
1140
- ] ? false : true : false);
1141
- export type IsRequiredArrayLiteralConstant<RequiredTuple extends string[]> = (RequiredTuple extends [
1142
- infer Left extends string,
1143
- ...infer _ extends string[]
1144
- ] ? TIsLiteralString<Left> : false);
1145
- export type TRequiredArray<Properties extends TProperties, RequiredProperties extends TProperties = {
1146
- [Key in keyof Properties as Properties[Key] extends TOptional<Properties[Key]> ? never : Key]: Properties[Key];
1147
- }, RequiredUnion extends string = Extract<keyof RequiredProperties, string>, RequiredTuple extends string[] = UnionToTuple<RequiredUnion>, Result extends string[] | undefined = (IsRequiredArrayLiteralConstant<RequiredTuple> extends true ? RequiredTuple : string[] | undefined)> = Result;
1148
- export type TAdditionalProperties = undefined | TSchema | boolean;
1149
- export interface ObjectOptions extends SchemaOptions {
1150
- /** Additional property constraints for this object */
1151
- additionalProperties?: TAdditionalProperties;
1152
- /** The minimum number of properties allowed on this object */
1153
- minProperties?: number;
1154
- /** The maximum number of properties allowed on this object */
1155
- maxProperties?: number;
1156
- }
1157
- export interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
1158
- [Kind]: "Object";
1159
- static: ObjectStatic<T, this["params"]>;
1160
- additionalProperties?: TAdditionalProperties;
1161
- type: "object";
1162
- properties: T;
1163
- required: TRequiredArray<T>;
1164
- }
1165
- export type TupleToUnion<T extends any[]> = {
1166
- [K in keyof T]: T[K];
1167
- }[number];
1168
- export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
1169
- export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
1170
- export type UnionToTuple<U, Acc extends unknown[] = [
1171
- ], R = UnionLast<U>> = [
1172
- U
1173
- ] extends [
1174
- never
1175
- ] ? Acc : UnionToTuple<Exclude<U, R>, [
1176
- Extract<U, R>,
1177
- ...Acc
1178
- ]>;
1179
- export type Trim<T> = T extends `${" "}${infer U}` ? Trim<U> : T extends `${infer U}${" "}` ? Trim<U> : T;
1180
- export type Assert<T, E> = T extends E ? T : never;
1181
- export type Evaluate<T> = T extends infer O ? {
1182
- [K in keyof O]: O[K];
1183
- } : never;
1184
- export type Ensure<T> = T extends infer U ? U : never;
1185
- export type EmptyString = "";
1186
- export type ZeroString = "0";
1187
- export type IncrementBase = {
1188
- m: "9";
1189
- t: "01";
1190
- "0": "1";
1191
- "1": "2";
1192
- "2": "3";
1193
- "3": "4";
1194
- "4": "5";
1195
- "5": "6";
1196
- "6": "7";
1197
- "7": "8";
1198
- "8": "9";
1199
- "9": "0";
1200
- };
1201
- export type IncrementTake<T extends keyof IncrementBase> = IncrementBase[T];
1202
- export type IncrementStep<T extends string> = T extends IncrementBase["m"] ? IncrementBase["t"] : T extends `${infer L extends keyof IncrementBase}${infer R}` ? L extends IncrementBase["m"] ? `${IncrementTake<L>}${IncrementStep<R>}` : `${IncrementTake<L>}${R}` : never;
1203
- export type IncrementReverse<T extends string> = T extends `${infer L}${infer R}` ? `${IncrementReverse<R>}${L}` : T;
1204
- export type TIncrement<T extends string> = IncrementReverse<IncrementStep<IncrementReverse<T>>>;
1205
- export type AssertRest<T, E extends TSchema[] = TSchema[]> = T extends E ? T : [
1206
- ];
1207
- export type AssertType<T, E extends TSchema = TSchema> = T extends E ? T : TNever;
1208
- export interface ArrayOptions extends SchemaOptions {
1209
- /** The minimum number of items in this array */
1210
- minItems?: number;
1211
- /** The maximum number of items in this array */
1212
- maxItems?: number;
1213
- /** Should this schema contain unique items */
1214
- uniqueItems?: boolean;
1215
- /** A schema for which some elements should match */
1216
- contains?: TSchema;
1217
- /** A minimum number of contains schema matches */
1218
- minContains?: number;
1219
- /** A maximum number of contains schema matches */
1220
- maxContains?: number;
1221
- }
1222
- export type ArrayStatic<T extends TSchema, P extends unknown[]> = Ensure<Static<T, P>[]>;
1223
- export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
1224
- [Kind]: "Array";
1225
- static: ArrayStatic<T, this["params"]>;
1226
- type: "array";
1227
- items: T;
1228
- }
1229
- export interface DateOptions extends SchemaOptions {
1230
- /** The exclusive maximum timestamp value */
1231
- exclusiveMaximumTimestamp?: number;
1232
- /** The exclusive minimum timestamp value */
1233
- exclusiveMinimumTimestamp?: number;
1234
- /** The maximum timestamp value */
1235
- maximumTimestamp?: number;
1236
- /** The minimum timestamp value */
1237
- minimumTimestamp?: number;
1238
- /** The multiple of timestamp value */
1239
- multipleOfTimestamp?: number;
1240
- }
1241
- export interface TDate extends TSchema, DateOptions {
1242
- [Kind]: "Date";
1243
- static: Date;
1244
- type: "date";
1245
- }
1246
- export interface Uint8ArrayOptions extends SchemaOptions {
1247
- maxByteLength?: number;
1248
- minByteLength?: number;
1249
- }
1250
- export interface TUint8Array extends TSchema, Uint8ArrayOptions {
1251
- [Kind]: "Uint8Array";
1252
- static: Uint8Array;
1253
- type: "uint8array";
1254
- }
1255
- export interface TUnknown extends TSchema {
1256
- [Kind]: "Unknown";
1257
- static: unknown;
1258
- }
1259
- export interface TVoid extends TSchema {
1260
- [Kind]: "Void";
1261
- static: void;
1262
- type: "void";
1263
- }
1264
- export interface SchemaOptions {
1265
- exportable?: boolean;
1266
- "x-nrg-node-type"?: string;
1267
- "x-nrg-form"?: {
1268
- icon?: string;
1269
- typedInputTypes?: string[];
1270
- editorLanguage?: string;
1271
- toggle?: boolean;
1272
- };
1273
-
1274
- $schema?: string;
1275
- /** Id for this schema */
1276
- $id?: string;
1277
- /** Title of this schema */
1278
- title?: string;
1279
- /** Description of this schema */
1280
- description?: string;
1281
- /** Default value for this schema */
1282
- default?: any;
1283
- /** Example values matching this schema */
1284
- examples?: any;
1285
- /** Optional annotation for readOnly */
1286
- readOnly?: boolean;
1287
- /** Optional annotation for writeOnly */
1288
- writeOnly?: boolean;
1289
- [prop: string]: any;
1290
- }
1291
- export interface TKind {
1292
- [Kind]: string;
1293
- }
1294
- export interface TSchema extends TKind, SchemaOptions {
1295
- [ReadonlyKind]?: string;
1296
- [OptionalKind]?: string;
1297
- [Hint]?: string;
1298
- params: unknown[];
1299
- static: unknown;
1300
- }
1301
- export interface TArgument<Index extends number = number> extends TSchema {
1302
- [Kind]: "Argument";
1303
- static: unknown;
1304
- index: Index;
1305
- }
1306
- export type TCompositeKeys<T extends TSchema[], Acc extends PropertyKey[] = [
1307
- ]> = (T extends [
1308
- infer L extends TSchema,
1309
- ...infer R extends TSchema[]
1310
- ] ? TCompositeKeys<R, [
1311
- ...Acc,
1312
- ...TKeyOfPropertyKeys<L>
1313
- ]> : TSetDistinct<Acc>);
1314
- export type TFilterNever<T extends TSchema[], Acc extends TSchema[] = [
1315
- ]> = (T extends [
1316
- infer L extends TSchema,
1317
- ...infer R extends TSchema[]
1318
- ] ? L extends TNever ? TFilterNever<R, [
1319
- ...Acc
1320
- ]> : TFilterNever<R, [
1321
- ...Acc,
1322
- L
1323
- ]> : Acc);
1324
- export type TCompositeProperty<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = [
1325
- ]> = (T extends [
1326
- infer L extends TSchema,
1327
- ...infer R extends TSchema[]
1328
- ] ? TCompositeProperty<R, K, [
1329
- ...Acc,
1330
- ...TIndexFromPropertyKeys<L, [
1331
- K
1332
- ]>
1333
- ]> : TFilterNever<Acc>);
1334
- export type TCompositeProperties<T extends TSchema[], K extends PropertyKey[], Acc = {}> = (K extends [
1335
- infer L extends PropertyKey,
1336
- ...infer R extends PropertyKey[]
1337
- ] ? TCompositeProperties<T, R, Acc & {
1338
- [_ in L]: TIntersectEvaluated<TCompositeProperty<T, L>>;
1339
- }> : Acc);
1340
- export type TCompositeEvaluate<T extends TSchema[], K extends PropertyKey[] = TCompositeKeys<T>, P extends TProperties = Evaluate<TCompositeProperties<T, K>>, R extends TSchema = TObject<P>> = R;
1341
- export type TComposite<T extends TSchema[]> = TCompositeEvaluate<T>;
1342
- type TFromArray$3<T extends readonly unknown[]> = T extends readonly [
1343
- infer L extends unknown,
1344
- ...infer R extends unknown[]
1345
- ] ? [
1346
- FromValue<L, false>,
1347
- ...TFromArray$3<R>
1348
- ] : T;
1349
- type TFromProperties$13<T extends Record<PropertyKey, unknown>> = {
1350
- -readonly [K in keyof T]: FromValue<T[K], false> extends infer R extends TSchema ? TReadonly<R> : TReadonly<TNever>;
1351
- };
1352
- export type TConditionalReadonly<T extends TSchema, Root extends boolean> = Root extends true ? T : TReadonly<T>;
1353
- export type FromValue<T, Root extends boolean> = T extends AsyncIterableIterator<unknown> ? TConditionalReadonly<TAny, Root> : T extends IterableIterator<unknown> ? TConditionalReadonly<TAny, Root> : T extends readonly unknown[] ? TReadonly<TTuple<AssertRest<TFromArray$3<T>>>> : T extends Uint8Array ? TUint8Array : T extends Date ? TDate : T extends Record<PropertyKey, unknown> ? TConditionalReadonly<TObject<Evaluate<TFromProperties$13<T>>>, Root> : T extends Function ? TConditionalReadonly<TFunction<[
1354
- ], TUnknown>, Root> : T extends undefined ? TUndefined : T extends null ? TNull : T extends symbol ? TSymbol : T extends number ? TLiteral<T> : T extends boolean ? TLiteral<T> : T extends string ? TLiteral<T> : T extends bigint ? TBigInt : TObject<{}>;
1355
- declare function FromValue<T, Root extends boolean>(value: T, root: Root): FromValue<T, Root>;
1356
- export type TConst<T> = FromValue<T, true>;
1357
- export type TConstructorParameters<Type extends TSchema> = (Type extends TConstructor<infer Parameters extends TSchema[], infer _InstanceType extends TSchema> ? TTuple<Parameters> : TNever);
1358
- export type TExcludeFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExclude<TTemplateLiteralToUnion<L>, R>);
1359
- export type TExcludeRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
1360
- [K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? never : L[K];
1361
- }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
1362
- export type TExclude<L extends TSchema, R extends TSchema> = (L extends TUnion<infer S> ? TExcludeRest<S, R> : L extends R ? TNever : L);
1363
- type TFromProperties$14<K extends TProperties, T extends TSchema> = ({
1364
- [K2 in keyof K]: TExclude<K[K2], T>;
1365
- });
1366
- type TFromMappedResult$9<R extends TMappedResult, T extends TSchema> = (TFromProperties$14<R["properties"], T>);
1367
- export type TExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult$9<R, T>> = (TMappedResult<P>);
1368
- type TFromProperties$15<P extends TProperties, Right extends TSchema, False extends TSchema, True extends TSchema> = ({
1369
- [K2 in keyof P]: TExtends<P[K2], Right, False, True>;
1370
- });
1371
- type TFromMappedResult$10<Left extends TMappedResult, Right extends TSchema, True extends TSchema, False extends TSchema> = (TFromProperties$15<Left["properties"], Right, True, False>);
1372
- export type TExtendsFromMappedResult<Left extends TMappedResult, Right extends TSchema, True extends TSchema, False extends TSchema, P extends TProperties = TFromMappedResult$10<Left, Right, True, False>> = (TMappedResult<P>);
1373
- export type TExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = ((Static<L> extends Static<R> ? T : U) extends infer O extends TSchema ? UnionToTuple<O> extends [
1374
- infer X extends TSchema,
1375
- infer Y extends TSchema
1376
- ] ? TUnion<[
1377
- X,
1378
- Y
1379
- ]> : O : never);
1380
- export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema> = TExtendsResolve<L, R, T, F>;
1381
- type TFromPropertyKey$2<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
1382
- [_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
1383
- };
1384
- type TFromPropertyKeys$2<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema, Acc extends TProperties = {}> = (K extends [
1385
- infer LK extends PropertyKey,
1386
- ...infer RK extends PropertyKey[]
1387
- ] ? TFromPropertyKeys$2<RK, U, L, R, Acc & TFromPropertyKey$2<LK, U, L, R>> : Acc);
1388
- type TFromMappedKey$3<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (TFromPropertyKeys$2<K["keys"], U, L, R>);
1389
- export type TExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = TFromMappedKey$3<T, U, L, R>> = (TMappedResult<P>);
1390
- export type TExtractFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExtract<TTemplateLiteralToUnion<L>, R>);
1391
- export type TExtractRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
1392
- [K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? L[K] : never;
1393
- }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
1394
- export type TExtract<L extends TSchema, U extends TSchema> = (L extends TUnion<infer S> ? TExtractRest<S, U> : L extends U ? L : TNever);
1395
- type TFromProperties$16<P extends TProperties, T extends TSchema> = ({
1396
- [K2 in keyof P]: TExtract<P[K2], T>;
1397
- });
1398
- type TFromMappedResult$11<R extends TMappedResult, T extends TSchema> = (TFromProperties$16<R["properties"], T>);
1399
- export type TExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult$11<R, T>> = (TMappedResult<P>);
1400
- export type TInstanceType<Type extends TSchema, Result extends TSchema = Type extends TConstructor<infer _Parameters extends TSchema[], infer InstanceType extends TSchema> ? InstanceType : TNever> = Result;
1401
- type TFromConstructor$1<Args extends TSchema[], Parameters extends TSchema[], InstanceType extends TSchema, Result extends TConstructor = TConstructor<TFromTypes$1<Args, Parameters>, TFromType$1<Args, InstanceType>>> = Result;
1402
- type TFromFunction$1<Args extends TSchema[], Parameters extends TSchema[], ReturnType extends TSchema, Result extends TFunction = TFunction<TFromTypes$1<Args, Parameters>, TFromType$1<Args, ReturnType>>> = Result;
1403
- type TFromIntersect$5<Args extends TSchema[], Types extends TSchema[], Result extends TIntersect = TIntersect<TFromTypes$1<Args, Types>>> = Result;
1404
- type TFromUnion$6<Args extends TSchema[], Types extends TSchema[], Result extends TUnion = TUnion<TFromTypes$1<Args, Types>>> = Result;
1405
- type TFromTuple$3<Args extends TSchema[], Types extends TSchema[], Result extends TTuple = TTuple<TFromTypes$1<Args, Types>>> = Result;
1406
- type TFromArray$4<Args extends TSchema[], Type extends TSchema, Result extends TArray = TArray<TFromType$1<Args, Type>>> = Result;
1407
- type TFromAsyncIterator$1<Args extends TSchema[], Type extends TSchema, Result extends TAsyncIterator = TAsyncIterator<TFromType$1<Args, Type>>> = Result;
1408
- type TFromIterator$1<Args extends TSchema[], Type extends TSchema, Result extends TIterator = TIterator<TFromType$1<Args, Type>>> = Result;
1409
- export type TFromPromise<Args extends TSchema[], Type extends TSchema, Result extends TPromise = TPromise<TFromType$1<Args, Type>>> = Result;
1410
- type TFromObject$5<Args extends TSchema[], Properties extends TProperties, MappedProperties extends TProperties = TFromProperties$17<Args, Properties>, Result extends TSchema = TObject<MappedProperties>> = Result;
1411
- type TFromRecord$1<Args extends TSchema[], Key extends TSchema, Value extends TSchema, MappedKey extends TSchema = TFromType$1<Args, Key>, MappedValue extends TSchema = TFromType$1<Args, Value>, Result extends TSchema = TRecordOrObject<MappedKey, MappedValue>> = Result;
1412
- export type TFromArgument<Args extends TSchema[], Index extends number, Result extends TSchema = Index extends keyof Args[Index] ? Args[Index] : TUnknown> = Result;
1413
- type TFromProperty$1<Args extends TSchema[], Type extends TSchema, IsReadonly extends boolean = Type extends TReadonly<Type> ? true : false, IsOptional extends boolean = Type extends TOptional<Type> ? true : false, Mapped extends TSchema = TFromType$1<Args, Type>, Result extends TSchema = ([
1414
- IsReadonly,
1415
- IsOptional
1416
- ] extends [
1417
- true,
1418
- true
1419
- ] ? TReadonlyOptional<Mapped> : [
1420
- IsReadonly,
1421
- IsOptional
1422
- ] extends [
1423
- true,
1424
- false
1425
- ] ? TReadonly<Mapped> : [
1426
- IsReadonly,
1427
- IsOptional
1428
- ] extends [
1429
- false,
1430
- true
1431
- ] ? TOptional<Mapped> : Mapped)> = Result;
1432
- type TFromProperties$17<Args extends TSchema[], Properties extends TProperties, Result extends TProperties = {
1433
- [Key in keyof Properties]: TFromProperty$1<Args, Properties[Key]>;
1434
- }> = Result;
1435
- type TFromTypes$1<Args extends TSchema[], Types extends TSchema[], Result extends TSchema[] = [
1436
- ]> = (Types extends [
1437
- infer Left extends TSchema,
1438
- ...infer Right extends TSchema[]
1439
- ] ? TFromTypes$1<Args, Right, [
1440
- ...Result,
1441
- TFromType$1<Args, Left>
1442
- ]> : Result);
1443
- type TFromType$1<Args extends TSchema[], Type extends TSchema> = (Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor$1<Args, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction$1<Args, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect$5<Args, Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion$6<Args, Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple$3<Args, Types> : Type extends TArray<infer Type extends TSchema> ? TFromArray$4<Args, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator$1<Args, Type> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator$1<Args, Type> : Type extends TPromise<infer Type extends TSchema> ? TFromPromise<Args, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject$5<Args, Properties> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TFromRecord$1<Args, Key, Value> : Type extends TArgument<infer Index extends number> ? TFromArgument<Args, Index> : Type);
1444
- /** `[JavaScript]` Instantiates a type with the given parameters */
1445
- export type TInstantiate<Type extends TSchema, Args extends TSchema[], Result extends TSchema = TFromType$1<Args, Type>> = Result;
1446
- export type TMappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode> = {
1447
- [_ in K]: TIntrinsic<TLiteral<Assert<K, TLiteralValue>>, M>;
1448
- };
1449
- export type TMappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode, Acc extends TProperties = {}> = (K extends [
1450
- infer L extends PropertyKey,
1451
- ...infer R extends PropertyKey[]
1452
- ] ? TMappedIntrinsicPropertyKeys<R, M, Acc & TMappedIntrinsicPropertyKey<L, M>> : Acc);
1453
- export type TMappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode> = (TMappedIntrinsicPropertyKeys<K["keys"], M>);
1454
- export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = TMappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
1455
- export type IntrinsicMode = "Uppercase" | "Lowercase" | "Capitalize" | "Uncapitalize";
1456
- type TFromTemplateLiteral$1<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [
1457
- infer L extends TTemplateLiteralKind,
1458
- ...infer R extends TTemplateLiteralKind[]
1459
- ] ? [
1460
- TIntrinsic<L, M>,
1461
- ...TFromTemplateLiteral$1<R, M>
1462
- ] : T : T;
1463
- export type TFromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends "Uncapitalize" ? Uncapitalize<T> : M extends "Capitalize" ? Capitalize<T> : M extends "Uppercase" ? Uppercase<T> : M extends "Lowercase" ? Lowercase<T> : string : T);
1464
- type TFromRest$6<T extends TSchema[], M extends IntrinsicMode, Acc extends TSchema[] = [
1465
- ]> = T extends [
1466
- infer L extends TSchema,
1467
- ...infer R extends TSchema[]
1468
- ] ? TFromRest$6<R, M, [
1469
- ...Acc,
1470
- TIntrinsic<L, M>
1471
- ]> : Acc;
1472
- export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TFromTemplateLiteral$1<S, M>> : T extends TUnion<infer S> ? TUnion<TFromRest$6<S, M>> : T extends TLiteral<infer S> ? TLiteral<TFromLiteralValue<S, M>> : T;
1473
- export type TCapitalize<T extends TSchema> = TIntrinsic<T, "Capitalize">;
1474
- export type TLowercase<T extends TSchema> = TIntrinsic<T, "Lowercase">;
1475
- export type TUncapitalize<T extends TSchema> = TIntrinsic<T, "Uncapitalize">;
1476
- export type TUppercase<T extends TSchema> = TIntrinsic<T, "Uppercase">;
1477
- export type TParameters<Type extends TSchema> = (Type extends TFunction<infer Parameters extends TSchema[], infer _ReturnType extends TSchema> ? TTuple<Parameters> : TNever);
1478
- export type TRestResolve<T extends TSchema> = T extends TIntersect<infer S extends TSchema[]> ? S : T extends TUnion<infer S extends TSchema[]> ? S : T extends TTuple<infer S extends TSchema[]> ? S : [
1479
- ];
1480
- export type TRest<T extends TSchema> = TRestResolve<T>;
1481
- export type TReturnType<Type extends TSchema, Result extends TSchema = Type extends TFunction<infer _Parameters extends TSchema[], infer ReturnType extends TSchema> ? ReturnType : TNever> = Result;
1482
- declare class JsonTypeBuilder {
1483
- /** `[Json]` Creates a Readonly and Optional property */
1484
- ReadonlyOptional<Type extends TSchema>(type: Type): TReadonlyOptional<Type>;
1485
- /** `[Json]` Creates a Readonly property */
1486
- Readonly<Type extends TMappedResult, Flag extends boolean>(type: Type, enable: Flag): TReadonlyFromMappedResult<Type, Flag>;
1487
- /** `[Json]` Creates a Readonly property */
1488
- Readonly<Type extends TSchema, Flag extends boolean>(type: Type, enable: Flag): TReadonlyWithFlag<Type, Flag>;
1489
- /** `[Json]` Creates a Optional property */
1490
- Readonly<Type extends TMappedResult>(type: Type): TReadonlyFromMappedResult<Type, true>;
1491
- /** `[Json]` Creates a Readonly property */
1492
- Readonly<Type extends TSchema>(type: Type): TReadonlyWithFlag<Type, true>;
1493
- /** `[Json]` Creates a Optional property */
1494
- Optional<Type extends TMappedResult, Flag extends boolean>(type: Type, enable: Flag): TOptionalFromMappedResult<Type, Flag>;
1495
- /** `[Json]` Creates a Optional property */
1496
- Optional<Type extends TSchema, Flag extends boolean>(type: Type, enable: Flag): TOptionalWithFlag<Type, Flag>;
1497
- /** `[Json]` Creates a Optional property */
1498
- Optional<Type extends TMappedResult>(type: Type): TOptionalFromMappedResult<Type, true>;
1499
- /** `[Json]` Creates a Optional property */
1500
- Optional<Type extends TSchema>(type: Type): TOptionalWithFlag<Type, true>;
1501
- /** `[Json]` Creates an Any type */
1502
- Any(options?: SchemaOptions): TAny;
1503
- /** `[Json]` Creates an Array type */
1504
- Array<Type extends TSchema>(items: Type, options?: ArrayOptions): TArray<Type>;
1505
- /** `[Json]` Creates a Boolean type */
1506
- Boolean(options?: SchemaOptions): TBoolean;
1507
- /** `[Json]` Intrinsic function to Capitalize LiteralString types */
1508
- Capitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TCapitalize<T>;
1509
- /** `[Json]` Creates a Composite object type */
1510
- Composite<T extends TSchema[]>(schemas: [
1511
- ...T
1512
- ], options?: ObjectOptions): TComposite<T>;
1513
- /** `[JavaScript]` Creates a readonly const type from the given value. */
1514
- Const</* const (not supported in 4.0) */ T>(value: T, options?: SchemaOptions): TConst<T>;
1515
- /** `[Json]` Creates a Enum type */
1516
- Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>;
1517
- /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
1518
- Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
1519
- /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
1520
- Exclude<L extends TTemplateLiteral, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromTemplateLiteral<L, R>;
1521
- /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
1522
- Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
1523
- /** `[Json]` Creates a Conditional type */
1524
- Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
1525
- /** `[Json]` Creates a Conditional type */
1526
- Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedKey<L, R, T, F>;
1527
- /** `[Json]` Creates a Conditional type */
1528
- Extends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtends<L, R, T, F>;
1529
- /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
1530
- Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
1531
- /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
1532
- Extract<L extends TTemplateLiteral, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromTemplateLiteral<L, R>;
1533
- /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
1534
- Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
1535
- /** `[Json]` Returns an Indexed property type for the given keys */
1536
- Index<Type extends TRef, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TIndexFromComputed<Type, Key>;
1537
- /** `[Json]` Returns an Indexed property type for the given keys */
1538
- Index<Type extends TSchema, Key extends TRef>(type: Type, key: Key, options?: SchemaOptions): TIndexFromComputed<Type, Key>;
1539
- /** `[Json]` Returns an Indexed property type for the given keys */
1540
- Index<Type extends TRef, Key extends TRef>(type: Type, key: Key, options?: SchemaOptions): TIndexFromComputed<Type, Key>;
1541
- /** `[Json]` Returns an Indexed property type for the given keys */
1542
- Index<Type extends TSchema, MappedResult extends TMappedResult>(type: Type, mappedResult: MappedResult, options?: SchemaOptions): TIndexFromMappedResult<Type, MappedResult>;
1543
- /** `[Json]` Returns an Indexed property type for the given keys */
1544
- Index<Type extends TSchema, MappedKey extends TMappedKey>(type: Type, mappedKey: MappedKey, options?: SchemaOptions): TIndexFromMappedKey<Type, MappedKey>;
1545
- /** `[Json]` Returns an Indexed property type for the given keys */
1546
- Index<Type extends TSchema, Key extends TSchema, PropertyKeys extends PropertyKey[] = TIndexPropertyKeys<Key>>(T: Type, K: Key, options?: SchemaOptions): TIndex<Type, PropertyKeys>;
1547
- /** `[Json]` Returns an Indexed property type for the given keys */
1548
- Index<Type extends TSchema, PropertyKeys extends PropertyKey[]>(type: Type, propertyKeys: readonly [
1549
- ...PropertyKeys
1550
- ], options?: SchemaOptions): TIndex<Type, PropertyKeys>;
1551
- /** `[Json]` Creates an Integer type */
1552
- Integer(options?: IntegerOptions): TInteger;
1553
- /** `[Json]` Creates an Intersect type */
1554
- Intersect<Types extends TSchema[]>(types: [
1555
- ...Types
1556
- ], options?: IntersectOptions): Intersect<Types>;
1557
- /** `[Json]` Creates a KeyOf type */
1558
- KeyOf<Type extends TSchema>(type: Type, options?: SchemaOptions): TKeyOf<Type>;
1559
- /** `[Json]` Creates a Literal type */
1560
- Literal<LiteralValue extends TLiteralValue>(literalValue: LiteralValue, options?: SchemaOptions): TLiteral<LiteralValue>;
1561
- /** `[Json]` Intrinsic function to Lowercase LiteralString types */
1562
- Lowercase<Type extends TSchema>(type: Type, options?: SchemaOptions): TLowercase<Type>;
1563
- /** `[Json]` Creates a Mapped object type */
1564
- Mapped<K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>, F extends TMappedFunction<I> = TMappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;
1565
- /** `[Json]` Creates a Mapped object type */
1566
- Mapped<K extends PropertyKey[], F extends TMappedFunction<K> = TMappedFunction<K>, R extends TMapped<K, F> = TMapped<K, F>>(key: [
1567
- ...K
1568
- ], map: F, options?: ObjectOptions): R;
1569
- /** `[Json]` Creates a Type Definition Module. */
1570
- Module<Properties extends TProperties>(properties: Properties): TModule<Properties>;
1571
- /** `[Json]` Creates a Never type */
1572
- Never(options?: SchemaOptions): TNever;
1573
- /** `[Json]` Creates a Not type */
1574
- Not<T extends TSchema>(type: T, options?: SchemaOptions): TNot<T>;
1575
- /** `[Json]` Creates a Null type */
1576
- Null(options?: SchemaOptions): TNull;
1577
- /** `[Json]` Creates a Number type */
1578
- Number(options?: NumberOptions): TNumber;
1579
- /** `[Json]` Creates an Object type */
1580
- Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
1581
- /** `[Json]` Constructs a type whose keys are picked from the given type */
1582
- Omit<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [
1583
- ...Key
1584
- ], options?: SchemaOptions): TOmit<Type, Key>;
1585
- /** `[Json]` Constructs a type whose keys are picked from the given type */
1586
- Omit<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TOmit<Type, Key>;
1587
- /** `[Json]` Constructs a type where all properties are optional */
1588
- Partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
1589
- /** `[Json]` Constructs a type where all properties are optional */
1590
- Partial<Type extends TSchema>(type: Type, options?: SchemaOptions): TPartial<Type>;
1591
- /** `[Json]` Constructs a type whose keys are picked from the given type */
1592
- Pick<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [
1593
- ...Key
1594
- ], options?: SchemaOptions): TPick<Type, Key>;
1595
- /** `[Json]` Constructs a type whose keys are picked from the given type */
1596
- Pick<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TPick<Type, Key>;
1597
- /** `[Json]` Creates a Record type */
1598
- Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: ObjectOptions): TRecordOrObject<Key, Value>;
1599
- /** `[Json]` Creates a Recursive type */
1600
- Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
1601
- /** `[Json]` Creates a Ref type.*/
1602
- Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
1603
- /**
1604
- * @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass
1605
- * a `string` value for the reference (and not a schema).
1606
- *
1607
- * To adhere to the 0.34.0 signature, Ref implementations should be updated to the following.
1608
- *
1609
- * ```typescript
1610
- * // pre-0.34.0
1611
- *
1612
- * const T = Type.String({ $id: 'T' })
1613
- *
1614
- * const R = Type.Ref(T)
1615
- * ```
1616
- * should be changed to the following
1617
- *
1618
- * ```typescript
1619
- * // post-0.34.0
1620
- *
1621
- * const T = Type.String({ $id: 'T' })
1622
- *
1623
- * const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T'))
1624
- * ```
1625
- * You can also create a generic function to replicate the pre-0.34.0 signature if required
1626
- *
1627
- * ```typescript
1628
- * const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!))
1629
- * ```
1630
- */
1631
- Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>;
1632
- /** `[Json]` Constructs a type where all properties are required */
1633
- Required<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TRequiredFromMappedResult<MappedResult>;
1634
- /** `[Json]` Constructs a type where all properties are required */
1635
- Required<Type extends TSchema>(type: Type, options?: SchemaOptions): TRequired<Type>;
1636
- /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
1637
- Rest<Type extends TSchema>(type: Type): TRest<Type>;
1638
- /** `[Json]` Creates a String type */
1639
- String(options?: StringOptions): TString;
1640
- /** `[Json]` Creates a TemplateLiteral type from template dsl string */
1641
- TemplateLiteral<Syntax extends string>(syntax: Syntax, options?: SchemaOptions): TTemplateLiteralSyntax<Syntax>;
1642
- /** `[Json]` Creates a TemplateLiteral type */
1643
- TemplateLiteral<Kinds extends TTemplateLiteralKind[]>(kinds: [
1644
- ...Kinds
1645
- ], options?: SchemaOptions): TTemplateLiteral<Kinds>;
1646
- /** `[Json]` Creates a Transform type */
1647
- Transform<Type extends TSchema>(type: Type): TransformDecodeBuilder<Type>;
1648
- /** `[Json]` Creates a Tuple type */
1649
- Tuple<Types extends TSchema[]>(types: [
1650
- ...Types
1651
- ], options?: SchemaOptions): TTuple<Types>;
1652
- /** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
1653
- Uncapitalize<Type extends TSchema>(type: Type, options?: SchemaOptions): TUncapitalize<Type>;
1654
- /** `[Json]` Creates a Union type */
1655
- Union<Types extends TSchema[]>(types: [
1656
- ...Types
1657
- ], options?: SchemaOptions): Union<Types>;
1658
- /** `[Json]` Creates an Unknown type */
1659
- Unknown(options?: SchemaOptions): TUnknown;
1660
- /** `[Json]` Creates a Unsafe type that will infers as the generic argument T */
1661
- Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
1662
- /** `[Json]` Intrinsic function to Uppercase LiteralString types */
1663
- Uppercase<T extends TSchema>(schema: T, options?: SchemaOptions): TUppercase<T>;
1664
- }
1665
- declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
1666
- /** `[JavaScript]` Creates a Generic Argument Type */
1667
- Argument<Index extends number>(index: Index): TArgument<Index>;
1668
- /** `[JavaScript]` Creates a AsyncIterator type */
1669
- AsyncIterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TAsyncIterator<Type>;
1670
- /** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
1671
- Awaited<Type extends TSchema>(schema: Type, options?: SchemaOptions): TAwaited<Type>;
1672
- /** `[JavaScript]` Creates a BigInt type */
1673
- BigInt(options?: BigIntOptions): TBigInt;
1674
- /** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
1675
- ConstructorParameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TConstructorParameters<Type>;
1676
- /** `[JavaScript]` Creates a Constructor type */
1677
- Constructor<Parameters extends TSchema[], InstanceType extends TSchema>(parameters: [
1678
- ...Parameters
1679
- ], instanceType: InstanceType, options?: SchemaOptions): TConstructor<Parameters, InstanceType>;
1680
- /** `[JavaScript]` Creates a Date type */
1681
- Date(options?: DateOptions): TDate;
1682
- /** `[JavaScript]` Creates a Function type */
1683
- Function<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [
1684
- ...Parameters
1685
- ], returnType: ReturnType, options?: SchemaOptions): TFunction<Parameters, ReturnType>;
1686
- /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
1687
- InstanceType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TInstanceType<Type>;
1688
- /** `[JavaScript]` Instantiates a type with the given parameters */
1689
- Instantiate<Type extends TSchema, Parameters extends TSchema[]>(schema: Type, parameters: [
1690
- ...Parameters
1691
- ]): TInstantiate<Type, Parameters>;
1692
- /** `[JavaScript]` Creates an Iterator type */
1693
- Iterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TIterator<Type>;
1694
- /** `[JavaScript]` Extracts the Parameters from the given Function type */
1695
- Parameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TParameters<Type>;
1696
- /** `[JavaScript]` Creates a Promise type */
1697
- Promise<Type extends TSchema>(item: Type, options?: SchemaOptions): TPromise<Type>;
1698
- /** `[JavaScript]` Creates a RegExp type */
1699
- RegExp(pattern: string, options?: RegExpOptions): TRegExp;
1700
- /** `[JavaScript]` Creates a RegExp type */
1701
- RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
1702
- /** `[JavaScript]` Extracts the ReturnType from the given Function type */
1703
- ReturnType<Type extends TSchema>(type: Type, options?: SchemaOptions): TReturnType<Type>;
1704
- /** `[JavaScript]` Creates a Symbol type */
1705
- Symbol(options?: SchemaOptions): TSymbol;
1706
- /** `[JavaScript]` Creates a Undefined type */
1707
- Undefined(options?: SchemaOptions): TUndefined;
1708
- /** `[JavaScript]` Creates a Uint8Array type */
1709
- Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
1710
- /** `[JavaScript]` Creates a Void type */
1711
- Void(options?: SchemaOptions): TVoid;
1712
- }
1713
9
  declare const TYPED_INPUT_TYPES: readonly [
1714
10
  "msg",
1715
11
  "flow",
@@ -1726,7 +22,7 @@ declare const TYPED_INPUT_TYPES: readonly [
1726
22
  "node",
1727
23
  "cred"
1728
24
  ];
1729
- export interface NodeRedRuntimeSettings {
25
+ interface NodeRedRuntimeSettings {
1730
26
  userDir?: string;
1731
27
  nodesDir?: string | string[];
1732
28
  flowFile?: string;
@@ -1917,7 +213,7 @@ export interface NodeRedRuntimeSettings {
1917
213
  apiMaxLength?: string;
1918
214
  [key: string]: unknown;
1919
215
  }
1920
- export interface NodeRedLog {
216
+ interface NodeRedLog {
1921
217
  info(msg: any): void;
1922
218
  warn(msg: any): void;
1923
219
  error(msg: any, error?: any): void;
@@ -1940,7 +236,7 @@ export interface NodeRedLog {
1940
236
  AUDIT: 98;
1941
237
  METRIC: 99;
1942
238
  }
1943
- export interface NodeRedNode {
239
+ interface NodeRedNode {
1944
240
  id: string;
1945
241
  type: string;
1946
242
  name?: string;
@@ -1950,7 +246,7 @@ export interface NodeRedNode {
1950
246
  g?: string;
1951
247
  wires: string[][];
1952
248
  credentials: any;
1953
- _node?: any;
249
+ _node?: INode;
1954
250
  send(msg: any): void;
1955
251
  receive(msg: any): void;
1956
252
  status(status: string | {
@@ -1966,14 +262,14 @@ export interface NodeRedNode {
1966
262
  context(): NodeRedNodeContext;
1967
263
  [key: string]: any;
1968
264
  }
1969
- export interface NodeRedNodeContext extends NodeRedContextStore {
265
+ interface NodeRedNodeContext extends NodeRedContextStore {
1970
266
  flow: NodeRedContextStore;
1971
267
  global: NodeRedContextStore;
1972
268
  }
1973
- export interface NodeRedNodes {
269
+ interface NodeRedNodes {
1974
270
  registerType(type: string, constructor: any, opts?: any): void;
1975
271
  getNode(id: string): (NodeRedNode & {
1976
- _node?: any;
272
+ _node?: INode;
1977
273
  }) | undefined;
1978
274
  createNode(node: NodeRedNode, config: Record<string, any>): void;
1979
275
  getCredentials(id: string): Record<string, any> | undefined;
@@ -1987,7 +283,7 @@ export interface NodeRedNodes {
1987
283
  enableNode(id: string): Promise<any>;
1988
284
  disableNode(id: string): Promise<any>;
1989
285
  }
1990
- export interface NodeRedUtil {
286
+ interface NodeRedUtil {
1991
287
  evaluateNodeProperty(value: any, type: string, node: any, msg: Record<string, any> | undefined, callback: (err: Error | null, result: any) => void): void;
1992
288
  generateId(): string;
1993
289
  cloneMessage<T = any>(msg: T): T;
@@ -2009,14 +305,14 @@ export interface NodeRedUtil {
2009
305
  getSetting(node: any, name: string, flow?: any): any;
2010
306
  encodeObject(obj: any): any;
2011
307
  }
2012
- export interface NodeRedHooks {
308
+ interface NodeRedHooks {
2013
309
  add(hookId: string, callback: (event: any) => void | Promise<void>): void;
2014
310
  remove(hookId: string): void;
2015
311
  trigger(hookId: string, event: any, callback?: (err?: Error) => void): void | Promise<void>;
2016
312
  has(hookId: string): boolean;
2017
313
  clear(): void;
2018
314
  }
2019
- export type NodeRedExpressApp = Express;
315
+ type NodeRedExpressApp = Express;
2020
316
  export interface RED {
2021
317
  /** Internationalization function */
2022
318
  _(key: string, substitutions?: Record<string, string>): string;
@@ -2039,7 +335,7 @@ export interface RED {
2039
335
  /** Node-RED version string */
2040
336
  version(): string;
2041
337
  }
2042
- export interface NodeRedContextStore {
338
+ interface NodeRedContextStore {
2043
339
  get(key: string, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
2044
340
  set(key: string, value: any, store: string | undefined, callback: (err: Error | null) => void): void;
2045
341
  keys(store: string | undefined, callback: (err: Error | null, keys: string[]) => void): void;
@@ -2057,7 +353,8 @@ declare class TypedInput<T = unknown> {
2057
353
  get value(): unknown;
2058
354
  resolve(msg?: Record<string, any>): Promise<T>;
2059
355
  }
2060
- export interface NrgSchemaExtensions {
356
+ interface NrgSchemaExtensions {
357
+ format?: "node-id" | "flow-id" | "topic-path" | (string & {});
2061
358
  exportable?: boolean;
2062
359
  "x-nrg-node-type"?: string;
2063
360
  "x-nrg-form"?: {
@@ -2067,91 +364,185 @@ export interface NrgSchemaExtensions {
2067
364
  toggle?: boolean;
2068
365
  };
2069
366
  }
367
+ /** Schema type representing a reference to a config node. Resolves to the node instance at runtime. */
2070
368
  export interface TNodeRef<T = any> extends TSchema {
2071
369
  [Kind]: "NodeRef";
2072
370
  static: T;
2073
371
  type: "string";
372
+ format: "node-id";
2074
373
  "x-nrg-node-type"?: string;
2075
374
  }
2076
- export type ResolveNodeRefs<T> = T extends TypedInput<any> ? T : T extends (...args: any[]) => any ? T : T extends Array<infer Item> ? ResolveNodeRefs<Item>[] : T extends object ? {
375
+ type ResolveNodeRefs<T> = T extends TypedInput<any> ? T : T extends (...args: any[]) => any ? T : T extends Array<infer Item> ? ResolveNodeRefs<Item>[] : T extends object ? {
2077
376
  [K in keyof T]: ResolveNodeRefs<T[K]>;
2078
377
  } : T;
378
+ /** Infers the TypeScript type from a schema, resolving node references to their instance types. */
2079
379
  export type Infer<T extends TSchema> = ResolveNodeRefs<Static<T>>;
2080
- export type TypedInputType = (typeof TYPED_INPUT_TYPES)[number];
380
+ type TypedInputType = (typeof TYPED_INPUT_TYPES)[number];
381
+ /** Schema type representing a Node-RED TypedInput (value + type pair). */
2081
382
  export interface TTypedInput<T = unknown> extends TSchema {
2082
383
  [Kind]: "TypedInput";
2083
384
  static: TypedInput<T>;
2084
385
  }
2085
- export interface NrgSchemaOptions extends SchemaOptions, NrgSchemaExtensions {
386
+ interface NrgSchemaOptions extends SchemaOptions, NrgSchemaExtensions {
2086
387
  }
388
+ /** An NRG object schema created by {@link defineSchema}. */
2087
389
  export type Schema<T extends TProperties = TProperties> = TObject<T>;
2088
- declare const NodeConfigSchema: TObject<{
2089
- id: TString;
2090
- type: TString;
2091
- name: TString;
2092
- z: TOptional<TString>;
390
+ type InferOr<T, Fallback> = T extends TSchema ? Infer<T> : Fallback;
391
+ type InferOutputs<T> = T extends readonly TSchema[] ? {
392
+ [K in keyof T]: T[K] extends TSchema ? Infer<T[K]> : never;
393
+ } : T extends TSchema ? Infer<T> : any;
394
+ declare const NodeConfigSchema: import("@sinclair/typebox").TObject<{
395
+ id: import("@sinclair/typebox").TString;
396
+ type: import("@sinclair/typebox").TString;
397
+ name: import("@sinclair/typebox").TString;
398
+ z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
2093
399
  }>;
2094
- declare const ConfigNodeConfigSchema: TObject<{
2095
- _users: TArray<TString>;
2096
- id: TString;
2097
- type: TString;
2098
- name: TString;
2099
- z: TOptional<TString>;
400
+ declare const ConfigNodeConfigSchema: import("@sinclair/typebox").TObject<{
401
+ _users: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
402
+ id: import("@sinclair/typebox").TString;
403
+ type: import("@sinclair/typebox").TString;
404
+ name: import("@sinclair/typebox").TString;
405
+ z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
2100
406
  }>;
2101
- declare const IONodeConfigSchema: TObject<{
2102
- wires: TArray<TArray<TString>>;
2103
- x: TNumber;
2104
- y: TNumber;
2105
- g: TOptional<TString>;
2106
- id: TString;
2107
- type: TString;
2108
- name: TString;
2109
- z: TOptional<TString>;
407
+ declare const IONodeConfigSchema: import("@sinclair/typebox").TObject<{
408
+ wires: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
409
+ x: import("@sinclair/typebox").TNumber;
410
+ y: import("@sinclair/typebox").TNumber;
411
+ g: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
412
+ id: import("@sinclair/typebox").TString;
413
+ type: import("@sinclair/typebox").TString;
414
+ name: import("@sinclair/typebox").TString;
415
+ z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
2110
416
  }>;
2111
417
  declare function NodeRef<T extends new (...args: any[]) => any>(nodeClass: T, options?: NrgSchemaOptions): TNodeRef<InstanceType<T>>;
2112
418
  declare function TypedInput$1<T = unknown>(options?: NrgSchemaOptions): TTypedInput<T>;
2113
- export declare const SchemaType: JavaScriptTypeBuilder & {
419
+ /**
420
+ * Extended TypeBox type builder with NRG-specific schema types.
421
+ * Includes all standard TypeBox types plus {@link NodeRef} and {@link TypedInput}.
422
+ */
423
+ export declare const SchemaType: import("@sinclair/typebox").JavaScriptTypeBuilder & {
2114
424
  NodeRef: typeof NodeRef;
2115
425
  TypedInput: typeof TypedInput$1;
2116
426
  };
427
+ /**
428
+ * Creates a validated object schema from a set of properties. Automatically
429
+ * marks non-JSON types (e.g., Function) as non-validatable.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * const ConfigsSchema = defineSchema({
434
+ * name: SchemaType.String({ default: "" }),
435
+ * timeout: SchemaType.Number({ default: 5000 }),
436
+ * }, { $id: "my-node:configs" });
437
+ * ```
438
+ */
2117
439
  export declare function defineSchema<T extends TProperties>(properties: T, options?: ObjectOptions & {
2118
440
  $id?: string;
2119
441
  }): Schema<T>;
2120
- export type NodeContextScope = "node" | "flow" | "global";
2121
- export interface NodeContextStore {
442
+ type NodeContextScope = "node" | "flow" | "global";
443
+ interface NodeContextStore {
2122
444
  get<T = any>(key: string): Promise<T>;
2123
445
  set<T = any>(key: string, value: T): Promise<void>;
2124
446
  keys(): Promise<string[]>;
2125
447
  }
2126
- export type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
2127
- export type NodeCredentials<TCredentials = any> = TCredentials;
2128
- export type IONodeContextScope = NodeContextScope;
2129
- export type IONodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof IONodeConfigSchema> & {
2130
- validateInput?: boolean;
2131
- validateOutput?: boolean;
2132
- };
2133
- export type IONodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
2134
- export type IONodeStatus = {
2135
- fill?: "red" | "green";
2136
- shape?: "dot" | "string";
2137
- text?: string;
2138
- } | string;
2139
- export type IONodeContext = {
2140
- (scope: IONodeContextScope, store?: string): NodeContextStore;
2141
- node: NodeContextStore;
2142
- flow: NodeContextStore;
2143
- global: NodeContextStore;
2144
- };
2145
- export type HexColor = `#${string}`;
2146
- export type ConfigNodeContextScope = Exclude<NodeContextScope, "flow">;
2147
- export type ConfigNodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof ConfigNodeConfigSchema>;
2148
- export type ConfigNodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
2149
- export type ConfigNodeContext = {
2150
- (scope: ConfigNodeContextScope, store?: string): NodeContextStore;
2151
- node: NodeContextStore;
2152
- global: NodeContextStore;
2153
- };
2154
- export declare class IONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> {
448
+ interface NodeConstructor<T = any, TConfig = any, TCredentials = any> {
449
+ readonly type: string;
450
+ readonly category: string;
451
+ readonly color?: string;
452
+ readonly align?: "left" | "right";
453
+ readonly inputs?: number;
454
+ readonly outputs?: number;
455
+ readonly configSchema?: Schema;
456
+ readonly credentialsSchema?: Schema;
457
+ readonly settingsSchema?: Schema;
458
+ readonly inputSchema?: Schema;
459
+ readonly outputsSchema?: Schema | Schema[];
460
+ readonly validateInput?: boolean;
461
+ readonly validateOutput?: boolean;
462
+ readonly name: string;
463
+ registered?(RED: RED): void | Promise<void>;
464
+ _registered?(RED: RED): void | Promise<void>;
465
+ new (RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>): T;
466
+ }
467
+ type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
468
+ type NodeCredentials<TCredentials = any> = TCredentials;
469
+ interface INode<TConfig = any, TCredentials = any, TSettings = any> {
470
+ readonly config: NodeConfig<TConfig>;
471
+ readonly id: string;
472
+ readonly name: string | undefined;
473
+ readonly z: string | undefined;
474
+ readonly credentials: NodeCredentials<TCredentials> | undefined;
475
+ readonly settings: TSettings;
476
+ i18n(key: string, substitutions?: Record<string, string>): string;
477
+ setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
478
+ setInterval(fn: () => void, ms: number): NodeJS.Timeout;
479
+ clearTimeout(timer: NodeJS.Timeout): void;
480
+ clearInterval(interval: NodeJS.Timeout): void;
481
+ on(event: string, callback: (...args: any[]) => void): void;
482
+ log(msg: any): void;
483
+ warn(message: string): void;
484
+ error(message: string, msg?: any): void;
485
+ created?(): void | Promise<void>;
486
+ closed?(removed?: boolean): void | Promise<void>;
487
+ }
488
+ /**
489
+ * Abstract base class for all NRG nodes. Provides lifecycle hooks, config
490
+ * validation, logging, timers, i18n, and settings management.
491
+ *
492
+ * Extend {@link IONode} for message-processing nodes or {@link ConfigNode}
493
+ * for shared configuration nodes.
494
+ */
495
+ declare abstract class Node$1<TConfig = any, TCredentials = any, TSettings = any> implements INode<TConfig, TCredentials, TSettings> {
496
+ static readonly type: string;
497
+ static readonly category: "config" | string;
498
+ static readonly configSchema?: Schema;
499
+ static readonly credentialsSchema?: Schema;
500
+ static readonly settingsSchema?: Schema;
501
+ private static _cachedSettings;
502
+ static registered?(RED: RED): void | Promise<void>;
503
+ static validateSettings(RED: RED): void;
504
+ protected readonly RED: RED;
505
+ protected readonly node: NodeRedNode;
506
+ protected readonly context: ConfigNodeContext | IONodeContext;
507
+ readonly config: NodeConfig<TConfig>;
508
+ private readonly timers;
509
+ private readonly intervals;
510
+ constructor(RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>);
511
+ i18n(key: string, substitutions?: Record<string, string>): string;
512
+ setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
513
+ setInterval(fn: () => void, ms: number): NodeJS.Timeout;
514
+ clearTimeout(timer: NodeJS.Timeout): void;
515
+ clearInterval(interval: NodeJS.Timeout): void;
516
+ created?(): void | Promise<void>;
517
+ closed?(removed?: boolean): void | Promise<void>;
518
+ on(event: string, callback: (...args: any[]) => void): void;
519
+ log(msg: any): void;
520
+ warn(message: string): void;
521
+ error(message: string, msg?: any): void;
522
+ get id(): string;
523
+ get name(): string | undefined;
524
+ get z(): string | undefined;
525
+ get credentials(): NodeCredentials<TCredentials> | undefined;
526
+ get settings(): TSettings;
527
+ }
528
+ /**
529
+ * Base class for nodes that process messages. Provides input/output handling,
530
+ * schema validation, status updates, and emit port management.
531
+ *
532
+ * @example
533
+ * ```ts
534
+ * export default class MyNode extends IONode<Config, any, Input, Output> {
535
+ * static readonly type = "my-node";
536
+ * static readonly category = "function";
537
+ * static readonly color = "#ffffff" as const;
538
+ *
539
+ * async input(msg: Input) {
540
+ * this.send({ payload: msg.payload.toUpperCase() });
541
+ * }
542
+ * }
543
+ * ```
544
+ */
545
+ export declare abstract class IONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> implements IIONode<TConfig, TCredentials, TInput, TOutput, TSettings> {
2155
546
  static readonly align?: "left" | "right";
2156
547
  static readonly color: HexColor;
2157
548
  static readonly inputSchema?: Schema;
@@ -2163,9 +554,17 @@ export declare class IONode<TConfig = any, TCredentials = any, TInput = any, TOu
2163
554
  private _send;
2164
555
  readonly config: IONodeConfig<TConfig>;
2165
556
  protected readonly context: IONodeContext;
2166
- constructor(RED: RED, node: any, config: IONodeConfig<TConfig>, credentials: IONodeCredentials<TCredentials>);
557
+ constructor(RED: RED, node: NodeRedNode, config: IONodeConfig<TConfig>, credentials: IONodeCredentials<TCredentials>);
2167
558
  input(msg: TInput): void | Promise<void>;
2168
559
  send(msg: TOutput): void;
560
+ /**
561
+ * Send a message to a specific output port by index or name.
562
+ * Named ports: `"error"`, `"complete"`, `"status"` — resolved automatically
563
+ * based on the node's emit port configuration.
564
+ * Numeric indices refer to the base output ports (0-based).
565
+ */
566
+ sendToPort(port: number | "error" | "complete" | "status", msg: TOutput): void;
567
+ private _getEmitPortIndex;
2169
568
  private _nodeSource;
2170
569
  status(status: IONodeStatus): void;
2171
570
  error(message: string, msg?: any): void;
@@ -2177,37 +576,40 @@ export declare class IONode<TConfig = any, TCredentials = any, TInput = any, TOu
2177
576
  get wires(): string[][];
2178
577
  get credentials(): IONodeCredentials<TCredentials> | undefined;
2179
578
  }
2180
- export declare abstract class ConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> {
2181
- static readonly category: string;
2182
- readonly config: ConfigNodeConfig<TConfig>;
2183
- protected readonly context: ConfigNodeContext;
2184
- constructor(RED: RED, node: any, config: ConfigNodeConfig<TConfig>, credentials: ConfigNodeCredentials<TCredentials>);
2185
- get userIds(): string[];
2186
- get users(): Node$1[];
2187
- getUser<T extends Node$1 = Node$1>(index: number): T | undefined;
2188
- get credentials(): ConfigNodeCredentials<TCredentials> | undefined;
2189
- }
2190
- export type InferOr<T, Fallback> = T extends TSchema ? Static<T> : Fallback;
2191
- export type InferOutputs<T> = T extends readonly TSchema[] ? {
2192
- [K in keyof T]: T[K] extends TSchema ? Static<T[K]> : never;
2193
- } : T extends TSchema ? Static<T> : any;
2194
- export type BoundIONode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined, TIn extends TSchema | undefined, TOut extends TSchema | readonly TSchema[] | undefined> = IONode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TIn, any>, InferOutputs<TOut>, InferOr<TS, any>>;
2195
- export type BoundConfigNode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined> = ConfigNode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TS, any>>;
2196
- export interface ConfigNodeInstance<TConfig = any, TCredentials = any> {
2197
- readonly config: ConfigNodeConfig<TConfig>;
2198
- readonly credentials: ConfigNodeCredentials<TCredentials> | undefined;
2199
- readonly id: string;
2200
- readonly name: string | undefined;
2201
- }
2202
- export interface IONodeInstance<TConfig = any, TCredentials = any, TInput = any, TOutput = any> {
579
+ type IONodeContextScope = NodeContextScope;
580
+ type IONodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof IONodeConfigSchema> & {
581
+ validateInput?: boolean;
582
+ validateOutput?: boolean;
583
+ };
584
+ type IONodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
585
+ type IONodeStatus = {
586
+ fill?: "red" | "green";
587
+ shape?: "dot" | "string";
588
+ text?: string;
589
+ } | string;
590
+ type IONodeContext = {
591
+ (scope: IONodeContextScope, store?: string): NodeContextStore;
592
+ node: NodeContextStore;
593
+ flow: NodeContextStore;
594
+ global: NodeContextStore;
595
+ };
596
+ type HexColor = `#${string}`;
597
+ type BoundIONode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined, TIn extends TSchema | undefined, TOut extends TSchema | readonly TSchema[] | undefined> = IONode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TIn, any>, InferOutputs<TOut>, InferOr<TS, any>>;
598
+ interface IIONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings> {
2203
599
  readonly config: IONodeConfig<TConfig>;
2204
600
  readonly credentials: IONodeCredentials<TCredentials> | undefined;
2205
- readonly id: string;
2206
- readonly name: string | undefined;
601
+ readonly x: number;
602
+ readonly y: number;
603
+ readonly g: string | undefined;
604
+ readonly wires: string[][];
2207
605
  input(msg: TInput): void | Promise<void>;
2208
606
  send(msg: TOutput): void;
607
+ status(status: IONodeStatus): void;
608
+ updateWires(wires: string[][]): void;
609
+ receive(msg: TInput): void;
610
+ sendToPort(port: number | "error" | "complete" | "status", msg: TOutput): void;
2209
611
  }
2210
- export interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined> {
612
+ interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined> {
2211
613
  type: string;
2212
614
  category?: string;
2213
615
  color?: HexColor;
@@ -2224,7 +626,44 @@ export interface IONodeDefinition<TConfigSchema extends TSchema | undefined = un
2224
626
  closed?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, removed?: boolean): void | Promise<void>;
2225
627
  input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>): void | Promise<void>;
2226
628
  }
2227
- export interface ConfigNodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined> {
629
+ /**
630
+ * Base class for configuration nodes that are shared across multiple nodes
631
+ * (e.g., server connections, credentials). Registered with `category: "config"`.
632
+ *
633
+ * @example
634
+ * ```ts
635
+ * export default class MyServer extends ConfigNode<Config> {
636
+ * static readonly type = "my-server";
637
+ * }
638
+ * ```
639
+ */
640
+ export declare abstract class ConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> implements IConfigNode<TConfig, TCredentials, TSettings> {
641
+ static readonly category: string;
642
+ readonly config: ConfigNodeConfig<TConfig>;
643
+ protected readonly context: ConfigNodeContext;
644
+ constructor(RED: RED, node: NodeRedNode, config: ConfigNodeConfig<TConfig>, credentials: ConfigNodeCredentials<TCredentials>);
645
+ get userIds(): string[];
646
+ get users(): INode[];
647
+ getUser<T extends INode = INode>(index: number): T | undefined;
648
+ get credentials(): ConfigNodeCredentials<TCredentials> | undefined;
649
+ }
650
+ type ConfigNodeContextScope = Exclude<NodeContextScope, "flow">;
651
+ type ConfigNodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof ConfigNodeConfigSchema>;
652
+ type ConfigNodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
653
+ type ConfigNodeContext = {
654
+ (scope: ConfigNodeContextScope, store?: string): NodeContextStore;
655
+ node: NodeContextStore;
656
+ global: NodeContextStore;
657
+ };
658
+ type BoundConfigNode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined> = ConfigNode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TS, any>>;
659
+ interface IConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings> {
660
+ readonly config: ConfigNodeConfig<TConfig>;
661
+ readonly credentials: ConfigNodeCredentials<TCredentials> | undefined;
662
+ readonly userIds: string[];
663
+ readonly users: INode[];
664
+ getUser<T extends INode = INode>(index: number): T | undefined;
665
+ }
666
+ interface ConfigNodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined> {
2228
667
  type: string;
2229
668
  configSchema?: TConfigSchema;
2230
669
  credentialsSchema?: TCredsSchema;
@@ -2233,50 +672,42 @@ export interface ConfigNodeDefinition<TConfigSchema extends TSchema | undefined
2233
672
  created?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>): void | Promise<void>;
2234
673
  closed?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>, removed?: boolean): void | Promise<void>;
2235
674
  }
2236
- export interface NodeClassBase<TInstance = unknown> {
2237
- readonly type: string;
2238
- readonly category: string;
2239
- new (...args: any[]): TInstance;
2240
- }
2241
- declare abstract class Node$1<TConfig = any, TCredentials = any, TSettings = any> {
2242
- static readonly type: string;
2243
- static readonly category: "config" | string;
2244
- static readonly configSchema?: Schema;
2245
- static readonly credentialsSchema?: Schema;
2246
- static readonly settingsSchema?: Schema;
2247
- private static _cachedSettings;
2248
- static registered?(RED: RED): void | Promise<void>;
2249
- static validateSettings(RED: RED): void;
2250
- protected readonly RED: RED;
2251
- protected readonly node: NodeRedNode;
2252
- protected readonly context: ConfigNodeContext | IONodeContext;
2253
- readonly config: NodeConfig<TConfig>;
2254
- private readonly timers;
2255
- private readonly intervals;
2256
- constructor(RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>);
2257
- i18n(key: string, substitutions?: Record<string, string>): string;
2258
- setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
2259
- setInterval(fn: () => void, ms: number): NodeJS.Timeout;
2260
- clearTimeout(timer: NodeJS.Timeout): void;
2261
- clearInterval(interval: NodeJS.Timeout): void;
2262
- created?(): void | Promise<void>;
2263
- closed?(removed?: boolean): void | Promise<void>;
2264
- on(event: string, callback: (...args: any[]) => void): void;
2265
- log(msg: any): void;
2266
- warn(message: string): void;
2267
- error(message: string, msg?: any): void;
2268
- get id(): string;
2269
- get name(): string | undefined;
2270
- get z(): string | undefined;
2271
- get credentials(): NodeCredentials<TCredentials> | undefined;
2272
- get settings(): TSettings;
2273
- }
2274
- export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeClassBase<IONodeInstance<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
2275
- export declare function defineConfigNode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined>(def: ConfigNodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema>): NodeClassBase<ConfigNodeInstance<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>>>;
675
+ /**
676
+ * Creates an IO node class from a definition object. Provides automatic type
677
+ * inference from schemas, reducing boilerplate compared to the class-based API.
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * export default defineIONode({
682
+ * type: "my-node",
683
+ * color: "#ffffff",
684
+ * configSchema: ConfigsSchema,
685
+ * inputSchema: InputSchema,
686
+ * outputsSchema: OutputSchema,
687
+ * async input(msg) {
688
+ * this.send({ payload: msg.payload.toUpperCase() });
689
+ * },
690
+ * });
691
+ * ```
692
+ */
693
+ export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeConstructor<IIONode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
694
+ /**
695
+ * Creates a config node class from a definition object.
696
+ *
697
+ * @example
698
+ * ```ts
699
+ * export default defineConfigNode({
700
+ * type: "my-server",
701
+ * configSchema: ConfigsSchema,
702
+ * credentialsSchema: CredsSchema,
703
+ * });
704
+ * ```
705
+ */
706
+ export declare function defineConfigNode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined>(def: ConfigNodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema>): NodeConstructor<IConfigNode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>>>;
707
+ /** Error class for NRG framework errors (validation failures, registration errors, etc.). */
2276
708
  export declare class NrgError extends Error {
2277
709
  constructor(message: string);
2278
710
  }
2279
- export type AnyNodeClass = ((abstract new (...args: any[]) => Node$1) & Partial<typeof Node$1>) | NodeClassBase<any>;
2280
711
  /**
2281
712
  * Registers a custom node with Node-RED.
2282
713
  *
@@ -2285,9 +716,9 @@ export type AnyNodeClass = ((abstract new (...args: any[]) => Node$1) & Partial<
2285
716
  * @throws If NodeClass does not extend Node
2286
717
  * @throws If NodeClass.type is not defined
2287
718
  */
2288
- export declare function registerType(RED: RED, NodeClass: AnyNodeClass): Promise<void>;
2289
- export type RegistrationFunction = ((RED: RED) => Promise<void>) & {
2290
- nodes: AnyNodeClass[];
719
+ export declare function registerType(RED: RED, NodeClass: NodeConstructor): Promise<void>;
720
+ type RegistrationFunction = ((RED: RED) => Promise<void>) & {
721
+ nodes: NodeConstructor[];
2291
722
  };
2292
723
  /**
2293
724
  * Registers multiple node classes with Node-RED.
@@ -2297,10 +728,22 @@ export type RegistrationFunction = ((RED: RED) => Promise<void>) & {
2297
728
  *
2298
729
  * @param nodes - Array of node classes to register
2299
730
  */
2300
- export declare function registerTypes(nodes: AnyNodeClass[]): RegistrationFunction;
731
+ export declare function registerTypes(nodes: NodeConstructor[]): RegistrationFunction;
732
+ /** Defines the set of nodes exported by a Node-RED package. */
2301
733
  export interface ModuleDefinition {
2302
- nodes: AnyNodeClass[];
734
+ nodes: NodeConstructor[];
2303
735
  }
736
+ /**
737
+ * Declares the nodes that make up a Node-RED module. The returned object
738
+ * is used as the default export of `src/server/index.ts`.
739
+ *
740
+ * @example
741
+ * ```ts
742
+ * export default defineModule({
743
+ * nodes: [MyNode, MyConfigNode],
744
+ * });
745
+ * ```
746
+ */
2304
747
  export declare function defineModule(definition: ModuleDefinition): ModuleDefinition;
2305
748
 
2306
749
  export {