contentful
Advanced tools
Comparing version 1.2.0 to 1.2.1
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
## v1.2.1 | ||
- Remove initial parameter on sync() call if nextSyncToken is also defined | ||
- Fix docs for sync() | ||
## v1.2.0 - 2015-10-13 | ||
@@ -5,0 +9,0 @@ - Allow response resolving to be turned off |
@@ -158,2 +158,3 @@ "use strict"; | ||
object.sync_token = object.nextSyncToken; | ||
delete object.initial; | ||
delete object.nextSyncToken; | ||
@@ -160,0 +161,0 @@ } |
@@ -122,2 +122,3 @@ 'use strict'; | ||
object.sync_token = object.nextSyncToken; | ||
delete object.initial; | ||
delete object.nextSyncToken; | ||
@@ -124,0 +125,0 @@ } |
{ | ||
"name": "contentful", | ||
"description": "Client for Contentful's Content Delivery API", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
124
README.md
@@ -69,2 +69,5 @@ # contentful.js [![Build Status](https://travis-ci.org/contentful/contentful.js.png?branch=master)](https://travis-ci.org/contentful/contentful.js) | ||
client.space() | ||
.then(function (space) { | ||
console.log(space.name) | ||
}) | ||
``` | ||
@@ -94,4 +97,9 @@ | ||
Links to other entries are not resolved when using this call. If you'd like to have your links resolved automatically, you should use the `entries()` call with [search parameters](#search-examples) | ||
```js | ||
client.entry('nyancat') | ||
.then(function (entry) { | ||
console.log(entry.id) | ||
}) | ||
``` | ||
@@ -131,18 +139,19 @@ | ||
client.entries({ content_type: 'cat' }) | ||
.then(function (entries) { | ||
console.log('Total entries:', entries.total) | ||
entries.forEach(function (entry) { | ||
console.log(entry.id) | ||
}) | ||
}) | ||
``` | ||
Returns a promise for a [collection][] of Entry objects: | ||
Returns a promise for a [collection][] of Entry objects, which is an array with 3 special properties: | ||
```js | ||
{ | ||
"sys": { | ||
"type": "Array" | ||
}, | ||
[ | ||
"total": 2, | ||
"skip": 0, | ||
"limit": 100, | ||
"items": [ | ||
/* Each item in the array is a full Entry object as shown above */ | ||
] | ||
} | ||
/* Each item in the array is a full Entry object as shown above */ | ||
] | ||
``` | ||
@@ -160,2 +169,4 @@ | ||
*Be aware that these search parameters are only applicable to `entries()` and not `entry()` | ||
Search entries that have been updated since the 1st of January, 2013: | ||
@@ -165,2 +176,5 @@ | ||
client.entries({ 'sys.updatedAt[gte]': '2013-01-01T00:00:00Z' }) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -172,2 +186,5 @@ | ||
client.entries({ 'sys.id[in]': 'finn,jake' ] }) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -182,2 +199,5 @@ | ||
}) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -193,2 +213,5 @@ | ||
client.entries({ query: 'bacon' }) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -203,2 +226,5 @@ | ||
}) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -213,2 +239,5 @@ | ||
}) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
@@ -220,2 +249,5 @@ client.entries({ | ||
}) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -229,2 +261,5 @@ | ||
}) | ||
.then(function (entries) { | ||
// ... | ||
}) | ||
``` | ||
@@ -242,2 +277,5 @@ | ||
client.asset('nyancat') | ||
.then(function (asset) { | ||
console.log(asset.fields.file.url) | ||
}) | ||
``` | ||
@@ -284,18 +322,18 @@ | ||
client.assets({ query: 'kitten' }) | ||
.then(function (assets) { | ||
assets.forEach(function (asset) { | ||
console.log(asset.fields.file.url) | ||
}) | ||
}) | ||
``` | ||
Returns a promise for a [collection][] of Asset objects: | ||
Returns a promise for a [collection][] of Asset objects, which is an array with 3 special properties: | ||
```js | ||
{ | ||
"sys": { | ||
"type": "Array" | ||
}, | ||
[ | ||
"total": 2, | ||
"skip": 0, | ||
"limit": 100, | ||
"items": [ | ||
/* Each item in the array is a full Asset object as shown above */ | ||
] | ||
} | ||
/* Each item in the array is a full Asset object as shown above */ | ||
] | ||
``` | ||
@@ -312,2 +350,5 @@ | ||
client.contentType('cat') | ||
.then(function (contentType) { | ||
console.log(contentType.name) | ||
}) | ||
``` | ||
@@ -339,17 +380,17 @@ | ||
client.contentTypes() | ||
.then(function (contentTypes) { | ||
contentTypes.forEach(function (contentType) { | ||
console.log(contentType.name) | ||
}) | ||
}) | ||
``` | ||
Returns a promise for a [collection][] of ContentType objects: | ||
Returns a promise for a [collection][] of ContentType objects, which is an array with 3 special properties: | ||
```js | ||
{ | ||
"sys": { | ||
"type": "Array" | ||
}, | ||
"total": 3, | ||
"skip": 0, | ||
"limit": 100, | ||
"items": [ | ||
/* Each item in the array is a full ContentType object as shown above */ | ||
] | ||
/* Each item in the array is a full ContentType object as shown above */ | ||
} | ||
@@ -364,3 +405,3 @@ ``` | ||
There are two supported options, pass `{ initial: true }` to start a brand new | ||
copy, or `{ syncToken: syncToken }` resume syncing using a token returned in a | ||
copy, or `{ nextSyncToken: syncToken }` resume syncing using a token returned in a | ||
previous call to `sync`. | ||
@@ -371,12 +412,18 @@ | ||
```js | ||
// E.g. by loading the token from persistent storage | ||
// Assuming you have some wrapper around browser storage | ||
var syncToken = storage.get('syncToken') | ||
var entries = storage.get('entries') | ||
var syncToken = getTokenFromLastRun() | ||
client.sync(token ? {syncToken: syncToken} : {initial: true}).then(function(data){ | ||
data.items.forEach(updateLocalCopy) | ||
if (syncToken !== data.nextSyncToken) { | ||
syncToken = data.nextSyncToken; | ||
return client.sync({syncToken: syncToken}) | ||
} | ||
client.sync(token ? {nextSyncToken: syncToken} : {initial: true}) | ||
.then(function(response){ | ||
response.items.forEach(function (entity) { | ||
if(entity.sys.type === 'Entry'){ | ||
entries[entity.sys.id] = entity | ||
} | ||
if(entity.sys.type === 'DeletedEntry'){ | ||
delete entries[entity.sys.id] | ||
} | ||
}) | ||
storage.set('entries', entries) | ||
storage.set('syncToken', data.nextSyncToken) | ||
}); | ||
@@ -435,11 +482,6 @@ ``` | ||
{ | ||
"sys": { | ||
"type": "Array" | ||
}, | ||
"total": 1, // Total number of items matching the query | ||
"skip": 0, // Offset into the result set represented by this response | ||
"limit": 100, // Effective limit on # of items returned in this response | ||
"items": [ | ||
// Full representations of each item | ||
] | ||
// Full representations of each item | ||
} | ||
@@ -446,0 +488,0 @@ ``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
357816
3172
490
1