drimion 0.2.3 → 0.2.4
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/cli/index.js
CHANGED
|
@@ -8,11 +8,17 @@ export type {{className}}Output = {
|
|
|
8
8
|
// define output - use never if no output needed
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @example usage with unions good for functional error handling
|
|
13
|
+
* export type {{className}}Error = UserNotFoundError | AccountLockedError
|
|
14
|
+
*/
|
|
15
|
+
export type {{className}}Error = string
|
|
16
|
+
|
|
11
17
|
export type {{className}}Metadata = {
|
|
12
18
|
// define metadata - use never if no metadata needed
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
export class {{className}} implements IUseCase<{{className}}Input, {{className}}Output> {
|
|
21
|
+
export class {{className}} implements IUseCase<{{className}}Input, {{className}}Output, {{className}}Error> {
|
|
16
22
|
public constructor() {}
|
|
17
23
|
|
|
18
24
|
public async execute(input: {{className}}Input): Promise<IResult<{{className}}Output, string, {{className}}Metadata>> {
|
|
@@ -145,7 +145,7 @@ export class Result<T = void, D = string, M = AnyObject>
|
|
|
145
145
|
*
|
|
146
146
|
* @returns `true` if the result is a failure, `false` if it is a success.
|
|
147
147
|
*/
|
|
148
|
-
public isError():
|
|
148
|
+
public isError(): this is Result<never, D, M> {
|
|
149
149
|
return this.#isError;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -167,7 +167,7 @@ export class Result<T = void, D = string, M = AnyObject>
|
|
|
167
167
|
*
|
|
168
168
|
* @returns `true` if the result is a success, `false` if it is a failure.
|
|
169
169
|
*/
|
|
170
|
-
public isSuccess():
|
|
170
|
+
public isSuccess(): this is Result<T, never, M> {
|
|
171
171
|
return this.#isSuccess;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -6,8 +6,9 @@ import type { IResult } from "./result.types";
|
|
|
6
6
|
*
|
|
7
7
|
* @template Input The input type.
|
|
8
8
|
* @template Output The output type.
|
|
9
|
+
* @template Error The error types if any–defaults to string.
|
|
9
10
|
*/
|
|
10
|
-
export interface ICommand<Input = void, Output = void, Error =
|
|
11
|
+
export interface ICommand<Input = void, Output = void, Error = string> {
|
|
11
12
|
execute(input: Input): Promise<IResult<Output, Error>>;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -18,8 +19,9 @@ export interface ICommand<Input = void, Output = void, Error = never> {
|
|
|
18
19
|
*
|
|
19
20
|
* @template Input The query parameters type.
|
|
20
21
|
* @template Output The returned data type.
|
|
22
|
+
* @template Error The error types if any–defaults to string.
|
|
21
23
|
*/
|
|
22
|
-
export interface IQuery<Input = void, Output = void, Error =
|
|
24
|
+
export interface IQuery<Input = void, Output = void, Error = string> {
|
|
23
25
|
execute(input: Input): Promise<IResult<Output, Error>>;
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -31,8 +33,9 @@ export interface IQuery<Input = void, Output = void, Error = never> {
|
|
|
31
33
|
*
|
|
32
34
|
* @template Input The input type.
|
|
33
35
|
* @template Output The output type.
|
|
36
|
+
* @template Error The error types if any–defaults to string.
|
|
34
37
|
*/
|
|
35
|
-
export type IUseCase<Input = void, Output = void, Error =
|
|
38
|
+
export type IUseCase<Input = void, Output = void, Error = string> = ICommand<
|
|
36
39
|
Input,
|
|
37
40
|
Output,
|
|
38
41
|
Error
|