Review this generated update, projection, and handler code before it serves account requests.
Allow only displayName and nested timezone updates, preserve the existing theme, remove passwordHash from runtime responses, and report unknown handler names.
TypeScript
interface Account {
id: string;
displayName: string;
role: "user" | "admin";
passwordHash: string;
preferences: { theme: "light" | "dark"; timezone: string };
}
type AccountPatch = Partial<Account>;
function applyPatch(current: Account, patch: AccountPatch): Account {
return { ...current, ...patch };
}
function publicAccount(account: Account): Omit<Account, "passwordHash"> {
return account;
}
type Handler = (account: Account) => string;
const handlers: Record<string, Handler> = {
summary: (account) => account.displayName,
};
function runHandler(name: string, account: Account): string {
return handlers[name](account);
}
generated code is illustrative, not from any one model