1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: Fix type error in EntityMetadata

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-05-03 11:20:29 -04:00
parent d1a659bf74
commit 0aaf0363c5
2 changed files with 6 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import { once } from "lodash";
import type { Disposer, StrictReactNode } from "@k8slens/utilities"; import type { Disposer, StrictReactNode } from "@k8slens/utilities";
import { iter } from "@k8slens/utilities"; import { iter } from "@k8slens/utilities";
import type { CategoryColumnRegistration, TitleCellProps } from "../../renderer/components/catalog/custom-category-columns"; import type { CategoryColumnRegistration, TitleCellProps } from "../../renderer/components/catalog/custom-category-columns";
import type { Literal, Metadata } from "../cluster-types";
export type { CategoryColumnRegistration, TitleCellProps }; 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 EntityMetadataObject = { [key in string]?: Metadata };
export type EntityMetadataValue = string | number | boolean | EntityMetadataObject | undefined; export type EntityMetadataValue = Literal;
export interface CatalogEntityMetadata extends EntityMetadataObject { export interface CatalogEntityMetadata extends EntityMetadataObject {
uid: string; uid: string;
@ -241,7 +242,7 @@ export interface CatalogEntityMetadata extends EntityMetadataObject {
shortName?: string; shortName?: string;
description?: string; description?: string;
source?: string; source?: string;
labels: Partial<Record<string, string>>; labels: { [key in string]?: string };
} }
export interface CatalogEntityStatus { export interface CatalogEntityStatus {

View File

@ -8,7 +8,7 @@ import { z } from "zod";
/** /**
* JSON serializable metadata type * JSON serializable metadata type
*/ */
export type ClusterMetadata = Partial<Record<string, Metadata>>; export type ClusterMetadata = { [key in string]?: Metadata };
/** /**
* Metadata for cluster's prometheus settings * Metadata for cluster's prometheus settings
@ -32,7 +32,7 @@ export type UpdateClusterModel = Omit<ClusterModel, "id">;
export type Literal = z.infer<typeof literalSchema>; export type Literal = z.infer<typeof literalSchema>;
export const literalSchema = z.string().or(z.number()).or(z.boolean()); 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<Metadata> = z.lazy(() => z.union([literalSchema, z.array(metadataSchema), z.record(metadataSchema)])); export const metadataSchema: z.ZodType<Metadata> = z.lazy(() => z.union([literalSchema, z.array(metadataSchema), z.record(metadataSchema)]));
export const prometheusPreferencesSchema = z.object({ export const prometheusPreferencesSchema = z.object({