Skip to main content

Types

Algorithm User Settings Type

type AlgorithmSingleTypeUnion = 'Float' | 'Number'
type AlgorithmArrayTypeUnion = ['Device'] | ['Sensor']
type AlgorithmTypeUnion = AlgorithmSingleTypeUnion | AlgorithmArrayTypeUnion

interface AlgorithmUserSetting <T extends AlgorithmTypeUnion = AlgorithmTypeUnion> {
type: T
default?: string
description?: string
}

interface AlgorithmUserUserSetting <
T extends AlgorithmTypeUnion = AlgorithmTypeUnion
> extends AlgorithmUserSetting<T> {
value?: T extends AlgorithmSingleTypeUnion
? string
: (
T extends AlgorithmArrayTypeUnion
? number []
: never
)
}

type AlgorithmSettings = {
user: {
[key: string]?: AlgorithmUserUserSetting
}
}

Post Algorithm Type

interface PostSpaceAlgorithm {
spaceAlgorithm: {
// Stringified AlgorithmSettings
userSettings: string
}
}