(data: LoadedSettingsData | null)
| 103 | } |
| 104 | |
| 105 | function migrateLoadedSettingsData(data: LoadedSettingsData | null): LoadedSettingsData | null { |
| 106 | if (!data) { |
| 107 | return null; |
| 108 | } |
| 109 | |
| 110 | const migratedData: LoadedSettingsData = { ...data }; |
| 111 | |
| 112 | // Migration: Remove old useNativeMetadataCache setting if it exists. |
| 113 | delete migratedData.useNativeMetadataCache; |
| 114 | |
| 115 | // Migration: Add API settings defaults if they don't exist. |
| 116 | if (typeof migratedData.enableAPI === "undefined") { |
| 117 | migratedData.enableAPI = false; |
| 118 | } |
| 119 | if (typeof migratedData.apiPort === "undefined") { |
| 120 | migratedData.apiPort = 8080; |
| 121 | } |
| 122 | if (typeof migratedData.apiAuthToken === "undefined") { |
| 123 | migratedData.apiAuthToken = ""; |
| 124 | } |
| 125 | if (typeof migratedData.enableMCP === "undefined") { |
| 126 | migratedData.enableMCP = false; |
| 127 | } |
| 128 | |
| 129 | // Migration: Migrate statusSuggestionTrigger to nlpTriggers if needed. |
| 130 | if (!migratedData.nlpTriggers && migratedData.statusSuggestionTrigger !== undefined) { |
| 131 | migratedData.nlpTriggers = { |
| 132 | triggers: [...DEFAULT_NLP_TRIGGERS.triggers], |
| 133 | }; |
| 134 | |
| 135 | const statusTriggerIndex = migratedData.nlpTriggers.triggers.findIndex( |
| 136 | (trigger) => trigger.propertyId === "status" |
| 137 | ); |
| 138 | if (statusTriggerIndex !== -1 && migratedData.statusSuggestionTrigger) { |
| 139 | migratedData.nlpTriggers.triggers[statusTriggerIndex].trigger = |
| 140 | migratedData.statusSuggestionTrigger; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // Migration: Initialize modal fields configuration if not present. |
| 145 | if (!migratedData.modalFieldsConfig) { |
| 146 | migratedData.modalFieldsConfig = initializeFieldConfig(undefined, migratedData.userFields); |
| 147 | } |
| 148 | |
| 149 | // Migration: Force enableBases to true (issue #1187). |
| 150 | if (migratedData.enableBases === false) { |
| 151 | migratedData.enableBases = true; |
| 152 | } |
| 153 | |
| 154 | // Migration: Update the unused legacy default custom filename template to the |
| 155 | // preferred double-brace syntax while preserving active custom templates. |
| 156 | if ( |
| 157 | migratedData.taskFilenameFormat !== "custom" && |
| 158 | migratedData.customFilenameTemplate === "{title}" |
| 159 | ) { |
| 160 | migratedData.customFilenameTemplate = "{{title}}"; |
| 161 | } |
| 162 |
no test coverage detected