@elizaos/capacitor-contacts 2.0.0-beta.1 → 2.0.3-beta.3
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/LICENSE +21 -0
- package/README.md +109 -0
- package/android/build.gradle +8 -0
- package/android/src/main/java/ai/eliza/plugins/contacts/ContactsPlugin.kt +18 -1
- package/dist/esm/definitions.d.ts +10 -0
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/web.d.ts +6 -4
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +39 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/esm/web.test.d.ts +2 -0
- package/dist/esm/web.test.d.ts.map +1 -0
- package/dist/esm/web.test.js +32 -0
- package/dist/esm/web.test.js.map +1 -0
- package/dist/plugin.cjs.js +39 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +39 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +12 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# @elizaos/capacitor-contacts
|
|
2
|
+
|
|
3
|
+
Capacitor plugin providing an Android `ContactsContract` bridge for elizaOS agents. Enables reading, creating, and importing contacts on Android from TypeScript/JavaScript code. On web and Node.js the plugin provides an explicit fallback that returns empty contact lists and rejects writes.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- **List contacts** — query the device address book with optional text search and result limit.
|
|
8
|
+
- **Create a contact** — insert a new contact with a display name, phone numbers, and email addresses.
|
|
9
|
+
- **Import vCard** — parse RFC 6350 vCard text and bulk-insert the contacts.
|
|
10
|
+
|
|
11
|
+
## Platform support
|
|
12
|
+
|
|
13
|
+
| Platform | `listContacts` | `createContact` | `importVCard` |
|
|
14
|
+
|----------|---------------|----------------|---------------|
|
|
15
|
+
| Android | Full | Full | Full |
|
|
16
|
+
| Web/Node | Returns `[]` | Throws | Throws |
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- `@capacitor/core ^8.3.1` in the host app.
|
|
21
|
+
- Android runtime permissions must be granted by the host app:
|
|
22
|
+
- `READ_CONTACTS` — required for `listContacts`.
|
|
23
|
+
- `WRITE_CONTACTS` — required for `createContact` and `importVCard`.
|
|
24
|
+
|
|
25
|
+
The permissions are declared in the plugin's `AndroidManifest.xml` and are merged automatically by the Android build system.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @elizaos/capacitor-contacts
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then sync Capacitor:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx cap sync android
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { Contacts } from "@elizaos/capacitor-contacts";
|
|
43
|
+
|
|
44
|
+
// List contacts (optionally filtered)
|
|
45
|
+
const { contacts } = await Contacts.listContacts({ query: "Alice", limit: 50 });
|
|
46
|
+
|
|
47
|
+
// Create a contact
|
|
48
|
+
const { id } = await Contacts.createContact({
|
|
49
|
+
displayName: "Alice Example",
|
|
50
|
+
phoneNumber: "+15555550100",
|
|
51
|
+
emailAddress: "alice@example.com",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Import from vCard text
|
|
55
|
+
const { imported } = await Contacts.importVCard({ vcardText: myVCardString });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
### `listContacts(options?)`
|
|
61
|
+
|
|
62
|
+
| Option | Type | Default | Description |
|
|
63
|
+
|---------|----------|---------|-------------|
|
|
64
|
+
| `query` | `string` | — | Case-insensitive search across name, phone, and email. |
|
|
65
|
+
| `limit` | `number` | `100` | Max contacts to return. Must be 1–500. |
|
|
66
|
+
|
|
67
|
+
Returns `{ contacts: ContactSummary[] }`.
|
|
68
|
+
|
|
69
|
+
### `createContact(options)`
|
|
70
|
+
|
|
71
|
+
| Option | Type | Required | Description |
|
|
72
|
+
|------------------|------------|----------|-------------|
|
|
73
|
+
| `displayName` | `string` | Yes | Contact display name. |
|
|
74
|
+
| `phoneNumber` | `string` | No | Single phone number (convenience alias). |
|
|
75
|
+
| `phoneNumbers` | `string[]` | No | Multiple phone numbers. |
|
|
76
|
+
| `emailAddress` | `string` | No | Single email address (convenience alias). |
|
|
77
|
+
| `emailAddresses` | `string[]` | No | Multiple email addresses. |
|
|
78
|
+
|
|
79
|
+
Returns `{ id: string }` (the new contact's `ContactsContract` ID).
|
|
80
|
+
|
|
81
|
+
### `importVCard(options)`
|
|
82
|
+
|
|
83
|
+
| Option | Type | Required | Description |
|
|
84
|
+
|-------------|----------|----------|-------------|
|
|
85
|
+
| `vcardText` | `string` | Yes | Raw vCard text (vCard 2.1 / 3.0 / 4.0). |
|
|
86
|
+
|
|
87
|
+
Parses `FN`, `N`, `TEL`, and `EMAIL` fields. Photo data is not imported. Returns `{ imported: ImportedContactSummary[] }`.
|
|
88
|
+
|
|
89
|
+
### `ContactSummary`
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
interface ContactSummary {
|
|
93
|
+
id: string;
|
|
94
|
+
lookupKey: string;
|
|
95
|
+
displayName: string;
|
|
96
|
+
phoneNumbers: string[];
|
|
97
|
+
emailAddresses: string[];
|
|
98
|
+
photoUri?: string;
|
|
99
|
+
starred: boolean;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Building
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
bun run --cwd plugins/plugin-native-contacts build
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Runs TypeScript compilation and Rollup to produce `dist/esm/` (ESM) and `dist/plugin.cjs.js` (CJS).
|
package/android/build.gradle
CHANGED
|
@@ -3,6 +3,11 @@ ext {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
apply plugin: 'com.android.library'
|
|
6
|
+
// Apply the Kotlin Android plugin so the plugin's .kt class is bundled into the
|
|
7
|
+
// library AAR. Without it AGP's built-in kotlinc compiles the sources but does
|
|
8
|
+
// NOT bundle the .class files, so the Capacitor plugin class is absent from the
|
|
9
|
+
// app dex at runtime (PluginLoadException -> the whole plugin set fails to load).
|
|
10
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
6
11
|
android {
|
|
7
12
|
namespace = "ai.eliza.plugins.contacts"
|
|
8
13
|
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
@@ -14,6 +19,9 @@ android {
|
|
|
14
19
|
sourceCompatibility JavaVersion.VERSION_17
|
|
15
20
|
targetCompatibility JavaVersion.VERSION_17
|
|
16
21
|
}
|
|
22
|
+
kotlinOptions {
|
|
23
|
+
jvmTarget = "17"
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
repositories {
|
|
@@ -9,8 +9,25 @@ import com.getcapacitor.Plugin
|
|
|
9
9
|
import com.getcapacitor.PluginCall
|
|
10
10
|
import com.getcapacitor.PluginMethod
|
|
11
11
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
12
|
+
import com.getcapacitor.annotation.Permission
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
// Declares the `contacts` alias so the Capacitor base Plugin auto-provides
|
|
15
|
+
// checkPermissions()/requestPermissions() — the app can REQUEST contacts access
|
|
16
|
+
// on first use of the Contacts feature instead of only rejecting (which forced
|
|
17
|
+
// the user to grant it from system Settings). Nothing requests this at launch;
|
|
18
|
+
// it is feature-gated to the Contacts view.
|
|
19
|
+
@CapacitorPlugin(
|
|
20
|
+
name = "ElizaContacts",
|
|
21
|
+
permissions = [
|
|
22
|
+
Permission(
|
|
23
|
+
alias = "contacts",
|
|
24
|
+
strings = [
|
|
25
|
+
Manifest.permission.READ_CONTACTS,
|
|
26
|
+
Manifest.permission.WRITE_CONTACTS,
|
|
27
|
+
],
|
|
28
|
+
),
|
|
29
|
+
],
|
|
30
|
+
)
|
|
14
31
|
class ContactsPlugin : Plugin() {
|
|
15
32
|
@PluginMethod
|
|
16
33
|
fun listContacts(call: PluginCall) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PermissionState } from "@capacitor/core";
|
|
1
2
|
export interface ContactSummary {
|
|
2
3
|
id: string;
|
|
3
4
|
lookupKey: string;
|
|
@@ -7,6 +8,10 @@ export interface ContactSummary {
|
|
|
7
8
|
photoUri?: string;
|
|
8
9
|
starred: boolean;
|
|
9
10
|
}
|
|
11
|
+
/** Runtime permission state for the contacts (READ/WRITE_CONTACTS) alias. */
|
|
12
|
+
export interface ContactsPermissionStatus {
|
|
13
|
+
contacts: PermissionState;
|
|
14
|
+
}
|
|
10
15
|
export interface ListContactsOptions {
|
|
11
16
|
query?: string;
|
|
12
17
|
limit?: number;
|
|
@@ -34,5 +39,10 @@ export interface ContactsPlugin {
|
|
|
34
39
|
importVCard(options: ImportVCardOptions): Promise<{
|
|
35
40
|
imported: ImportedContactSummary[];
|
|
36
41
|
}>;
|
|
42
|
+
/** Current contacts (READ/WRITE_CONTACTS) permission state. Web: granted. */
|
|
43
|
+
checkPermissions(): Promise<ContactsPermissionStatus>;
|
|
44
|
+
/** Prompt for contacts access (no-op grant on web). Feature-gated; never
|
|
45
|
+
* requested at launch. */
|
|
46
|
+
requestPermissions(): Promise<ContactsPermissionStatus>;
|
|
37
47
|
}
|
|
38
48
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM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YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,CACV,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC;QAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAChD,QAAQ,EAAE,sBAAsB,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,6EAA6E;IAC7E,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtD;+BAC2B;IAC3B,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACzD"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
-
import type { ContactSummary, ContactsPlugin, CreateContactOptions, ImportedContactSummary, ImportVCardOptions, ListContactsOptions } from "./definitions";
|
|
2
|
+
import type { ContactsPermissionStatus, ContactSummary, ContactsPlugin, CreateContactOptions, ImportedContactSummary, ImportVCardOptions, ListContactsOptions } from "./definitions";
|
|
3
3
|
export declare class ContactsWeb extends WebPlugin implements ContactsPlugin {
|
|
4
|
-
listContacts(
|
|
4
|
+
listContacts(options?: ListContactsOptions): Promise<{
|
|
5
5
|
contacts: ContactSummary[];
|
|
6
6
|
}>;
|
|
7
|
-
createContact(
|
|
7
|
+
createContact(options: CreateContactOptions): Promise<{
|
|
8
8
|
id: string;
|
|
9
9
|
}>;
|
|
10
|
-
importVCard(
|
|
10
|
+
importVCard(options: ImportVCardOptions): Promise<{
|
|
11
11
|
imported: ImportedContactSummary[];
|
|
12
12
|
}>;
|
|
13
|
+
checkPermissions(): Promise<ContactsPermissionStatus>;
|
|
14
|
+
requestPermissions(): Promise<ContactsPermissionStatus>;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/esm/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AA8BvB,qBAAa,WAAY,SAAQ,SAAU,YAAW,cAAc;IAC5D,YAAY,CAChB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC;QAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IAKpC,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAKrE,WAAW,CACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,QAAQ,EAAE,sBAAsB,EAAE,CAAA;KAAE,CAAC;IAO5C,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAIrD,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAG9D"}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
function normalizeLimit(limit) {
|
|
3
|
+
if (limit === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
6
|
+
throw new Error("limit must be between 1 and 500");
|
|
7
|
+
}
|
|
8
|
+
const normalized = Math.trunc(limit);
|
|
9
|
+
if (normalized < 1 || normalized > 500) {
|
|
10
|
+
throw new Error("limit must be between 1 and 500");
|
|
11
|
+
}
|
|
12
|
+
return normalized;
|
|
13
|
+
}
|
|
14
|
+
function nonEmptyString(value) {
|
|
15
|
+
return typeof value === "string" ? value.trim() : "";
|
|
16
|
+
}
|
|
17
|
+
function validateCreateContactOptions(options) {
|
|
18
|
+
if (!nonEmptyString(options?.displayName)) {
|
|
19
|
+
throw new Error("displayName is required");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function validateImportVCardOptions(options) {
|
|
23
|
+
if (!nonEmptyString(options?.vcardText)) {
|
|
24
|
+
throw new Error("vcardText is required");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
2
27
|
export class ContactsWeb extends WebPlugin {
|
|
3
|
-
async listContacts(
|
|
28
|
+
async listContacts(options) {
|
|
29
|
+
normalizeLimit(options?.limit);
|
|
4
30
|
return { contacts: [] };
|
|
5
31
|
}
|
|
6
|
-
async createContact(
|
|
32
|
+
async createContact(options) {
|
|
33
|
+
validateCreateContactOptions(options);
|
|
7
34
|
throw new Error("Contacts are only available on Android.");
|
|
8
35
|
}
|
|
9
|
-
async importVCard(
|
|
36
|
+
async importVCard(options) {
|
|
37
|
+
validateImportVCardOptions(options);
|
|
10
38
|
throw new Error("Contact imports are only available on Android.");
|
|
11
39
|
}
|
|
40
|
+
// Web has no contacts permission model; report granted so the shared view
|
|
41
|
+
// flow proceeds (listContacts then returns an empty list on web).
|
|
42
|
+
async checkPermissions() {
|
|
43
|
+
return { contacts: "granted" };
|
|
44
|
+
}
|
|
45
|
+
async requestPermissions() {
|
|
46
|
+
return { contacts: "granted" };
|
|
47
|
+
}
|
|
12
48
|
}
|
|
13
49
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,4BAA4B,CAAC,OAA6B;IACjE,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,OAA2B;IAC7D,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,YAAY,CAChB,OAA6B;QAE7B,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAA6B;QAC/C,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAA2B;QAE3B,0BAA0B,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,0EAA0E;IAC1E,kEAAkE;IAClE,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.test.d.ts","sourceRoot":"","sources":["../../src/web.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { ContactsWeb } from "./web";
|
|
3
|
+
describe("ContactsWeb fallback", () => {
|
|
4
|
+
it.each([
|
|
5
|
+
0,
|
|
6
|
+
-1,
|
|
7
|
+
501,
|
|
8
|
+
Number.POSITIVE_INFINITY,
|
|
9
|
+
Number.NaN,
|
|
10
|
+
])("rejects malformed listContacts limit %s", async (limit) => {
|
|
11
|
+
const contacts = new ContactsWeb();
|
|
12
|
+
await expect(contacts.listContacts({ limit })).rejects.toThrow("limit must be between 1 and 500");
|
|
13
|
+
});
|
|
14
|
+
it("returns an empty contact list for valid web fallback queries", async () => {
|
|
15
|
+
const contacts = new ContactsWeb();
|
|
16
|
+
await expect(contacts.listContacts({ limit: 25.9, query: "../../ada" })).resolves.toEqual({ contacts: [] });
|
|
17
|
+
});
|
|
18
|
+
it("rejects malformed create/import payloads before Android-only fallback errors", async () => {
|
|
19
|
+
const contacts = new ContactsWeb();
|
|
20
|
+
await expect(contacts.createContact({ displayName: " \t\n " })).rejects.toThrow("displayName is required");
|
|
21
|
+
await expect(contacts.createContact({
|
|
22
|
+
displayName: ["Ada Lovelace"],
|
|
23
|
+
})).rejects.toThrow("displayName is required");
|
|
24
|
+
await expect(contacts.importVCard({ vcardText: "" })).rejects.toThrow("vcardText is required");
|
|
25
|
+
await expect(contacts.importVCard({
|
|
26
|
+
vcardText: { text: "BEGIN:VCARD" },
|
|
27
|
+
})).rejects.toThrow("vcardText is required");
|
|
28
|
+
await expect(contacts.createContact({ displayName: "Ada Lovelace" })).rejects.toThrow("Contacts are only available on Android.");
|
|
29
|
+
await expect(contacts.importVCard({ vcardText: "BEGIN:VCARD\nFN:Ada\nEND:VCARD" })).rejects.toThrow("Contact imports are only available on Android.");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=web.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.test.js","sourceRoot":"","sources":["../../src/web.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;A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,CAAC,CAAC,OAAO,CAAC,OAAO,CACnE,uBAAuB,CACxB,CAAC;QACF,MAAM,MAAM,CACV,QAAQ,CAAC,WAAW,CAAC;YACnB,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAuB;SACxD,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAC3C,MAAM,MAAM,CACV,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CACxD,CAAC,OAAO,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;QAC7D,MAAM,MAAM,CACV,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,gCAAgC,EAAE,CAAC,CACtE,CAAC,OAAO,CAAC,OAAO,CAAC,gDAAgD,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -7,16 +7,52 @@ const Contacts = core.registerPlugin("ElizaContacts", {
|
|
|
7
7
|
web: loadWeb,
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
function normalizeLimit(limit) {
|
|
11
|
+
if (limit === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
14
|
+
throw new Error("limit must be between 1 and 500");
|
|
15
|
+
}
|
|
16
|
+
const normalized = Math.trunc(limit);
|
|
17
|
+
if (normalized < 1 || normalized > 500) {
|
|
18
|
+
throw new Error("limit must be between 1 and 500");
|
|
19
|
+
}
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
|
22
|
+
function nonEmptyString(value) {
|
|
23
|
+
return typeof value === "string" ? value.trim() : "";
|
|
24
|
+
}
|
|
25
|
+
function validateCreateContactOptions(options) {
|
|
26
|
+
if (!nonEmptyString(options?.displayName)) {
|
|
27
|
+
throw new Error("displayName is required");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function validateImportVCardOptions(options) {
|
|
31
|
+
if (!nonEmptyString(options?.vcardText)) {
|
|
32
|
+
throw new Error("vcardText is required");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
10
35
|
class ContactsWeb extends core.WebPlugin {
|
|
11
|
-
async listContacts(
|
|
36
|
+
async listContacts(options) {
|
|
37
|
+
normalizeLimit(options?.limit);
|
|
12
38
|
return { contacts: [] };
|
|
13
39
|
}
|
|
14
|
-
async createContact(
|
|
40
|
+
async createContact(options) {
|
|
41
|
+
validateCreateContactOptions(options);
|
|
15
42
|
throw new Error("Contacts are only available on Android.");
|
|
16
43
|
}
|
|
17
|
-
async importVCard(
|
|
44
|
+
async importVCard(options) {
|
|
45
|
+
validateImportVCardOptions(options);
|
|
18
46
|
throw new Error("Contact imports are only available on Android.");
|
|
19
47
|
}
|
|
48
|
+
// Web has no contacts permission model; report granted so the shared view
|
|
49
|
+
// flow proceeds (listContacts then returns an empty list on web).
|
|
50
|
+
async checkPermissions() {
|
|
51
|
+
return { contacts: "granted" };
|
|
52
|
+
}
|
|
53
|
+
async requestPermissions() {
|
|
54
|
+
return { contacts: "granted" };
|
|
55
|
+
}
|
|
20
56
|
}
|
|
21
57
|
|
|
22
58
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.ContactsWeb());\nexport const Contacts = registerPlugin(\"ElizaContacts\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class ContactsWeb extends WebPlugin {\n async listContacts(
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.ContactsWeb());\nexport const Contacts = registerPlugin(\"ElizaContacts\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nfunction normalizeLimit(limit) {\n if (limit === undefined)\n return undefined;\n if (typeof limit !== \"number\" || !Number.isFinite(limit)) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n const normalized = Math.trunc(limit);\n if (normalized < 1 || normalized > 500) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n return normalized;\n}\nfunction nonEmptyString(value) {\n return typeof value === \"string\" ? value.trim() : \"\";\n}\nfunction validateCreateContactOptions(options) {\n if (!nonEmptyString(options?.displayName)) {\n throw new Error(\"displayName is required\");\n }\n}\nfunction validateImportVCardOptions(options) {\n if (!nonEmptyString(options?.vcardText)) {\n throw new Error(\"vcardText is required\");\n }\n}\nexport class ContactsWeb extends WebPlugin {\n async listContacts(options) {\n normalizeLimit(options?.limit);\n return { contacts: [] };\n }\n async createContact(options) {\n validateCreateContactOptions(options);\n throw new Error(\"Contacts are only available on Android.\");\n }\n async importVCard(options) {\n validateImportVCardOptions(options);\n throw new Error(\"Contact imports are only available on Android.\");\n }\n // Web has no contacts permission model; report granted so the shared view\n // flow proceeds (listContacts then returns an empty list on web).\n async checkPermissions() {\n return { contacts: \"granted\" };\n }\n async requestPermissions() {\n return { contacts: \"granted\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,MAAC,QAAQ,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACxD,IAAI,GAAG,EAAE,OAAO;AAChB,CAAC;;ACJD,SAAS,cAAc,CAAC,KAAK,EAAE;AAC/B,IAAI,IAAI,KAAK,KAAK,SAAS;AAC3B,QAAQ,OAAO,SAAS;AACx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AAC,OAAO,EAAE;AAC/B,QAAQ,0BAA0B,CAAC,OAAO,CAAC;AAC3C,QAAQ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC;AACzE,IAAI;AACJ;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;AACtC,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;AACtC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -6,16 +6,52 @@ var capacitorContacts = (function (exports, core) {
|
|
|
6
6
|
web: loadWeb,
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
function normalizeLimit(limit) {
|
|
10
|
+
if (limit === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
13
|
+
throw new Error("limit must be between 1 and 500");
|
|
14
|
+
}
|
|
15
|
+
const normalized = Math.trunc(limit);
|
|
16
|
+
if (normalized < 1 || normalized > 500) {
|
|
17
|
+
throw new Error("limit must be between 1 and 500");
|
|
18
|
+
}
|
|
19
|
+
return normalized;
|
|
20
|
+
}
|
|
21
|
+
function nonEmptyString(value) {
|
|
22
|
+
return typeof value === "string" ? value.trim() : "";
|
|
23
|
+
}
|
|
24
|
+
function validateCreateContactOptions(options) {
|
|
25
|
+
if (!nonEmptyString(options?.displayName)) {
|
|
26
|
+
throw new Error("displayName is required");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function validateImportVCardOptions(options) {
|
|
30
|
+
if (!nonEmptyString(options?.vcardText)) {
|
|
31
|
+
throw new Error("vcardText is required");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
9
34
|
class ContactsWeb extends core.WebPlugin {
|
|
10
|
-
async listContacts(
|
|
35
|
+
async listContacts(options) {
|
|
36
|
+
normalizeLimit(options?.limit);
|
|
11
37
|
return { contacts: [] };
|
|
12
38
|
}
|
|
13
|
-
async createContact(
|
|
39
|
+
async createContact(options) {
|
|
40
|
+
validateCreateContactOptions(options);
|
|
14
41
|
throw new Error("Contacts are only available on Android.");
|
|
15
42
|
}
|
|
16
|
-
async importVCard(
|
|
43
|
+
async importVCard(options) {
|
|
44
|
+
validateImportVCardOptions(options);
|
|
17
45
|
throw new Error("Contact imports are only available on Android.");
|
|
18
46
|
}
|
|
47
|
+
// Web has no contacts permission model; report granted so the shared view
|
|
48
|
+
// flow proceeds (listContacts then returns an empty list on web).
|
|
49
|
+
async checkPermissions() {
|
|
50
|
+
return { contacts: "granted" };
|
|
51
|
+
}
|
|
52
|
+
async requestPermissions() {
|
|
53
|
+
return { contacts: "granted" };
|
|
54
|
+
}
|
|
19
55
|
}
|
|
20
56
|
|
|
21
57
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.ContactsWeb());\nexport const Contacts = registerPlugin(\"ElizaContacts\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class ContactsWeb extends WebPlugin {\n async listContacts(
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.ContactsWeb());\nexport const Contacts = registerPlugin(\"ElizaContacts\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nfunction normalizeLimit(limit) {\n if (limit === undefined)\n return undefined;\n if (typeof limit !== \"number\" || !Number.isFinite(limit)) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n const normalized = Math.trunc(limit);\n if (normalized < 1 || normalized > 500) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n return normalized;\n}\nfunction nonEmptyString(value) {\n return typeof value === \"string\" ? value.trim() : \"\";\n}\nfunction validateCreateContactOptions(options) {\n if (!nonEmptyString(options?.displayName)) {\n throw new Error(\"displayName is required\");\n }\n}\nfunction validateImportVCardOptions(options) {\n if (!nonEmptyString(options?.vcardText)) {\n throw new Error(\"vcardText is required\");\n }\n}\nexport class ContactsWeb extends WebPlugin {\n async listContacts(options) {\n normalizeLimit(options?.limit);\n return { contacts: [] };\n }\n async createContact(options) {\n validateCreateContactOptions(options);\n throw new Error(\"Contacts are only available on Android.\");\n }\n async importVCard(options) {\n validateImportVCardOptions(options);\n throw new Error(\"Contact imports are only available on Android.\");\n }\n // Web has no contacts permission model; report granted so the shared view\n // flow proceeds (listContacts then returns an empty list on web).\n async checkPermissions() {\n return { contacts: \"granted\" };\n }\n async requestPermissions() {\n return { contacts: \"granted\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,UAAC,QAAQ,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACxD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJD,SAAS,cAAc,CAAC,KAAK,EAAE;IAC/B,IAAI,IAAI,KAAK,KAAK,SAAS;IAC3B,QAAQ,OAAO,SAAS;IACxB,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC9D,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC;IAC1D,IAAI;IACJ,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IACxC,IAAI,I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MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;IACtC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/capacitor-contacts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3-beta.3",
|
|
4
4
|
"description": "Android ContactsContract bridge for ElizaOS.",
|
|
5
5
|
"main": "./dist/plugin.cjs.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"bun": "./src/index.ts",
|
|
12
|
+
"development": "./src/index.ts",
|
|
11
13
|
"import": "./dist/esm/index.js",
|
|
12
14
|
"require": "./dist/plugin.cjs.js"
|
|
13
15
|
},
|
|
@@ -20,9 +22,11 @@
|
|
|
20
22
|
"dist"
|
|
21
23
|
],
|
|
22
24
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"clean": "node
|
|
25
|
-
"
|
|
25
|
+
"build": "node ../../packages/scripts/with-package-build-lock.mjs plugins/plugin-native-contacts -- bun run build:unlocked",
|
|
26
|
+
"clean": "node ../../packages/scripts/rm-path-recursive.mjs dist",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"prepublishOnly": "bun run build",
|
|
29
|
+
"build:unlocked": "bun run clean && tsc && bunx rollup -c rollup.config.mjs"
|
|
26
30
|
},
|
|
27
31
|
"license": "MIT",
|
|
28
32
|
"capacitor": {
|
|
@@ -31,11 +35,10 @@
|
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
|
-
"@capacitor/cli": "^8.0.0",
|
|
35
38
|
"@capacitor/core": "^8.3.1",
|
|
36
|
-
"rimraf": "^6.0.0",
|
|
37
39
|
"rollup": "^4.60.2",
|
|
38
|
-
"typescript": "^6.0.3"
|
|
40
|
+
"typescript": "^6.0.3",
|
|
41
|
+
"vitest": "^4.0.0"
|
|
39
42
|
},
|
|
40
43
|
"peerDependencies": {
|
|
41
44
|
"@capacitor/core": "^8.3.1"
|
|
@@ -53,5 +56,6 @@
|
|
|
53
56
|
},
|
|
54
57
|
"publishConfig": {
|
|
55
58
|
"access": "public"
|
|
56
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "f54b0f4eaed317d59fa7dbcdce20f4cdb0734420"
|
|
57
61
|
}
|