react-native-contacts 8.0.3 → 8.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -4,79 +4,117 @@ export function getContactById(contactId: string): Promise<Contact | null>;
4
4
  export function getCount(): Promise<number>;
5
5
  export function getPhotoForId(contactId: string): Promise<string>;
6
6
  export function addContact(contact: Partial<Contact>): Promise<Contact>;
7
- export function openContactForm(contact: Partial<Contact>): Promise<Contact | null>;
7
+ export function openContactForm(
8
+ contact: Partial<Contact>
9
+ ): Promise<Contact | null>;
8
10
  export function openExistingContact(contact: Contact): Promise<Contact>;
9
- export function viewExistingContact(contact: { recordID: string }): Promise<Contact | void>
11
+ export function viewExistingContact(contact: {
12
+ recordID: string;
13
+ }): Promise<Contact | void>;
10
14
  export function editExistingContact(contact: Contact): Promise<Contact>;
11
- export function updateContact(contact: Partial<Contact> & {recordID: string}): Promise<void>;
15
+ export function updateContact(
16
+ contact: Partial<Contact> & { recordID: string }
17
+ ): Promise<void>;
12
18
  export function deleteContact(contact: Contact): Promise<void>;
13
19
  export function getContactsMatchingString(str: string): Promise<Contact[]>;
14
- export function getContactsByPhoneNumber(phoneNumber: string): Promise<Contact[]>;
15
- export function getContactsByEmailAddress(emailAddress: string): Promise<Contact[]>;
16
- export function checkPermission(): Promise<'authorized' | 'denied' | 'undefined'>;
17
- export function requestPermission(): Promise<'authorized' | 'denied' | 'undefined'>;
18
- export function writePhotoToPath(contactId: string, file: string): Promise<boolean>;
20
+ export function getContactsByPhoneNumber(
21
+ phoneNumber: string
22
+ ): Promise<Contact[]>;
23
+ export function getContactsByEmailAddress(
24
+ emailAddress: string
25
+ ): Promise<Contact[]>;
26
+ export function checkPermission(): Promise<
27
+ "authorized" | "denied" | "undefined"
28
+ >;
29
+ export function requestPermission(): Promise<
30
+ "authorized" | "denied" | "undefined"
31
+ >;
32
+ export function writePhotoToPath(
33
+ contactId: string,
34
+ file: string
35
+ ): Promise<boolean>;
19
36
  export function iosEnableNotesUsage(enabled: boolean): void;
20
37
 
38
+ export function getGroups(): Promise<Group[]>;
39
+ export function getGroup(identifier: string): Promise<Group | null>;
40
+ export function deleteGroup(identifier: string): Promise<boolean>;
41
+ export function updateGroup(
42
+ identifier: string,
43
+ groupData: Pick<Group, "name">
44
+ ): Promise<Group>;
45
+ export function addGroup(group: Pick<Group, "name">): Promise<Group>;
46
+ export function contactsInGroup(identifier: string): Promise<Contact[]>;
47
+ export function addContactsToGroup(
48
+ groupIdentifier: string,
49
+ contactIdentifiers: string[]
50
+ ): Promise<boolean>;
51
+ export function removeContactsFromGroup(
52
+ groupIdentifier: string,
53
+ contactIdentifiers: string[]
54
+ ): Promise<boolean>;
55
+ export interface Group {
56
+ identifier: string;
57
+ name: string;
58
+ }
21
59
  export interface EmailAddress {
22
- label: string;
23
- email: string;
60
+ label: string;
61
+ email: string;
24
62
  }
25
63
 
26
64
  export interface PhoneNumber {
27
- label: string;
28
- number: string;
65
+ label: string;
66
+ number: string;
29
67
  }
30
68
 
31
69
  export interface PostalAddress {
32
- label: string;
33
- formattedAddress: string;
34
- street: string;
35
- pobox: string;
36
- neighborhood: string;
37
- city: string;
38
- region: string;
39
- state: string;
40
- postCode: string;
41
- country: string;
70
+ label: string;
71
+ formattedAddress: string;
72
+ street: string;
73
+ pobox: string;
74
+ neighborhood: string;
75
+ city: string;
76
+ region: string;
77
+ state: string;
78
+ postCode: string;
79
+ country: string;
42
80
  }
43
81
 
44
82
  export interface InstantMessageAddress {
45
- username: string;
46
- service: string;
83
+ username: string;
84
+ service: string;
47
85
  }
48
86
 
