//----------------------------------------------------------------------- // // Copyright (c) aliasvault. All rights reserved. // Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information. // //----------------------------------------------------------------------- namespace AliasClientDb; using System.ComponentModel.DataAnnotations; using AliasClientDb.Abstracts; /// /// FieldDefinition entity that defines the schema for fields. /// public class FieldDefinition : SyncableEntity { /// /// Gets or sets the field definition ID. /// [Key] public Guid Id { get; set; } /// /// Gets or sets the field key for system fields (e.g., 'login.username', 'card.number'). /// NULL for custom (user-defined) fields. /// System fields use predefined keys like: /// - login.username, login.password, login.notes, login.url /// - card.number, card.cardholder_name, card.cvv /// - identity.first_name, identity.email, identity.phone_numbers /// - alias.email, alias.first_name (legacy) /// Custom fields have FieldKey = NULL and are identified by their GUID and Label. /// [StringLength(100)] public string? FieldKey { get; set; } /// /// Gets or sets the field type (Text, Password, Email, URL, Date, etc.). /// [Required] [StringLength(50)] public string FieldType { get; set; } = "Text"; /// /// Gets or sets the display label for the field. /// [Required] [StringLength(255)] public string Label { get; set; } = string.Empty; /// /// Gets or sets a value indicating whether this field supports multiple values. /// public bool IsMultiValue { get; set; } = false; /// /// Gets or sets a value indicating whether the field value is hidden (masked) by default in the UI. /// public bool IsHidden { get; set; } = false; /// /// Gets or sets a value indicating whether history tracking is enabled for this field. /// public bool EnableHistory { get; set; } = false; /// /// Gets or sets the weight for sorting fields in the UI. This primarily applies to custom fields. /// public int Weight { get; set; } = 0; /// /// Gets or sets the applicable item types as JSON array (e.g., '["Login","Identity"]'). /// Null means applicable to all types. /// public string? ApplicableToTypes { get; set; } /// /// Gets or sets the field values using this definition. /// public virtual ICollection FieldValues { get; set; } = []; /// /// Gets or sets the field history entries using this definition. /// public virtual ICollection FieldHistories { get; set; } = []; }