# linagora.esn.dav.import

> Common stuffs used by Contact and Calendar to import contacts/events from VCF/ICS files to Sabre DAV

Latest version **1.10.5** (published 2022-05-10) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install linagora.esn.dav.import
pnpm add linagora.esn.dav.import
yarn add linagora.esn.dav.import
bun add linagora.esn.dav.import
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.10.5 |
| Published | 2022-05-10 |
| First published | 2018-07-05 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.12.0 |
| Dependencies | 8 |
| Unpacked size | 73.6 KB |
| Known vulnerabilities | 0 (+8 in 3 direct dependencies) |
| Install scripts | yes |
| Author | Linagora R&D |
| Maintainers | linagora_ci |

## Links

- npm: https://www.npmjs.com/package/linagora.esn.dav.import
- Repository: https://ci.linagora.com/linagora/lgs/openpaas/linagora.esn.dav.import
- npm.io page: https://npm.io/package/linagora.esn.dav.import

## Dependencies (8)

- [q](https://npm.io/package/q.md) 1.4.1
- [cors](https://npm.io/package/cors.md) 2.8.1
- [async](https://npm.io/package/async.md) 2.0.1
- [bower](https://npm.io/package/bower.md) 1.8.8
- [lodash](https://npm.io/package/lodash.md) 4.17.15
- [express](https://npm.io/package/express.md) 4.17.1
- [glob-all](https://npm.io/package/glob-all.md) 3.1.0
- [awesome-module](https://npm.io/package/awesome-module.md) 1.1.0

## Recent versions

- 1.10.5 (latest) — 2022-05-10
- 1.10.4 — 2022-05-10
- 1.10.3 — 2022-04-12
- 1.10.2 — 2022-02-24
- 1.10.0 — 2022-01-06
- 1.10.0-rc1 — 2021-11-03
- 1.9.0-rc9 — 2021-10-26
- 1.9.0-rc8 — 2021-04-01
- 1.9.0-rc6 — 2021-02-23
- 1.9.0-rc5 — 2021-01-25
- 1.9.0-rc4 — 2021-01-21
- 1.9.0-rc3 — 2020-12-22
- 1.9.0-rc2 — 2020-12-18
- 1.9.0-rc1 — 2020-12-16
- 1.9.0-beta2 — 2020-11-27
- … 68 more at https://npm.io/package/linagora.esn.dav.import/versions

## README

# linagora.esn.dav.import

Common stuffs used by Contact and Calendar to import contacts/events from VCF/ICS files to Sabre DAV

## Usage

Assume that you want to import contacts from vCard files:

__Step 1:__ register vCard file handler

```js
// in your backend
const davImport = dependencies('dav.import');

const vcardHandler = {
  contentType: 'text/vcard',

  /**
   * Parse lines in a chunk to DAV items
   * @param  {Array<String>} lines          - Lines to be read
   * @param  {Array<String>} remainingLines - Remaing lines from last chunk
   * @return {Object}                       - An object of:
   *                                          + items: DAV items read from lines
   *                                          + remainingLines: remaining lines of uncomplete DAV item
   */
  readLines(lines, remainingLines) {},

  /**
   * Import item to DAV server
   * @param  {String} item   - A single DAV item parsed from chunks
   * @param  {String} target - Address book or calendar path to import DAV item to
   * @param  {String} token  - To authenticate against DAV server
   * @return {Promise}       - Resolve on success
   */
  importItem(item, { target, token }) {},

  /**
   * Validate target path
   * @param  {Object} user      - The user object, can be used to check user's right on the target
   * @param  {String} target    - Address book or calendar path to import DAV items to
   * @return {Boolean|Promise}  - Return or resolve true if the target is valid
   */
  targetValidator(user, target) {}
};

davImport.lib.importer.addFileHandler(vcardHandler.contentType, vcardHandler);
```

__Step 2:__ use Angular service to import file

```js
var target = '/addressbooks/bookId/bookHome.json';

davImportService.importFromFile(file, target).then(function() {
  // import request submitted and will be process by job queue
});
```

## Licence

[Affero GPL v3](http://www.gnu.org/licenses/agpl-3.0.html)

---
_Source: https://npm.io/package/linagora.esn.dav.import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
