@alextheman/utility 5.15.0 → 5.16.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.cjs +88 -46
- package/dist/index.d.cts +246 -217
- package/dist/index.d.ts +245 -216
- package/dist/index.js +88 -47
- package/dist/internal/index.cjs +26 -3
- package/dist/internal/index.d.cts +15 -2
- package/dist/internal/index.d.ts +15 -2
- package/dist/internal/index.js +26 -3
- package/dist/node/index.cjs +26 -3
- package/dist/node/index.js +26 -3
- package/dist/v6/index.cjs +146 -3
- package/dist/v6/index.d.cts +123 -6
- package/dist/v6/index.d.ts +123 -6
- package/dist/v6/index.js +145 -4
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DotenvParseOutput } from "dotenv";
|
|
2
1
|
import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from "zod";
|
|
2
|
+
import { DotenvParseOutput } from "dotenv";
|
|
3
3
|
|
|
4
4
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
5
5
|
declare const FILE_PATH_PATTERN: string;
|
|
@@ -16,6 +16,34 @@ declare const UUID_REGEX: RegExp;
|
|
|
16
16
|
declare const VERSION_NUMBER_PATTERN: string;
|
|
17
17
|
declare const VERSION_NUMBER_REGEX: RegExp;
|
|
18
18
|
//#endregion
|
|
19
|
+
//#region src/root/deprecated/APIError.d.ts
|
|
20
|
+
type HTTPErrorCode = 400 | 401 | 403 | 404 | 418 | 500;
|
|
21
|
+
declare const httpErrorCodeLookup: Record<HTTPErrorCode, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Represents common errors you may get from a HTTP API request.
|
|
24
|
+
*
|
|
25
|
+
* @category Types
|
|
26
|
+
*
|
|
27
|
+
* @deprecated Please use `APIError` from `@alextheman/utility/v6` instead.
|
|
28
|
+
*/
|
|
29
|
+
declare class APIError extends Error {
|
|
30
|
+
status: number;
|
|
31
|
+
/**
|
|
32
|
+
* @param status - A HTTP status code. Can be any number, but numbers between 400 and 600 are encouraged to fit with HTTP status code conventions.
|
|
33
|
+
* @param message - An error message to display alongside the status code.
|
|
34
|
+
* @param options - Extra options to be passed to super Error constructor.
|
|
35
|
+
*/
|
|
36
|
+
constructor(status?: HTTPErrorCode | number, message?: string, options?: ErrorOptions);
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether the given input may have been caused by an APIError.
|
|
39
|
+
*
|
|
40
|
+
* @param input - The input to check.
|
|
41
|
+
*
|
|
42
|
+
* @returns `true` if the input is an APIError, and `false` otherwise. The type of the input will also be narrowed down to APIError if `true`.
|
|
43
|
+
*/
|
|
44
|
+
static check(input: unknown): input is APIError;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
19
47
|
//#region src/root/deprecated/DataError.d.ts
|
|
20
48
|
interface ExpectErrorOptions$1 {
|
|
21
49
|
expectedCode?: string;
|
|
@@ -503,219 +531,6 @@ declare function removeUndefinedFromObject<RecordType extends Record<PropertyKey
|
|
|
503
531
|
*/
|
|
504
532
|
declare function parseBoolean(inputString: string): boolean;
|
|
505
533
|
//#endregion
|
|
506
|
-
//#region src/root/types/APIError.d.ts
|
|
507
|
-
type HTTPErrorCode = 400 | 401 | 403 | 404 | 418 | 500;
|
|
508
|
-
declare const httpErrorCodeLookup: Record<HTTPErrorCode, string>;
|
|
509
|
-
/**
|
|
510
|
-
* Represents common errors you may get from a HTTP API request.
|
|
511
|
-
*
|
|
512
|
-
* @category Types
|
|
513
|
-
*/
|
|
514
|
-
declare class APIError extends Error {
|
|
515
|
-
status: number;
|
|
516
|
-
/**
|
|
517
|
-
* @param status - A HTTP status code. Can be any number, but numbers between 400 and 600 are encouraged to fit with HTTP status code conventions.
|
|
518
|
-
* @param message - An error message to display alongside the status code.
|
|
519
|
-
* @param options - Extra options to be passed to super Error constructor.
|
|
520
|
-
*/
|
|
521
|
-
constructor(status?: HTTPErrorCode | number, message?: string, options?: ErrorOptions);
|
|
522
|
-
/**
|
|
523
|
-
* Checks whether the given input may have been caused by an APIError.
|
|
524
|
-
*
|
|
525
|
-
* @param input - The input to check.
|
|
526
|
-
*
|
|
527
|
-
* @returns `true` if the input is an APIError, and `false` otherwise. The type of the input will also be narrowed down to APIError if `true`.
|
|
528
|
-
*/
|
|
529
|
-
static check(input: unknown): input is APIError;
|
|
530
|
-
}
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region src/root/types/VersionNumber.d.ts
|
|
533
|
-
/**
|
|
534
|
-
* Options to apply to the stringification of the version number.
|
|
535
|
-
*
|
|
536
|
-
* @category Class Options
|
|
537
|
-
*/
|
|
538
|
-
interface FormatOptionsBase {
|
|
539
|
-
/** Whether you want to omit the "v" prefix or not (defaults to false). */
|
|
540
|
-
omitPrefix?: boolean;
|
|
541
|
-
}
|
|
542
|
-
interface FormatOptionsIncludeMinor extends FormatOptionsBase {
|
|
543
|
-
/** Whether you want to omit the minor version or not */
|
|
544
|
-
omitMinor?: false;
|
|
545
|
-
/** Whether you want to omit the patch version or not */
|
|
546
|
-
omitPatch?: boolean;
|
|
547
|
-
}
|
|
548
|
-
interface FormatOptionsOmitMinor extends FormatOptionsBase {
|
|
549
|
-
/** Whether you want to omit the minor version or not */
|
|
550
|
-
omitMinor?: true;
|
|
551
|
-
/** Whether you want to omit the patch version or not */
|
|
552
|
-
omitPatch?: never;
|
|
553
|
-
}
|
|
554
|
-
type FormatStringOptions = FormatOptionsIncludeMinor | FormatOptionsOmitMinor;
|
|
555
|
-
/**
|
|
556
|
-
* Represents a software version number, considered to be made up of a major, minor, and patch part.
|
|
557
|
-
*
|
|
558
|
-
* @category Types
|
|
559
|
-
*/
|
|
560
|
-
declare class VersionNumber {
|
|
561
|
-
private static readonly NON_NEGATIVE_TUPLE_ERROR;
|
|
562
|
-
/** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
|
|
563
|
-
readonly major: number;
|
|
564
|
-
/** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
|
|
565
|
-
readonly minor: number;
|
|
566
|
-
/** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
|
|
567
|
-
readonly patch: number;
|
|
568
|
-
/**
|
|
569
|
-
* @param input - The input to create a new instance of `VersionNumber` from.
|
|
570
|
-
*/
|
|
571
|
-
constructor(input: string | [number, number, number] | VersionNumber);
|
|
572
|
-
/**
|
|
573
|
-
* Gets the current version type of the current instance of `VersionNumber`.
|
|
574
|
-
*
|
|
575
|
-
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
576
|
-
*/
|
|
577
|
-
get type(): VersionType;
|
|
578
|
-
private static formatString;
|
|
579
|
-
/**
|
|
580
|
-
* Checks if the provided version numbers have the exact same major, minor, and patch numbers.
|
|
581
|
-
*
|
|
582
|
-
* @param firstVersion - The first version number to compare.
|
|
583
|
-
* @param secondVersion - The second version number to compare.
|
|
584
|
-
*
|
|
585
|
-
* @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
|
|
586
|
-
*/
|
|
587
|
-
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
588
|
-
/**
|
|
589
|
-
* Get a formatted string representation of the current version number
|
|
590
|
-
*
|
|
591
|
-
* @param options - Options to apply to the string formatting.
|
|
592
|
-
*
|
|
593
|
-
* @returns A formatted string representation of the current version number with the options applied.
|
|
594
|
-
*/
|
|
595
|
-
format(options?: FormatStringOptions): string;
|
|
596
|
-
/**
|
|
597
|
-
* Increments the current version number by the given increment type, returning the result as a new reference in memory.
|
|
598
|
-
*
|
|
599
|
-
* @param incrementType - The type of increment. Can be one of the following:
|
|
600
|
-
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
601
|
-
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
602
|
-
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
603
|
-
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
604
|
-
*
|
|
605
|
-
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
606
|
-
*/
|
|
607
|
-
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
608
|
-
/**
|
|
609
|
-
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
610
|
-
*
|
|
611
|
-
* @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
|
|
612
|
-
*
|
|
613
|
-
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
614
|
-
*/
|
|
615
|
-
[Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
|
|
616
|
-
/**
|
|
617
|
-
* Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
|
|
618
|
-
*
|
|
619
|
-
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
620
|
-
*/
|
|
621
|
-
toJSON(): string;
|
|
622
|
-
/**
|
|
623
|
-
* Get a string representation of the current version number.
|
|
624
|
-
*
|
|
625
|
-
* @returns A stringified representation of the current version number with the prefix.
|
|
626
|
-
*/
|
|
627
|
-
toString(): string;
|
|
628
|
-
}
|
|
629
|
-
declare const zodVersionNumber: z.ZodType<VersionNumber>;
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region src/root/types/ArrayElement.d.ts
|
|
632
|
-
/**
|
|
633
|
-
* Gets the individual element types from an array type.
|
|
634
|
-
*
|
|
635
|
-
* @category Types
|
|
636
|
-
*
|
|
637
|
-
* @template ArrayType - The type of the array itself.
|
|
638
|
-
*/
|
|
639
|
-
type ArrayElement<ArrayType extends ReadonlyArray<unknown>> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
640
|
-
//#endregion
|
|
641
|
-
//#region src/root/types/CallReturnType.d.ts
|
|
642
|
-
type CallReturnType<Function, Arguments> = Function extends ((arg: Arguments) => infer Return) ? Return : never;
|
|
643
|
-
//#endregion
|
|
644
|
-
//#region src/root/types/CreateEnumType.d.ts
|
|
645
|
-
/**
|
|
646
|
-
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
647
|
-
*
|
|
648
|
-
* @category Types
|
|
649
|
-
*
|
|
650
|
-
* @template ObjectType - The type of the object to get the value types for.
|
|
651
|
-
*/
|
|
652
|
-
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
653
|
-
//#endregion
|
|
654
|
-
//#region src/root/types/DisallowUndefined.d.ts
|
|
655
|
-
/**
|
|
656
|
-
* Resolves to an error message type if the type argument could potentially be undefined.
|
|
657
|
-
*
|
|
658
|
-
* @category Types
|
|
659
|
-
*
|
|
660
|
-
* @template InputType - The type to disallow undefined on.
|
|
661
|
-
*/
|
|
662
|
-
type DisallowUndefined<InputType> = undefined extends InputType ? ["Error: Generic type cannot include undefined"] : InputType;
|
|
663
|
-
//#endregion
|
|
664
|
-
//#region src/root/types/IgnoreCase.d.ts
|
|
665
|
-
/**
|
|
666
|
-
* Allows case-insensitive variants of a known string type.
|
|
667
|
-
*
|
|
668
|
-
* @category Types
|
|
669
|
-
*
|
|
670
|
-
* @template StringType - The input string type.
|
|
671
|
-
*/
|
|
672
|
-
type IgnoreCase<StringType extends string> = string extends StringType ? string : StringType extends `${infer FirstCharacter}${infer SecondCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${Uppercase<SecondCharacter> | Lowercase<SecondCharacter>}${IgnoreCase<Remainder>}` : StringType extends `${infer FirstCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${IgnoreCase<Remainder>}` : "";
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
675
|
-
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
676
|
-
//#endregion
|
|
677
|
-
//#region src/root/types/NonNull.d.ts
|
|
678
|
-
/**
|
|
679
|
-
* Removes `null` from a type.
|
|
680
|
-
*
|
|
681
|
-
* @category Types
|
|
682
|
-
*
|
|
683
|
-
* @template InputType - The type to check.
|
|
684
|
-
*/
|
|
685
|
-
type NonNull<InputType> = InputType extends null ? never : InputType;
|
|
686
|
-
//#endregion
|
|
687
|
-
//#region src/root/types/NonUndefined.d.ts
|
|
688
|
-
/**
|
|
689
|
-
* Removes `undefined` from a type.
|
|
690
|
-
*
|
|
691
|
-
* @category Types
|
|
692
|
-
*
|
|
693
|
-
* @template InputType - The type to check.
|
|
694
|
-
*/
|
|
695
|
-
type NonUndefined<InputType> = InputType extends undefined ? never : InputType;
|
|
696
|
-
//#endregion
|
|
697
|
-
//#region src/root/types/NullableOnCondition.d.ts
|
|
698
|
-
/**
|
|
699
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
700
|
-
*
|
|
701
|
-
* @category Types
|
|
702
|
-
*
|
|
703
|
-
* @param Condition - The condition to check.
|
|
704
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
705
|
-
*/
|
|
706
|
-
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
707
|
-
//#endregion
|
|
708
|
-
//#region src/root/types/OptionalOnCondition.d.ts
|
|
709
|
-
/**
|
|
710
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `undefined`
|
|
711
|
-
*
|
|
712
|
-
* @category Types
|
|
713
|
-
*
|
|
714
|
-
* @param Condition - The condition to check.
|
|
715
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
716
|
-
*/
|
|
717
|
-
type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | undefined;
|
|
718
|
-
//#endregion
|
|
719
534
|
//#region src/root/functions/parsers/parseEnv.d.ts
|
|
720
535
|
/**
|
|
721
536
|
* Represents the three common development environments.
|
|
@@ -1121,6 +936,207 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
|
|
|
1121
936
|
*/
|
|
1122
937
|
declare const normalizeIndents: typeof normaliseIndents;
|
|
1123
938
|
//#endregion
|
|
939
|
+
//#region src/root/types/VersionNumber.d.ts
|
|
940
|
+
/**
|
|
941
|
+
* Options to apply to the stringification of the version number.
|
|
942
|
+
*
|
|
943
|
+
* @category Class Options
|
|
944
|
+
*/
|
|
945
|
+
interface FormatOptionsBase {
|
|
946
|
+
/** Whether you want to omit the "v" prefix or not (defaults to false). */
|
|
947
|
+
omitPrefix?: boolean;
|
|
948
|
+
}
|
|
949
|
+
interface FormatOptionsIncludeMinor extends FormatOptionsBase {
|
|
950
|
+
/** Whether you want to omit the minor version or not */
|
|
951
|
+
omitMinor?: false;
|
|
952
|
+
/** Whether you want to omit the patch version or not */
|
|
953
|
+
omitPatch?: boolean;
|
|
954
|
+
}
|
|
955
|
+
interface FormatOptionsOmitMinor extends FormatOptionsBase {
|
|
956
|
+
/** Whether you want to omit the minor version or not */
|
|
957
|
+
omitMinor?: true;
|
|
958
|
+
/** Whether you want to omit the patch version or not */
|
|
959
|
+
omitPatch?: never;
|
|
960
|
+
}
|
|
961
|
+
type FormatStringOptions = FormatOptionsIncludeMinor | FormatOptionsOmitMinor;
|
|
962
|
+
/**
|
|
963
|
+
* Represents a software version number, considered to be made up of a major, minor, and patch part.
|
|
964
|
+
*
|
|
965
|
+
* @category Types
|
|
966
|
+
*/
|
|
967
|
+
declare class VersionNumber {
|
|
968
|
+
private static readonly NON_NEGATIVE_TUPLE_ERROR;
|
|
969
|
+
/** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
|
|
970
|
+
readonly major: number;
|
|
971
|
+
/** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
|
|
972
|
+
readonly minor: number;
|
|
973
|
+
/** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
|
|
974
|
+
readonly patch: number;
|
|
975
|
+
/**
|
|
976
|
+
* @param input - The input to create a new instance of `VersionNumber` from.
|
|
977
|
+
*/
|
|
978
|
+
constructor(input: string | [number, number, number] | VersionNumber);
|
|
979
|
+
/**
|
|
980
|
+
* Gets the current version type of the current instance of `VersionNumber`.
|
|
981
|
+
*
|
|
982
|
+
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
983
|
+
*/
|
|
984
|
+
get type(): VersionType;
|
|
985
|
+
private static formatString;
|
|
986
|
+
/**
|
|
987
|
+
* Checks if the provided version numbers have the exact same major, minor, and patch numbers.
|
|
988
|
+
*
|
|
989
|
+
* @param firstVersion - The first version number to compare.
|
|
990
|
+
* @param secondVersion - The second version number to compare.
|
|
991
|
+
*
|
|
992
|
+
* @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
|
|
993
|
+
*/
|
|
994
|
+
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
995
|
+
/**
|
|
996
|
+
* Get a formatted string representation of the current version number
|
|
997
|
+
*
|
|
998
|
+
* @param options - Options to apply to the string formatting.
|
|
999
|
+
*
|
|
1000
|
+
* @returns A formatted string representation of the current version number with the options applied.
|
|
1001
|
+
*/
|
|
1002
|
+
format(options?: FormatStringOptions): string;
|
|
1003
|
+
/**
|
|
1004
|
+
* Increments the current version number by the given increment type, returning the result as a new reference in memory.
|
|
1005
|
+
*
|
|
1006
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
1007
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
1008
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
1009
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
1010
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
1011
|
+
*
|
|
1012
|
+
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
1013
|
+
*/
|
|
1014
|
+
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
1015
|
+
/**
|
|
1016
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
1017
|
+
*
|
|
1018
|
+
* @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
|
|
1019
|
+
*
|
|
1020
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
1021
|
+
*/
|
|
1022
|
+
[Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
|
|
1023
|
+
/**
|
|
1024
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
|
|
1025
|
+
*
|
|
1026
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
1027
|
+
*/
|
|
1028
|
+
toJSON(): string;
|
|
1029
|
+
/**
|
|
1030
|
+
* Get a string representation of the current version number.
|
|
1031
|
+
*
|
|
1032
|
+
* @returns A stringified representation of the current version number with the prefix.
|
|
1033
|
+
*/
|
|
1034
|
+
toString(): string;
|
|
1035
|
+
}
|
|
1036
|
+
declare const zodVersionNumber: z.ZodType<VersionNumber>;
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/root/types/ArrayElement.d.ts
|
|
1039
|
+
/**
|
|
1040
|
+
* Gets the individual element types from an array type.
|
|
1041
|
+
*
|
|
1042
|
+
* @category Types
|
|
1043
|
+
*
|
|
1044
|
+
* @template ArrayType - The type of the array itself.
|
|
1045
|
+
*/
|
|
1046
|
+
type ArrayElement<ArrayType extends ReadonlyArray<unknown>> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/root/types/CallReturnType.d.ts
|
|
1049
|
+
type CallReturnType<Function, Arguments> = Function extends ((arg: Arguments) => infer Return) ? Return : never;
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/root/types/CreateEnumType.d.ts
|
|
1052
|
+
/**
|
|
1053
|
+
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
1054
|
+
*
|
|
1055
|
+
* @category Types
|
|
1056
|
+
*
|
|
1057
|
+
* @template ObjectType - The type of the object to get the value types for.
|
|
1058
|
+
*/
|
|
1059
|
+
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/root/types/DisallowUndefined.d.ts
|
|
1062
|
+
/**
|
|
1063
|
+
* Resolves to an error message type if the type argument could potentially be undefined.
|
|
1064
|
+
*
|
|
1065
|
+
* @category Types
|
|
1066
|
+
*
|
|
1067
|
+
* @template InputType - The type to disallow undefined on.
|
|
1068
|
+
*/
|
|
1069
|
+
type DisallowUndefined<InputType> = undefined extends InputType ? ["Error: Generic type cannot include undefined"] : InputType;
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region src/root/types/IgnoreCase.d.ts
|
|
1072
|
+
/**
|
|
1073
|
+
* Allows case-insensitive variants of a known string type.
|
|
1074
|
+
*
|
|
1075
|
+
* @category Types
|
|
1076
|
+
*
|
|
1077
|
+
* @template StringType - The input string type.
|
|
1078
|
+
*/
|
|
1079
|
+
type IgnoreCase<StringType extends string> = string extends StringType ? string : StringType extends `${infer FirstCharacter}${infer SecondCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${Uppercase<SecondCharacter> | Lowercase<SecondCharacter>}${IgnoreCase<Remainder>}` : StringType extends `${infer FirstCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${IgnoreCase<Remainder>}` : "";
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
1082
|
+
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region src/root/types/NonNull.d.ts
|
|
1085
|
+
/**
|
|
1086
|
+
* Removes `null` from a type.
|
|
1087
|
+
*
|
|
1088
|
+
* @category Types
|
|
1089
|
+
*
|
|
1090
|
+
* @template InputType - The type to check.
|
|
1091
|
+
*/
|
|
1092
|
+
type NonNull<InputType> = InputType extends null ? never : InputType;
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region src/root/types/NonUndefined.d.ts
|
|
1095
|
+
/**
|
|
1096
|
+
* Removes `undefined` from a type.
|
|
1097
|
+
*
|
|
1098
|
+
* @category Types
|
|
1099
|
+
*
|
|
1100
|
+
* @template InputType - The type to check.
|
|
1101
|
+
*/
|
|
1102
|
+
type NonUndefined<InputType> = InputType extends undefined ? never : InputType;
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/root/types/NullableOnCondition.d.ts
|
|
1105
|
+
/**
|
|
1106
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
1107
|
+
*
|
|
1108
|
+
* @category Types
|
|
1109
|
+
*
|
|
1110
|
+
* @param Condition - The condition to check.
|
|
1111
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
1112
|
+
*/
|
|
1113
|
+
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/root/types/OptionalOnCondition.d.ts
|
|
1116
|
+
/**
|
|
1117
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `undefined`
|
|
1118
|
+
*
|
|
1119
|
+
* @category Types
|
|
1120
|
+
*
|
|
1121
|
+
* @param Condition - The condition to check.
|
|
1122
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
1123
|
+
*/
|
|
1124
|
+
type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | undefined;
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/root/errors/assertNotNull.d.ts
|
|
1127
|
+
/**
|
|
1128
|
+
* Asserts that a given input is not `null`, and throws a DataError if it does.
|
|
1129
|
+
*
|
|
1130
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `null`.
|
|
1131
|
+
*
|
|
1132
|
+
* @template InputType The type of the input.
|
|
1133
|
+
*
|
|
1134
|
+
* @param input - The input to assert against
|
|
1135
|
+
*
|
|
1136
|
+
* @throws {DataError} If the input is `null`.
|
|
1137
|
+
*/
|
|
1138
|
+
declare function assertNotNull<InputType>(input: InputType): asserts input is NonNull<InputType>;
|
|
1139
|
+
//#endregion
|
|
1124
1140
|
//#region src/v6/CodeError.d.ts
|
|
1125
1141
|
interface ExpectErrorOptions<ErrorCode extends string = string> {
|
|
1126
1142
|
expectedCode?: ErrorCode;
|
|
@@ -1186,6 +1202,12 @@ declare class CodeError<ErrorCode extends string = string> extends Error {
|
|
|
1186
1202
|
* @returns The `CodeError` that was thrown by the `errorFunction`
|
|
1187
1203
|
*/
|
|
1188
1204
|
static expectErrorAsync<ErrorCode extends string = string>(this: typeof CodeError, errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions<ErrorCode>): Promise<CodeError>;
|
|
1205
|
+
/**
|
|
1206
|
+
* Converts the `CodeError` instance to a serialised JSON payload.
|
|
1207
|
+
*
|
|
1208
|
+
* @returns A JSON serialised version of the current `CodeError` instance.
|
|
1209
|
+
*/
|
|
1210
|
+
toJSON(): Omit<CodeError<ErrorCode>, "toJSON" | "name">;
|
|
1189
1211
|
}
|
|
1190
1212
|
//#endregion
|
|
1191
1213
|
//#region src/v6/DataError.d.ts
|
|
@@ -1194,14 +1216,15 @@ declare class CodeError<ErrorCode extends string = string> extends Error {
|
|
|
1194
1216
|
*
|
|
1195
1217
|
* @category Types
|
|
1196
1218
|
*
|
|
1197
|
-
* @template DataType
|
|
1219
|
+
* @template DataType The type of the data that caused the error.
|
|
1220
|
+
* @template ErrorCode The type of the standardised error code.
|
|
1198
1221
|
*/
|
|
1199
1222
|
declare class DataError$1<DataType extends object = Record<PropertyKey, unknown>, ErrorCode extends string = string> extends CodeError<ErrorCode> {
|
|
1200
1223
|
data: DataType;
|
|
1201
1224
|
/**
|
|
1202
1225
|
* @param data - The data that caused the error.
|
|
1203
1226
|
* @param code - A standardised code (e.g. UNEXPECTED_DATA).
|
|
1204
|
-
* @param message
|
|
1227
|
+
* @param message - A human-readable error message (e.g. The data provided is invalid).
|
|
1205
1228
|
* @param options - Extra options to pass to super Error constructor.
|
|
1206
1229
|
*/
|
|
1207
1230
|
constructor(data: DataType, code: ErrorCode, message?: string, options?: ErrorOptions);
|
|
@@ -1250,6 +1273,12 @@ declare class DataError$1<DataType extends object = Record<PropertyKey, unknown>
|
|
|
1250
1273
|
* @returns The `DataError` that was thrown by the `errorFunction`
|
|
1251
1274
|
*/
|
|
1252
1275
|
static expectErrorAsync<DataType extends Record<PropertyKey, unknown>, ErrorCode extends string = string>(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions<ErrorCode>): Promise<DataError$1<DataType, ErrorCode>>;
|
|
1276
|
+
/**
|
|
1277
|
+
* Converts the `DataError` instance to a serialised JSON payload.
|
|
1278
|
+
*
|
|
1279
|
+
* @returns A JSON serialised version of the current `DataError` instance.
|
|
1280
|
+
*/
|
|
1281
|
+
toJSON(): Omit<DataError$1<DataType, ErrorCode>, "toJSON" | "name">;
|
|
1253
1282
|
}
|
|
1254
1283
|
//#endregion
|
|
1255
1284
|
//#region src/root/zod/parseZodSchema.d.ts
|
|
@@ -1311,4 +1340,4 @@ declare const az: {
|
|
|
1311
1340
|
};
|
|
1312
1341
|
};
|
|
1313
1342
|
//#endregion
|
|
1314
|
-
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1343
|
+
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, assertNotNull, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|