Code Monkey home page Code Monkey logo

cozy-browser-sdk's Introduction

cozy-browser-sdk

This document covers the API documentation of the SDK for Cozy apps without a server.

Disclaimer: This is not a tutorial to write Cozy application, if you want to understand how to write apps without a server with Cozy, you can read this tutorial.

What is it for?

cozy-browser-sdk is a javascript library made by Cozy. It enables client-side applications to easily make requests to the data-system. The Data-system is the data storage API of the Cozy.

How to use it?

You just have to copy a single file (dist/cozysdk-client.js) to your app repository. You can then require it by using any build tool or include it in your html page through a <script> tag.

We recommend you to follow this tutorial to setup the Cozy SDK tutorial properly.

You can also use npm (npm install cozysdk-client) and then require it from your JS file:

var cozySDK = require('cozysdk-client');

What can it do?

License

Cozy Browser SDK is developed by Cozy Cloud and distributed under the MIT license.

What is Cozy?

Cozy Logo

Cozy is a platform that brings all your web services in the same private space. With it, your web apps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one profiles you.

Community

You can reach the Cozy Community by:

  • Chatting with us on IRC #cozycloud on irc.freenode.net
  • Posting on our Forum
  • Posting issues on the Github repos
  • Mentioning us on Twitter

cozy-browser-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cozy-browser-sdk's Issues

Display a warning when unable to get the auth token

Applications using this SDK must run inside an iframe of the Home, otherwise they won't get the token.
When we are unable to get the auth token, we should display a warning, explaining the user the application cannot be used alone.

Add a method to log client errors on server

On most of our own applications, we have a method that allow to log client-side errors into application logs. It would be nice to provide such a method to serverless applications.
Once done, this method could be used inside our own applications, instead of current duplicated code.

/cc @m4dz

Return promise on requests

When running a request (run, create, destroyโ€ฆ) it may sometimes be useful to get a Promise rather than deal with callbacks. I think we can easily support both, and then let the playRequest helper returns a Promise too.

@aenario, sounds good to you?

Treat response type as JSON

When perfoming a request, the documentation recommand to do a items = JSON.parse('' + res) to get the JSONified result. As long as the expected result is always a JSON object, this post-treatment should be done by the SDK, not the app itself.

Allow to add a binary / attachment

We need to find a proper API, I offer :

Option 1 - mikeal/request like, where we return the xhr object, so the app can setup its listeners

file = document.getElementbyId('input_file').files[0]
request = cozysdk.attachBinary 'Note', 454id543, 'binary_name.ext', file, callback
request.addEventListener("abort", transferCanceled);
request.upload.addEventListener("progress", updateProgress);
request.upload.addEventListener("abort", transferCanceled);

Option 2 - with a progressback

file = document.getElementbyId('input_file').files[0]
progressback = (event) -> event instanceof ProgressEvent
cozysdk.attachBinary 'Note', 454id543, 'binary_name.ext', file, callback, progressback

*1 event is a ProgressEvent

Option 3 - only provide the url, and some doc on how to use it with <form>

Create() : response contains only _id

 cozysdk.create('Track', model, (error, response) => {
    console.log('CREATE TRACK', error, response);
});

when an object is created the response looks like this :

CREATE TRACK null Object { _id: "6ff5933b1feaf95ed8068bd78303431d" }

it would perhaps be better if we would have the full document created (with all attributes)

[Doc] Multiple defineView?

Hi,

I am quite new to CouchDB, so I might miss something, but how are multiple defineView handled? I have two main concerns:

  1. First one is that if I defineView a previously defined view, it will overwrite it. Is there any plans (maybe in the long term) to ensure a Cozy app cannot override pre-existing views and potentially break other installed apps?
  2. When multiple apps get installed, all of them will populate the views by defining their own. But nothing seems to clean the defined views, for example when apps are uninstalled. Then, the number of views in the CouchDB can only keep increasing. Is there any mechanism to clean the useless views or is it of no importance?

Thanks!

node_module maybe not complet

hi,
after a npm i cozysdk-client -- save ("cozysdk-client": "0.0.5")
i use CommonJS and so i need to do into app.js
var cozysdk = require('../vendor/cozysdk-client');

an npm build return this error:
Error: Cannot find module './utils/client' from '/myproject/vendor'
Error: Cannot find module './utils/client' from '/stuff/myproject/node_modules/cozysdk-client/dist'

ls /node_modules/cozysdk/

  • dist

ls /node_modules/cozysdk-client/dist

  • cozysdk-client.js
  • cozysdk-client.js.map

with the https://cdn.rawgit.com/cozy/cozy-browser-sdk/wip-v1/dist/cozysdk-client.js
everything was fine
https://github.com/cozy/cozy-browser-sdk/blob/master/dist/cozysdk-client.js#L5

So maybe it miss the ./utils folder into the npm version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.