/**
 * Tauri adapter for public plugin structured configuration documents (#130).
 */

import { invoke } from "@tauri-apps/api/core";

import type { PluginConfigDocument, PluginConfigDocumentWriteResult } from "@/domain";
import type {
  PluginConfigDocumentReadInput,
  PluginConfigDocumentUpdateInput,
  PluginConfigGateway,
} from "@/ports";

export class TauriPluginConfigGateway implements PluginConfigGateway {
  readDocument(input: PluginConfigDocumentReadInput): Promise<PluginConfigDocument> {
    return invoke<PluginConfigDocument>("plugin_config_read_document", { input });
  }

  updateDocument(
    input: PluginConfigDocumentUpdateInput,
  ): Promise<PluginConfigDocumentWriteResult> {
    return invoke<PluginConfigDocumentWriteResult>("plugin_config_update_document", { input });
  }
}
