import { PartialDeep } from "type-fest" ; import deepmerge from "deepmerge" ; import { DefinitionsAliasMap } from "../__generated__/definitions" ; import { ApiCallOptions } from "../internal/api" ; export type Definition < T extends keyof DefinitionsAliasMap > = DefinitionsAliasMap [ T ] ; export function isResourceOfType < T extends keyof DefinitionsAliasMap > ( input , type ) { const [ api , version , kind ] = type . split ( "." ) ; const apiVersion = api == "core" ? version : `${ api }/${ version }` ; return input . apiVersion === apiVersion && input . kind === kind ; } export function patchResource < T > ( input , patch ) { return deepmerge < PartialDeep < T > > ( input , patch , { arrayMerge : ( target , source ) => source , } ) as T ; } export function strategicPatchResource < T > ( input , patch ) { return deepmerge < PartialDeep < T > > ( input , patch ) as T ; } export type ResourceMetaAnnotations = { [ key ] : any ; } ; export type ResourceMetadata < TAnnotations = ResourceMetaAnnotations > = { namespace ? : string ; name : string ; annotations ? : TAnnotations ; } ; export type Resource < Version extends string , Kind extends string , Spec , Metadata = ResourceMetadata > = { apiVersion : Version ; kind : Kind ; metadata : Metadata ; spec : Spec ; } ; export type ResourceCallOptions = ApiCallOptions ;