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> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Pairlist } from '@/types'; import PairlistConfigParameter from '@/components/ftbot/PairlistConfigParameter.vue';
import { ref } from 'vue';
import PairlistConfigParameter from './PairlistConfigParameter.vue';
import { computed } from 'vue';
import { usePairlistConfigStore } from '@/stores/pairlistConfig'; import { usePairlistConfigStore } from '@/stores/pairlistConfig';
import { Pairlist } from '@/types';
import { computed, ref } from 'vue';
const pairlistStore = usePairlistConfigStore(); const pairlistStore = usePairlistConfigStore();

View File

@ -7,6 +7,7 @@ import {
Pairlist, Pairlist,
PairlistConfig, PairlistConfig,
PairlistParamType, PairlistParamType,
PairlistParamValue,
PairlistPayloadItem, PairlistPayloadItem,
PairlistsPayload, PairlistsPayload,
TradingMode, 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) { if (type === PairlistParamType.number) {
return Number(value); return Number(value);
} else if (type === PairlistParamType.boolean) { } else if (type === PairlistParamType.boolean) {

View File

@ -31,15 +31,45 @@ export enum PairlistParamType {
option = 'option', option = 'option',
} }
export interface PairlistParameter { export type PairlistParamValue = string | number | boolean;
interface PairlistParameterBase {
description: string; description: string;
help: string; help: string;
type: PairlistParamType; type: PairlistParamType;
}
export interface StringPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.string;
value?: string; value?: string;
default: 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 { export interface PairlistPayloadItem {
method: string; method: string;
[key: string]: string | number | boolean; [key: string]: string | number | boolean;