// // This file is auto-generated from core/models/src/vault/SystemFieldRegistry.ts // Do not edit this file directly. Run 'npm run generate:models' to regenerate. #nullable enable namespace AliasClientDb.Models; /// /// Field categories for grouping in UI. /// public enum FieldCategory { /// Primary fields. Primary, /// Login fields. Login, /// Alias fields. Alias, /// Card fields. Card, /// Custom fields. Custom, /// Notes fields. Notes, /// Metadata fields. Metadata } /// /// Per-item-type configuration for a system field. /// /// Whether this field is shown by default in create mode (vs. hidden behind an "add" button) public record ItemTypeFieldConfig(bool ShowByDefault); /// /// System field definition with metadata. /// /// Unique system field key (e.g., 'login.username') /// Field type for rendering/validation /// Whether field is hidden/masked by default /// Whether field supports multiple values /// ApplicableToTypes /// Whether to track field value history /// Category for grouping in UI. 'Primary' fields are shown in the name block. /// Default display order within category (lower = first) public record SystemFieldDefinition( string FieldKey, string FieldType, bool IsHidden, bool IsMultiValue, IReadOnlyDictionary ApplicableToTypes, bool EnableHistory, FieldCategory Category, int DefaultDisplayOrder); /// /// Registry of all system-defined fields. /// These fields are immutable and their metadata is defined in code. /// public static class SystemFieldRegistry { /// /// All system field definitions indexed by field key. /// public static readonly IReadOnlyDictionary Fields = new Dictionary { [FieldKey.LoginEmail] = new SystemFieldDefinition( FieldKey: "login.email", FieldType: "Email", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Login"] = new ItemTypeFieldConfig(false), ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: true, Category: FieldCategory.Login, DefaultDisplayOrder: 10), [FieldKey.LoginUsername] = new SystemFieldDefinition( FieldKey: "login.username", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Login"] = new ItemTypeFieldConfig(true), ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: true, Category: FieldCategory.Login, DefaultDisplayOrder: 15), [FieldKey.LoginPassword] = new SystemFieldDefinition( FieldKey: "login.password", FieldType: "Password", IsHidden: true, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Login"] = new ItemTypeFieldConfig(true), ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: true, Category: FieldCategory.Login, DefaultDisplayOrder: 20), [FieldKey.LoginUrl] = new SystemFieldDefinition( FieldKey: "login.url", FieldType: "URL", IsHidden: false, IsMultiValue: true, ApplicableToTypes: new Dictionary { ["Login"] = new ItemTypeFieldConfig(true), ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Primary, DefaultDisplayOrder: 5), [FieldKey.AliasFirstName] = new SystemFieldDefinition( FieldKey: "alias.first_name", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Alias, DefaultDisplayOrder: 20), [FieldKey.AliasLastName] = new SystemFieldDefinition( FieldKey: "alias.last_name", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Alias, DefaultDisplayOrder: 30), [FieldKey.AliasGender] = new SystemFieldDefinition( FieldKey: "alias.gender", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Alias, DefaultDisplayOrder: 50), [FieldKey.AliasBirthdate] = new SystemFieldDefinition( FieldKey: "alias.birthdate", FieldType: "Date", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Alias"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Alias, DefaultDisplayOrder: 60), [FieldKey.CardCardholderName] = new SystemFieldDefinition( FieldKey: "card.cardholder_name", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 10), [FieldKey.CardNumber] = new SystemFieldDefinition( FieldKey: "card.number", FieldType: "Hidden", IsHidden: true, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 20), [FieldKey.CardExpiryMonth] = new SystemFieldDefinition( FieldKey: "card.expiry_month", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 30), [FieldKey.CardExpiryYear] = new SystemFieldDefinition( FieldKey: "card.expiry_year", FieldType: "Text", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 40), [FieldKey.CardCvv] = new SystemFieldDefinition( FieldKey: "card.cvv", FieldType: "Hidden", IsHidden: true, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 50), [FieldKey.CardPin] = new SystemFieldDefinition( FieldKey: "card.pin", FieldType: "Hidden", IsHidden: true, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["CreditCard"] = new ItemTypeFieldConfig(false) }, EnableHistory: false, Category: FieldCategory.Card, DefaultDisplayOrder: 60), [FieldKey.NotesContent] = new SystemFieldDefinition( FieldKey: "notes.content", FieldType: "TextArea", IsHidden: false, IsMultiValue: false, ApplicableToTypes: new Dictionary { ["Login"] = new ItemTypeFieldConfig(false), ["Alias"] = new ItemTypeFieldConfig(false), ["CreditCard"] = new ItemTypeFieldConfig(false), ["Note"] = new ItemTypeFieldConfig(true) }, EnableHistory: false, Category: FieldCategory.Notes, DefaultDisplayOrder: 100) }; /// /// Get system field definition by key. /// /// The field key to look up. /// The field definition, or null if not found. public static SystemFieldDefinition? GetSystemField(string fieldKey) { return Fields.TryGetValue(fieldKey, out var field) ? field : null; } /// /// Check if a field key represents a system field. /// /// The field key to check. /// True if the field key is a system field. public static bool IsSystemField(string fieldKey) { return Fields.ContainsKey(fieldKey); } /// /// Check if a field applies to a specific item type. /// /// The field definition. /// The item type to check. /// True if the field applies to the item type. public static bool FieldAppliesToType(SystemFieldDefinition field, string itemType) { return field.ApplicableToTypes.ContainsKey(itemType); } /// /// Get all system fields applicable to a specific item type. /// Results are sorted by DefaultDisplayOrder. /// /// The item type. /// Fields applicable to the item type. public static IEnumerable GetFieldsForItemType(string itemType) { return Fields.Values .Where(f => f.ApplicableToTypes.ContainsKey(itemType)) .OrderBy(f => f.DefaultDisplayOrder); } /// /// Get system fields that should be shown by default for a specific item type. /// Results are sorted by DefaultDisplayOrder. /// /// The item type. /// Fields shown by default for the item type. public static IEnumerable GetDefaultFieldsForItemType(string itemType) { return Fields.Values .Where(f => f.ApplicableToTypes.TryGetValue(itemType, out var config) && config.ShowByDefault) .OrderBy(f => f.DefaultDisplayOrder); } /// /// Get system fields that are NOT shown by default for a specific item type. /// These are the fields that can be added via an "add field" button. /// Results are sorted by DefaultDisplayOrder. /// /// The item type. /// Optional fields for the item type. public static IEnumerable GetOptionalFieldsForItemType(string itemType) { return Fields.Values .Where(f => f.ApplicableToTypes.TryGetValue(itemType, out var config) && !config.ShowByDefault) .OrderBy(f => f.DefaultDisplayOrder); } /// /// Check if a field key matches a known system field prefix. /// /// The field key to check. /// True if the field key has a system field prefix. public static bool IsSystemFieldPrefix(string fieldKey) { return fieldKey.StartsWith("login.") || fieldKey.StartsWith("alias.") || fieldKey.StartsWith("card.") || fieldKey.StartsWith("notes."); } }