49
87
  export interface Birthday {
50
- day: number;
51
- month: number;
52
- year?: number;
88
+ day: number;
89
+ month: number;
90
+ year?: number;
53
91
  }
54
92
 
55
93
  export interface UrlAddress {
56
- url: string;
57
- label: string;
94
+ url: string;
95
+ label: string;
58
96
  }
59
97
 
60
98
  export interface Contact {
61
- recordID: string;
62
- backTitle: string;
63
- company: string|null;
64
- emailAddresses: EmailAddress[];
65
- displayName: string|null;
66
- familyName: string;
67
- givenName: string|null;
68
- middleName: string;
69
- jobTitle: string|null;
70
- phoneNumbers: PhoneNumber[];
71
- hasThumbnail: boolean;
72
- thumbnailPath: string;
73
- isStarred: boolean;
74
- postalAddresses: PostalAddress[];
75
- prefix: string|null;
76
- suffix: string|null;
77
- department: string|null;
78
- birthday?: Birthday;
79
- imAddresses: InstantMessageAddress[];
80
- urlAddresses: UrlAddress[];
81
- note: string|null;
99
+ recordID: string;
100
+ backTitle: string;
101
+ company: string | null;
102
+ emailAddresses: EmailAddress[];
103
+ displayName: string | null;
104
+ familyName: string;
105
+ givenName: string | null;
106
+ middleName: string;
107
+ jobTitle: string | null;
108
+ phoneNumbers: PhoneNumber[];
109
+ hasThumbnail: boolean;
110
+ thumbnailPath: string;
111
+ isStarred: boolean;
112
+ postalAddresses: PostalAddress[];
113
+ prefix: string | null;
114
+ suffix: string | null;
115
+ department: string | null;
116
+ birthday?: Birthday;
117
+ imAddresses: InstantMessageAddress[];
118
+ urlAddresses: UrlAddress[];
119
+ note: string | null;
82
120
  }
package/index.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { NativeModules } from "react-native";
2
2
  import NativeContacts from "./src/NativeContacts";
3
- import { Contact, PermissionType } from "./type";
3
+ import { Contact, Group, PermissionType } from "./type";
4
4
 
5
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
6
- const Contacts = isTurboModuleEnabled ? NativeContacts : NativeModules.Contacts;
5
+ const Contacts = NativeModules.Contacts ?? NativeContacts;
7
6
 
8
7
  async function getAll(): Promise<Contact[]> {
9
8
  return Contacts.getAll();
@@ -87,6 +86,31 @@ async function writePhotoToPath(
87
86
  ): Promise<boolean> {
88
87
  return Contacts.writePhotoToPath(contactId, file);
89
88
  }
89
+
90
+ async function getGroups(): Promise<Group[]> {
91
+ return Contacts.getGroups();
92
+ }
93
+ async function getGroup(identifier: string): Promise<Group | null> {
94
+ return Contacts.getGroup(identifier);
95
+ }
96
+ async function deleteGroup(identifier: string): Promise<boolean> {
97
+ return Contacts.deleteGroup(identifier);
98
+ }
99
+ async function updateGroup(identifier: string, groupData: Pick<Group, 'name'>): Promise<Group> {
100
+ return Contacts.updateGroup(identifier, groupData);
101
+ }
102
+ async function addGroup(group: Pick<Group, 'name'>): Promise<Group>{
103
+ return Contacts.addGroup(group);
104
+ }
105
+ async function contactsInGroup(identifier: string): Promise<Contact[]> {
106
+ return Contacts.contactsInGroup(identifier);
107
+ }
108
+ async function addContactsToGroup(groupIdentifier: string, contactIdentifiers: string[]): Promise<boolean> {
109
+ return Contacts.addContactsToGroup(groupIdentifier, contactIdentifiers);
110
+ }
111
+ async function removeContactsFromGroup(groupIdentifier: string, contactIdentifiers: string[]): Promise<boolean> {
112
+ return Contacts.removeContactsFromGroup(groupIdentifier, contactIdentifiers);
113
+ }
90
114
  export default {
91
115
  getAll,
92
116
  getAllWithoutPhotos,
@@ -106,4 +130,12 @@ export default {
106
130
  checkPermission,
107
131
  requestPermission,
108
132
  writePhotoToPath,
133
+ getGroups,
134
+ getGroup,
135
+ deleteGroup,
136
+ updateGroup,
137
+ addGroup,
138
+ contactsInGroup,
139
+ addContactsToGroup,
140
+ removeContactsFromGroup
109
141
  };