feat: add contact methods in plugin API

This commit is contained in:
Paulhenry Saux
2026-07-22 19:34:45 +02:00
parent 959d4bd6ce
commit 7bf62e4bdc
3 changed files with 53 additions and 0 deletions
+7
View File
@@ -29,6 +29,7 @@ import type {
} from './protocol';
import { themeSnapshotToCSS, type ThemeSnapshot } from './host-theme';
import type { SlotName } from '../plugin-types';
import { ContactCard } from '../jmap/types';
// ─── Module-scope state ──────────────────────────────────────
@@ -204,6 +205,12 @@ function buildPluginApi(manifest: PluginManifest) {
opts?: { keywords?: Record<string, boolean>; accountId?: string },
) => callApi('jmap.importRaw', [rawBytes, mailboxRoles, opts]),
},
contacts: {
get: (contactId: string) => callApi('contact.get', [contactId]) as Promise<ContactCard>,
update: (contactId: string, updates: Partial<ContactCard>) => callApi('contact.update', [contactId, updates]),
create: (contact: ContactCard) => callApi('contact.create', [contact]) as Promise<string>,
search: (query: string) => callApi('contact.search', [query]) as Promise<ContactCard[]>,
},
/**
* Used to alterate files before they are uploaded to server.
* Edited files are saved on indexedDB and remove once the upload to server begins.