Make parameter types more explicit

This commit is contained in:
Matthias 2023-06-10 08:46:36 +02:00
parent 51055bd256
commit c3a4f1def6
3 changed files with 37 additions and 7 deletions

View File

@ -55,11 +55,10 @@
</template>
<script setup lang="ts">
import { Pairlist } from '@/types';
import { ref } from 'vue';
import PairlistConfigParameter from './PairlistConfigParameter.vue';
import { computed } from 'vue';
import PairlistConfigParameter from '@/components/ftbot/PairlistConfigParameter.vue';
import { usePairlistConfigStore } from '@/stores/pairlistConfig';
import { Pairlist } from '@/types';
import { computed, ref } from 'vue';
const pairlistStore = usePairlistConfigStore();

View File

@ -7,6 +7,7 @@ import {
Pairlist,
PairlistConfig,
PairlistParamType,
PairlistParamValue,
PairlistPayloadItem,
PairlistsPayload,
TradingMode,
@ -165,7 +166,7 @@ export const usePairlistConfigStore = defineStore(
}
}
function convertToParamType(type: PairlistParamType, value: string) {
function convertToParamType(type: PairlistParamType, value: PairlistParamValue) {
if (type === PairlistParamType.number) {
return Number(value);
} else if (type === PairlistParamType.boolean) {

View File

@ -31,15 +31,45 @@ export enum PairlistParamType {
option = 'option',
}
export interface PairlistParameter {
export type PairlistParamValue = string | number | boolean;
interface PairlistParameterBase {
description: string;
help: string;
type: PairlistParamType;
}
export interface StringPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.string;
value?: string;
default: string;
options?: string[];
}
export interface NumberPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.number;
value?: number;
default: number;
}
export interface BooleanPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.boolean;
value?: boolean;
default: boolean;
}
export interface OptionPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.option;
options: string[];
value?: string;
default: string;
}
export type PairlistParameter =
| StringPairlistParameter
| NumberPairlistParameter
| BooleanPairlistParameter
| OptionPairlistParameter;
export interface PairlistPayloadItem {
method: string;
[key: string]: string | number | boolean;