@seedcord/services 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,68 +1,60 @@
1
- import { o as isSeedcordError, r as SeedcordErrorTypeString, s as SeedcordErrorCode, t as BaseSeedcordError } from "./SeedcordError-D6uPv6qc.mjs";
1
+ import { EventEmitter } from "node:events";
2
2
  import { Logform, Logger as Logger$1 } from "winston";
3
3
  import TransportStream from "winston-transport";
4
- import { EventEmitter } from "node:events";
5
- import { HealthCheckConfig, ILogger, TypedExclude } from "@seedcord/types";
4
+ import { EpochMs, HealthCheckConfig, ILogger, TypedExclude } from "@seedcord/types";
6
5
  import { Writable } from "node:stream";
7
6
 
8
- //#region src/CooldownManager.d.ts
7
+ //#region src/RateLimiter.d.ts
8
+ /**
9
+ * A usage window for a {@link RateLimiter} key.
10
+ */
11
+ interface RateLimitWindow {
12
+ /** Window length in milliseconds. */
13
+ delay: number;
14
+ /**
15
+ * Hits allowed inside the window before the key is limited.
16
+ *
17
+ * @defaultValue `1`
18
+ */
19
+ limit?: number;
20
+ }
9
21
  /**
10
- * Configuration options for CooldownManager.
22
+ * The outcome of a {@link RateLimiter.hit}.
11
23
  */
