From 0aaf0363c546a61e01ee876c567a3861e215a1a3 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 3 May 2023 11:20:29 -0400 Subject: [PATCH] chore: Fix type error in EntityMetadata Signed-off-by: Sebastian Malton --- packages/core/src/common/catalog/catalog-entity.ts | 7 ++++--- packages/core/src/common/cluster-types.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core/src/common/catalog/catalog-entity.ts b/packages/core/src/common/catalog/catalog-entity.ts index 8eb73f7943..f673cc232f 100644 --- a/packages/core/src/common/catalog/catalog-entity.ts +++ b/packages/core/src/common/catalog/catalog-entity.ts @@ -10,6 +10,7 @@ import { once } from "lodash"; import type { Disposer, StrictReactNode } from "@k8slens/utilities"; import { iter } from "@k8slens/utilities"; import type { CategoryColumnRegistration, TitleCellProps } from "../../renderer/components/catalog/custom-category-columns"; +import type { Literal, Metadata } from "../cluster-types"; export type { CategoryColumnRegistration, TitleCellProps }; @@ -232,8 +233,8 @@ export abstract class CatalogCategory extends (EventEmitter as new () => TypedEm } } -export type EntityMetadataObject = { [Key in string]?: EntityMetadataValue }; -export type EntityMetadataValue = string | number | boolean | EntityMetadataObject | undefined; +export type EntityMetadataObject = { [key in string]?: Metadata }; +export type EntityMetadataValue = Literal; export interface CatalogEntityMetadata extends EntityMetadataObject { uid: string; @@ -241,7 +242,7 @@ export interface CatalogEntityMetadata extends EntityMetadataObject { shortName?: string; description?: string; source?: string; - labels: Partial>; + labels: { [key in string]?: string }; } export interface CatalogEntityStatus { diff --git a/packages/core/src/common/cluster-types.ts b/packages/core/src/common/cluster-types.ts index 13ca549036..f3859fb76f 100644 --- a/packages/core/src/common/cluster-types.ts +++ b/packages/core/src/common/cluster-types.ts @@ -8,7 +8,7 @@ import { z } from "zod"; /** * JSON serializable metadata type */ -export type ClusterMetadata = Partial>; +export type ClusterMetadata = { [key in string]?: Metadata }; /** * Metadata for cluster's prometheus settings @@ -32,7 +32,7 @@ export type UpdateClusterModel = Omit; export type Literal = z.infer; export const literalSchema = z.string().or(z.number()).or(z.boolean()); -export type Metadata = Literal | { [key: string]: Metadata } | Metadata[]; +export type Metadata = Literal | { [key in string]?: Metadata } | Metadata[]; export const metadataSchema: z.ZodType = z.lazy(() => z.union([literalSchema, z.array(metadataSchema), z.record(metadataSchema)])); export const prometheusPreferencesSchema = z.object({