# owncloud-sdk

> ownCloud client library for JavaScript

Latest version **3.1.0** (published 2024-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install owncloud-sdk
pnpm add owncloud-sdk
yarn add owncloud-sdk
bun add owncloud-sdk
```

## 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 | 3.1.0 |
| Published | 2024-04-19 |
| First published | 2019-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 82.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 74 |
| Author | ownclouders |
| Maintainers | ownclouders |
| Keywords | owncloud, api, ownCloud, javascript, client, node, nodejs, js, promise |

## Links

- npm: https://www.npmjs.com/package/owncloud-sdk
- Repository: https://github.com/owncloud/owncloud-sdk
- Homepage: https://owncloud.github.io/owncloud-sdk/
- Issues: https://github.com/owncloud/owncloud-sdk/issues
- npm.io page: https://npm.io/package/owncloud-sdk

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.1.0 (latest) — 2024-04-19
- 3.1.0-alpha.10 — 2023-10-18
- 3.1.0-alpha.9 — 2023-09-25
- 3.1.0-alpha.8 — 2023-08-22
- 3.1.0-alpha.7 — 2023-07-31
- 3.1.0-alpha.6 — 2023-07-26
- 3.1.0-alpha.5 — 2023-07-12
- 3.1.0-alpha.4 — 2023-03-21
- 3.1.0-alpha.3 — 2023-01-30
- 3.1.0-alpha.2 — 2023-01-27
- 3.1.0-alpha.1 — 2022-12-06
- 3.0.0 — 2022-11-28
- 3.0.0-alpha.17 — 2022-08-16
- 3.0.0-alpha.16 — 2022-08-09
- 3.0.0-alpha.15 — 2022-07-13
- … 275 more at https://npm.io/package/owncloud-sdk/versions

## README

[![docs](https://img.shields.io/badge/api_docs-online-blue.svg)](https://owncloud.github.io/owncloud-sdk/)

# ownCloud JavaScript SDK

**Deprecation notice: The `owncloud-sdk` has been deprecated and discontinued in favor of the [web-client package](https://github.com/owncloud/web/tree/master/packages/web-client). This means the package won't get any updates in the future.**

Use this light-weight JS library with a promise-based interface for seamless communication with your ownCloud instance, both from the browser and from Node backends.

## Installation

Run either 

```
npm install owncloud-sdk
```

or

```
yarn add owncloud-sdk
```

to add the `owncloud-sdk` to your project.

If you haven't done so already, you also need to add the following `peerDependencies` to your dependencies:

```
npm install axios cross-fetch promise qs utf8 uuid webdav xml-js
```

or

```
yarn add axios cross-fetch promise qs utf8 uuid webdav xml-js
```

## Usage

```js
const owncloud = require('owncloud-sdk');
let oc = new owncloud({
      baseUrl: config.owncloudURL,
      auth: {
        basic: {
          username: config.username,
          password: config.password
        }
      }
});

// Login
oc.login().then(status => {
    // STUFF
}).catch(error => {
    // HANDLE ERROR
});

// Share File With Link
oc.shares.shareFileWithLink('linkToYourFile').then(shareInfo => {
    console.log("Link is : " + shareInfo.getLink());
}).catch(error => {
    // HANDLE ERROR
});

// List all files
oc.files.list('/path/to/file/folder').then(files => {
    console.log(files);
}).catch(error => {
    console.log(error);
});
```

## Example Projects

### ownCloud web

[ownCloud web](https://github.com/owncloud/web) is the next generation web frontend for ownCloud.

### ownCloud file-picker

[ownCloud file-picker](github.com/owncloud/file-picker) is an integration to access the files in your ownCloud, e.g. in a chat app.

## Documentation

The full API documentation is available [on the docs website](https://owncloud.dev/owncloud-sdk/).

### Building the docs

The docs are based on JSDocs.
To build them, run the following command and follow the instructions on the terminal:

```
yarn build:docs
```

## Unit/Integration tests

### Overview

`owncloud-sdk` uses [pactjs](https://github.com/pact-foundation/pact-js) with jest for unit and integration tests.

On the pact provider side, tests have 4 different `interactions`:

- interactions that work on both oc10 & ocis
- interactions that are "pending" on oc10 but should work on ocis
- interactions that are "pending" on ocis but should work on oc10
- interactions that are "pending" on both ocis & oc10

The CI is not expected to fail for the interactions that are "pending" but it's expected to fail for those interactions that were already verified and started failing. Pact.io has a system to handle such a scenario called [pending pacts](https://docs.pact.io/pact_broker/advanced_topics/pending_pacts/ 'pending pacts'). This feature allows changed contracts to be verified without failing the provider's build.

Four different pacts for the different buckets of interactions are created when running the provider tests. Pacts that are allowed to fail are marked as `pending` else not.

In a consumer test, a new mock provider is created using the function `createProvider`. It takes two parameters: `pendingOnOc10` and `pendingOnOcis` in order. Each parameter can have value `true` or `false` depending upon which provider-version the test is still pending.

To add a new consumer test which is expected to fail on ocis but pass on oc10 provider, provider should be created as:

```js
describe('feature', function () {
  it('new test feature', function () {
    const isPendingOnOc10 = true // set this as true if the test is allowed to fail on oc10 provider
    const isPendingOnOcis = false // set this as true if the test is allowed to fail on ocis provider
    const provider = createProvider(isPendingOnOc10, isPendingOnOcis)
    // get interactions
    // execute test
    provider.executeTest(() => {
      // test body
    })
  })
})
```
### Running tests

At first, you need to create `config.json` file.

```
cp tests/config/config.sample.json tests/config/config.json
```

### Consumer tests

The pact consumer tests checks owncloud sdk against the pact mock server. In order to run these tests, use the following command:

```
yarn test-consumer
```

> Note: If you have pacts from old test run in `tests/pacts` your tests will fail. Make sure to delete that before you run the tests again.

> Note: The pact tests need node 14. You can switch node versions locally with `nvm install 14` and then `make` to get all the correct dependencies.

### Provider tests

The pact provider tests the pacts generated from the consumer tests against the real owncloud backend server. For this you will need an actual owncloud server running. Then you can run the pact tests with the following command:
```
PROVIDER_BASE_URL=<owncloud-backend-url> yarn test-provider
```

## Credits

This project was originally created by <a href="https://github.com/noveens">Noveen Sachdeva</a>, <a href="https://github.com/PVince81">Vincent Petry</a> and <a href="https://github.com/DeepDiver1975">Thomas Müller</a> as part of the [2017 Google Summer of Code](https://summerofcode.withgoogle.com/archive/2017/projects/5166409181036544).

## License

The ownCloud SDK is released under the [MIT License](https://github.com/owncloud/owncloud-sdk/blob/master/LICENSE.md).

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