{
    "type": "object",
    "properties": {
        "user": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Unique identifier for the user"
                },
                "name": {
                    "type": "string",
                    "description": "Updated user's full name"
                },
                "firstName": {
                    "type": "string",
                    "description": "Updated user's first name"
                },
                "lastName": {
                    "type": "string",
                    "description": "Updated user's last name"
                },
                "email": {
                    "type": "string",
                    "description": "Updated user's email address"
                },
                "phone": {
                    "type": "string",
                    "description": "Updated user's phone number"
                },
                "username": {
                    "type": "string",
                    "description": "Updated user's username"
                },
                "companyId": {
                    "type": "string",
                    "description": "Company ID the user belongs to"
                },
                "locationIds": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "Updated array of location IDs the user has access to"
                },
                "roles": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "role": {
                                "type": "string",
                                "enum": ["admin", "user", "readonly", "manager", "agent", "owner"],
                                "description": "User role"
                            },
                            "locationId": {
                                "type": "string",
                                "description": "Location ID for this role"
                            },
                            "type": {
                                "type": "string",
                                "enum": ["account", "location", "company"],
                                "description": "Role scope type"
                            }
                        }
                    },
                    "description": "Updated user roles and permissions"
                },
                "permissions": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "Updated specific permissions granted to the user"
                },
                "profile": {
                    "type": "object",
                    "properties": {
                        "avatar": {
                            "type": "string",
                            "description": "Updated URL to user's avatar image"
                        },
                        "bio": {
                            "type": "string",
                            "description": "Updated user's biography"
                        },
                        "timezone": {
                            "type": "string",
                            "description": "Updated user's timezone"
                        },
                        "language": {
                            "type": "string",
                            "description": "Updated user's preferred language"
                        },
                        "title": {
                            "type": "string",
                            "description": "Updated user's job title"
                        },
                        "department": {
                            "type": "string",
                            "description": "Updated user's department"
                        },
                        "address": {
                            "type": "object",
                            "properties": {
                                "street": {
                                    "type": "string",
                                    "description": "Updated street address"
                                },
                                "city": {
                                    "type": "string",
                                    "description": "Updated city"
                                },
                                "state": {
                                    "type": "string",
                                    "description": "Updated state/Province"
                                },
                                "postalCode": {
                                    "type": "string",
                                    "description": "Updated postal/ZIP code"
                                },
                                "country": {
                                    "type": "string",
                                    "description": "Updated country"
                                }
                            },
                            "description": "Updated user's address"
                        }
                    },
                    "description": "Updated user profile information"
                },
                "preferences": {
                    "type": "object",
                    "properties": {
                        "notifications": {
                            "type": "object",
                            "properties": {
                                "email": {
                                    "type": "boolean",
                                    "description": "Updated email notifications enabled"
                                },
                                "sms": {
                                    "type": "boolean",
                                    "description": "Updated SMS notifications enabled"
                                },
                                "desktop": {
                                    "type": "boolean",
                                    "description": "Updated desktop notifications enabled"
                                },
                                "mobile": {
                                    "type": "boolean",
                                    "description": "Updated mobile push notifications enabled"
                                }
                            },
                            "description": "Updated notification preferences"
                        },
                        "theme": {
                            "type": "string",
                            "enum": ["light", "dark", "auto"],
                            "description": "Updated UI theme preference"
                        },
                        "dateFormat": {
                            "type": "string",
                            "description": "Updated preferred date format"
                        },
                        "timeFormat": {
                            "type": "string",
                            "enum": ["12h", "24h"],
                            "description": "Updated preferred time format"
                        }
                    },
                    "description": "Updated user preferences"
                },
                "status": {
                    "type": "string",
                    "enum": ["active", "inactive", "pending", "suspended", "invited"],
                    "description": "Updated user account status"
                },
                "isEmailVerified": {
                    "type": "boolean",
                    "description": "Whether the user's email is verified"
                },
                "isPhoneVerified": {
                    "type": "boolean",
                    "description": "Whether the user's phone is verified"
                },
                "isTwoFactorEnabled": {
                    "type": "boolean",
                    "description": "Whether two-factor authentication is enabled"
                },
                "lastLoginAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Last login timestamp"
                },
                "lastActiveAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Last activity timestamp"
                },
                "updatedBy": {
                    "type": "string",
                    "description": "User ID who updated this user"
                },
                "updatedAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the user was updated"
                },
                "version": {
                    "type": "integer",
                    "description": "User record version number"
                },
                "previousValues": {
                    "type": "object",
                    "description": "Previous values before update (for audit trail)"
                }
            },
            "description": "Updated user details"
        },
        "changes": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "field": {
                        "type": "string",
                        "description": "Field that was changed"
                    },
                    "oldValue": {
                        "type": "string",
                        "description": "Previous value"
                    },
                    "newValue": {
                        "type": "string",
                        "description": "New value"
                    },
                    "changedAt": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the change was made"
                    }
                }
            },
            "description": "Summary of changes made"
        },
        "notifications": {
            "type": "object",
            "properties": {
                "emailSent": {
                    "type": "boolean",
                    "description": "Whether notification email was sent to user"
                },
                "adminNotified": {
                    "type": "boolean",
                    "description": "Whether admin users were notified"
                }
            },
            "description": "Notification status"
        },
        "success": {
            "type": "boolean",
            "description": "Whether the user was updated successfully"
        },
        "message": {
            "type": "string",
            "description": "Success or error message"
        }
    },
    "version": 1
}
