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

js-data-jsonapi

v0.0.0-alpha.21

Published

JsonApi adapter for js-data.

Downloads

145

Readme

#js-data-jsonapi

npm version npm downloads cicleci build Coveralls

###JsonApi Adapter for js-data This adapter implements the JsonApi Protocol and ties it to a js-data data store.

It ties

  • JsonApi types to js-data resource
  • JsonApi relations to js-data toOne, toMany Relationships

See the Project Wiki site for more information and examples (under construction)

##Goals |Goal|Status|Tests| |----|------|-----| |Serialize JsonApi requests|code complete |yes| |When deserializing JsonApi data add 'ParentIds' so that js-data belongsTo relationships can work|code complete|yes| |When deserializing JsonApi data add 'LocalKey/LocalKeys' or 'ForeignKeys' depending on js-data configurations so that js-data hasOne and hasMany relationships can work|code complete|yes| |Add metadata to indicate if an object is a jsonApi reference, indicating that it is partially populated only|code complete|yes| |Transparently request full objects when requested from js-data cache and object is a jsonApi reference only, e.g. Not fully populated| code complete|yes| |Store hyperlinking data within metadata of stored data|code complete|yes| |Use metadata hyperlinks to request related data from JsonApi data store|complete|yes| |Use metadata hyperlinks to add new items to relationships|Not started|No|

Known Issues

  1. Test coverage is pretty good.~~Testing is by no means complete, there are many more scenarios that need to be covered off~~
    • (Done).
  2. None of the xxxxAll adapter methods have been tested yet. e.g ~~findAll,~~ destroyAll, updateAll
    • findAll (done)
  3. Bower package has not been tested
  4. The code creates the DSHttpDataAdapter internally.
    • Allow the adapter to be injected or a constructor function passed via constructor options. (Done)
  5. Code is some what brittle in terms of requiring your js-data configuration to match very closely your jsonApi
    • Could look at adding additional configuration to allow flexible mapping between js-data and jsonapi
    • Further documentation required illustrating the relationships between JsonApi data structure and js-data configuration (Partially Done)
  6. I haven't actually tested this against a 3rd part JsonApi implementation yet like ember.
    • More testing to be done...... (In Progress)

Quick Start

npm install --save js-data js-data-http js-data-jsonapi or bower install --save js-data js-data-http js-data-jsonapi.

Load js-data-jsonapi.js after js-data-http.js and after js-data.js.

var adapter = new DSJsonApiAdapter.JsonApiAdapter();

var store = new JSData.DS();
store.registerAdapter('jsonApi', adapter, { default: true });

// "store" will now use the jsonApi adapter for all async operations

Or alternatively to use an existing HttpAdapter for example when using js-data-angular

.run(function(DS, DSHttpAdapter) {
    
    var options = {adapter:DSHttpAdapter};
    var adapter = new DSJsonApiAdapter.JsonApiAdapter(options);
    DS.registerAdapter('jsonApi', adapter, { default: true });
    ....
}

Version

0.0.0-alpha.21

Tech

js-data-jsonapi uses a number of open source projects to work properly:

License

The MIT License (MIT)

Copyright (c) 2015-2016 Blair Jacobs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.