export type ConfigurationSchemaDefinition> = { readonly categories: { [key in C]: CategoryDefinition; }; readonly schema: S; }; export type RootConfigurationSchema = { readonly [key: string]: RootConfigurationProperty; }; export type ConfigurationSchema = { readonly [key: string]: ConfigurationProperty; }; export type ConfigurationPropertyType = "string" | "number" | "boolean" | "array" | "dictionary" | "object"; export type CategoryDefinition = { name: string; description?: string; }; export type RootConfigurationProperty = ConfigurationProperty & { /** * Category for the configuration. For documentation purposes. */ readonly category?: C; }; export type ConfigurationPropertyBase = { readonly type: ConfigurationPropertyType; /** * Description for the configuration. */ readonly description?: string; /** * Mark this config as deprecated.It will log a warning when used. */ readonly deprecated?: boolean; }; export type StringConfigurationProperty = ConfigurationPropertyBase & { type: "string"; /** * List of supported values. Only supported for type: string. */ readonly enum?: readonly string[]; }; export type NumberConfigurationProperty = ConfigurationPropertyBase & { type: "number"; }; export type BooleanConfigurationProperty = ConfigurationPropertyBase & { type: "boolean"; }; export type ArrayConfigurationProperty = ConfigurationPropertyBase & { type: "array"; items: PrimitiveConfigurationProperty; }; export type DictionaryConfigurationProperty = ConfigurationPropertyBase & { type: "dictionary"; items: PrimitiveConfigurationProperty; }; export type ObjectConfigurationProperty = ConfigurationPropertyBase & { type: "object"; properties: ConfigurationSchema; }; export type ConfigurationProperty = | PrimitiveConfigurationProperty | ArrayConfigurationProperty | DictionaryConfigurationProperty; export type PrimitiveConfigurationProperty = | ObjectConfigurationProperty | StringConfigurationProperty | NumberConfigurationProperty | BooleanConfigurationProperty; export type EnumType> = T[number]; export type ProcessedConfiguration = { [K in keyof S]: InferredProcessedType; }; // prettier-ignore export type InferredProcessedType = T extends ArrayConfigurationProperty ? InferredProcessedArrayType : T extends DictionaryConfigurationProperty ? InferredProcessedDictionaryType : T extends PrimitiveConfigurationProperty ? InferredProcessedPrimitiveType : never; export type InferredProcessedArrayType = InferredProcessedPrimitiveType[]; export type InferredProcessedDictionaryType = Record< string, InferredProcessedPrimitiveType >; // prettier-ignore export type InferredProcessedPrimitiveType = T extends { type: "string", enum: ReadonlyArray } ? EnumType : T extends { type: "string" } ? string : T extends { type: "number" } ? number : T extends { type: "boolean" } ? boolean : T extends ObjectConfigurationProperty ? ProcessedConfiguration : never; // prettier-ignore export type InferredRawType = T extends ArrayConfigurationProperty ? InferredRawArrayType : T extends DictionaryConfigurationProperty ? InferredRawDictionaryType : T extends PrimitiveConfigurationProperty ? InferredRawPrimitiveType : never; export type InferredRawArrayType = | NonNullable>[] | InferredRawPrimitiveType; export type InferredRawDictionaryType = Record>; // prettier-ignore export type InferredRawPrimitiveType = T extends { type: "string", enum: ReadonlyArray } ? EnumType : T extends { type: "string" } ? string | undefined : T extends { type: "number" } ? number | undefined : T extends { type: "boolean" } ? boolean | undefined : T extends ObjectConfigurationProperty ? RawConfiguration | undefined : never; export type RawConfiguration = { [K in keyof S]?: InferredRawType; };