🌳
pt0/deployF/k8sF/kubeCoalesceF.mts
3import { type KubeResource } from "./ctxF/klusterCtxF.mts"
7type KubeCoalesceStore = { resourcesA: KubeResource[] }
9export const kubeCoalesceCtx = genContext<KubeCoalesceStore>()
11export const getReqKubeCoalesceCtx = (): KubeCoalesceStore => {
12 const store = kubeCoalesceCtx.getStore()
14 return store
17export const wrapKubeCoalesce = async <T,>(fnc: (props: any) => Promise<T>, props?: Record<string, unknown>): Promise<T> => {
18 if (!kubeCoalesceCtx.getStore()) {
19 const resourcesA: KubeResource[] = []
20 kubeCoalesceCtx.enterWith({resourcesA}) // ctx:clear
21 }
22 const ret = await fnc(props)
23 const action = getAction()
24 const actionFnc = (coalActions as unknown as Record<string, (() => void | Promise<void>) | undefined>)[action as string]
25 if (actionFnc) {
26 await actionFnc()
27 }
28 return ret