npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

owncloud-sdk

v3.1.0

Published

ownCloud client library for JavaScript

Downloads

1,695

Readme

docs

ownCloud JavaScript SDK

Deprecation notice: The owncloud-sdk has been deprecated and discontinued in favor of the web-client package. 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

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 is the next generation web frontend for ownCloud.

ownCloud file-picker

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.

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 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. 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:

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 Noveen Sachdeva, Vincent Petry and Thomas Müller as part of the 2017 Google Summer of Code.

License

The ownCloud SDK is released under the MIT License.