From aa9e01a582349898c307c9766382581e2f26953e Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 12 Jul 2020 17:47:39 +0200 Subject: [PATCH] Add support for Secret values on general places --- src/language-service/src/schemas/core.ts | 22 ++++++++++++------- .../src/schemas/integrations/hacs.ts | 4 +++- .../src/schemas/integrations/panel_iframe.ts | 4 ++-- src/language-service/src/schemas/types.ts | 5 +++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/language-service/src/schemas/core.ts b/src/language-service/src/schemas/core.ts index 94691f739e..d4614c78b3 100644 --- a/src/language-service/src/schemas/core.ts +++ b/src/language-service/src/schemas/core.ts @@ -1,5 +1,11 @@ import { HomeAssistantRoot } from "./homeassistant"; -import { DeviceClasses, IncludeNamed, UnitSystem, TimeZone } from "./types"; +import { + DeviceClasses, + IncludeNamed, + UnitSystem, + Secret, + TimeZone, +} from "./types"; export interface Core { auth_mfa_modules?: Array | IncludeNamed; // TODO: Extract similar as in integrations @@ -29,7 +35,7 @@ export interface Core { * * @TJS-type integer */ - elevation?: number; + elevation?: number | Secret; /** * Latitude of your location required to calculate the time the sun rises and sets. @@ -38,7 +44,7 @@ export interface Core { * @minimum -90 * @maximum 90 */ - latitude?: number; + latitude?: number | Secret; /** * Longitude of your location required to calculate the time the sun rises and sets. @@ -47,13 +53,13 @@ export interface Core { * @minimum -180 * @maximum 180 */ - longitude?: number; + longitude?: number | Secret; /** * Name of the location where Home Assistant is running. * https://www.home-assistant.io/docs/configuration/basic/#name */ - name?: string; + name?: string | Secret; /** * Packages in Home Assistant provide a way to bundle different component’s configuration together. It allows for "splitting" your configuration. @@ -66,20 +72,20 @@ export interface Core { * https://www.home-assistant.io/docs/configuration/basic/#time_zone * https://www.wikiwand.com/en/List_of_tz_database_time_zones */ - time_zone?: TimeZone; + time_zone?: TimeZone | Secret; /** * "metric" for Metric, "imperial" for Imperial. * This also sets temperature unit Home Assistant will use. * https://www.home-assistant.io/docs/configuration/basic/#unit_system */ - unit_system?: UnitSystem; + unit_system?: UnitSystem | Secret; /** * List of folders that can be used as sources for sending files. * https://www.home-assistant.io/docs/configuration/basic/#whitelist_external_dirs */ - whitelist_external_dirs?: string[]; + whitelist_external_dirs?: string[] | Secret; } export interface CoreCustomize { diff --git a/src/language-service/src/schemas/integrations/hacs.ts b/src/language-service/src/schemas/integrations/hacs.ts index 5bfcac61d5..ba88aeba22 100644 --- a/src/language-service/src/schemas/integrations/hacs.ts +++ b/src/language-service/src/schemas/integrations/hacs.ts @@ -3,6 +3,8 @@ * https://hacs.xyz/ * Source: https://github.com/hacs/integration/blob/1.1.2/custom_components/hacs/configuration_schema.py */ +import { Secret } from "../types"; + export type Domain = "hacs"; export interface Schema { /** @@ -11,7 +13,7 @@ export interface Schema { * * @TJS-pattern ^[0-9a-fA-F]{40}$ */ - token: string; + token: string | Secret; /** * Enable tracking of AppDaemon apps. diff --git a/src/language-service/src/schemas/integrations/panel_iframe.ts b/src/language-service/src/schemas/integrations/panel_iframe.ts index 8b4a692f35..f2c91aacbe 100644 --- a/src/language-service/src/schemas/integrations/panel_iframe.ts +++ b/src/language-service/src/schemas/integrations/panel_iframe.ts @@ -2,7 +2,7 @@ * iframe Panel integration * Source: https://github.com/home-assistant/core/blob/dev/homeassistant/components/panel_iframe/__init__.py */ -import { IncludeNamed } from "../types"; +import { IncludeNamed, Secret } from "../types"; export type Domain = "panel_iframe"; export interface Schema { @@ -34,5 +34,5 @@ interface Item { * * @TJS-format uri */ - url: string; + url: string | Secret; } diff --git a/src/language-service/src/schemas/types.ts b/src/language-service/src/schemas/types.ts index 27ac75adb7..d252a9f662 100644 --- a/src/language-service/src/schemas/types.ts +++ b/src/language-service/src/schemas/types.ts @@ -100,6 +100,11 @@ export type IncludeNamed = string; */ export type Integer = number; +/** + * @TJS-pattern ^!secret\s([a-zA-Z0-9_-]+)$ + */ +export type Secret = string; + /** * @TJS-type string * @TJS-pattern [.]yaml|[.]yml$