@seedcord/core 0.1.0-next.4 → 0.1.0-next.5

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.
@@ -0,0 +1,2391 @@
1
+ import { t as IsNever } from "./is-never-Ddaba1Su.mjs";
2
+ import { Logger } from "@seedcord/logger";
3
+ import { EventMap, TypedEventEmitter } from "@seedcord/event-emitter";
4
+ import { HealthCheckConfig, TypedExclude } from "@seedcord/types";
5
+
6
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/characters.d.ts
7
+ /**
8
+ Matches any digit as a string ('0'-'9').
9
+
10
+ @example
11
+ ```
12
+ import type {DigitCharacter} from 'type-fest';
13
+
14
+ const a: DigitCharacter = '0'; // Valid
15
+ // @ts-expect-error
16
+ const b: DigitCharacter = 0; // Invalid
17
+ ```
18
+
19
+ @category Type
20
+ */
21
+ type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
22
+ //#endregion
23
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-intersection.d.ts
24
+ /**
25
+ Convert a union type to an intersection type.
26
+
27
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
28
+
29
+ @example
30
+ ```
31
+ import type {UnionToIntersection} from 'type-fest';
32
+
33
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
34
+
35
+ type Intersection = UnionToIntersection<Union>;
36
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
37
+ ```
38
+
39
+ @category Type
40
+ */
41
+ type UnionToIntersection<Union> = (// `extends unknown` is always going to be the case and is used to convert the
42
+ // `Union` into a [distributive conditional
43
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
44
+ Union extends unknown // The union type is used as the only argument to a function since the union
45
+ // of function arguments is an intersection.
46
+ ? (distributedUnion: Union) => void // This won't happen.
47
+ : never // Infer the `Intersection` type since TypeScript represents the positional
48
+ // arguments of unions of functions as an intersection of the union.
49
+ ) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
50
+ ? Intersection & Union : never;
51
+ //#endregion
52
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
53
+ /**
54
+ Returns a boolean for whether the given type is `any`.
55
+
56
+ @link https://stackoverflow.com/a/49928360/1490091
57
+
58
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
59
+
60
+ @example
61
+ ```
62
+ import type {IsAny} from 'type-fest';
63
+
64
+ const typedObject = {a: 1, b: 2} as const;
65
+ const anyObject: any = {a: 1, b: 2};
66
+
67
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
68
+ return object[key];
69
+ }
70
+
71
+ const typedA = get(typedObject, 'a');
72
+ //=> 1
73
+
74
+ const anyA = get(anyObject, 'a');
75
+ //=> any
76
+ ```
77
+
78
+ @category Type Guard
79
+ @category Utilities
80
+ */
81
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
82
+ //#endregion
83
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
84
+ /**
85
+ Returns a boolean for whether the given key is an optional key of type.
86
+
87
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
88
+
89
+ @example
90
+ ```
91
+ import type {IsOptionalKeyOf} from 'type-fest';
92
+
93
+ type User = {
94
+ name: string;
95
+ surname: string;
96
+
97
+ luckyNumber?: number;
98
+ };
99
+
100
+ type Admin = {
101
+ name: string;
102
+ surname?: string;
103
+ };
104
+
105
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
106
+ //=> true
107
+
108
+ type T2 = IsOptionalKeyOf<User, 'name'>;
109
+ //=> false
110
+
111
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
112
+ //=> boolean
113
+
114
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
115
+ //=> false
116
+
117
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
118
+ //=> boolean
119
+ ```
120
+
121
+ @category Type Guard
122
+ @category Utilities
123
+ */
124
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
125
+ //#endregion
126
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
127
+ /**
128
+ Extract all optional keys from the given type.
129
+
130
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
131
+
132
+ @example
133
+ ```
134
+ import type {OptionalKeysOf, Except} from 'type-fest';
135
+
136
+ type User = {
137
+ name: string;
138
+ surname: string;
139
+
140
+ luckyNumber?: number;
141
+ };
142
+
143
+ const REMOVE_FIELD = Symbol('remove field symbol');
144
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
145
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
146
+ };
147
+
148
+ const update1: UpdateOperation<User> = {
149
+ name: 'Alice',
150
+ };
151
+
152
+ const update2: UpdateOperation<User> = {
153
+ name: 'Bob',
154
+ luckyNumber: REMOVE_FIELD,
155
+ };
156
+ ```
157
+
158
+ @category Utilities
159
+ */
160
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
161
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
162
+ : never;
163
+ //#endregion
164
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
165
+ /**
166
+ Extract all required keys from the given type.
167
+
168
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
169
+
170
+ @example
171
+ ```
172
+ import type {RequiredKeysOf} from 'type-fest';
173
+
174
+ declare function createValidation<
175
+ Entity extends object,
176
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
177
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
178
+
179
+ type User = {
180
+ name: string;
181
+ surname: string;
182
+ luckyNumber?: number;
183
+ };
184
+
185
+ const validator1 = createValidation<User>('name', value => value.length < 25);
186
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
187
+
188
+ // @ts-expect-error
189
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
190
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
191
+ ```
192
+
193
+ @category Utilities
194
+ */
195
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
196
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
197
+ //#endregion
198
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
199
+ /**
200
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
201
+
202
+ Use-cases:
203
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
204
+
205
+ Note:
206
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
207
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
208
+
209
+ @example
210
+ ```
211
+ import type {If} from 'type-fest';
212
+
213
+ type A = If<true, 'yes', 'no'>;
214
+ //=> 'yes'
215
+
216
+ type B = If<false, 'yes', 'no'>;
217
+ //=> 'no'
218
+
219
+ type C = If<boolean, 'yes', 'no'>;
220
+ //=> 'yes' | 'no'
221
+
222
+ type D = If<any, 'yes', 'no'>;
223
+ //=> 'yes' | 'no'
224
+
225
+ type E = If<never, 'yes', 'no'>;
226
+ //=> 'no'
227
+ ```
228
+
229
+ @example
230
+ ```
231
+ import type {If, IsAny, IsNever} from 'type-fest';
232
+
233
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
234
+ //=> 'not any'
235
+
236
+ type B = If<IsNever<never>, 'is never', 'not never'>;
237
+ //=> 'is never'
238
+ ```
239
+
240
+ @example
241
+ ```
242
+ import type {If, IsEqual} from 'type-fest';
243
+
244
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
245
+
246
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
247
+ //=> 'equal'
248
+
249
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
250
+ //=> 'not equal'
251
+ ```
252
+
253
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
254
+
255
+ @example
256
+ ```
257
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
258
+
259
+ type HundredZeroes = StringRepeat<'0', 100>;
260
+
261
+ // The following implementation is not tail recursive
262
+ type Includes<S extends string, Char extends string> =
263
+ S extends `${infer First}${infer Rest}`
264
+ ? If<IsEqual<First, Char>,
265
+ 'found',
266
+ Includes<Rest, Char>>
267
+ : 'not found';
268
+
269
+ // Hence, instantiations with long strings will fail
270
+ // @ts-expect-error
271
+ type Fails = Includes<HundredZeroes, '1'>;
272
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273
+ // Error: Type instantiation is excessively deep and possibly infinite.
274
+
275
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
276
+ type IncludesWithoutIf<S extends string, Char extends string> =
277
+ S extends `${infer First}${infer Rest}`
278
+ ? IsEqual<First, Char> extends true
279
+ ? 'found'
280
+ : IncludesWithoutIf<Rest, Char>
281
+ : 'not found';
282
+
283
+ // Now, instantiations with long strings will work
284
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
285
+ //=> 'not found'
286
+ ```
287
+
288
+ @category Type Guard
289
+ @category Utilities
290
+ */
291
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
292
+ //#endregion
293
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/unknown-array.d.ts
294
+ /**
295
+ Represents an array with `unknown` value.
296
+
297
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
298
+
299
+ @example
300
+ ```
301
+ import type {UnknownArray} from 'type-fest';
302
+
303
+ type IsArray<T> = T extends UnknownArray ? true : false;
304
+
305
+ type A = IsArray<['foo']>;
306
+ //=> true
307
+
308
+ type B = IsArray<readonly number[]>;
309
+ //=> true
310
+
311
+ type C = IsArray<string>;
312
+ //=> false
313
+ ```
314
+
315
+ @category Type
316
+ @category Array
317
+ */
318
+ type UnknownArray = readonly unknown[];
319
+ //#endregion
320
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
321
+ /**
322
+ Returns a boolean for whether A is false.
323
+
324
+ @example
325
+ ```
326
+ type A = Not<true>;
327
+ //=> false
328
+
329
+ type B = Not<false>;
330
+ //=> true
331
+ ```
332
+ */
333
+ type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
334
+ /**
335
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
336
+
337
+ @example
338
+ ```
339
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
340
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
341
+ //=> 'VALID'
342
+
343
+ // When `T` is `any` => Returns `IfAny` branch
344
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
345
+ //=> 'IS_ANY'
346
+
347
+ // When `T` is `never` => Returns `IfNever` branch
348
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
349
+ //=> 'IS_NEVER'
350
+ ```
351
+
352
+ Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
353
+
354
+ @example
355
+ ```ts
356
+ import type {StringRepeat} from 'type-fest';
357
+
358
+ type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
359
+
360
+ // The following implementation is not tail recursive
361
+ type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
362
+
363
+ // Hence, instantiations with long strings will fail
364
+ // @ts-expect-error
365
+ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
366
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367
+ // Error: Type instantiation is excessively deep and possibly infinite.
368
+
369
+ // To fix this, move the recursion into a helper type
370
+ type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
371
+
372
+ type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
373
+
374
+ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
375
+ //=> ''
376
+ ```
377
+ */
378
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
379
+ /**
380
+ Indicates the value of `exactOptionalPropertyTypes` compiler option.
381
+ */
382
+ type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
383
+ //#endregion
384
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/array.d.ts
385
+ /**
386
+ Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
387
+
388
+ @example
389
+ ```
390
+ type A = CollapseRestElement<[string, string, ...number[]]>;
391
+ //=> [string, string, number]
392
+
393
+ type B = CollapseRestElement<[...string[], number, number]>;
394
+ //=> [string, number, number]
395
+
396
+ type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
397
+ //=> [string, string, number | bigint]
398
+
399
+ type D = CollapseRestElement<[string, number]>;
400
+ //=> [string, number]
401
+ ```
402
+
403
+ Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
404
+
405
+ @example
406
+ ```
407
+ // `exactOptionalPropertyTypes` enabled
408
+ type A = CollapseRestElement<[string?, string?, ...number[]]>;
409
+ //=> [string, string, number]
410
+
411
+ // `exactOptionalPropertyTypes` disabled
412
+ type B = CollapseRestElement<[string?, string?, ...number[]]>;
413
+ //=> [string | undefined, string | undefined, number]
414
+ ```
415
+ */
416
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
417
+ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
418
+ ? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
419
+ // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
420
+ ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
421
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
422
+ : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
423
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
424
+ : never; // Should never happen
425
+ //#endregion
426
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/numeric.d.ts
427
+ type _Numeric = number | bigint;
428
+ type Zero = 0 | 0n;
429
+ /**
430
+ Matches the hidden `Infinity` type.
431
+
432
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
433
+
434
+ @see {@link NegativeInfinity}
435
+
436
+ @category Numeric
437
+ */
438
+ // See https://github.com/microsoft/TypeScript/issues/31752
439
+ // eslint-disable-next-line no-loss-of-precision
440
+ type PositiveInfinity = 1e999;
441
+ /**
442
+ Matches the hidden `-Infinity` type.
443
+
444
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
445
+
446
+ @see {@link PositiveInfinity}
447
+
448
+ @category Numeric
449
+ */
450
+ // See https://github.com/microsoft/TypeScript/issues/31752
451
+ // eslint-disable-next-line no-loss-of-precision
452
+ type NegativeInfinity = -1e999;
453
+ /**
454
+ A negative `number`/`bigint` (`-∞ < x < 0`)
455
+
456
+ Use-case: Validating and documenting parameters.
457
+
458
+ @see {@link NegativeInteger}
459
+ @see {@link NonNegative}
460
+
461
+ @category Numeric
462
+ */
463
+ type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
464
+ /**
465
+ Returns a boolean for whether the given number is a negative number.
466
+
467
+ @see {@link Negative}
468
+
469
+ @example
470
+ ```
471
+ import type {IsNegative} from 'type-fest';
472
+
473
+ type ShouldBeFalse = IsNegative<1>;
474
+ type ShouldBeTrue = IsNegative<-1>;
475
+ ```
476
+
477
+ @category Numeric
478
+ */
479
+ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
480
+ //#endregion
481
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tuple-of.d.ts
482
+ /**
483
+ Create a tuple type of the specified length with elements of the specified type.
484
+
485
+ @example
486
+ ```
487
+ import type {TupleOf} from 'type-fest';
488
+
489
+ type RGB = TupleOf<3, number>;
490
+ //=> [number, number, number]
491
+
492
+ type Line = TupleOf<2, {x: number; y: number}>;
493
+ //=> [{x: number; y: number}, {x: number; y: number}]
494
+
495
+ type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
496
+ //=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
497
+ ```
498
+
499
+ @example
500
+ ```
501
+ import type {TupleOf} from 'type-fest';
502
+
503
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
504
+
505
+ type ZeroToFour = Range<0, 5>;
506
+ //=> '0' | '1' | '2' | '3' | '4'
507
+
508
+ type ThreeToEight = Range<3, 9>;
509
+ //=> '3' | '4' | '5' | '6' | '7' | '8'
510
+ ```
511
+
512
+ Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
513
+
514
+ @example
515
+ ```
516
+ import type {TupleOf} from 'type-fest';
517
+
518
+ type StringArray = TupleOf<number, string>;
519
+ //=> string[]
520
+ ```
521
+
522
+ Note: If the type for elements is not specified, it will default to `unknown`.
523
+
524
+ @example
525
+ ```
526
+ import type {TupleOf} from 'type-fest';
527
+
528
+ type UnknownTriplet = TupleOf<3>;
529
+ //=> [unknown, unknown, unknown]
530
+ ```
531
+
532
+ Note: If the specified length is negative, the result will be an empty tuple.
533
+
534
+ @example
535
+ ```
536
+ import type {TupleOf} from 'type-fest';
537
+
538
+ type EmptyTuple = TupleOf<-3, string>;
539
+ //=> []
540
+ ```
541
+
542
+ Note: If the specified length has a decimal part, the decimal part will be ignored.
543
+
544
+ @example
545
+ ```
546
+ import type {TupleOf} from 'type-fest';
547
+
548
+ type DecimalLength = TupleOf<3.5, string>;
549
+ //=> [string, string, string]
550
+ ```
551
+
552
+ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
553
+
554
+ @category Array
555
+ */
556
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], []>;
557
+ type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
558
+ type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [...RepeatTupleTenTimes<Accumulator>, ...DigitTupleOf<First, Fill>]> : Accumulator;
559
+ type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
560
+ type DigitTupleOf<Digit extends DigitCharacter, Fill> = [[], [Fill], [Fill, Fill], [Fill, Fill, Fill], [Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill]][Digit];
561
+ //#endregion
562
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/string.d.ts
563
+ /**
564
+ Converts a numeric string to a number.
565
+
566
+ @example
567
+ ```
568
+ type PositiveInt = StringToNumber<'1234'>;
569
+ //=> 1234
570
+
571
+ type NegativeInt = StringToNumber<'-1234'>;
572
+ //=> -1234
573
+
574
+ type PositiveFloat = StringToNumber<'1234.56'>;
575
+ //=> 1234.56
576
+
577
+ type NegativeFloat = StringToNumber<'-1234.56'>;
578
+ //=> -1234.56
579
+
580
+ type PositiveInfinity = StringToNumber<'Infinity'>;
581
+ //=> Infinity
582
+
583
+ type NegativeInfinity = StringToNumber<'-Infinity'>;
584
+ //=> -Infinity
585
+ ```
586
+
587
+ @category String
588
+ @category Numeric
589
+ @category Template literal
590
+ */
591
+ type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends 'Infinity' ? PositiveInfinity : S extends '-Infinity' ? NegativeInfinity : never;
592
+ /**
593
+ Returns an array of the characters of the string.
594
+
595
+ @example
596
+ ```
597
+ type A = StringToArray<'abcde'>;
598
+ //=> ['a', 'b', 'c', 'd', 'e']
599
+
600
+ type B = StringToArray<string>;
601
+ //=> never
602
+ ```
603
+
604
+ @category String
605
+ */
606
+ type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [...Result, F]> : Result;
607
+ /**
608
+ Returns the length of the given string.
609
+
610
+ @example
611
+ ```
612
+ type A = StringLength<'abcde'>;
613
+ //=> 5
614
+
615
+ type B = StringLength<string>;
616
+ //=> never
617
+ ```
618
+
619
+ @category String
620
+ @category Template literal
621
+ */
622
+ type StringLength<S extends string> = string extends S ? never : StringToArray<S>['length'];
623
+ /**
624
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
625
+
626
+ @example
627
+ ```
628
+ type A = SameLengthPositiveNumericStringGt<'50', '10'>;
629
+ //=> true
630
+
631
+ type B = SameLengthPositiveNumericStringGt<'10', '10'>;
632
+ //=> false
633
+ ```
634
+ */
635
+ type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
636
+ type NumericString = '0123456789';
637
+ /**
638
+ Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
639
+
640
+ @example
641
+ ```
642
+ type A = PositiveNumericStringGt<'500', '1'>;
643
+ //=> true
644
+
645
+ type B = PositiveNumericStringGt<'1', '1'>;
646
+ //=> false
647
+
648
+ type C = PositiveNumericStringGt<'1', '500'>;
649
+ //=> false
650
+ ```
651
+ */
652
+ type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [TupleOf<StringLength<A>, 0>, TupleOf<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain['length'] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
653
+ /**
654
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
655
+
656
+ @example
657
+ ```
658
+ type A = PositiveNumericCharacterGt<'5', '1'>;
659
+ //=> true
660
+
661
+ type B = PositiveNumericCharacterGt<'1', '1'>;
662
+ //=> false
663
+ ```
664
+ */
665
+ type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
666
+ //#endregion
667
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/numeric.d.ts
668
+ /**
669
+ Returns the number with reversed sign.
670
+
671
+ @example
672
+ ```
673
+ type A = ReverseSign<-1>;
674
+ //=> 1
675
+
676
+ type B = ReverseSign<1>;
677
+ //=> -1
678
+
679
+ type C = ReverseSign<NegativeInfinity>;
680
+ //=> PositiveInfinity
681
+
682
+ type D = ReverseSign<PositiveInfinity>;
683
+ //=> NegativeInfinity
684
+ ```
685
+ */
686
+ type ReverseSign<N extends number> = // Handle edge cases
687
+ N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends NegativeInfinity ? PositiveInfinity // Handle negative numbers
688
+ : `${N}` extends `-${infer P extends number}` ? P // Handle positive numbers
689
+ : `-${N}` extends `${infer R extends number}` ? R : never;
690
+ //#endregion
691
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
692
+ /**
693
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
694
+
695
+ @example
696
+ ```
697
+ import type {Simplify} from 'type-fest';
698
+
699
+ type PositionProps = {
700
+ top: number;
701
+ left: number;
702
+ };
703
+
704
+ type SizeProps = {
705
+ width: number;
706
+ height: number;
707
+ };
708
+
709
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
710
+ type Props = Simplify<PositionProps & SizeProps>;
711
+ ```
712
+
713
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
714
+
715
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
716
+
717
+ @example
718
+ ```
719
+ import type {Simplify} from 'type-fest';
720
+
721
+ interface SomeInterface {
722
+ foo: number;
723
+ bar?: string;
724
+ baz: number | undefined;
725
+ }
726
+
727
+ type SomeType = {
728
+ foo: number;
729
+ bar?: string;
730
+ baz: number | undefined;
731
+ };
732
+
733
+ const literal = {foo: 123, bar: 'hello', baz: 456};
734
+ const someType: SomeType = literal;
735
+ const someInterface: SomeInterface = literal;
736
+
737
+ declare function fn(object: Record<string, unknown>): void;
738
+
739
+ fn(literal); // Good: literal object type is sealed
740
+ fn(someType); // Good: type is sealed
741
+ // @ts-expect-error
742
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
743
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
744
+ ```
745
+
746
+ @link https://github.com/microsoft/TypeScript/issues/15300
747
+ @see {@link SimplifyDeep}
748
+ @category Object
749
+ */
750
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
751
+ //#endregion
752
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
753
+ /**
754
+ Returns a boolean for whether the two given types are equal.
755
+
756
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
757
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
758
+
759
+ Use-cases:
760
+ - If you want to make a conditional branch based on the result of a comparison of two types.
761
+
762
+ @example
763
+ ```
764
+ import type {IsEqual} from 'type-fest';
765
+
766
+ // This type returns a boolean for whether the given array includes the given item.
767
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
768
+ type Includes<Value extends readonly any[], Item> =
769
+ Value extends readonly [Value[0], ...infer rest]
770
+ ? IsEqual<Value[0], Item> extends true
771
+ ? true
772
+ : Includes<rest, Item>
773
+ : false;
774
+ ```
775
+
776
+ @category Type Guard
777
+ @category Utilities
778
+ */
779
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
780
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
781
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
782
+ //#endregion
783
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
784
+ /**
785
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
786
+
787
+ This is the counterpart of `PickIndexSignature`.
788
+
789
+ Use-cases:
790
+ - Remove overly permissive signatures from third-party types.
791
+
792
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
793
+
794
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
795
+
796
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
797
+
798
+ ```
799
+ const indexed: Record<string, unknown> = {}; // Allowed
800
+
801
+ // @ts-expect-error
802
+ const keyed: Record<'foo', unknown> = {}; // Error
803
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
804
+ ```
805
+
806
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
807
+
808
+ ```
809
+ type Indexed = {} extends Record<string, unknown>
810
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
811
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
812
+
813
+ type IndexedResult = Indexed;
814
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
815
+
816
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
817
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
818
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
819
+
820
+ type KeyedResult = Keyed;
821
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
822
+ ```
823
+
824
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
825
+
826
+ ```
827
+ type OmitIndexSignature<ObjectType> = {
828
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
829
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
830
+ };
831
+ ```
832
+
833
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
834
+
835
+ ```
836
+ type OmitIndexSignature<ObjectType> = {
837
+ [KeyType in keyof ObjectType
838
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
839
+ as {} extends Record<KeyType, unknown>
840
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
841
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
842
+ ]: ObjectType[KeyType];
843
+ };
844
+ ```
845
+
846
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
847
+
848
+ @example
849
+ ```
850
+ import type {OmitIndexSignature} from 'type-fest';
851
+
852
+ type Example = {
853
+ // These index signatures will be removed.
854
+ [x: string]: any;
855
+ [x: number]: any;
856
+ [x: symbol]: any;
857
+ [x: `head-${string}`]: string;
858
+ [x: `${string}-tail`]: string;
859
+ [x: `head-${string}-tail`]: string;
860
+ [x: `${bigint}`]: string;
861
+ [x: `embedded-${number}`]: string;
862
+
863
+ // These explicitly defined keys will remain.
864
+ foo: 'bar';
865
+ qux?: 'baz';
866
+ };
867
+
868
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
869
+ //=> {foo: 'bar'; qux?: 'baz'}
870
+ ```
871
+
872
+ @see {@link PickIndexSignature}
873
+ @category Object
874
+ */
875
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
876
+ //#endregion
877
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
878
+ /**
879
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
880
+
881
+ This is the counterpart of `OmitIndexSignature`.
882
+
883
+ @example
884
+ ```
885
+ import type {PickIndexSignature} from 'type-fest';
886
+
887
+ declare const symbolKey: unique symbol;
888
+
889
+ type Example = {
890
+ // These index signatures will remain.
891
+ [x: string]: unknown;
892
+ [x: number]: unknown;
893
+ [x: symbol]: unknown;
894
+ [x: `head-${string}`]: string;
895
+ [x: `${string}-tail`]: string;
896
+ [x: `head-${string}-tail`]: string;
897
+ [x: `${bigint}`]: string;
898
+ [x: `embedded-${number}`]: string;
899
+
900
+ // These explicitly defined keys will be removed.
901
+ ['kebab-case-key']: string;
902
+ [symbolKey]: string;
903
+ foo: 'bar';
904
+ qux?: 'baz';
905
+ };
906
+
907
+ type ExampleIndexSignature = PickIndexSignature<Example>;
908
+ // {
909
+ // [x: string]: unknown;
910
+ // [x: number]: unknown;
911
+ // [x: symbol]: unknown;
912
+ // [x: `head-${string}`]: string;
913
+ // [x: `${string}-tail`]: string;
914
+ // [x: `head-${string}-tail`]: string;
915
+ // [x: `${bigint}`]: string;
916
+ // [x: `embedded-${number}`]: string;
917
+ // }
918
+ ```
919
+
920
+ @see {@link OmitIndexSignature}
921
+ @category Object
922
+ */
923
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
924
+ //#endregion
925
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
926
+ // Merges two objects without worrying about index signatures.
927
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
928
+ /**
929
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
930
+
931
+ This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
932
+
933
+ @example
934
+ ```
935
+ import type {Merge} from 'type-fest';
936
+
937
+ type Foo = {
938
+ a: string;
939
+ b: number;
940
+ };
941
+
942
+ type Bar = {
943
+ a: number; // Conflicts with Foo['a']
944
+ c: boolean;
945
+ };
946
+
947
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
948
+ type WithIntersection = (Foo & Bar)['a'];
949
+ //=> never
950
+
951
+ // With `Merge`, `a` is cleanly overridden to `number`.
952
+ type WithMerge = Merge<Foo, Bar>['a'];
953
+ //=> number
954
+ ```
955
+
956
+ @example
957
+ ```
958
+ import type {Merge} from 'type-fest';
959
+
960
+ type Foo = {
961
+ [x: string]: unknown;
962
+ [x: number]: unknown;
963
+ foo: string;
964
+ bar: symbol;
965
+ };
966
+
967
+ type Bar = {
968
+ [x: number]: number;
969
+ [x: symbol]: unknown;
970
+ bar: Date;
971
+ baz: boolean;
972
+ };
973
+
974
+ export type FooBar = Merge<Foo, Bar>;
975
+ //=> {
976
+ // [x: string]: unknown;
977
+ // [x: number]: number;
978
+ // [x: symbol]: unknown;
979
+ // foo: string;
980
+ // bar: Date;
981
+ // baz: boolean;
982
+ // }
983
+ ```
984
+
985
+ Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
986
+
987
+ @see {@link ObjectMerge}
988
+ @category Object
989
+ */
990
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
991
+ ? Source extends unknown // For distributing `Source`
992
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
993
+ : never;
994
+ // Should never happen
995
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
996
+ //#endregion
997
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
998
+ /**
999
+ Merges user specified options with default options.
1000
+
1001
+ @example
1002
+ ```
1003
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1004
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1005
+ type SpecifiedOptions = {leavesOnly: true};
1006
+
1007
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1008
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
1009
+ ```
1010
+
1011
+ @example
1012
+ ```
1013
+ // Complains if default values are not provided for optional options
1014
+
1015
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1016
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
1017
+ type SpecifiedOptions = {};
1018
+
1019
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1020
+ // ~~~~~~~~~~~~~~~~~~~
1021
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
1022
+ ```
1023
+
1024
+ @example
1025
+ ```
1026
+ // Complains if an option's default type does not conform to the expected type
1027
+
1028
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1029
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
1030
+ type SpecifiedOptions = {};
1031
+
1032
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1033
+ // ~~~~~~~~~~~~~~~~~~~
1034
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1035
+ ```
1036
+
1037
+ @example
1038
+ ```
1039
+ // Complains if an option's specified type does not conform to the expected type
1040
+
1041
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1042
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1043
+ type SpecifiedOptions = {leavesOnly: 'yes'};
1044
+
1045
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1046
+ // ~~~~~~~~~~~~~~~~
1047
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1048
+ ```
1049
+ */
1050
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
1051
+ ? Result : never;
1052
+ type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
1053
+ /**
1054
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
1055
+
1056
+ Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
1057
+
1058
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
1059
+
1060
+ @example
1061
+ ```
1062
+ import type {LiteralUnion} from 'type-fest';
1063
+
1064
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
1065
+ //=> string
1066
+
1067
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
1068
+ //=> number
1069
+
1070
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
1071
+ //=> `on${string}`
1072
+
1073
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
1074
+ //=> 'click' | 'change' | `on${string}`
1075
+
1076
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
1077
+ //=> string | null | undefined
1078
+ ```
1079
+ */
1080
+ //#endregion
1081
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/some-extend.d.ts
1082
+ /**
1083
+ @see {@link SomeExtend}
1084
+ */
1085
+ type SomeExtendOptions = {
1086
+ /**
1087
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1088
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1089
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1090
+ @default true
1091
+ @example
1092
+ ```
1093
+ import type {SomeExtend} from 'type-fest';
1094
+ type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
1095
+ //=> false
1096
+ type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
1097
+ //=> true
1098
+ type C = SomeExtend<[1, never], never, {strictNever: true}>;
1099
+ //=> true
1100
+ type D = SomeExtend<[1, never], never, {strictNever: false}>;
1101
+ //=> true
1102
+ type E = SomeExtend<[never], any, {strictNever: true}>;
1103
+ //=> true
1104
+ type F = SomeExtend<[never], any, {strictNever: false}>;
1105
+ //=> true
1106
+ ```
1107
+ */
1108
+ strictNever?: boolean;
1109
+ };
1110
+ type DefaultSomeExtendOptions = {
1111
+ strictNever: true;
1112
+ };
1113
+ /**
1114
+ Returns a boolean for whether some element in an array type extends another type.
1115
+
1116
+ @example
1117
+ ```
1118
+ import type {SomeExtend} from 'type-fest';
1119
+
1120
+ type A = SomeExtend<['1', '2', 3], number>;
1121
+ //=> true
1122
+
1123
+ type B = SomeExtend<[1, 2, 3], string>;
1124
+ //=> false
1125
+
1126
+ type C = SomeExtend<[string, number | string], number>;
1127
+ //=> boolean
1128
+
1129
+ type D = SomeExtend<[true, boolean, true], false>;
1130
+ //=> boolean
1131
+ ```
1132
+
1133
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1134
+
1135
+ ```
1136
+ // @exactOptionalPropertyTypes: true
1137
+ import type {SomeExtend} from 'type-fest';
1138
+
1139
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
1140
+ //=> true
1141
+ ```
1142
+
1143
+ ```
1144
+ // @exactOptionalPropertyTypes: false
1145
+ import type {SomeExtend} from 'type-fest';
1146
+
1147
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
1148
+ //=> boolean
1149
+
1150
+ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
1151
+ //=> true
1152
+ ```
1153
+
1154
+ @see {@link SomeExtendOptions}
1155
+
1156
+ @category Utilities
1157
+ @category Array
1158
+ */
1159
+ type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
1160
+ type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
1161
+ ? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
1162
+ //#endregion
1163
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or-all.d.ts
1164
+ /**
1165
+ Returns a boolean for whether any of the given elements is `true`.
1166
+
1167
+ Use-cases:
1168
+ - Check if at least one condition in a list of booleans is met.
1169
+
1170
+ @example
1171
+ ```
1172
+ import type {OrAll} from 'type-fest';
1173
+
1174
+ type FFT = OrAll<[false, false, true]>;
1175
+ //=> true
1176
+
1177
+ type FFF = OrAll<[false, false, false]>;
1178
+ //=> false
1179
+ ```
1180
+
1181
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
1182
+ For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
1183
+
1184
+ @example
1185
+ ```
1186
+ import type {OrAll} from 'type-fest';
1187
+
1188
+ type A = OrAll<[false, boolean]>;
1189
+ //=> boolean
1190
+
1191
+ type B = OrAll<[true, boolean]>;
1192
+ //=> true
1193
+ ```
1194
+
1195
+ Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
1196
+
1197
+ @example
1198
+ ```
1199
+ import type {OrAll} from 'type-fest';
1200
+
1201
+ type A = OrAll<[never, never, true]>;
1202
+ //=> true
1203
+
1204
+ type B = OrAll<[never, never, false]>;
1205
+ //=> false
1206
+
1207
+ type C = OrAll<[never, never, never]>;
1208
+ //=> false
1209
+
1210
+ type D = OrAll<[never, never, boolean]>;
1211
+ //=> boolean
1212
+ ```
1213
+
1214
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
1215
+
1216
+ @example
1217
+ ```
1218
+ import type {OrAll} from 'type-fest';
1219
+
1220
+ type A = OrAll<[false, any]>;
1221
+ //=> boolean
1222
+
1223
+ type B = OrAll<[true, any]>;
1224
+ //=> true
1225
+ ```
1226
+
1227
+ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
1228
+
1229
+ @see {@link Or}
1230
+ @see {@link AndAll}
1231
+ */
1232
+ type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
1233
+ //#endregion
1234
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or.d.ts
1235
+ /**
1236
+ Returns a boolean for whether either of two given types is `true`.
1237
+
1238
+ Use-case: Constructing complex conditional types where at least one condition must be satisfied.
1239
+
1240
+ @example
1241
+ ```
1242
+ import type {Or} from 'type-fest';
1243
+
1244
+ type TT = Or<true, true>;
1245
+ //=> true
1246
+
1247
+ type TF = Or<true, false>;
1248
+ //=> true
1249
+
1250
+ type FT = Or<false, true>;
1251
+ //=> true
1252
+
1253
+ type FF = Or<false, false>;
1254
+ //=> false
1255
+ ```
1256
+
1257
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
1258
+ For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
1259
+
1260
+ @example
1261
+ ```
1262
+ import type {Or} from 'type-fest';
1263
+
1264
+ type A = Or<false, boolean>;
1265
+ //=> boolean
1266
+
1267
+ type B = Or<boolean, false>;
1268
+ //=> boolean
1269
+
1270
+ type C = Or<true, boolean>;
1271
+ //=> true
1272
+
1273
+ type D = Or<boolean, true>;
1274
+ //=> true
1275
+
1276
+ type E = Or<boolean, boolean>;
1277
+ //=> boolean
1278
+ ```
1279
+
1280
+ Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
1281
+
1282
+ @example
1283
+ ```
1284
+ import type {Or} from 'type-fest';
1285
+
1286
+ type A = Or<true, never>;
1287
+ //=> true
1288
+
1289
+ type B = Or<never, true>;
1290
+ //=> true
1291
+
1292
+ type C = Or<false, never>;
1293
+ //=> false
1294
+
1295
+ type D = Or<never, false>;
1296
+ //=> false
1297
+
1298
+ type E = Or<boolean, never>;
1299
+ //=> boolean
1300
+
1301
+ type F = Or<never, boolean>;
1302
+ //=> boolean
1303
+
1304
+ type G = Or<never, never>;
1305
+ //=> false
1306
+ ```
1307
+
1308
+ @see {@link OrAll}
1309
+ @see {@link And}
1310
+ @see {@link Xor}
1311
+ */
1312
+ type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
1313
+ //#endregion
1314
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/all-extend.d.ts
1315
+ /**
1316
+ @see {@link AllExtend}
1317
+ */
1318
+ type AllExtendOptions = {
1319
+ /**
1320
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1321
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1322
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1323
+ @default true
1324
+ @example
1325
+ ```
1326
+ import type {AllExtend} from 'type-fest';
1327
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1328
+ //=> false
1329
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1330
+ //=> true
1331
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
1332
+ //=> true
1333
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
1334
+ //=> true
1335
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1336
+ //=> true
1337
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1338
+ //=> true
1339
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
1340
+ //=> false
1341
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
1342
+ //=> false
1343
+ ```
1344
+ */
1345
+ strictNever?: boolean;
1346
+ };
1347
+ type DefaultAllExtendOptions = {
1348
+ strictNever: true;
1349
+ };
1350
+ /**
1351
+ Returns a boolean for whether every element in an array type extends another type.
1352
+
1353
+ @example
1354
+ ```
1355
+ import type {AllExtend} from 'type-fest';
1356
+
1357
+ type A = AllExtend<[1, 2, 3], number>;
1358
+ //=> true
1359
+
1360
+ type B = AllExtend<[1, 2, '3'], number>;
1361
+ //=> false
1362
+
1363
+ type C = AllExtend<[number, number | string], number>;
1364
+ //=> boolean
1365
+
1366
+ type D = AllExtend<[true, boolean, true], true>;
1367
+ //=> boolean
1368
+ ```
1369
+
1370
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1371
+
1372
+ ```
1373
+ // @exactOptionalPropertyTypes: true
1374
+ import type {AllExtend} from 'type-fest';
1375
+
1376
+ type A = AllExtend<[1?, 2?, 3?], number>;
1377
+ //=> true
1378
+ ```
1379
+
1380
+ ```
1381
+ // @exactOptionalPropertyTypes: false
1382
+ import type {AllExtend} from 'type-fest';
1383
+
1384
+ type A = AllExtend<[1?, 2?, 3?], number>;
1385
+ //=> boolean
1386
+
1387
+ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
1388
+ //=> true
1389
+ ```
1390
+
1391
+ @see {@link AllExtendOptions}
1392
+
1393
+ @category Utilities
1394
+ @category Array
1395
+ */
1396
+ type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
1397
+ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
1398
+ ? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
1399
+ //#endregion
1400
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and-all.d.ts
1401
+ /**
1402
+ Returns a boolean for whether all of the given elements are `true`.
1403
+
1404
+ Use-cases:
1405
+ - Check if all conditions in a list of booleans are met.
1406
+
1407
+ @example
1408
+ ```
1409
+ import type {AndAll} from 'type-fest';
1410
+
1411
+ type TTT = AndAll<[true, true, true]>;
1412
+ //=> true
1413
+
1414
+ type TTF = AndAll<[true, true, false]>;
1415
+ //=> false
1416
+
1417
+ type TFT = AndAll<[true, false, true]>;
1418
+ //=> false
1419
+ ```
1420
+
1421
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
1422
+ For example, `AndAll<[true, boolean]>` expands to `AndAll<[true, true]> | AndAll<[true, false]>`, which simplifies to `true | false` (i.e., `boolean`).
1423
+
1424
+ @example
1425
+ ```
1426
+ import type {AndAll} from 'type-fest';
1427
+
1428
+ type A = AndAll<[true, boolean]>;
1429
+ //=> boolean
1430
+
1431
+ type B = AndAll<[false, boolean]>;
1432
+ //=> false
1433
+ ```
1434
+
1435
+ Note: If any of the elements is `never`, the result becomes `false`.
1436
+
1437
+ @example
1438
+ ```
1439
+ import type {AndAll} from 'type-fest';
1440
+
1441
+ type A = AndAll<[true, true, never]>;
1442
+ //=> false
1443
+
1444
+ type B = AndAll<[false, never, never]>;
1445
+ //=> false
1446
+
1447
+ type C = AndAll<[never, never, never]>;
1448
+ //=> false
1449
+
1450
+ type D = AndAll<[boolean, true, never]>;
1451
+ //=> false
1452
+ ```
1453
+
1454
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
1455
+
1456
+ @example
1457
+ ```
1458
+ import type {AndAll} from 'type-fest';
1459
+
1460
+ type A = AndAll<[false, any]>;
1461
+ //=> false
1462
+
1463
+ type B = AndAll<[true, any]>;
1464
+ //=> boolean
1465
+ ```
1466
+
1467
+ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](https://en.wikipedia.org/wiki/Logical_conjunction#:~:text=In%20keeping%20with%20the%20concept%20of%20vacuous%20truth%2C%20when%20conjunction%20is%20defined%20as%20an%20operator%20or%20function%20of%20arbitrary%20arity%2C%20the%20empty%20conjunction%20(AND%2Ding%20over%20an%20empty%20set%20of%20operands)%20is%20often%20defined%20as%20having%20the%20result%20true.), i.e., there are no `false` elements in an empty tuple.
1468
+
1469
+ @see {@link And}
1470
+ @see {@link OrAll}
1471
+ */
1472
+ type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
1473
+ //#endregion
1474
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and.d.ts
1475
+ /**
1476
+ Returns a boolean for whether two given types are both `true`.
1477
+
1478
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
1479
+
1480
+ @example
1481
+ ```
1482
+ import type {And} from 'type-fest';
1483
+
1484
+ type TT = And<true, true>;
1485
+ //=> true
1486
+
1487
+ type TF = And<true, false>;
1488
+ //=> false
1489
+
1490
+ type FT = And<false, true>;
1491
+ //=> false
1492
+
1493
+ type FF = And<false, false>;
1494
+ //=> false
1495
+ ```
1496
+
1497
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
1498
+ For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
1499
+
1500
+ @example
1501
+ ```
1502
+ import type {And} from 'type-fest';
1503
+
1504
+ type A = And<true, boolean>;
1505
+ //=> boolean
1506
+
1507
+ type B = And<boolean, true>;
1508
+ //=> boolean
1509
+
1510
+ type C = And<false, boolean>;
1511
+ //=> false
1512
+
1513
+ type D = And<boolean, false>;
1514
+ //=> false
1515
+
1516
+ type E = And<boolean, boolean>;
1517
+ //=> boolean
1518
+ ```
1519
+
1520
+ Note: If either of the types is `never`, the result becomes `false`.
1521
+
1522
+ @example
1523
+ ```
1524
+ import type {And} from 'type-fest';
1525
+
1526
+ type A = And<true, never>;
1527
+ //=> false
1528
+
1529
+ type B = And<never, true>;
1530
+ //=> false
1531
+
1532
+ type C = And<false, never>;
1533
+ //=> false
1534
+
1535
+ type D = And<never, false>;
1536
+ //=> false
1537
+
1538
+ type E = And<boolean, never>;
1539
+ //=> false
1540
+
1541
+ type F = And<never, boolean>;
1542
+ //=> false
1543
+
1544
+ type G = And<never, never>;
1545
+ //=> false
1546
+ ```
1547
+
1548
+ @see {@link AndAll}
1549
+ @see {@link Or}
1550
+ @see {@link Xor}
1551
+ */
1552
+ type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
1553
+ //#endregion
1554
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/absolute.d.ts
1555
+ /**
1556
+ Returns the absolute value of the specified number or bigint.
1557
+
1558
+ @example
1559
+ ```
1560
+ import type {Absolute} from 'type-fest';
1561
+
1562
+ type A = Absolute<-1>;
1563
+ //=> 1
1564
+
1565
+ type B = Absolute<1>;
1566
+ //=> 1
1567
+
1568
+ type C = Absolute<0>;
1569
+ //=> 0
1570
+
1571
+ type D = Absolute<-1.025>;
1572
+ //=> 1.025
1573
+
1574
+ type E = Absolute<-9999n>;
1575
+ //=> 9999n
1576
+ ```
1577
+
1578
+ Returns back the same type if the input is not a literal type.
1579
+
1580
+ @example
1581
+ ```
1582
+ import type {Absolute} from 'type-fest';
1583
+
1584
+ type A = Absolute<number>;
1585
+ //=> number
1586
+
1587
+ type B = Absolute<bigint>;
1588
+ //=> bigint
1589
+
1590
+ type C = Absolute<number | bigint>;
1591
+ //=> number | bigint
1592
+ ```
1593
+
1594
+ @category Numeric
1595
+ */
1596
+ type Absolute<N extends number | bigint> = N extends bigint // Also, distributes `N`
1597
+ ? `${N}` extends `-${infer Magnitude extends bigint}` ? Magnitude : N : `${N}` extends `-${infer Magnitude}` // This doesn't use the `extends number` constraint approach because that fails with the `-Infinity` case
1598
+ ? StringToNumber<Magnitude> : N;
1599
+ //#endregion
1600
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than.d.ts
1601
+ /**
1602
+ Returns a boolean for whether a given number is greater than another number.
1603
+
1604
+ @example
1605
+ ```
1606
+ import type {GreaterThan} from 'type-fest';
1607
+
1608
+ type A = GreaterThan<1, -5>;
1609
+ //=> true
1610
+
1611
+ type B = GreaterThan<1, 1>;
1612
+ //=> false
1613
+
1614
+ type C = GreaterThan<1, 5>;
1615
+ //=> false
1616
+ ```
1617
+
1618
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1619
+
1620
+ @example
1621
+ ```
1622
+ import type {GreaterThan} from 'type-fest';
1623
+
1624
+ type A = GreaterThan<number, 1>;
1625
+ //=> boolean
1626
+
1627
+ type B = GreaterThan<1, number>;
1628
+ //=> boolean
1629
+
1630
+ type C = GreaterThan<number, number>;
1631
+ //=> boolean
1632
+ ```
1633
+
1634
+ @example
1635
+ ```
1636
+ import type {GreaterThan} from 'type-fest';
1637
+
1638
+ // Use `GreaterThan` to constrain a function parameter to positive numbers.
1639
+ declare function setPositive<N extends number>(value: GreaterThan<N, 0> extends true ? N : never): void;
1640
+
1641
+ setPositive(1); // ✅ Allowed
1642
+ setPositive(2); // ✅ Allowed
1643
+
1644
+ // @ts-expect-error
1645
+ setPositive(0);
1646
+
1647
+ // @ts-expect-error
1648
+ setPositive(-1);
1649
+ ```
1650
+ */
1651
+ type GreaterThan<A extends number, B extends number> = A extends number // For distributing `A`
1652
+ ? B extends number // For distributing `B`
1653
+ ? number extends A | B ? boolean : [IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>, IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${Absolute<B>}`, `${Absolute<A>}`> : never : never : never // Should never happen
1654
+ : never;
1655
+ //#endregion
1656
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
1657
+ /**
1658
+ Returns a boolean for whether a given number is greater than or equal to another number.
1659
+
1660
+ @example
1661
+ ```
1662
+ import type {GreaterThanOrEqual} from 'type-fest';
1663
+
1664
+ type A = GreaterThanOrEqual<1, -5>;
1665
+ //=> true
1666
+
1667
+ type B = GreaterThanOrEqual<1, 1>;
1668
+ //=> true
1669
+
1670
+ type C = GreaterThanOrEqual<1, 5>;
1671
+ //=> false
1672
+ ```
1673
+
1674
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1675
+
1676
+ @example
1677
+ ```
1678
+ import type {GreaterThanOrEqual} from 'type-fest';
1679
+
1680
+ type A = GreaterThanOrEqual<number, 1>;
1681
+ //=> boolean
1682
+
1683
+ type B = GreaterThanOrEqual<1, number>;
1684
+ //=> boolean
1685
+
1686
+ type C = GreaterThanOrEqual<number, number>;
1687
+ //=> boolean
1688
+ ```
1689
+
1690
+ @example
1691
+ ```
1692
+ import type {GreaterThanOrEqual} from 'type-fest';
1693
+
1694
+ // Use `GreaterThanOrEqual` to constrain a function parameter to non-negative numbers.
1695
+ declare function setNonNegative<N extends number>(value: GreaterThanOrEqual<N, 0> extends true ? N : never): void;
1696
+
1697
+ setNonNegative(0); // ✅ Allowed
1698
+ setNonNegative(1); // ✅ Allowed
1699
+
1700
+ // @ts-expect-error
1701
+ setNonNegative(-1);
1702
+
1703
+ // @ts-expect-error
1704
+ setNonNegative(-2);
1705
+ ```
1706
+ */
1707
+ type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? boolean : A extends number // For distributing `A`
1708
+ ? B extends number // For distributing `B`
1709
+ ? A extends B ? true : GreaterThan<A, B> : never // Should never happen
1710
+ : never;
1711
+ //#endregion
1712
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/less-than.d.ts
1713
+ /**
1714
+ Returns a boolean for whether a given number is less than another number.
1715
+
1716
+ @example
1717
+ ```
1718
+ import type {LessThan} from 'type-fest';
1719
+
1720
+ type A = LessThan<1, -5>;
1721
+ //=> false
1722
+
1723
+ type B = LessThan<1, 1>;
1724
+ //=> false
1725
+
1726
+ type C = LessThan<1, 5>;
1727
+ //=> true
1728
+ ```
1729
+
1730
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1731
+
1732
+ @example
1733
+ ```
1734
+ import type {LessThan} from 'type-fest';
1735
+
1736
+ type A = LessThan<number, 1>;
1737
+ //=> boolean
1738
+
1739
+ type B = LessThan<1, number>;
1740
+ //=> boolean
1741
+
1742
+ type C = LessThan<number, number>;
1743
+ //=> boolean
1744
+ ```
1745
+
1746
+ @example
1747
+ ```
1748
+ import type {LessThan} from 'type-fest';
1749
+
1750
+ // Use `LessThan` to constrain a function parameter to negative numbers.
1751
+ declare function setNegative<N extends number>(value: LessThan<N, 0> extends true ? N : never): void;
1752
+
1753
+ setNegative(-1); // ✅ Allowed
1754
+ setNegative(-2); // ✅ Allowed
1755
+
1756
+ // @ts-expect-error
1757
+ setNegative(0);
1758
+
1759
+ // @ts-expect-error
1760
+ setNegative(1);
1761
+ ```
1762
+ */
1763
+ type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
1764
+ //#endregion
1765
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/tuple.d.ts
1766
+ // Should never happen
1767
+ /**
1768
+ Returns the maximum value from a tuple of integers.
1769
+
1770
+ Note:
1771
+ - Float numbers are not supported.
1772
+
1773
+ @example
1774
+ ```
1775
+ type A = TupleMax<[1, 2, 5, 3]>;
1776
+ //=> 5
1777
+
1778
+ type B = TupleMax<[1, 2, 5, 3, 99, -1]>;
1779
+ //=> 99
1780
+ ```
1781
+ */
1782
+ type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? GreaterThan<F, Result> extends true ? TupleMax<R, F> : TupleMax<R, Result> : Result;
1783
+ //#endregion
1784
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/subtract.d.ts
1785
+ /**
1786
+ Returns the difference between two numbers.
1787
+
1788
+ Note:
1789
+ - A or B can only support `-999` ~ `999`.
1790
+
1791
+ @example
1792
+ ```
1793
+ import type {Subtract, PositiveInfinity} from 'type-fest';
1794
+
1795
+ type A = Subtract<333, 222>;
1796
+ //=> 111
1797
+
1798
+ type B = Subtract<111, -222>;
1799
+ //=> 333
1800
+
1801
+ type C = Subtract<-111, 222>;
1802
+ //=> -333
1803
+
1804
+ type D = Subtract<18, 96>;
1805
+ //=> -78
1806
+
1807
+ type E = Subtract<PositiveInfinity, 9999>;
1808
+ //=> Infinity
1809
+
1810
+ type F = Subtract<PositiveInfinity, PositiveInfinity>;
1811
+ //=> number
1812
+ ```
1813
+
1814
+ @category Numeric
1815
+ */
1816
+ // TODO: Support big integer.
1817
+ type Subtract<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
1818
+ number extends A | B ? number // Handle cases when A and B are both +/- infinity
1819
+ : A extends B & (PositiveInfinity | NegativeInfinity) ? number // Handle cases when A is - infinity or B is + infinity
1820
+ : A extends NegativeInfinity ? NegativeInfinity : B extends PositiveInfinity ? NegativeInfinity // Handle cases when A is + infinity or B is - infinity
1821
+ : A extends PositiveInfinity ? PositiveInfinity : B extends NegativeInfinity ? PositiveInfinity // Handle case when numbers are equal to each other
1822
+ : A extends B ? 0 // Handle cases when A or B is 0
1823
+ : A extends 0 ? ReverseSign<B> : B extends 0 ? A // Handle remaining regular cases
1824
+ : SubtractPostChecks<A, B>;
1825
+ /**
1826
+ Subtracts two numbers A and B, such that they are not equal and neither of them are 0, +/- infinity or the `number` type
1827
+ */
1828
+ type SubtractPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] ? SubtractPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we subtract the absolute values and then reverse the sign
1829
+ ? ReverseSign<SubtractPositives<Absolute<A>, Absolute<B>>> // When the signs are different we can add the absolute values and then reverse the sign if A < B
1830
+ : [...TupleOf<Absolute<A>>, ...TupleOf<Absolute<B>>] extends infer R extends unknown[] ? LessThan<A, B> extends true ? ReverseSign<R['length']> : R['length'] : never;
1831
+ /**
1832
+ Subtracts two positive numbers.
1833
+ */
1834
+ type SubtractPositives<A extends number, B extends number> = LessThan<A, B> extends true // When A < B we can reverse the result of B - A
1835
+ ? ReverseSign<SubtractIfAGreaterThanB<B, A>> : SubtractIfAGreaterThanB<A, B>;
1836
+ /**
1837
+ Subtracts two positive numbers A and B such that A > B.
1838
+ */
1839
+ type SubtractIfAGreaterThanB<A extends number, B extends number> = // This is where we always want to end up and do the actual subtraction
1840
+ TupleOf<A> extends [...TupleOf<B>, ...infer R] ? R['length'] : never;
1841
+ //#endregion
1842
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/sum.d.ts
1843
+ /**
1844
+ Returns the sum of two numbers.
1845
+
1846
+ Note:
1847
+ - A or B can only support `-999` ~ `999`.
1848
+
1849
+ @example
1850
+ ```
1851
+ import type {Sum, PositiveInfinity, NegativeInfinity} from 'type-fest';
1852
+
1853
+ type A = Sum<111, 222>;
1854
+ //=> 333
1855
+
1856
+ type B = Sum<-111, 222>;
1857
+ //=> 111
1858
+
1859
+ type C = Sum<111, -222>;
1860
+ //=> -111
1861
+
1862
+ type D = Sum<PositiveInfinity, -9999>;
1863
+ //=> Infinity
1864
+
1865
+ type E = Sum<PositiveInfinity, NegativeInfinity>;
1866
+ //=> number
1867
+ ```
1868
+
1869
+ @category Numeric
1870
+ */
1871
+ // TODO: Support big integer.
1872
+ type Sum<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
1873
+ number extends A | B ? number // Handle cases when A and B are both +/- infinity
1874
+ : A extends B & (PositiveInfinity | NegativeInfinity) ? A // A or B could be used here as they are equal
1875
+ // Handle cases when A and B are opposite infinities
1876
+ : A | B extends PositiveInfinity | NegativeInfinity ? number // Handle cases when A is +/- infinity
1877
+ : A extends PositiveInfinity | NegativeInfinity ? A // Handle cases when B is +/- infinity
1878
+ : B extends PositiveInfinity | NegativeInfinity ? B // Handle cases when A or B is 0 or it's the same number with different signs
1879
+ : A extends 0 ? B : B extends 0 ? A : A extends ReverseSign<B> ? 0 // Handle remaining regular cases
1880
+ : SumPostChecks<A, B>;
1881
+ /**
1882
+ Adds two numbers A and B, such that they are not equal with different signs and neither of them are 0, +/- infinity or the `number` type
1883
+ */
1884
+ type SumPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] // When both numbers are positive we can add them together
1885
+ ? SumPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we add the absolute values and then reverse the sign
1886
+ ? ReverseSign<SumPositives<Absolute<A>, Absolute<B>>> // When the signs are different we can subtract the absolute values, remove the sign
1887
+ // and then reverse the sign if the larger absolute value is negative
1888
+ : Absolute<Subtract<Absolute<A>, Absolute<B>>> extends infer Result extends number ? TupleMax<[Absolute<A>, Absolute<B>]> extends infer Max_ extends number ? Max_ extends A | B // The larger absolute value is positive, so the result is positive
1889
+ ? Result // The larger absolute value is negative, so the result is negative
1890
+ : ReverseSign<Result> : never : never;
1891
+ /**
1892
+ Adds two positive numbers.
1893
+ */
1894
+ type SumPositives<A extends number, B extends number> = [...TupleOf<A>, ...TupleOf<B>]['length'] extends infer Result extends number ? Result : never;
1895
+ //#endregion
1896
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/exclude-exactly.d.ts
1897
+ /**
1898
+ A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
1899
+
1900
+ @example
1901
+ ```
1902
+ import type {ExcludeExactly} from 'type-fest';
1903
+
1904
+ type TestExclude1 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
1905
+ //=> 1 | 2 | 3
1906
+
1907
+ type TestExcludeExactly1 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
1908
+ //=> 'a' | 'b' | 'c' | 1 | 2 | 3
1909
+
1910
+ type TestExclude2 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
1911
+ //=> never
1912
+
1913
+ type TestExcludeExactly2 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
1914
+ //=> 'a' | 'b' | 'c' | 1 | 2 | 3
1915
+
1916
+ type TestExclude3 = Exclude<{a: string} | {a: string; b: string}, {a: string}>;
1917
+ //=> never
1918
+
1919
+ type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string}, {a: string}>;
1920
+ //=> {a: string; b: string}
1921
+ ```
1922
+
1923
+ @category Improved Built-in
1924
+ */
1925
+ type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, _ExcludeExactly<Union, Delete>, // If `Union` is `any`, then if `Delete` is `any`, return `never`, else return `Union`.
1926
+ If<IsAny<Delete>, never, Union>, // If `Union` is `never`, then if `Delete` is `never`, return `never`, else return `Union`.
1927
+ If<IsNever<Delete>, never, Union>>;
1928
+ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unknown // For distributing `Union`
1929
+ ? [Delete extends unknown // For distributing `Delete`
1930
+ ? If<IsEqual<Union, Delete>, true, never> : never] extends [never] ? Union : never : never, // If `Delete` is `any` or `never`, then return `Union`,
1931
+ // because `Union` cannot be `any` or `never` here.
1932
+ Union, Union>;
1933
+ //#endregion
1934
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-member.d.ts
1935
+ /**
1936
+ Returns an arbitrary member of a union type.
1937
+
1938
+ Use-cases:
1939
+ - Implementing recursive type functions that accept a union type.
1940
+
1941
+ @example
1942
+ ```
1943
+ import type {UnionMember, IsNever} from 'type-fest';
1944
+
1945
+ type UnionLength<T, Acc extends any[] = []> =
1946
+ UnionMember<T> extends infer Member
1947
+ ? IsNever<Member> extends false
1948
+ ? UnionLength<Exclude<T, Member>, [...Acc, Member]>
1949
+ : Acc['length']
1950
+ : never;
1951
+
1952
+ type T1 = UnionLength<'foo' | 'bar' | 'baz'>;
1953
+ //=> 3
1954
+
1955
+ type T2 = UnionLength<{a: string}>;
1956
+ //=> 1
1957
+ ```
1958
+
1959
+ - Picking an arbitrary member from a union
1960
+
1961
+ @example
1962
+ ```
1963
+ import type {UnionMember, Primitive, LiteralToPrimitive} from 'type-fest';
1964
+
1965
+ type IsHomogenous<T extends Primitive> = [T] extends [LiteralToPrimitive<UnionMember<T>>] ? true : false;
1966
+
1967
+ type T1 = IsHomogenous<1 | 2 | 3 | 4>;
1968
+ //=> true
1969
+
1970
+ type T2 = IsHomogenous<'foo' | 'bar'>;
1971
+ //=> true
1972
+
1973
+ type T3 = IsHomogenous<'foo' | 'bar' | 1>;
1974
+ //=> false
1975
+ ```
1976
+
1977
+ Returns `never` when the input is `never`.
1978
+
1979
+ @example
1980
+ ```
1981
+ import type {UnionMember} from 'type-fest';
1982
+
1983
+ type LastNever = UnionMember<never>;
1984
+ //=> never
1985
+ ```
1986
+
1987
+ @category Type
1988
+ */
1989
+ type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
1990
+ //#endregion
1991
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-tuple.d.ts
1992
+ /**
1993
+ Convert a union type into an unordered tuple type of its elements.
1994
+
1995
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
1996
+
1997
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
1998
+
1999
+ @example
2000
+ ```
2001
+ import type {UnionToTuple} from 'type-fest';
2002
+
2003
+ type Numbers = 1 | 2 | 3;
2004
+ type NumbersTuple = UnionToTuple<Numbers>;
2005
+ //=> [1, 2, 3]
2006
+ ```
2007
+
2008
+ @example
2009
+ ```
2010
+ import type {UnionToTuple} from 'type-fest';
2011
+
2012
+ const pets = {
2013
+ dog: '🐶',
2014
+ cat: '🐱',
2015
+ snake: '🐍',
2016
+ };
2017
+
2018
+ type Pet = keyof typeof pets;
2019
+ //=> 'dog' | 'cat' | 'snake'
2020
+
2021
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
2022
+ //=> ['dog', 'cat', 'snake']
2023
+ ```
2024
+
2025
+ @category Array
2026
+ */
2027
+ type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
2028
+ // Nudges the compiler that `UnionToTuple` always yields an array.
2029
+ type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
2030
+ //#endregion
2031
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-range.d.ts
2032
+ /**
2033
+ Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.
2034
+
2035
+ You skip over numbers using the `Step` parameter (defaults to `1`). For example, `IntRange<0, 10, 2>` will create a union of `0 | 2 | 4 | 6 | 8`.
2036
+
2037
+ Note: `Start` or `End` must be non-negative and smaller than `1000`.
2038
+
2039
+ Use-cases:
2040
+ 1. This can be used to define a set of valid input/output values. for example:
2041
+
2042
+ @example
2043
+ ```
2044
+ import type {IntRange} from 'type-fest';
2045
+
2046
+ type Age = IntRange<0, 20>;
2047
+ //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
2048
+
2049
+ type FontSize = IntRange<10, 20>;
2050
+ //=> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
2051
+
2052
+ type EvenNumber = IntRange<0, 11, 2>;
2053
+ //=> 0 | 2 | 4 | 6 | 8 | 10
2054
+ ```
2055
+
2056
+ 2. This can be used to define random numbers in a range. For example, `type RandomNumber = IntRange<0, 100>;`
2057
+
2058
+ @example
2059
+ ```
2060
+ import type {IntRange} from 'type-fest';
2061
+
2062
+ type ZeroToNine = IntRange<0, 10>;
2063
+ //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
2064
+
2065
+ type Hundreds = IntRange<100, 901, 100>;
2066
+ //=> 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
2067
+ ```
2068
+
2069
+ @see {@link IntClosedRange}
2070
+ */
2071
+ type IntRange<Start extends number, End extends number, Step extends number = 1> = PrivateIntRange<Start, End, Step>;
2072
+ /**
2073
+ The actual implementation of `IntRange`. It's private because it has some arguments that don't need to be exposed.
2074
+ */
2075
+ type PrivateIntRange<Start extends number, End extends number, Step extends number, // The gap between each number, gap = step - 1
2076
+ Gap extends number = Subtract<Step, 1>, // The final `List` is `[...StartLengthTuple, ...[number, ...GapLengthTuple], ...[number, ...GapLengthTuple], ... ...]`, so can initialize the `List` with `[...StartLengthTuple]`
2077
+ List extends unknown[] = TupleOf<Start, never>, EndLengthTuple extends unknown[] = TupleOf<End>> = Gap extends 0 // Handle the case that without `Step`
2078
+ ? List['length'] extends End // The result of "List[length] === End"
2079
+ ? Exclude<List[number], never> // All unused elements are `never`, so exclude them
2080
+ : PrivateIntRange<Start, End, Step, Gap, [...List, List['length']]> // Handle the case that with `Step`
2081
+ : List extends [...(infer U), ...EndLengthTuple] // The result of "List[length] >= End", because the `...TupleOf<Gap, never>` maybe make `List` too long.
2082
+ ? Exclude<List[number], never> : PrivateIntRange<Start, End, Step, Gap, [...List, List['length'], ...TupleOf<Gap, never>]>;
2083
+ //#endregion
2084
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-closed-range.d.ts
2085
+ /**
2086
+ Generate a union of numbers between a specified start and end (both inclusive), with an optional step.
2087
+
2088
+ You skip over numbers using the `Step` parameter (defaults to `1`). For example, `IntClosedRange<0, 10, 2>` will create a union of `0 | 2 | 4 | 6 | 8 | 10`.
2089
+
2090
+ Note: `Start` or `End` must be non-negative and smaller than `999`.
2091
+
2092
+ Use-cases:
2093
+ 1. This can be used to define a set of valid input/output values. for example:
2094
+
2095
+ @example
2096
+ ```
2097
+ import type {IntClosedRange} from 'type-fest';
2098
+
2099
+ type Age = IntClosedRange<0, 20>;
2100
+ //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
2101
+
2102
+ type FontSize = IntClosedRange<10, 20>;
2103
+ //=> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
2104
+
2105
+ type EvenNumber = IntClosedRange<0, 10, 2>;
2106
+ //=> 0 | 2 | 4 | 6 | 8 | 10
2107
+ ```
2108
+
2109
+ 2. This can be used to define random numbers in a range. For example, `type RandomNumber = IntClosedRange<0, 100>;`
2110
+
2111
+ @example
2112
+ ```
2113
+ import type {IntClosedRange} from 'type-fest';
2114
+
2115
+ type ZeroToNine = IntClosedRange<0, 9>;
2116
+ //=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
2117
+
2118
+ type Hundreds = IntClosedRange<100, 900, 100>;
2119
+ //=> 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
2120
+ ```
2121
+
2122
+ @see {@link IntRange}
2123
+ */
2124
+ type IntClosedRange<Start extends number, End extends number, Skip extends number = 1> = IntRange<Start, Sum<End, 1>, Skip>;
2125
+ //#endregion
2126
+ //#region src/node/Lifecycle/LifecycleTypes.d.ts
2127
+ /** Actions that can occur during lifecycle phases */
2128
+ type LifecycleAction = 'start' | 'complete' | 'error';
2129
+ /**
2130
+ * Creates event names for lifecycle managers with phase numbers and actions
2131
+ * @typeParam Prefix - The prefix string for lifecycle events
2132
+ * @typeParam Phases - Array of phase numbers to generate events for
2133
+ */
2134
+ type PhaseEvents<Prefix extends string, Phases extends number[]> = `phase:${IntClosedRange<1, Phases['length']>}:${TypedExclude<LifecycleAction, 'error'>}` | `${Prefix}:${LifecycleAction}`;
2135
+ /**
2136
+ * Event payload map for a lifecycle. The phase and prefix `start`/`complete` events have an empty
2137
+ * payload, and the `${Prefix}:error` event's payload is the thrown error.
2138
+ * @typeParam Prefix - The prefix string for lifecycle events
2139
+ * @typeParam Phases - Array of phase numbers to generate events for
2140
+ */
2141
+ type PhaseEventMap<Prefix extends string, Phases extends number[]> = { [K in PhaseEvents<Prefix, Phases>]: K extends `${string}:error` ? readonly [error: unknown] : readonly [] };
2142
+ /** Base interface for a lifecycle task */
2143
+ interface LifecycleTask {
2144
+ /** Name of the task */
2145
+ name: string;
2146
+ /** Function to execute the task */
2147
+ task: () => Promise<void>;
2148
+ /** Timeout for the task */
2149
+ timeout: number;
2150
+ }
2151
+ //#endregion
2152
+ //#region src/node/Lifecycle/CoordinatedLifecycle.d.ts
2153
+ /**
2154
+ * Abstract base class for coordinated lifecycle management (startup/shutdown)
2155
+ */
2156
+ declare abstract class CoordinatedLifecycle<TPhase extends number, TEvents extends EventMap<TEvents>> extends TypedEventEmitter<TEvents> {
2157
+ protected readonly phaseOrder: TPhase[];
2158
+ protected readonly phaseEnum: Record<number, string>;
2159
+ protected readonly logger: Logger;
2160
+ protected readonly tasksMap: Map<TPhase, LifecycleTask[]>;
2161
+ protected constructor(loggerName: string, phaseOrder: TPhase[], phaseEnum: Record<number, string>);
2162
+ /**
2163
+ * Adds a lifecycle task to a specific phase.
2164
+ *
2165
+ * Tasks are executed in phase order during lifecycle operations.
2166
+ * Each task has a timeout to prevent hanging operations.
2167
+ *
2168
+ * @param phase - The lifecycle phase to add the task to
2169
+ * @param taskName - Unique name for the task (used for logging and removal)
2170
+ * @param task - Async function to execute during the phase
2171
+ * @param timeoutMs - Maximum time allowed for task execution in milliseconds
2172
+ * @example
2173
+ * ```typescript
2174
+ * lifecycle.addTask(StartupPhase.Services, 'start-database', async () => {
2175
+ * await database.connect();
2176
+ * }, 10000);
2177
+ * ```
2178
+ */
2179
+ addTask(phase: TPhase, taskName: string, task: () => Promise<void>, timeoutMs: number): void;
2180
+ /**
2181
+ * Removes a lifecycle task from a specific phase.
2182
+ *
2183
+ * @param phase - The lifecycle phase to remove the task from
2184
+ * @param taskName - Name of the task to remove
2185
+ * @returns True if the task was found and removed, false otherwise
2186
+ */
2187
+ removeTask(phase: TPhase, taskName: string): boolean;
2188
+ /**
2189
+ * Run all tasks in a specific phase
2190
+ */
2191
+ protected runPhase(phase: TPhase): Promise<void>;
2192
+ /**
2193
+ * Run a single task with timeout
2194
+ */
2195
+ protected runTaskWithTimeout(phase: TPhase, task: LifecycleTask): Promise<void>;
2196
+ private emitPhase;
2197
+ protected onListenerError(error: unknown, event: string | symbol): void;
2198
+ protected abstract canAddTask(): boolean;
2199
+ protected abstract canRemoveTask(): boolean;
2200
+ protected abstract getTaskType(): string;
2201
+ protected abstract executeTasksInPhase(phase: TPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
2202
+ }
2203
+ //#endregion
2204
+ //#region src/node/Lifecycle/CoordinatedShutdown.d.ts
2205
+ /**
2206
+ * Shutdown phases for coordinated application shutdown.
2207
+ */
2208
+ declare enum ShutdownPhase {
2209
+ /** Stop accepting new requests/interactions */
2210
+ StopAcceptingRequests = 1,
2211
+ /** Stop background services (health checks, etc.) */
2212
+ StopServices = 2,
2213
+ /** Disconnect from external resources (database, APIs) */
2214
+ ExternalResources = 3,
2215
+ /** Disconnect from Discord */
2216
+ DiscordCleanup = 4,
2217
+ /** Final cleanup tasks */
2218
+ FinalCleanup = 5
2219
+ }
2220
+ /**
2221
+ * Strict-event-emitter payload map for coordinated shutdown phases.
2222
+ */
2223
+ type CoordinatedShutdownEvents = PhaseEventMap<'shutdown', UnionToTuple<ShutdownPhase>>;
2224
+ /**
2225
+ * CoordinatedShutdown manages graceful application shutdown by executing registered tasks across defined phases.
2226
+ *
2227
+ * It listens for termination signals (SIGINT, SIGTERM) and runs tasks in parallel within each phase.
2228
+ * Tasks can be added or removed dynamically, and each task has an associated timeout.
2229
+ */
2230
+ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, CoordinatedShutdownEvents> {
2231
+ private readonly isShutdownEnabled;
2232
+ private isShuttingDown;
2233
+ private exitCode;
2234
+ private onSigTerm;
2235
+ private onSigInt;
2236
+ constructor(enabled?: boolean);
2237
+ protected canAddTask(): boolean;
2238
+ protected canRemoveTask(): boolean;
2239
+ protected getTaskType(): string;
2240
+ protected executeTasksInPhase(phase: ShutdownPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
2241
+ private registerSignalHandlers;
2242
+ private removeSignalHandlers;
2243
+ /**
2244
+ * Adds a task to a specific shutdown phase with timeout.
2245
+ *
2246
+ * @param phase - The shutdown phase from {@link ShutdownPhase}
2247
+ * @param taskName - Unique identifier for the task
2248
+ * @param task - Async function to execute
2249
+ * @param timeoutMs - Task timeout in milliseconds. {@default `5000`}
2250
+ */
2251
+ addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
2252
+ /**
2253
+ * Removes a task from a specific shutdown phase.
2254
+ *
2255
+ * @param phase - The shutdown phase to remove from
2256
+ * @param taskName - Name of the task to remove
2257
+ * @returns True if task was found and removed
2258
+ */
2259
+ removeTask(phase: ShutdownPhase, taskName: string): boolean;
2260
+ /**
2261
+ * Executes the coordinated shutdown sequence.
2262
+ *
2263
+ * Runs all registered tasks across shutdown phases in reverse order.
2264
+ * Tasks within each phase are executed in parallel for faster shutdown.
2265
+ * Process exits with the specified code when complete.
2266
+ *
2267
+ * @param exitCode - Process exit code. {@default `0`}
2268
+ * @param exitProcess - Whether to exit the process after shutdown. {@default `true`}
2269
+ * @returns Promise that resolves when shutdown is complete
2270
+ * @example
2271
+ * ```typescript
2272
+ * shutdown.addTask(ShutdownPhase.Services, 'database', () => db.disconnect(), 5000);
2273
+ * await shutdown.run(0); // Graceful shutdown
2274
+ * ```
2275
+ */
2276
+ run(exitCode?: number, exitProcess?: boolean): Promise<void>;
2277
+ }
2278
+ //#endregion
2279
+ //#region src/node/Lifecycle/CoordinatedStartup.d.ts
2280
+ /**
2281
+ * Startup phases for coordinated initialization
2282
+ *
2283
+ * Defines the order in which different components are initialized during bot startup.
2284
+ */
2285
+ declare enum StartupPhase {
2286
+ /** Validate environment variables and config files */
2287
+ Validation = 1,
2288
+ /** Discover plugin constructors via decorators or registry */
2289
+ Discovery = 2,
2290
+ /** Register plugin metadata and declared dependencies */
2291
+ Registration = 3,
2292
+ /** Inject and validate plugin-specific configuration */
2293
+ Configuration = 4,
2294
+ /** Instantiate plugin classes with Core and arguments */
2295
+ Instantiation = 5,
2296
+ /** Activate plugins by calling their init/setup methods */
2297
+ Activation = 6,
2298
+ /** Mark seedcord as ready and start handling interactions */
2299
+ Ready = 7
2300
+ }
2301
+ /**
2302
+ * Strict-event-emitter payload map for coordinated startup phases.
2303
+ */
2304
+ type CoordinatedStartupEvents = PhaseEventMap<'startup', UnionToTuple<StartupPhase>>;
2305
+ /**
2306
+ * Manages bot startup lifecycle with ordered phases
2307
+ *
2308
+ * Coordinates initialization of all bot components in a predictable sequence.
2309
+ * Tasks are executed within their designated phases to ensure proper dependency order.
2310
+ */
2311
+ declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase, CoordinatedStartupEvents> {
2312
+ private isStartingUp;
2313
+ private hasStarted;
2314
+ constructor();
2315
+ /**
2316
+ * Adds a task to a specific startup phase with timeout.
2317
+ *
2318
+ * @param phase - The startup phase from {@link StartupPhase}
2319
+ * @param taskName - Unique identifier for the task
2320
+ * @param task - Async function to execute
2321
+ * @param timeoutMs - Task timeout in milliseconds. {@default `10000`}
2322
+ */
2323
+ addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
2324
+ protected canAddTask(): boolean;
2325
+ protected canRemoveTask(): boolean;
2326
+ protected getTaskType(): string;
2327
+ protected executeTasksInPhase(phase: StartupPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
2328
+ /**
2329
+ * Executes the coordinated startup sequence.
2330
+ *
2331
+ * Runs all registered tasks across startup phases in the correct order.
2332
+ * Each phase completes before the next phase begins. Tasks within a phase
2333
+ * are executed sequentially to maintain predictable initialization.
2334
+ *
2335
+ * @returns Promise that resolves when startup is complete
2336
+ * @throws An {@link Error} If startup fails or is called multiple times
2337
+ * @example
2338
+ * ```typescript
2339
+ * const startup = new CoordinatedStartup();
2340
+ * startup.addTask(StartupPhase.Services, 'database', () => db.connect(), 10000);
2341
+ * await startup.run();
2342
+ * ```
2343
+ */
2344
+ run(): Promise<void>;
2345
+ protected runTaskWithTimeout(phase: StartupPhase, task: LifecycleTask): Promise<void>;
2346
+ /**
2347
+ * Aborts the startup sequence if it is currently running.
2348
+ */
2349
+ abort(): void;
2350
+ /**
2351
+ * Check if startup has completed
2352
+ */
2353
+ get isReady(): boolean;
2354
+ /**
2355
+ * Check if startup is currently running
2356
+ */
2357
+ get isRunning(): boolean;
2358
+ }
2359
+ //#endregion
2360
+ //#region src/node/HealthCheck.d.ts
2361
+ /**
2362
+ * HTTP health check service for monitoring bot status.
2363
+ *
2364
+ * Provides a simple HTTP endpoint that responds with JSON status
2365
+ * information, useful for container orchestration and monitoring.
2366
+ */
2367
+ declare class HealthCheck {
2368
+ /** @internal */
2369
+ readonly logger: Logger;
2370
+ readonly port: number;
2371
+ readonly path: string;
2372
+ readonly host: string | undefined;
2373
+ private server?;
2374
+ constructor(shutdown: CoordinatedShutdown, options?: HealthCheckConfig);
2375
+ /**
2376
+ * Starts the health check server.
2377
+ * @returns Promise that resolves when the server is listening
2378
+ * @internal
2379
+ */
2380
+ init(): Promise<void>;
2381
+ /**
2382
+ * Stops the health check server.
2383
+ *
2384
+ * @returns Promise that resolves when the server is closed
2385
+ * @internal
2386
+ */
2387
+ stop(): Promise<void>;
2388
+ }
2389
+ //#endregion
2390
+ export { CoordinatedLifecycle, CoordinatedShutdown, CoordinatedShutdownEvents, CoordinatedStartup, CoordinatedStartupEvents, HealthCheck, type LifecycleTask, ShutdownPhase, StartupPhase };
2391
+ //# sourceMappingURL=node.index.d.mts.map