ProjectionLab Plugin API
    Preparing search index...

    Type Alias PluginAPI

    The public plugin API surface exposed on window.projectionlabPluginAPI.

    All methods throw an Error if the API key is invalid or missing.

    type PluginAPI = {
        updateAccount: (
            accountId: string,
            data: Record<string, unknown>,
            options?: UpdateAccountOptions,
        ) => Promise<void>;
        exportData: (params?: PluginKeyParam) => Promise<CompleteAccountDataExport>;
        restoreCurrentFinances: (
            newToday: StartingConditions,
            options?: PluginKeyParam,
        ) => Promise<void>;
        restorePlans: (newPlans: Plan[], options?: PluginKeyParam) => Promise<void>;
        restoreProgress: (
            newProgress: ProgressState,
            options?: PluginKeyParam,
        ) => Promise<void>;
        restoreSettings: (
            newSettings: SettingsState,
            options?: PluginKeyParam,
        ) => Promise<void>;
        validateApiKey: (params?: PluginKeyParam) => void;
    }
    Index

    Properties

    updateAccount: (
        accountId: string,
        data: Record<string, unknown>,
        options?: UpdateAccountOptions,
    ) => Promise<void>

    Updates an account in Current Finances with new data.

    Type Declaration

      • (
            accountId: string,
            data: Record<string, unknown>,
            options?: UpdateAccountOptions,
        ): Promise<void>
      • Parameters

        • accountId: string

          The ID of the account to update (from Current Finances).

        • data: Record<string, unknown>

          Key-value pairs to merge into the account.

        • Optionaloptions: UpdateAccountOptions

          Authentication and behavior options.

        Returns Promise<void>

    If the API key is invalid, the accountId doesn't match any account, or (when force is false) a property in data doesn't exist on the account.

    await window.projectionlabPluginAPI.updateAccount(
    '12345',
    { balance: 1000 },
    { key: 'your-api-key' },
    )
    exportData: (params?: PluginKeyParam) => Promise<CompleteAccountDataExport>

    Exports all account data based on the current state.

    Type Declaration

      • (params?: PluginKeyParam): Promise<CompleteAccountDataExport>
      • Parameters

        • Optionalparams: PluginKeyParam

        Returns Promise<CompleteAccountDataExport>

        The complete account data export.

    const data = await window.projectionlabPluginAPI.exportData({
    key: 'your-api-key',
    })
    restoreCurrentFinances: (
        newToday: StartingConditions,
        options?: PluginKeyParam,
    ) => Promise<void>

    Replaces the Current Finances state with new data.

    Type Declaration

      • (newToday: StartingConditions, options?: PluginKeyParam): Promise<void>
      • Parameters

        • newToday: StartingConditions

          The new Current Finances state.

        • Optionaloptions: PluginKeyParam

          Authentication options.

        Returns Promise<void>

    This overwrites important data structures. It is your responsibility to ensure the data you pass is well-formed.

    await window.projectionlabPluginAPI.restoreCurrentFinances(
    exportedData.today,
    { key: 'your-api-key' },
    )
    restorePlans: (newPlans: Plan[], options?: PluginKeyParam) => Promise<void>

    Replaces all Plans with a new set of plans.

    Type Declaration

      • (newPlans: Plan[], options?: PluginKeyParam): Promise<void>
      • Parameters

        • newPlans: Plan[]

          The new plans array.

        • Optionaloptions: PluginKeyParam

          Authentication options.

        Returns Promise<void>

    This overwrites important data structures. It is your responsibility to ensure the data you pass is well-formed.

    await window.projectionlabPluginAPI.restorePlans(
    exportedData.plans,
    { key: 'your-api-key' },
    )
    restoreProgress: (
        newProgress: ProgressState,
        options?: PluginKeyParam,
    ) => Promise<void>

    Replaces the Progress state with new data.

    Type Declaration

      • (newProgress: ProgressState, options?: PluginKeyParam): Promise<void>
      • Parameters

        • newProgress: ProgressState

          The new progress data.

        • Optionaloptions: PluginKeyParam

          Authentication options.

        Returns Promise<void>

    This overwrites important data structures. It is your responsibility to ensure the data you pass is well-formed.

    await window.projectionlabPluginAPI.restoreProgress(
    exportedData.progress,
    { key: 'your-api-key' },
    )
    restoreSettings: (
        newSettings: SettingsState,
        options?: PluginKeyParam,
    ) => Promise<void>

    Replaces the Settings state with new data.

    Type Declaration

      • (newSettings: SettingsState, options?: PluginKeyParam): Promise<void>
      • Parameters

        • newSettings: SettingsState

          The new settings data.

        • Optionaloptions: PluginKeyParam

          Authentication options.

        Returns Promise<void>

    This overwrites important data structures. It is your responsibility to ensure the data you pass is well-formed.

    await window.projectionlabPluginAPI.restoreSettings(
    exportedData.settings,
    { key: 'your-api-key' },
    )
    validateApiKey: (params?: PluginKeyParam) => void

    Validates an API key without performing any data operations. Throws if the key is invalid or missing.

    try {
    window.projectionlabPluginAPI.validateApiKey({ key: 'your-api-key' })
    } catch (error) {
    console.error('Invalid API key')
    }