c8bfbf00d7
## Introduction ### Twenty-sever Standardizing resolver input and transpilation models + return type on destroy and delete ~~Finally~~ Did plug everything under a feature flag and add coverage Next will do same for the view resolver and service v2 ### Twenty-front Refactored view field service in order to use codegenerated strictly typed mutations and adapt to new api contract
22 lines
461 B
TypeScript
22 lines
461 B
TypeScript
export const mergeUpdateInExistingRecord = <
|
|
TExisting,
|
|
P extends keyof TExisting,
|
|
TUpdate extends Partial<TExisting>,
|
|
>({
|
|
existing,
|
|
properties,
|
|
update,
|
|
}: {
|
|
existing: TExisting;
|
|
update: TUpdate;
|
|
properties: P[];
|
|
}) =>
|
|
properties.reduce((acc, property) => {
|
|
const isPropertyUpdated = update[property] !== undefined;
|
|
|
|
return {
|
|
...acc,
|
|
...(isPropertyUpdated ? { [property]: update[property] } : {}),
|
|
};
|
|
}, existing);
|