Skip to content

yathit/sprintly-service

Repository files navigation

Sprint.ly offline module

This javascript module is a wrapper on Sprint.ly API providing offline support and client-side full-text search.

Browser support

Target browsers are Chrome 35+, Firefox 30+, Safari 8+ and IE 18+.

Documentation

See generated API documentation.

Check out sprint.ly offline app

Use playground web page to try out the following Getting Started tutorial.

Unit tests: basic, entity-list, api-test

Getting started

Basic usage

All operations are asynchronous, and return Q.Promise.

var service = new sprintly.Service();
service.login(username, key); // this will return list of products after successful login
var product = new sprintly.Product(service, {id: 1, name: 'sprint.ly'});

Product has all sprint.ly entities available via Annotation, Attachment, Blocking, Comment, Deploy, Favorite, Item and People Entities providing CRUD and query operations.

CRUD operation on Entity are get, add (create), put (update or create) and delete. These operation will invalidate both server and local. On network error, the operation will be on service queue. If not on queue, the result on resolve callback is consistent with server value.

product.Item.get(123).then(function(x) {
  console.log(x);  // final data from server (~150 ms)
}, function(e) {
  throw e;        
}, function(x) {
  console.log(x);  // local cache data (~15 ms)
});

Query

Use ydn.db.Storage object on product.db to query data without hitting backend service.

# update cache to get fresh data, this will hit backend service
product.Item.update();

product.db.from('items').where('assigned_to', '=', 123).list().then(function(x) {
  console.log(x);
});

Database table name is entity name (in plural) in sprint.ly API path. All available index queries can be found on sprintly.Product.schema.

Loader

A loader is available for handling user session. Start the loader by sprint.run method.

sprintly.run(); 

Loader will dispatch sprintly-ready, sprintly-login, sprintly-login-fail and sprintly-logout events to window. Use sprintly-ready event to start your application.

window.addEventHandler('sprintly-ready', function(x) {
  sprintly.product['123'].Item.get(456);
});

sprintly.login(username, key, true); // save user name and password in `localStorage`.

Build

Generate documentation.

jsdoc src/sprintly/**.js -t jsdoc-template -c jsdoc.json -d ./doc
# only for first time
cp -r ~/work/jaguarjs-jsdoc/static/ ./doc/

Upload doc

gsutil -m cp -R doc/* gs://dev.yathit.com/sprintly/api-doc/
# just update html
gsutil -m cp doc/*.html gs://dev.yathit.com/sprintly/api-doc/

About

Javascript module for sprintly backend service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages