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

sprintly-data

v2.2.0

Published

JavaScript models and collections for the Sprintly API

Downloads

43

Readme

Sprintly JavaScript SDK

Models and Collections for the Sprintly API

wercker status

Installation

npm (Browserify / Webpack / node / iojs):

npm install --save sprintly-data

UMD bundle (AMD, global variable) is also available via npm install.

Usage

The Client takes and email and API key and returns a client object with a Products Collection and a User Model.

var sprintly = require('sprintly-data');
var client = sprintly.createClient(email, apiKey);
// => {
//     VERSION: 1.1.0,
//     products: [Backbone.Collection],
//     user: [Backbone.Model]
//   }

Alternately, you can provide an OAuth token:

var client = sprintly.createClient({ token: 'xxxAbc123'});

These objects are "empty" when you first create them, so you'll need to call fetch make a request to the API. This works just like Backbone.Collection#fetch.

client.products.fetch();
// => [Promise]

Items are accessed through filter collections attached to the items' product.

var myProduct = clients.products.get(1);
var backlog = myProduct.getItemsByStatus('backlog');

backlog.fetch(function(items) {
  // backlog items loaded
})

A backing collection that uses backbone-supermodel is also available on a product model, as well as the Item supermodel.

myProduct.items
// => [Backbone.Collection]

myProduct.ItemModel
// => [Supermodel.Model]

API

sprintly.createClient(email, apiKey)

sprintly.createClient({ token: })

Create an instance of the sprintly-data client. This can be done with your username and API key, or with an OAuth token (NB: you will also need a client server to facilitate OAuth login.)

Products

client.products

Instance of Backbone.Collection containing a user's products. Use fetch() to populate with data.

Items

If you want to consume the full collection, you'll find the collectionConsumer function handy. It returns a promise for when the collection has been fully filled.

var promise = sprintly.collectionConsumer(product.getItemsByStatus('backlog'))
promise.then(function () {
  console.log('all done');
});
promise.progess(function () {
  console.log('first page of results have loaded');
});

product.items

A Backbone Collection that contains all items that have been fetched from the server

product.getItemsByStatus(status)

Creat an empty collection that can retrive items for a status. Returns and instance of Backbone.Collection.

product.createItem(attrs, options)

Create a new item. Return an instance of product.ItemModel.

product.members

A Backbone Collection for all of the users belonging to the product. Use product.members.fetch() to populate with data from the server.

product.tags

A Backbone Collecion with the Tags associated with the product. Use products.tags.fetch() to populated with data from the server.

Development

Prerequisites

  • node >= 0.10 and npm
$ npm install

Tests

The full test suite requires a Sprintly account with an api key and the id of product you want to use during testing.

$ export [email protected] \
    SPRINTLY_API_KEY=abc123 \
    SPRINTLY_PRODUCT_ID=54321

Then run the test suite with:

$ npm test

Or if you'd like to run tests in the browser, build the test bundle and open the html runner in your favorite browser.

$ npm run build-test
$ open test/index.html

To run a partial test suite (unit tests only), use the gulp task:

$ gulp test

Build Tasks

To build just the standalone browser bundle, run:

$ npm run build

To build a minified standalone browser bundle, run:

$ npm run prepublish

To build the files for the browser based test suite, run:

$ npm run build-test

Or, re-build the test files any time a file changes with:

$ npm run watch-test

Lint files

$ gulp lint

Internal Development Tools

If you need to point to a non-production sprint.ly server you can set the following global variable before loading sprintly-data:

var __sprintly_data_config = { BASE_URL: 'https://sprint.ly/api' };