12
- interface CooldownOptions {
13
- /** Cooldown window in milliseconds (default 1000) */
14
- cooldown?: number;
15
- /** Custom error class to throw when a key is still cooling down; receives the remaining ms. */
16
- err?: new (msg: string, remaining: number) => Error;
17
- /** Message passed to the error constructor (default "Cooldown active") */
18
- message?: string;
24
+ interface RateLimitResult {
25
+ /** Whether the key is at or over its limit for the current window. */
26
+ limited: boolean;
27
+ /** Absolute epoch milliseconds when the key next frees up. Convert to seconds for Discord timestamp markup. */
28
+ expires: EpochMs;
19
29
  }
20
30
  /**
21
- * Lightweight utility for per-key cooldowns.
31
+ * Tracks per-key usage windows and reports when a key is limited and when it frees up.
22
32
  *
23
- * Manages time-based restrictions on operations by key,
24
- * useful for rate limiting, command cooldowns, and spam prevention.
33
+ * Each key holds a sliding window of hit expiry times, and is limited once its live-hit count
34
+ * reaches the window's `limit`. Expired hits are dropped on the next read, and a background sweep
35
+ * drops fully-expired keys so the map does not grow without bound.
25
36
  */
26
- declare class CooldownManager {
27
- private readonly window;
28
- private readonly Err;
29
- private readonly msg;
37
+ declare class RateLimiter {
30
38
  private readonly map;
39
+ constructor();
40
+ /** Number of keys currently tracked. */
41
+ get size(): number;
31
42
  /**
32
- * Creates a new CooldownManager instance.
33
- *
34
- * @param opts - Configuration options for the cooldown behavior
35
- */
36
- constructor(opts?: CooldownOptions);
37
- /**
38
- * Records usage timestamp for a key without any cooldown checks.
39
- *
40
- * @param key - The unique identifier for the cooldown entry
41
- */
42
- set(key: string): void;
43
- /**
44
- * Verifies cooldown status for a key and updates timestamp if not active.
45
- *
46
- * If the cooldown is still active, throws the configured error.
47
- * If not active, updates the timestamp and returns successfully.
48
- *
49
- * @param key - The unique identifier to check cooldown for
50
- * @throws An {@link Err} When the cooldown is still active for the given key
51
- */
52
- check(key: string): void;
53
- /**
54
- * Checks if a key is currently cooling down without updating timestamp.
43
+ * Records a hit for `key` and reports whether the key is now limited.
55
44
  *
56
- * @param key - The unique identifier to check
57
- * @returns True if the key is still cooling down, false otherwise
45
+ * @param key - The bucket to record against. The caller builds it from its own scope.
46
+ * @param window - The usage window to apply for this hit.
58
47
  */
59
- isActive(key: string): boolean;
48
+ hit(key: string, window: RateLimitWindow): RateLimitResult;
60
49
  /**
61
- * Removes a key from the cooldown map.
50
+ * Reports whether `key` is limited right now without recording a hit.
62
51
  *
63
- * @param key - The unique identifier to remove (useful for manual resets)
52
+ * The read half of a peek-then-commit. A gate calls `peek` to decide whether to refuse, and
53
+ * `hit` to charge the slot only once it is the gate that let the request through.
64
54
  */
65
- clear(key: string): void;
55
+ peek(key: string, window: RateLimitWindow): RateLimitResult;
56
+ private live;
57
+ private sweep;
66
58
  }
67
59
  //#endregion
68
60
  //#region src/Logger/Types.d.ts
@@ -168,7 +160,11 @@ interface LoggerConfiguration {
168
160
  * Options for creating a Logger instance.
169
161
  */
170
162
  interface LoggerOptions {
171
- /** Channel to log to (defaults to configured default channel) */
163
+ /**
164
+ * Channel to log to.
165
+ *
166
+ * @defaultValue the configured default channel
167
+ */
172
168
  channel?: string;
173
169
  /** Format mode for output */
174
170
  format?: LoggerFormatMode;
@@ -255,12 +251,8 @@ declare class Logger implements ILogger {
255
251
  private channel;
256
252
  private readonly registry;
257
253
  readonly utils: LoggerUtilities;
258
- private static readonly instances;
259
- private static instance;
260
254
  /**
261
- * Configures global logger settings.
262
- *
263
- * Applies configuration to all channels and clears instance cache.
255
+ * Configures global logger settings, applied to all channels.
264
256
  *
265
257
  * @param config - Partial configuration to merge with defaults
266
258
  */
@@ -279,7 +271,7 @@ declare class Logger implements ILogger {
279
271
  */
280
272
  setChannel(channel: string): void;
281
273
  /**
282
- * Returns a new Logger instance configured for the specified channel. Loggers are cached per (label, channel) pair.
274
+ * Returns a new Logger for this label on the specified channel.
283
275
  *
284
276
  * @param channel - Channel name to use
285
277
  */
@@ -545,7 +537,24 @@ declare class StrictEventEmitter<TEvents extends SEEventMapLike<TEvents>> extend
545
537
  }): Promise<TEvents[TEventKey]>;
546
538
  }
547
539
  //#endregion
548
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/union-to-intersection.d.ts
540
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/characters.d.ts
541
+ /**
542
+ Matches any digit as a string ('0'-'9').
543
+
544
+ @example
545
+ ```
546
+ import type {DigitCharacter} from 'type-fest';
547
+
548
+ const a: DigitCharacter = '0'; // Valid
549
+ // @ts-expect-error
550
+ const b: DigitCharacter = 0; // Invalid
551
+ ```
552
+
553
+ @category Type
554
+ */
555
+ type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
556
+ //#endregion
557
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-intersection.d.ts
549
558
  /**
550
559
  Convert a union type to an intersection type.
551
560
 
@@ -574,7 +583,7 @@ Union extends unknown // The union type is used as the only argument to a functi
574
583
  ) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
575
584
  ? Intersection & Union : never;
576
585
  //#endregion
577
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/is-any.d.ts
586
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
578
587
  /**
579
588
  Returns a boolean for whether the given type is `any`.
580
589
 
@@ -605,7 +614,7 @@ const anyA = get(anyObject, 'a');
605
614
  */
606
615
  type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
607
616
  //#endregion
608
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/is-optional-key-of.d.ts
617
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
609
618
  /**
610
619
  Returns a boolean for whether the given key is an optional key of type.
611
620
 
@@ -648,7 +657,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
648
657
  */
649
658
  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;
650
659
  //#endregion
651
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/optional-keys-of.d.ts
660
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
652
661
  /**
653
662
  Extract all optional keys from the given type.
654
663
 
@@ -686,7 +695,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
686
695
  ? (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`
687
696
  : never;
688
697
  //#endregion
689
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/required-keys-of.d.ts
698
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
690
699
  /**
691
700
  Extract all required keys from the given type.
692
701
 
@@ -720,7 +729,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
720
729
  type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
721
730
  ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
722
731
  //#endregion
723
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/is-never.d.ts
732
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-never.d.ts
724
733
  /**
725
734
  Returns a boolean for whether the given type is `never`.
726
735
 
@@ -776,7 +785,7 @@ type B = IsTrueFixed<never>;
776
785
  */
777
786
  type IsNever<T> = [T] extends [never] ? true : false;
778
787
  //#endregion
779
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/if.d.ts
788
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
780
789
  /**
781
790
  An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
782
791
 
@@ -871,7 +880,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
871
880
  */
872
881
  type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
873
882
  //#endregion
874
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/unknown-array.d.ts
883
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/unknown-array.d.ts
875
884
  /**
876
885
  Represents an array with `unknown` value.
877
886
 
@@ -898,7 +907,7 @@ type C = IsArray<string>;
898
907
  */
899
908
  type UnknownArray = readonly unknown[];
900
909
  //#endregion
901
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/type.d.ts
910
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
902
911
  /**
903
912
  Returns a boolean for whether A is false.
904
913
 
@@ -962,7 +971,7 @@ Indicates the value of `exactOptionalPropertyTypes` compiler option.
962
971
  */
963
972
  type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
964
973
  //#endregion
965
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/array.d.ts
974
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/array.d.ts
966
975
  /**
967
976
  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.
968
977
 
@@ -1004,7 +1013,7 @@ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extend
1004
1013
  : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
1005
1014
  : never; // Should never happen
1006
1015
  //#endregion
1007
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/numeric.d.ts
1016
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/numeric.d.ts
1008
1017
  type _Numeric = number | bigint;
1009
1018
  type Zero = 0 | 0n;
1010
1019
  /**
@@ -1059,7 +1068,7 @@ type ShouldBeTrue = IsNegative<-1>;
1059
1068
  */
1060
1069
  type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
1061
1070
  //#endregion
1062
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/tuple-of.d.ts
1071
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tuple-of.d.ts
1063
1072
  /**
1064
1073
  Create a tuple type of the specified length with elements of the specified type.
1065
1074
 
@@ -1087,7 +1096,7 @@ type ZeroToFour = Range<0, 5>;
1087
1096
  //=> '0' | '1' | '2' | '3' | '4'
1088
1097
 
1089
1098
  type ThreeToEight = Range<3, 9>;
1090
- //=> '5' | '3' | '4' | '6' | '7' | '8'
1099
+ //=> '3' | '4' | '5' | '6' | '7' | '8'
1091
1100
  ```
1092
1101
 
1093
1102
  Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
@@ -1120,14 +1129,27 @@ type EmptyTuple = TupleOf<-3, string>;
1120
1129
  //=> []
1121
1130
  ```
1122
1131
 
1132
+ Note: If the specified length has a decimal part, the decimal part will be ignored.
1133
+
1134
+ @example
1135
+ ```
1136
+ import type {TupleOf} from 'type-fest';
1137
+
1138
+ type DecimalLength = TupleOf<3.5, string>;
1139
+ //=> [string, string, string]
1140
+ ```
1141
+
1123
1142
  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>>`.
1124
1143
 
1125
1144
  @category Array
1126
1145
  */
1127
- type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill, []>, Fill[], []>;
1128
- type _TupleOf<L extends number, Fill, Accumulator extends UnknownArray> = number extends L ? Fill[] : L extends Accumulator['length'] ? Accumulator : _TupleOf<L, Fill, [...Accumulator, Fill]>;
1146
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], []>;
1147
+ type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
1148
+ 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;
1149
+ type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
1150
+ 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];
1129
1151
  //#endregion
1130
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/string.d.ts
1152
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/string.d.ts
1131
1153
  /**
1132
1154
  Converts a numeric string to a number.
1133
1155
 
@@ -1232,7 +1254,7 @@ type B = PositiveNumericCharacterGt<'1', '1'>;
1232
1254
  */
1233
1255
  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;
1234
1256
  //#endregion
1235
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/numeric.d.ts
1257
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/numeric.d.ts
1236
1258
  /**
1237
1259
  Returns the number with reversed sign.
1238
1260
 
@@ -1256,7 +1278,7 @@ N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends Nega
1256
1278
  : `${N}` extends `-${infer P extends number}` ? P // Handle positive numbers
1257
1279
  : `-${N}` extends `${infer R extends number}` ? R : never;
1258
1280
  //#endregion
1259
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/simplify.d.ts
1281
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
1260
1282
  /**
1261
1283
  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.
1262
1284
 
@@ -1317,7 +1339,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
1317
1339
  */
1318
1340
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
1319
1341
  //#endregion
1320
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/is-equal.d.ts
1342
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
1321
1343
  /**
1322
1344
  Returns a boolean for whether the two given types are equal.
1323
1345
 
@@ -1348,7 +1370,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
1348
1370
  // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
1349
1371
  type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
1350
1372
  //#endregion
1351
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/omit-index-signature.d.ts
1373
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
1352
1374
  /**
1353
1375
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
1354
1376
 
@@ -1442,7 +1464,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
1442
1464
  */
1443
1465
  type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
1444
1466
  //#endregion
1445
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/pick-index-signature.d.ts
1467
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
1446
1468
  /**
1447
1469
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
1448
1470
 
@@ -1490,7 +1512,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
1490
1512
  */
1491
1513
  type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
1492
1514
  //#endregion
1493
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/merge.d.ts
1515
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
1494
1516
  // Merges two objects without worrying about index signatures.
1495
1517
  type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
1496
1518
  /**
@@ -1562,7 +1584,7 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
1562
1584
  // Should never happen
1563
1585
  type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
1564
1586
  //#endregion
1565
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/object.d.ts
1587
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
1566
1588
  /**
1567
1589
  Merges user specified options with default options.
1568
1590
 
@@ -1615,9 +1637,38 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
1615
1637
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1616
1638
  ```
1617
1639
  */
1618
- type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
1640
+ 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>`
1641
+ ? Result : never;
1642
+ 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] }>>>;
1643
+ /**
1644
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
1645
+
1646
+ 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>`.
1647
+
1648
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
1649
+
1650
+ @example
1651
+ ```
1652
+ import type {LiteralUnion} from 'type-fest';
1653
+
1654
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
1655
+ //=> string
1656
+
1657
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
1658
+ //=> number
1659
+
1660
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
1661
+ //=> `on${string}`
1662
+
1663
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
1664
+ //=> 'click' | 'change' | `on${string}`
1665
+
1666
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
1667
+ //=> string | null | undefined
1668
+ ```
1669
+ */
1619
1670
  //#endregion
1620
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/some-extend.d.ts
1671
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/some-extend.d.ts
1621
1672
  /**
1622
1673
  @see {@link SomeExtend}
1623
1674
  */
@@ -1699,7 +1750,7 @@ type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOpt
1699
1750
  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`.
1700
1751
  ? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
1701
1752
  //#endregion
1702
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/or-all.d.ts
1753
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or-all.d.ts
1703
1754
  /**
1704
1755
  Returns a boolean for whether any of the given elements is `true`.
1705
1756
 
@@ -1770,7 +1821,7 @@ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in a
1770
1821
  */
1771
1822
  type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
1772
1823
  //#endregion
1773
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/or.d.ts
1824
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or.d.ts
1774
1825
  /**
1775
1826
  Returns a boolean for whether either of two given types is `true`.
1776
1827
 
@@ -1850,7 +1901,7 @@ type G = Or<never, never>;
1850
1901
  */
1851
1902
  type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
1852
1903
  //#endregion
1853
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/all-extend.d.ts
1904
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/all-extend.d.ts
1854
1905
  /**
1855
1906
  @see {@link AllExtend}
1856
1907
  */
@@ -1936,7 +1987,7 @@ type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptio
1936
1987
  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.
1937
1988
  ? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
1938
1989
  //#endregion
1939
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/and-all.d.ts
1990
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and-all.d.ts
1940
1991
  /**
1941
1992
  Returns a boolean for whether all of the given elements are `true`.
1942
1993
 
@@ -2010,7 +2061,7 @@ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](htt
2010
2061
  */
2011
2062
  type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
2012
2063
  //#endregion
2013
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/and.d.ts
2064
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and.d.ts
2014
2065
  /**
2015
2066
  Returns a boolean for whether two given types are both `true`.
2016
2067
 
@@ -2090,7 +2141,7 @@ type G = And<never, never>;
2090
2141
  */
2091
2142
  type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
2092
2143
  //#endregion
2093
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/absolute.d.ts
2144
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/absolute.d.ts
2094
2145
  /**
2095
2146
  Returns the absolute value of the specified number or bigint.
2096
2147
 
@@ -2136,7 +2187,7 @@ type Absolute<N extends number | bigint> = N extends bigint // Also, distributes
2136
2187
  ? `${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
2137
2188
  ? StringToNumber<Magnitude> : N;
2138
2189
  //#endregion
2139
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/greater-than.d.ts
2190
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than.d.ts
2140
2191
  /**
2141
2192
  Returns a boolean for whether a given number is greater than another number.
2142
2193
 
@@ -2192,7 +2243,7 @@ type GreaterThan<A extends number, B extends number> = A extends number // For d
2192
2243
  ? 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
2193
2244
  : never;
2194
2245
  //#endregion
2195
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
2246
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
2196
2247
  /**
2197
2248
  Returns a boolean for whether a given number is greater than or equal to another number.
2198
2249
 
@@ -2248,7 +2299,7 @@ type GreaterThanOrEqual<A extends number, B extends number> = number extends A |
2248
2299
  ? A extends B ? true : GreaterThan<A, B> : never // Should never happen
2249
2300
  : never;
2250
2301
  //#endregion
2251
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/less-than.d.ts
2302
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/less-than.d.ts
2252
2303
  /**
2253
2304
  Returns a boolean for whether a given number is less than another number.
2254
2305
 
@@ -2301,7 +2352,7 @@ setNegative(1);
2301
2352
  */
2302
2353
  type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
2303
2354
  //#endregion
2304
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/internal/tuple.d.ts
2355
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/tuple.d.ts
2305
2356
  // Should never happen
2306
2357
  /**
2307
2358
  Returns the maximum value from a tuple of integers.
@@ -2320,7 +2371,7 @@ type B = TupleMax<[1, 2, 5, 3, 99, -1]>;
2320
2371
  */
2321
2372
  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;
2322
2373
  //#endregion
2323
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/subtract.d.ts
2374
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/subtract.d.ts
2324
2375
  /**
2325
2376
  Returns the difference between two numbers.
2326
2377
 
@@ -2378,7 +2429,7 @@ Subtracts two positive numbers A and B such that A > B.
2378
2429
  type SubtractIfAGreaterThanB<A extends number, B extends number> = // This is where we always want to end up and do the actual subtraction
2379
2430
  TupleOf<A> extends [...TupleOf<B>, ...infer R] ? R['length'] : never;
2380
2431
  //#endregion
2381
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/sum.d.ts
2432
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/sum.d.ts
2382
2433
  /**
2383
2434
  Returns the sum of two numbers.
2384
2435
 
@@ -2432,7 +2483,7 @@ Adds two positive numbers.
2432
2483
  */
2433
2484
  type SumPositives<A extends number, B extends number> = [...TupleOf<A>, ...TupleOf<B>]['length'] extends infer Result extends number ? Result : never;
2434
2485
  //#endregion
2435
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/exclude-exactly.d.ts
2486
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/exclude-exactly.d.ts
2436
2487
  /**
2437
2488
  A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
2438
2489
 
@@ -2470,7 +2521,7 @@ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unkn
2470
2521
  // because `Union` cannot be `any` or `never` here.
2471
2522
  Union, Union>;
2472
2523
  //#endregion
2473
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/union-member.d.ts
2524
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-member.d.ts
2474
2525
  /**
2475
2526
  Returns an arbitrary member of a union type.
2476
2527
 
@@ -2527,7 +2578,7 @@ type LastNever = UnionMember<never>;
2527
2578
  */
2528
2579
  type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
2529
2580
  //#endregion
2530
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/union-to-tuple.d.ts
2581
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-tuple.d.ts
2531
2582
  /**
2532
2583
  Convert a union type into an unordered tuple type of its elements.
2533
2584
 
@@ -2567,7 +2618,7 @@ type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends Unk
2567
2618
  // Nudges the compiler that `UnionToTuple` always yields an array.
2568
2619
  type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
2569
2620
  //#endregion
2570
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/int-range.d.ts
2621
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-range.d.ts
2571
2622
  /**
2572
2623
  Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.
2573
2624
 
@@ -2620,7 +2671,7 @@ List extends unknown[] = TupleOf<Start, never>, EndLengthTuple extends unknown[]
2620
2671
  : List extends [...(infer U), ...EndLengthTuple] // The result of "List[length] >= End", because the `...TupleOf<Gap, never>` maybe make `List` too long.
2621
2672
  ? Exclude<List[number], never> : PrivateIntRange<Start, End, Step, Gap, [...List, List['length'], ...TupleOf<Gap, never>]>;
2622
2673
  //#endregion
2623
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/int-closed-range.d.ts
2674
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-closed-range.d.ts
2624
2675
  /**
2625
2676
  Generate a union of numbers between a specified start and end (both inclusive), with an optional step.
2626
2677
 
@@ -2784,7 +2835,7 @@ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, Co
2784
2835
  * @param phase - The shutdown phase from {@link ShutdownPhase}
2785
2836
  * @param taskName - Unique identifier for the task
2786
2837
  * @param task - Async function to execute
2787
- * @param timeoutMs - Task timeout in milliseconds {@default 5000}
2838
+ * @param timeoutMs - Task timeout in milliseconds. {@default `5000`}
2788
2839
  */
2789
2840
  addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
2790
2841
  /**
@@ -2802,8 +2853,8 @@ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, Co
2802
2853
  * Tasks within each phase are executed in parallel for faster shutdown.
2803
2854
  * Process exits with the specified code when complete.
2804
2855
  *
2805
- * @param exitCode - Process exit code {@default 0}
2806
- * @param exitProcess - Whether to exit the process after shutdown {@default true}
2856
+ * @param exitCode - Process exit code. {@default `0`}
2857
+ * @param exitProcess - Whether to exit the process after shutdown. {@default `true`}
2807
2858
  * @returns Promise that resolves when shutdown is complete
2808
2859
  * @example
2809
2860
  * ```typescript
@@ -2883,7 +2934,7 @@ declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase, Coor
2883
2934
  * @param phase - The startup phase from {@link StartupPhase}
2884
2935
  * @param taskName - Unique identifier for the task
2885
2936
  * @param task - Async function to execute
2886
- * @param timeoutMs - Task timeout in milliseconds {@default 10000}
2937
+ * @param timeoutMs - Task timeout in milliseconds. {@default `10000`}
2887
2938
  */
2888
2939
  addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
2889
2940
  protected canAddTask(): boolean;
@@ -2926,5 +2977,5 @@ declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase, Coor
2926
2977
  /** Package version */
2927
2978
  declare const version: string;
2928
2979
  //#endregion
2929
- export { type BaseSeedcordError, type BaseTransportConfig, type ChannelConfig, type ConsoleTransportConfig, CooldownManager, CooldownOptions, CoordinatedLifecycle, CoordinatedShutdown, CoordinatedShutdownEvents, CoordinatedStartup, CoordinatedStartupEvents, type FileTransportConfig, HealthCheck, type ILoggerSink, type ILoggerSinkHandle, type LifecycleTask, Logger, LoggerChannelRegistry, type LoggerConfiguration, type LoggerFileConfig, type LoggerFilePatternsConfig, type LoggerFormatMode, type LoggerLevel, type LoggerOptions, type LoggerSinkLogEntry, LoggerUtilities, SEArgsTuple, SEEventMapLike, SENoEvents, SeedcordErrorCode, type SeedcordErrorTypeString, ShutdownPhase, StartupPhase, type StreamTransportConfig, StrictEventEmitter, type TransportConfig, isSeedcordError, version };
2980
+ export { type BaseTransportConfig, type ChannelConfig, type ConsoleTransportConfig, CoordinatedLifecycle, CoordinatedShutdown, CoordinatedShutdownEvents, CoordinatedStartup, CoordinatedStartupEvents, type FileTransportConfig, HealthCheck, type ILoggerSink, type ILoggerSinkHandle, type LifecycleTask, Logger, LoggerChannelRegistry, type LoggerConfiguration, type LoggerFileConfig, type LoggerFilePatternsConfig, type LoggerFormatMode, type LoggerLevel, type LoggerOptions, type LoggerSinkLogEntry, LoggerUtilities, RateLimitResult, RateLimitWindow, RateLimiter, SEArgsTuple, SEEventMapLike, SENoEvents, ShutdownPhase, StartupPhase, type StreamTransportConfig, StrictEventEmitter, type TransportConfig, version };
2930
2981
  //# sourceMappingURL=index.d.mts.map