import { FileSystem } from "./fs.js";

export interface ServiceAnalyzer {
	detect: (fs: FileSystem, root: string) => boolean;
	analyze: (fs: FileSystem, root: string) => Promise<ServiceInfo>;
}

export interface ConfigVar {
	name: string;
	category: ConfigVarCategory;
	type?: ConfigVarType;
	semanticType?: ConfigVarSemanticType;
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
	defaultValue?: any;
	description?: string;
	required?: boolean;
	sensitive?: boolean;
}

export enum ConfigVarCategory {
	CommandLineFlag = "CommandLineFlag",
	EnvironmentVariable = "EnvironmentVariable",
}

export enum ConfigVarType {
	String = "String",
	Number = "Number",
	Boolean = "Boolean",
}

export enum ConfigVarSemanticType {
	EXPANDED_ENV_VAR = "EXPANDED_ENV_VAR",
	PORT = "PORT",
	FILESYSTEM_PATH = "FILESYSTEM_PATH",
	DATABASE_URL = "DATABASE_URL",
	SQLITE_PATH = "SQLITE_PATH",
	POSTGRES_URL = "POSTGRES_URL",
	POSTGRES_PASSWORD = "POSTGRES_PASSWORD",
	POSTGRES_USER = "POSTGRES_USER",
	POSTGRES_DB = "POSTGRES_DB",
	POSTGRES_PORT = "POSTGRES_PORT",
	POSTGRES_HOST = "POSTGRES_HOST",
	POSTGRES_SSL = "POSTGRES_SSL",
	MONGO_URL = "MONGO_URL",
	MONGO_PASSWORD = "MONGO_PASSWORD",
	MONGO_USER = "MONGO_USER",
	MONGO_DB = "MONGO_DB",
	MONGO_PORT = "MONGO_PORT",
	MONGO_HOST = "MONGO_HOST",
	MONGO_SSL = "MONGO_SSL",
}

export interface ServiceInfo {
	name: string;
	location: string;
	configVars: Array<ConfigVar>;
	commands: Array<string>;
}
