New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

contentful

Package Overview
Dependencies
Maintainers
5
Versions
466
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

test/integration/sync-test.js

4

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
## v1.1.0 - 2015-03-24
### Added
- Add support for the sync endpoint
## v1.0.0 - 2015-03-24
### Changed
- Replace `questor` with `axios`

@@ -93,2 +93,31 @@ 'use strict';

return nodeify(this._request(''), callback);
},
_pagedSync: function (sync) {
var self = this;
return this._request('/sync', sync.query)
.then(function (data) {
sync.append(data);
if(!sync.done){
return self._pagedSync(sync);
} else {
return {
items: sync.items,
nextSyncToken: sync.nextSyncToken
};
}
});
},
sync: function (object, callback) {
if (!object || (!object.initial && !object.nextSyncToken)) {
throw new Error('Please provide either the initial flag or a nextSyncToken for syncing');
}
var query = Query.parse(object);
var deferred = this._pagedSync(new Sync(query))
.then(function (response) {
response.items = SearchResult.parse(response);
return response;
});
return nodeify(deferred, callback);
}

@@ -222,2 +251,25 @@ });

var Sync = redefine.Class({
constructor: function Sync(query) {
this.query = query;
this.items = [];
this.done = false;
},
append: function (data) {
this.items = this.items.concat(data.items);
if(data.nextPageUrl){
var nextPageUrl = data.nextPageUrl.split('?');
this.query = _.omit(this.query, 'initial', 'sync_token');
this.query.sync_token = querystring.parse(nextPageUrl[1]).sync_token;
} else if(data.nextSyncUrl){
var nextSyncUrl = data.nextSyncUrl.split('?');
this.nextSyncToken = querystring.parse(nextSyncUrl[1]).sync_token;
this.done = true;
}
}
});
exports.createClient = function(options) {

@@ -224,0 +276,0 @@ return new Client(options || {});

2

package.json
{
"name": "contentful",
"description": "Client for Contentful's Content Delivery API",
"version": "1.0.0",
"version": "1.1.0",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -74,2 +74,15 @@ # contentful.js

});
var syncToken;
// Get all data in a space
client.sync({initial: true})
.then(function(data){
syncToken = data.nextSyncToken;
});
// Get all data since the last sync
client.sync({nextSyncToken: syncToken})
.then(function(data){
syncToken = data.nextSyncToken;
});
```

@@ -88,10 +101,6 @@

* .entries() = get entries of current space
* ...
* .sync() = get all the data in a space
### not supported
* Sync
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc