import type { ActionConfig } from '../ActionConfig'; import type { ActionBox } from '../ActionBox'; export function initSpecialPropertiesConfig(actionBox: ActionBox) { const { name, config, server: { specialFactories }, originalInstance, } = actionBox; if (!config.specialProperties) { const spcfg: ActionConfig['specialProperties'] = {}; config.specialProperties = spcfg; Object.entries(originalInstance) .forEach(([prop, value]) => { if (typeof value === 'object' && specialFactories.has(value.constructor)) { if (!value.meta || !value.meta.typeName) { throw new Error(`The ${prop} special property of the ${name} action must implement the SpecialProperty interface.`); } // eslint-disable-next-line no-param-reassign value.propertyName = prop; // todo это странно, нужно будет переделать if (!config.permanent) { throw new Error(`The "${name}" action must be permanent to use special properties.`); } spcfg[prop] = value.meta; } }); } }