import type { ActionConfig } from '../../ActionConfig'; import { actionConfigStore } from './store'; export function action(cfg?: Partial) { return (constructor: Function) => { const ac = actionConfigStore.get(constructor); const parentType = Object.getPrototypeOf(constructor); try { const parentAc = actionConfigStore.get(parentType, false); const pac = { ...parentAc } as Partial; const { properties, methods, hooks } = pac; delete pac.properties; delete pac.methods; delete pac.hooks; properties?.forEach((propConf, key) => { ac.properties.set(key, propConf); }); ac.methods = { ...methods, ...ac.methods }; ac.hooks = { ...hooks, ...ac.hooks }; Object.assign(ac, pac, cfg); } catch (e) { Object.assign(ac, cfg); } }; }