-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
342 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Process } from '../interfaces/index'; | ||
|
||
export const getBaseProcess = (process: Process) => | ||
|
||
class BaseAdapterProcess { | ||
|
||
static process: Process = process; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { getBaseProcess } from '../_base'; | ||
import { Scroller } from '../../scroller'; | ||
import { ADAPTER_METHODS, validate } from '../../inputs/index'; | ||
import { AdapterProcess, IValidatedData, ProcessStatus } from '../../interfaces/index'; | ||
|
||
interface IParseInput<T> { | ||
data: IValidatedData; | ||
params?: T; | ||
} | ||
|
||
export const getBaseAdapterProcess = (process: AdapterProcess) => | ||
|
||
class BaseAdapterProcess extends getBaseProcess(process) { | ||
|
||
static process: AdapterProcess = process; | ||
|
||
static parseInput<T>(scroller: Scroller, options: T): IParseInput<T> { | ||
const inputData = validate(options, ADAPTER_METHODS[process]); | ||
const result: IParseInput<T> = { data: inputData }; | ||
|
||
if (inputData.isValid) { | ||
result.params = Object.entries(inputData.params) | ||
.reduce((acc, [key, { value }]) => ({ | ||
...acc, | ||
[key]: value | ||
}), {} as T); | ||
} else { | ||
scroller.logger.log(() => inputData.showErrors()); | ||
scroller.workflow.call({ | ||
process, | ||
status: ProcessStatus.error, | ||
payload: { error: `Wrong argument of the "${process}" method call` } | ||
}); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
}; |
Oops, something went wrong.