|
| 1 | +# CardDAV plugin |
| 2 | + |
| 3 | +Query and manage CardDAV contacts with SQL. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +```sql |
| 8 | +-- List all available address books |
| 9 | +SELECT * FROM carddav_address_books; |
| 10 | + |
| 11 | +-- Get all contacts from a CardDAV address book |
| 12 | +SELECT * FROM carddav_contacts WHERE address_book = 'contacts/'; |
| 13 | + |
| 14 | +-- Search for contacts by name |
| 15 | +SELECT full_name, email, phone FROM carddav_contacts |
| 16 | +WHERE address_book = 'contacts/' AND full_name LIKE '%John%'; |
| 17 | + |
| 18 | +-- Insert a new contact |
| 19 | +INSERT INTO carddav_contacts (address_book, uid, full_name, email, phone) |
| 20 | +VALUES ( 'contacts/', 'unique-id-123', 'John Doe', '[email protected]', '+1234567890'); |
| 21 | + |
| 22 | +-- Update a contact |
| 23 | +UPDATE carddav_contacts |
| 24 | +SET email = '[email protected]', organization = 'New Company' |
| 25 | +WHERE address_book = 'contacts/' AND uid = 'unique-id-123'; |
| 26 | +``` |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +```bash |
| 31 | +anyquery install carddav |
| 32 | +``` |
| 33 | + |
| 34 | +Anyquery will ask you for your CardDAV server URL, username, and password during installation. Refer to the [guide](#popular-carddav-providers) below for more information on how to configure your CardDAV server. |
| 35 | + |
| 36 | +### Popular CardDAV Providers |
| 37 | + |
| 38 | +#### Nextcloud |
| 39 | + |
| 40 | +```txt |
| 41 | +URL: https://your-nextcloud.com/remote.php/dav/addressbooks/users/yourusername/ |
| 42 | +``` |
| 43 | + |
| 44 | +Create an app-specific password in Settings → Security → App passwords. |
| 45 | + |
| 46 | +#### Google Contacts |
| 47 | + |
| 48 | +Enable CardDAV API in Google Admin Console (for Workspace accounts). The Google Contacts API is not supported, but you can use Anyquery's integration for [Google Contacts](https://anyquery.dev/integrations/google_contacts). |
| 49 | + |
| 50 | +#### Apple iCloud |
| 51 | + |
| 52 | +```txt |
| 53 | +URL: https://contacts.icloud.com/ |
| 54 | +Username: The email used by your Apple account |
| 55 | +Password: Your Apple ID password |
| 56 | +``` |
| 57 | + |
| 58 | +Use an app-specific password from Apple ID settings. Refer to [Apple's documentation](https://support.apple.com/en-au/102654#:~:text=Sign%20in%20to%20your%20Apple%20Account%20on%20account.apple.com,the%20steps%20on%20your%20screen.) |
| 59 | + |
| 60 | +## Tables |
| 61 | + |
| 62 | +### `carddav_address_books` |
| 63 | + |
| 64 | +List available address books on the CardDAV server. |
| 65 | + |
| 66 | +#### Schema |
| 67 | + |
| 68 | +| Column index | Column name | Type | Description | |
| 69 | +| ------------ | ----------------- | ------- | ----------------------------------- | |
| 70 | +| 0 | path | TEXT | Address book path (use for queries) | |
| 71 | +| 1 | name | TEXT | Display name of the address book | |
| 72 | +| 2 | description | TEXT | Description of the address book | |
| 73 | +| 3 | max_resource_size | INTEGER | Maximum resource size | |
| 74 | + |
| 75 | +### `carddav_contacts` |
| 76 | + |
| 77 | +Query and manage contacts from CardDAV address books. |
| 78 | + |
| 79 | +#### Schema |
| 80 | + |
| 81 | +| Column index | Column name | Type | Description | |
| 82 | +| ------------ | ------------ | ---- | ----------------------------- | |
| 83 | +| 0 | address_book | TEXT | Address book path (parameter) | |
| 84 | +| 1 | uid | TEXT | Unique identifier | |
| 85 | +| 2 | etag | TEXT | ETag for conflict detection | |
| 86 | +| 3 | path | TEXT | CardDAV resource path | |
| 87 | +| 4 | full_name | TEXT | Full display name | |
| 88 | +| 5 | given_name | TEXT | First name | |
| 89 | +| 6 | family_name | TEXT | Last name | |
| 90 | +| 7 | middle_name | TEXT | Middle name | |
| 91 | +| 8 | prefix | TEXT | Name prefix (Mr., Dr., etc.) | |
| 92 | +| 9 | suffix | TEXT | Name suffix (Jr., Sr., etc.) | |
| 93 | +| 10 | nickname | TEXT | Nickname | |
| 94 | +| 11 | email | TEXT | Primary email address | |
| 95 | +| 12 | home_email | TEXT | Home email address | |
| 96 | +| 13 | work_email | TEXT | Work email address | |
| 97 | +| 14 | other_email | TEXT | Other email address | |
| 98 | +| 15 | emails | TEXT | All emails (JSON array) | |
| 99 | +| 16 | phone | TEXT | Primary phone number | |
| 100 | +| 17 | mobile_phone | TEXT | Mobile phone number | |
| 101 | +| 18 | work_phone | TEXT | Work phone number | |
| 102 | +| 19 | organization | TEXT | Organization/Company | |
| 103 | +| 20 | title | TEXT | Job title | |
| 104 | +| 21 | role | TEXT | Role/Position | |
| 105 | +| 22 | birthday | TEXT | Birthday (YYYY-MM-DD) | |
| 106 | +| 23 | anniversary | TEXT | Anniversary (YYYY-MM-DD) | |
| 107 | +| 24 | note | TEXT | Notes | |
| 108 | +| 25 | url | TEXT | Website URL | |
| 109 | +| 26 | categories | TEXT | Categories (JSON array) | |
| 110 | +| 27 | modified_at | TEXT | Last modified timestamp | |
| 111 | + |
| 112 | +## Development |
| 113 | + |
| 114 | +To develop and test the CardDAV plugin: |
| 115 | + |
| 116 | +```bash |
| 117 | +cd plugins/carddav |
| 118 | +make |
| 119 | +make test # Run unit tests |
| 120 | +make integration-test # Run integration tests with real CardDAV server |
| 121 | +``` |
| 122 | + |
| 123 | +For manual testing, start anyquery in dev mode and load the plugin: |
| 124 | + |
| 125 | +```bash |
| 126 | +anyquery --dev |
| 127 | +``` |
| 128 | + |
| 129 | +```sql |
| 130 | +SELECT load_dev_plugin('carddav', 'devManifest.json'); |
| 131 | +``` |
| 132 | + |
| 133 | +Configure your CardDAV credentials in `devManifest.json` before running tests. The test script will verify plugin functionality by listing address books, querying contacts, and testing insert/update operations. |
| 134 | + |
| 135 | +## Limitations |
| 136 | + |
| 137 | +- Address book creation and deletion are not supported yet |
| 138 | +- Some CardDAV servers may have different URL formats or authentication requirements |
| 139 | +- Large contact lists may take time to query due to CardDAV protocol limitations |
| 140 | +- The plugin does not cache data - each query hits the CardDAV server directly |
0 commit comments