Skip to content

SettingsMigrationComponentConstructorParams<TMigratableSettings>

Parameters for the SettingsMigrationComponent constructor.

Import:

import type { SettingsMigrationComponentConstructorParams } from 'obsidian-dev-utils/obsidian/components/settings-migration-component';

Signature:

export interface SettingsMigrationComponentConstructorParams<TMigratableSettings extends object>

Properties

PropertyTypeDescription
apiVersionRangestringThe semver range of contract versions this plugin compiled against, e.g. '^1'.
appAppThe Obsidian app instance.
contract?PluginApiContractThe contract this plugin expects of the provider, which wins over the provider's own when supplied.

Worth supplying, and worth keeping NARROW. A migration usually needs one method that has existed since the provider's first contract version, while the same plugin may read other parts of that API through a much newer one. Declaring the wider expectation here would refuse to offer the migration to a user on an older provider — which is precisely the user who still has settings to migrate.
pluginSettingsComponentPluginSettingsComponentBase<object>The settings component of the plugin making the proposal.

Taken as a whole component rather than as a bare "ready" flag so the host cannot forget to wire the wait: whatever getProposedSettings reads is meaningless until this component has read data.json.
providerPluginIdstringThe manifest.id of the plugin that owns these settings now, as listed in Obsidian's community plugin registry.
sourcePluginIdstringThe manifest.id of the plugin making the proposal, so the provider's dialog can say whose settings these are.

Methods

MethodReturnsDescription
getProposedSettings(this)null | TMigratableSettingsReads the values currently waiting to be handed over.

Called afresh on every edge rather than once, so an implementation simply reads its plugin's settings. Return null when there is nothing pending — after a migration has been applied, or on a vault that never had these settings configured.
retireProposedSettings(this)Promisable<void>Records that the pending values have been handed over, so the offer is not made again.

Called ONLY when the user actually applied the migration.