@alextheman/utility 5.12.0 → 5.13.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 +487 -426
- package/dist/index.d.cts +174 -59
- package/dist/index.d.ts +174 -59
- package/dist/index.js +488 -426
- package/dist/internal/index.cjs +244 -185
- package/dist/internal/index.d.cts +101 -41
- package/dist/internal/index.d.ts +101 -41
- package/dist/internal/index.js +244 -185
- package/dist/node/index.cjs +197 -138
- package/dist/node/index.d.cts +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +197 -138
- package/dist/v6/index.cjs +114 -115
- package/dist/v6/index.d.cts +12 -12
- package/dist/v6/index.d.ts +12 -12
- package/dist/v6/index.js +114 -115
- package/package.json +1 -1
|
@@ -1,19 +1,92 @@
|
|
|
1
1
|
import { ExecaMethod } from "execa";
|
|
2
2
|
|
|
3
|
-
//#region src/root/
|
|
3
|
+
//#region src/root/types/CreateEnumType.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* @category Types
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
9
|
+
* @template ObjectType - The type of the object to get the value types for.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
14
|
+
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/root/types/NullableOnCondition.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
19
|
+
*
|
|
20
|
+
* @category Types
|
|
21
|
+
*
|
|
22
|
+
* @param Condition - The condition to check.
|
|
23
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
24
|
+
*/
|
|
25
|
+
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/v6/CodeError.d.ts
|
|
28
|
+
interface ExpectErrorOptions$1<ErrorCode extends string = string> {
|
|
29
|
+
expectedCode?: ErrorCode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents errors that can be described using a standardised error code, and a human-readable error message.
|
|
33
|
+
*
|
|
34
|
+
* @category Types
|
|
35
|
+
*
|
|
36
|
+
* @template ErrorCode The type of the standardised error code.
|
|
37
|
+
*/
|
|
38
|
+
declare class CodeError<ErrorCode extends string = string> extends Error {
|
|
39
|
+
code: ErrorCode;
|
|
40
|
+
/**
|
|
41
|
+
* @param code - A standardised code (e.g. UNEXPECTED_DATA).
|
|
42
|
+
* @param message - A human-readable error message (e.g. The data provided is invalid).
|
|
43
|
+
* @param options - Extra options to pass to super Error constructor.
|
|
44
|
+
*/
|
|
45
|
+
constructor(code: ErrorCode, message?: string, options?: ErrorOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the given input may have been caused by a CodeError.
|
|
48
|
+
*
|
|
49
|
+
* @param input - The input to check.
|
|
50
|
+
*
|
|
51
|
+
* @returns `true` if the input is a CodeError, and `false` otherwise. The type of the input will also be narrowed down to CodeError if `true`.
|
|
52
|
+
*/
|
|
53
|
+
static check(input: unknown): input is CodeError<string>;
|
|
54
|
+
protected static checkCaughtError<ErrorCode extends string = string>(this: typeof CodeError, error: unknown, options?: ExpectErrorOptions$1<ErrorCode>): CodeError;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the thrown `CodeError` from a given function if one was thrown, and re-throws any other errors, or throws a default `CodeError` if no error thrown.
|
|
57
|
+
*
|
|
58
|
+
* @param errorFunction - The function expected to throw the error.
|
|
59
|
+
* @param options - Extra options to apply.
|
|
60
|
+
*
|
|
61
|
+
* @throws {Error} Any other errors thrown by the `errorFunction` that are not a `CodeError`.
|
|
62
|
+
* @throws {Error} If no `CodeError` was thrown by the `errorFunction`
|
|
63
|
+
*
|
|
64
|
+
* @returns The `CodeError` that was thrown by the `errorFunction`
|
|
65
|
+
*/
|
|
66
|
+
static expectError<ErrorCode extends string = string>(this: typeof CodeError, errorFunction: () => unknown, options?: ExpectErrorOptions$1<ErrorCode>): CodeError;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the thrown `CodeError` from a given asynchronous function if one was thrown, and re-throws any other errors, or throws a default `CodeError` if no error thrown.
|
|
69
|
+
*
|
|
70
|
+
* @param errorFunction - The function expected to throw the error.
|
|
71
|
+
* @param options - Extra options to apply.
|
|
72
|
+
*
|
|
73
|
+
* @throws {Error} Any other errors thrown by the `errorFunction` that are not a `CodeError`.
|
|
74
|
+
* @throws {Error} If no `CodeError` was thrown by the `errorFunction`
|
|
75
|
+
*
|
|
76
|
+
* @returns The `CodeError` that was thrown by the `errorFunction`
|
|
77
|
+
*/
|
|
78
|
+
static expectErrorAsync<ErrorCode extends string = string>(this: typeof CodeError, errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions$1<ErrorCode>): Promise<CodeError>;
|
|
79
|
+
}
|
|
12
80
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
15
|
-
|
|
81
|
+
//#region src/v6/DataError.d.ts
|
|
82
|
+
type DefaultDataErrorCode = "INVALID_DATA";
|
|
83
|
+
interface ExpectErrorOptions<ErrorCode extends string = DefaultDataErrorCode> {
|
|
84
|
+
expectedCode?: ErrorCode | DefaultDataErrorCode;
|
|
16
85
|
}
|
|
86
|
+
declare const DataErrorCode: {
|
|
87
|
+
readonly INVALID_DATA: "INVALID_DATA";
|
|
88
|
+
};
|
|
89
|
+
type DataErrorCode = CreateEnumType<typeof DataErrorCode>;
|
|
17
90
|
/**
|
|
18
91
|
* Represents errors you may get that may've been caused by a specific piece of data.
|
|
19
92
|
*
|
|
@@ -21,8 +94,7 @@ interface ExpectErrorOptions {
|
|
|
21
94
|
*
|
|
22
95
|
* @template DataType - The type of the data that caused the error.
|
|
23
96
|
*/
|
|
24
|
-
declare class DataError<DataType extends Record<PropertyKey, unknown
|
|
25
|
-
code: string;
|
|
97
|
+
declare class DataError<DataType extends object = Record<PropertyKey, unknown>, ErrorCode extends string = DataErrorCode> extends CodeError<ErrorCode | DataErrorCode> {
|
|
26
98
|
data: DataType;
|
|
27
99
|
/**
|
|
28
100
|
* @param data - The data that caused the error.
|
|
@@ -30,8 +102,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
30
102
|
* @param message - A human-readable error message (e.g. The data provided is invalid).
|
|
31
103
|
* @param options - Extra options to pass to super Error constructor.
|
|
32
104
|
*/
|
|
33
|
-
constructor(data: DataType, code?:
|
|
34
|
-
private static checkCaughtError;
|
|
105
|
+
constructor(data: DataType, code?: ErrorCode | DefaultDataErrorCode, message?: string, options?: ErrorOptions);
|
|
35
106
|
/**
|
|
36
107
|
* Checks whether the given input may have been caused by a DataError.
|
|
37
108
|
*
|
|
@@ -39,7 +110,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
39
110
|
*
|
|
40
111
|
* @returns `true` if the input is a DataError, and `false` otherwise. The type of the input will also be narrowed down to DataError if `true`.
|
|
41
112
|
*/
|
|
42
|
-
static check<DataType extends Record<PropertyKey, unknown
|
|
113
|
+
static check<DataType extends object = Record<PropertyKey, unknown>, ErrorCode extends string = DataErrorCode>(input: unknown): input is DataError<DataType, ErrorCode>;
|
|
43
114
|
/**
|
|
44
115
|
* Gets the thrown `DataError` from a given function if one was thrown, and re-throws any other errors, or throws a default `DataError` if no error thrown.
|
|
45
116
|
*
|
|
@@ -51,7 +122,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
51
122
|
*
|
|
52
123
|
* @returns The `DataError` that was thrown by the `errorFunction`
|
|
53
124
|
*/
|
|
54
|
-
static expectError(errorFunction: () => unknown, options?: ExpectErrorOptions): DataError
|
|
125
|
+
static expectError<DataType extends Record<PropertyKey, unknown>, ErrorCode extends string = DefaultDataErrorCode>(errorFunction: () => unknown, options?: ExpectErrorOptions<ErrorCode>): DataError<DataType, ErrorCode>;
|
|
55
126
|
/**
|
|
56
127
|
* Gets the thrown `DataError` from a given asynchronous function if one was thrown, and re-throws any other errors, or throws a default `DataError` if no error thrown.
|
|
57
128
|
*
|
|
@@ -63,33 +134,9 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
63
134
|
*
|
|
64
135
|
* @returns The `DataError` that was thrown by the `errorFunction`
|
|
65
136
|
*/
|
|
66
|
-
static expectErrorAsync(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions): Promise<DataError
|
|
137
|
+
static expectErrorAsync<DataType extends Record<PropertyKey, unknown>, ErrorCode extends string = DefaultDataErrorCode>(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions<ErrorCode>): Promise<DataError<DataType, ErrorCode>>;
|
|
67
138
|
}
|
|
68
139
|
//#endregion
|
|
69
|
-
//#region src/root/types/CreateEnumType.d.ts
|
|
70
|
-
/**
|
|
71
|
-
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
72
|
-
*
|
|
73
|
-
* @category Types
|
|
74
|
-
*
|
|
75
|
-
* @template ObjectType - The type of the object to get the value types for.
|
|
76
|
-
*/
|
|
77
|
-
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
80
|
-
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/root/types/NullableOnCondition.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
85
|
-
*
|
|
86
|
-
* @category Types
|
|
87
|
-
*
|
|
88
|
-
* @param Condition - The condition to check.
|
|
89
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
90
|
-
*/
|
|
91
|
-
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
92
|
-
//#endregion
|
|
93
140
|
//#region src/internal/DependencyGroup.d.ts
|
|
94
141
|
declare const DependencyGroup: {
|
|
95
142
|
readonly DEPENDENCIES: "dependencies";
|
|
@@ -131,7 +178,10 @@ declare const ModuleType: {
|
|
|
131
178
|
type ModuleType = CreateEnumType<typeof ModuleType>;
|
|
132
179
|
//#endregion
|
|
133
180
|
//#region src/internal/packageJsonNotFoundError.d.ts
|
|
134
|
-
|
|
181
|
+
interface PackageJsonNotFoundErrorPayload {
|
|
182
|
+
packagePath: string;
|
|
183
|
+
}
|
|
184
|
+
declare function packageJsonNotFoundError(packagePath: string): DataError<PackageJsonNotFoundErrorPayload, "PACKAGE_JSON_NOT_FOUND">;
|
|
135
185
|
//#endregion
|
|
136
186
|
//#region src/internal/PackageManager.d.ts
|
|
137
187
|
declare const PackageManager: {
|
|
@@ -143,6 +193,16 @@ type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
|
143
193
|
//#region src/internal/parseJsonFromStdout.d.ts
|
|
144
194
|
declare function parseJsonFromStdout(stdout: string): Record<string, unknown>;
|
|
145
195
|
//#endregion
|
|
196
|
+
//#region src/internal/sayHello.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
199
|
+
*
|
|
200
|
+
* [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
|
|
201
|
+
*
|
|
202
|
+
* @returns The lyrics string in markdown format.
|
|
203
|
+
*/
|
|
204
|
+
declare function sayHello(): string;
|
|
205
|
+
//#endregion
|
|
146
206
|
//#region src/internal/setupPackageEndToEnd.d.ts
|
|
147
207
|
interface SetupPackageEndToEndOptions {
|
|
148
208
|
dependencyGroup?: DependencyGroup;
|
|
@@ -152,4 +212,4 @@ declare function setupPackageEndToEnd(temporaryPath: string, packageManager: Pac
|
|
|
152
212
|
cwd: string;
|
|
153
213
|
}>>;
|
|
154
214
|
//#endregion
|
|
155
|
-
export { DependencyGroup, type IsTypeArgumentString, ModuleType, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, getPackageJsonPath, packageJsonNotFoundError, parseJsonFromStdout, sayHello, setupPackageEndToEnd };
|
|
215
|
+
export { DependencyGroup, type IsTypeArgumentString, ModuleType, type PackageJsonNotFoundErrorPayload, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, getPackageJsonPath, packageJsonNotFoundError, parseJsonFromStdout, sayHello, setupPackageEndToEnd };
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,19 +1,92 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
import { ExecaMethod } from "execa";
|
|
3
|
-
//#region src/root/
|
|
3
|
+
//#region src/root/types/CreateEnumType.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* @category Types
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
9
|
+
* @template ObjectType - The type of the object to get the value types for.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
14
|
+
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/root/types/NullableOnCondition.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
19
|
+
*
|
|
20
|
+
* @category Types
|
|
21
|
+
*
|
|
22
|
+
* @param Condition - The condition to check.
|
|
23
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
24
|
+
*/
|
|
25
|
+
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/v6/CodeError.d.ts
|
|
28
|
+
interface ExpectErrorOptions$1<ErrorCode extends string = string> {
|
|
29
|
+
expectedCode?: ErrorCode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents errors that can be described using a standardised error code, and a human-readable error message.
|
|
33
|
+
*
|
|
34
|
+
* @category Types
|
|
35
|
+
*
|
|
36
|
+
* @template ErrorCode The type of the standardised error code.
|
|
37
|
+
*/
|
|
38
|
+
declare class CodeError<ErrorCode extends string = string> extends Error {
|
|
39
|
+
code: ErrorCode;
|
|
40
|
+
/**
|
|
41
|
+
* @param code - A standardised code (e.g. UNEXPECTED_DATA).
|
|
42
|
+
* @param message - A human-readable error message (e.g. The data provided is invalid).
|
|
43
|
+
* @param options - Extra options to pass to super Error constructor.
|
|
44
|
+
*/
|
|
45
|
+
constructor(code: ErrorCode, message?: string, options?: ErrorOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the given input may have been caused by a CodeError.
|
|
48
|
+
*
|
|
49
|
+
* @param input - The input to check.
|
|
50
|
+
*
|
|
51
|
+
* @returns `true` if the input is a CodeError, and `false` otherwise. The type of the input will also be narrowed down to CodeError if `true`.
|
|
52
|
+
*/
|
|
53
|
+
static check(input: unknown): input is CodeError<string>;
|
|
54
|
+
protected static checkCaughtError<ErrorCode extends string = string>(this: typeof CodeError, error: unknown, options?: ExpectErrorOptions$1<ErrorCode>): CodeError;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the thrown `CodeError` from a given function if one was thrown, and re-throws any other errors, or throws a default `CodeError` if no error thrown.
|
|
57
|
+
*
|
|
58
|
+
* @param errorFunction - The function expected to throw the error.
|
|
59
|
+
* @param options - Extra options to apply.
|
|
60
|
+
*
|
|
61
|
+
* @throws {Error} Any other errors thrown by the `errorFunction` that are not a `CodeError`.
|
|
62
|
+
* @throws {Error} If no `CodeError` was thrown by the `errorFunction`
|
|
63
|
+
*
|
|
64
|
+
* @returns The `CodeError` that was thrown by the `errorFunction`
|
|
65
|
+
*/
|
|
66
|
+
static expectError<ErrorCode extends string = string>(this: typeof CodeError, errorFunction: () => unknown, options?: ExpectErrorOptions$1<ErrorCode>): CodeError;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the thrown `CodeError` from a given asynchronous function if one was thrown, and re-throws any other errors, or throws a default `CodeError` if no error thrown.
|
|
69
|
+
*
|
|
70
|
+
* @param errorFunction - The function expected to throw the error.
|
|
71
|
+
* @param options - Extra options to apply.
|
|
72
|
+
*
|
|
73
|
+
* @throws {Error} Any other errors thrown by the `errorFunction` that are not a `CodeError`.
|
|
74
|
+
* @throws {Error} If no `CodeError` was thrown by the `errorFunction`
|
|
75
|
+
*
|
|
76
|
+
* @returns The `CodeError` that was thrown by the `errorFunction`
|
|
77
|
+
*/
|
|
78
|
+
static expectErrorAsync<ErrorCode extends string = string>(this: typeof CodeError, errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions$1<ErrorCode>): Promise<CodeError>;
|
|
79
|
+
}
|
|
12
80
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
15
|
-
|
|
81
|
+
//#region src/v6/DataError.d.ts
|
|
82
|
+
type DefaultDataErrorCode = "INVALID_DATA";
|
|
83
|
+
interface ExpectErrorOptions<ErrorCode extends string = DefaultDataErrorCode> {
|
|
84
|
+
expectedCode?: ErrorCode | DefaultDataErrorCode;
|
|
16
85
|
}
|
|
86
|
+
declare const DataErrorCode: {
|
|
87
|
+
readonly INVALID_DATA: "INVALID_DATA";
|
|
88
|
+
};
|
|
89
|
+
type DataErrorCode = CreateEnumType<typeof DataErrorCode>;
|
|
17
90
|
/**
|
|
18
91
|
* Represents errors you may get that may've been caused by a specific piece of data.
|
|
19
92
|
*
|
|
@@ -21,8 +94,7 @@ interface ExpectErrorOptions {
|
|
|
21
94
|
*
|
|
22
95
|
* @template DataType - The type of the data that caused the error.
|
|
23
96
|
*/
|
|
24
|
-
declare class DataError<DataType extends Record<PropertyKey, unknown
|
|
25
|
-
code: string;
|
|
97
|
+
declare class DataError<DataType extends object = Record<PropertyKey, unknown>, ErrorCode extends string = DataErrorCode> extends CodeError<ErrorCode | DataErrorCode> {
|
|
26
98
|
data: DataType;
|
|
27
99
|
/**
|
|
28
100
|
* @param data - The data that caused the error.
|
|
@@ -30,8 +102,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
30
102
|
* @param message - A human-readable error message (e.g. The data provided is invalid).
|
|
31
103
|
* @param options - Extra options to pass to super Error constructor.
|
|
32
104
|
*/
|
|
33
|
-
constructor(data: DataType, code?:
|
|
34
|
-
private static checkCaughtError;
|
|
105
|
+
constructor(data: DataType, code?: ErrorCode | DefaultDataErrorCode, message?: string, options?: ErrorOptions);
|
|
35
106
|
/**
|
|
36
107
|
* Checks whether the given input may have been caused by a DataError.
|
|
37
108
|
*
|
|
@@ -39,7 +110,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
39
110
|
*
|
|
40
111
|
* @returns `true` if the input is a DataError, and `false` otherwise. The type of the input will also be narrowed down to DataError if `true`.
|
|
41
112
|
*/
|
|
42
|
-
static check<DataType extends Record<PropertyKey, unknown
|
|
113
|
+
static check<DataType extends object = Record<PropertyKey, unknown>, ErrorCode extends string = DataErrorCode>(input: unknown): input is DataError<DataType, ErrorCode>;
|
|
43
114
|
/**
|
|
44
115
|
* Gets the thrown `DataError` from a given function if one was thrown, and re-throws any other errors, or throws a default `DataError` if no error thrown.
|
|
45
116
|
*
|
|
@@ -51,7 +122,7 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
51
122
|
*
|
|
52
123
|
* @returns The `DataError` that was thrown by the `errorFunction`
|
|
53
124
|
*/
|
|
54
|
-
static expectError(errorFunction: () => unknown, options?: ExpectErrorOptions): DataError
|
|
125
|
+
static expectError<DataType extends Record<PropertyKey, unknown>, ErrorCode extends string = DefaultDataErrorCode>(errorFunction: () => unknown, options?: ExpectErrorOptions<ErrorCode>): DataError<DataType, ErrorCode>;
|
|
55
126
|
/**
|
|
56
127
|
* Gets the thrown `DataError` from a given asynchronous function if one was thrown, and re-throws any other errors, or throws a default `DataError` if no error thrown.
|
|
57
128
|
*
|
|
@@ -63,33 +134,9 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
63
134
|
*
|
|
64
135
|
* @returns The `DataError` that was thrown by the `errorFunction`
|
|
65
136
|
*/
|
|
66
|
-
static expectErrorAsync(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions): Promise<DataError
|
|
137
|
+
static expectErrorAsync<DataType extends Record<PropertyKey, unknown>, ErrorCode extends string = DefaultDataErrorCode>(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions<ErrorCode>): Promise<DataError<DataType, ErrorCode>>;
|
|
67
138
|
}
|
|
68
139
|
//#endregion
|
|
69
|
-
//#region src/root/types/CreateEnumType.d.ts
|
|
70
|
-
/**
|
|
71
|
-
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
72
|
-
*
|
|
73
|
-
* @category Types
|
|
74
|
-
*
|
|
75
|
-
* @template ObjectType - The type of the object to get the value types for.
|
|
76
|
-
*/
|
|
77
|
-
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
80
|
-
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/root/types/NullableOnCondition.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
85
|
-
*
|
|
86
|
-
* @category Types
|
|
87
|
-
*
|
|
88
|
-
* @param Condition - The condition to check.
|
|
89
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
90
|
-
*/
|
|
91
|
-
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
92
|
-
//#endregion
|
|
93
140
|
//#region src/internal/DependencyGroup.d.ts
|
|
94
141
|
declare const DependencyGroup: {
|
|
95
142
|
readonly DEPENDENCIES: "dependencies";
|
|
@@ -131,7 +178,10 @@ declare const ModuleType: {
|
|
|
131
178
|
type ModuleType = CreateEnumType<typeof ModuleType>;
|
|
132
179
|
//#endregion
|
|
133
180
|
//#region src/internal/packageJsonNotFoundError.d.ts
|
|
134
|
-
|
|
181
|
+
interface PackageJsonNotFoundErrorPayload {
|
|
182
|
+
packagePath: string;
|
|
183
|
+
}
|
|
184
|
+
declare function packageJsonNotFoundError(packagePath: string): DataError<PackageJsonNotFoundErrorPayload, "PACKAGE_JSON_NOT_FOUND">;
|
|
135
185
|
//#endregion
|
|
136
186
|
//#region src/internal/PackageManager.d.ts
|
|
137
187
|
declare const PackageManager: {
|
|
@@ -143,6 +193,16 @@ type PackageManager = CreateEnumType<typeof PackageManager>;
|
|
|
143
193
|
//#region src/internal/parseJsonFromStdout.d.ts
|
|
144
194
|
declare function parseJsonFromStdout(stdout: string): Record<string, unknown>;
|
|
145
195
|
//#endregion
|
|
196
|
+
//#region src/internal/sayHello.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
199
|
+
*
|
|
200
|
+
* [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
|
|
201
|
+
*
|
|
202
|
+
* @returns The lyrics string in markdown format.
|
|
203
|
+
*/
|
|
204
|
+
declare function sayHello(): string;
|
|
205
|
+
//#endregion
|
|
146
206
|
//#region src/internal/setupPackageEndToEnd.d.ts
|
|
147
207
|
interface SetupPackageEndToEndOptions {
|
|
148
208
|
dependencyGroup?: DependencyGroup;
|
|
@@ -152,4 +212,4 @@ declare function setupPackageEndToEnd(temporaryPath: string, packageManager: Pac
|
|
|
152
212
|
cwd: string;
|
|
153
213
|
}>>;
|
|
154
214
|
//#endregion
|
|
155
|
-
export { DependencyGroup, type IsTypeArgumentString, ModuleType, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, getPackageJsonPath, packageJsonNotFoundError, parseJsonFromStdout, sayHello, setupPackageEndToEnd };
|
|
215
|
+
export { DependencyGroup, type IsTypeArgumentString, ModuleType, type PackageJsonNotFoundErrorPayload, PackageManager, getDependenciesFromGroup, getExpectedTgzName, getPackageJsonContents, getPackageJsonPath, packageJsonNotFoundError, parseJsonFromStdout, sayHello, setupPackageEndToEnd };
|