import { NativeModules } from "react-native"; import NativeContacts from "./src/NativeContacts"; import { Contact, Group, PermissionType } from "./type"; const Contacts = NativeModules.Contacts ?? NativeContacts; async function getAll(): Promise { return Contacts.getAll(); } async function getAllWithoutPhotos(): Promise { return Contacts.getAllWithoutPhotos(); } async function getContactById(contactId: string): Promise { return Contacts.getContactById(contactId); } async function getCount(): Promise { return Contacts.getCount(); } async function getPhotoForId(contactId: string): Promise { return Contacts.getPhotoForId(contactId); } async function addContact(contact: Partial): Promise { return Contacts.addContact(contact); } async function openContactForm(contact: Partial): Promise { return Contacts.openContactForm(contact); } async function openExistingContact(contact: Contact): Promise { return Contacts.openExistingContact(contact); } async function viewExistingContact(contact: { recordID: string; }): Promise { return Contacts.viewExistingContact(contact); } async function editExistingContact(contact: Contact): Promise { return Contacts.editExistingContact(contact); } async function updateContact( contact: Partial & { recordID: string } ): Promise { return Contacts.updateContact(contact); } async function deleteContact(contact: Contact): Promise { return Contacts.deleteContact(contact); } async function getContactsMatchingString(str: string): Promise { return Contacts.getContactsMatchingString(str); } async function getContactsByPhoneNumber( phoneNumber: string ): Promise { return Contacts.getContactsByPhoneNumber(phoneNumber); } async function getContactsByEmailAddress( emailAddress: string ): Promise { return Contacts.getContactsByEmailAddress(emailAddress); } async function checkPermission(): Promise { return Contacts.checkPermission(); } async function requestPermission(): Promise { return Contacts.requestPermission(); } async function writePhotoToPath( contactId: string, file: string ): Promise { return Contacts.writePhotoToPath(contactId, file); } async function getGroups(): Promise { return Contacts.getGroups(); } async function getGroup(identifier: string): Promise { return Contacts.getGroup(identifier); } async function deleteGroup(identifier: string): Promise { return Contacts.deleteGroup(identifier); } async function updateGroup(identifier: string, groupData: Pick): Promise { return Contacts.updateGroup(identifier, groupData); } async function addGroup(group: Pick): Promise{ return Contacts.addGroup(group); } async function contactsInGroup(identifier: string): Promise { return Contacts.contactsInGroup(identifier); } async function addContactsToGroup(groupIdentifier: string, contactIdentifiers: string[]): Promise { return Contacts.addContactsToGroup(groupIdentifier, contactIdentifiers); } async function removeContactsFromGroup(groupIdentifier: string, contactIdentifiers: string[]): Promise { return Contacts.removeContactsFromGroup(groupIdentifier, contactIdentifiers); } export default { getAll, getAllWithoutPhotos, getContactById, getCount, getPhotoForId, addContact, openContactForm, openExistingContact, viewExistingContact, editExistingContact, updateContact, deleteContact, getContactsMatchingString, getContactsByPhoneNumber, getContactsByEmailAddress, checkPermission, requestPermission, writePhotoToPath, getGroups, getGroup, deleteGroup, updateGroup, addGroup, contactsInGroup, addContactsToGroup, removeContactsFromGroup };