command-action
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "command-action", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -35,3 +35,2 @@ import { Command } from '../instance' | ||
public rollback() {} | ||
@@ -38,0 +37,0 @@ protected async exec(): Promise<void> { |
@@ -1,2 +0,2 @@ | ||
import { ActionMethod, Context, PropsType } from '../types' | ||
import { ActionMethod, CommandActionConfig, Context, PropsType } from '../types' | ||
@@ -6,2 +6,5 @@ class Command { | ||
public provider: PropsType | null = null | ||
public config: CommandActionConfig = { | ||
defaultForceFailures: false | ||
} | ||
@@ -16,2 +19,11 @@ public static instance() { | ||
public settings(config: Partial<CommandActionConfig>) { | ||
this.config = { | ||
...this.config, | ||
...config | ||
} | ||
return this | ||
} | ||
public async runWithProvider<Props extends PropsType, Result extends Props = Props>( | ||
@@ -18,0 +30,0 @@ action: ActionMethod<Props, Result>, props: (Parameters<typeof action>)[0], provider: PropsType |
@@ -0,1 +1,2 @@ | ||
import { Command } from '../instance' | ||
import { PropsType, ActionInstance, FailureType } from '../types' | ||
@@ -5,5 +6,5 @@ import { ForcedActionError } from '../Errors' | ||
interface FailureMeta extends Record<string, any> { | ||
exstras?: Record<string, any> | ||
extras?: Record<string, any> | ||
type: string | ||
message: string | string[] | ||
message?: string | string[] | ||
force: boolean | ||
@@ -49,3 +50,3 @@ } | ||
public fail({ type = FailureType.Standard, message, force = false, ...rest }: FailParams): never { | ||
public fail({ type = FailureType.Standard, message, force = Command.config.defaultForceFailures, ...rest }: FailParams): never { | ||
this._failureMeta = { | ||
@@ -55,3 +56,3 @@ type, | ||
force, | ||
exstras: rest | ||
extras: rest | ||
} | ||
@@ -58,0 +59,0 @@ |
@@ -24,1 +24,5 @@ import { ContextClass } from './Context' | ||
} | ||
export interface CommandActionConfig { | ||
defaultForceFailures: boolean | ||
} |
35766
961