import { IconKey, IconKeyOff, IconLockOff, IconPassword, IconUser, IconUserOff, TablerIcon, } from '@tabler/icons'; import { TileBaseType } from './tile'; export interface ServiceType extends TileBaseType { id: string; name: string; url: string; behaviour: ServiceBehaviourType; network: ServiceNetworkType; appearance: ServiceAppearanceType; integration: ServiceIntegrationType; } export type ConfigServiceType = Omit & { integration?: ConfigServiceIntegrationType | null; }; interface ServiceBehaviourType { onClickUrl: string; isOpeningNewTab: boolean; } interface ServiceNetworkType { enabledStatusChecker: boolean; okStatus: number[]; } interface ServiceAppearanceType { iconUrl: string; } export type IntegrationType = | 'readarr' | 'radarr' | 'sonarr' | 'lidarr' | 'sabnzbd' | 'jellyseerr' | 'overseerr' | 'deluge' | 'qBittorrent' | 'transmission' | 'nzbGet'; export type ServiceIntegrationType = { type: IntegrationType | null; properties: ServiceIntegrationPropertyType[]; }; export type ConfigServiceIntegrationType = Omit & { properties: ConfigServiceIntegrationPropertyType[]; }; export type ServiceIntegrationPropertyType = { type: 'private' | 'public'; field: IntegrationField; value?: string | null; isDefined: boolean; }; type ConfigServiceIntegrationPropertyType = Omit; export type IntegrationField = 'apiKey' | 'password' | 'username'; export const integrationFieldProperties: { [key in ServiceIntegrationType['type']]: IntegrationField[]; } = { lidarr: ['apiKey'], radarr: ['apiKey'], sonarr: ['apiKey'], sabnzbd: ['apiKey'], readarr: ['apiKey'], overseerr: ['apiKey'], jellyseerr: ['apiKey'], deluge: ['password'], nzbGet: ['username', 'password'], qBittorrent: ['username', 'password'], transmission: ['username', 'password'], }; export type IntegrationFieldDefinitionType = { type: 'private' | 'public'; icon: TablerIcon; iconUnset: TablerIcon; label: string; }; export const integrationFieldDefinitions: { [key in IntegrationField]: IntegrationFieldDefinitionType; } = { apiKey: { type: 'private', icon: IconKey, iconUnset: IconKeyOff, label: 'API Key', }, username: { type: 'public', icon: IconUser, iconUnset: IconUserOff, label: 'Username', }, password: { type: 'private', icon: IconPassword, iconUnset: IconLockOff, label: 'Password', }, };