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
463
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 4.1.0 to 4.1.1

11

package.json
{
"name": "contentful",
"description": "Client for Contentful's Content Delivery API",
"version": "4.1.1",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",
"main": "index.js",
"main": "./dist/contentful.js",
"repository": {

@@ -24,3 +25,3 @@ "type": "git",

"lint": "eslint lib test",
"pretest": "standard lib/*.js && standard lib/**/*.js && standard test/**/*.js",
"pretest": "npm run lint",
"test:ci": "npm run build && ./node_modules/contentful-sdk-core/bin/test-ci.sh",

@@ -109,5 +110,2 @@ "test:cover": "BABEL_ENV=test babel-node ./node_modules/istanbul/lib/cli.js cover test/runner",

},
"publishConfig": {
"tag": "beta"
},
"config": {

@@ -117,4 +115,3 @@ "commitizen": {

}
},
"version": "4.1.0"
}
}
[![npm](https://img.shields.io/npm/v/contentful.svg)](https://www.npmjs.com/package/contentful)
[![Build Status](https://travis-ci.org/contentful/contentful.js.svg?branch=master)](https://travis-ci.org/contentful/contentful.js)
[![Coverage Status](https://coveralls.io/repos/github/contentful/contentful.js/badge.svg?branch=master)](https://coveralls.io/github/contentful/contentful.js?branch=master)
[![Dependency Status](https://david-dm.org/contentful/contentful.js.svg)](https://david-dm.org/contentful/contentful.js)
[![devDependency Status](https://david-dm.org/contentful/contentful.js/dev-status.svg)](https://david-dm.org/contentful/contentful.js#info=devDependencies)
[![Dependency Status](https://img.shields.io/david/contentful/contentful.js.svg)](https://david-dm.org/contentful/contentful.js)
[![devDependency Status](https://img.shields.io/david/dev/contentful/contentful.js.svg)](https://david-dm.org/contentful/contentful.js#info=devDependencies)

@@ -24,4 +24,2 @@ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## Supported environments
Browsers and Node.js:

@@ -32,3 +30,3 @@ - Chrome

- Safari
- node.js (0.10, iojs-3.x, 4.x, 5.x)
- node.js (4.x, 6.x)

@@ -41,2 +39,10 @@ Other browsers should also work, but at the moment we're only running automated tests on the browsers and Node.js versions specified above.

- [Installation](#installation)
- [Authentication](#authentication)
- [Your first request](#your-first-request)
- [Using this SDK with the Preview API](#using-this-SDK-with-the-Preview-API)
- [Advanced features](#advanced-features)
- [Troubleshooting](#troubleshooting)
- [Documentation/References](#documentationreferences)
## Installation

@@ -50,6 +56,6 @@

Or, if you'd like to use a standalone built file you can use the following script tag or just download it from [unpkg](https://unpkg.com), under the `browser-dist` directory:
Or, if you'd like to use a standalone built file you can use the following script tag or just download it from [unpkg](https://unpkg.com), under the `dist` directory:
``` html
<script src="https://unpkg.com/contentful@latest/browser-dist/contentful.min.js"></script>
<script src="https://unpkg.com/contentful@latest/dist/contentful.min.js"></script>
```

@@ -61,3 +67,3 @@ **It is not recommended to use the above URL for production.**

``` html
<script src="https://unpkg.com/contentful@3.0.0/browser-dist/contentful.min.js"></script>
<script src="https://unpkg.com/contentful@4.1.0/dist/contentful.min.js"></script>
```

@@ -101,3 +107,4 @@

```js
var client = contentful.createClient({
const contentful = require('contentful')
const client = contentful.createClient({
space: 'developer_bookshelf',

@@ -111,2 +118,98 @@ accessToken: 'preview_0b7f6x59a0',

## Advanced features
### Link resolution
contentful.js does, by default, resolve links unless specified otherwise.
To disable it just set `resolveLinks` to `false` when creating the Contentful client. Like so
```js
const contentful = require('contentful')
const client = contentful.createClient({
accessToken:'<you-access-token>',
space: '<your-space-id>',
resolveLinks: false
})
```
Please note that the link resolution is only possible when requesting records from the collection endpoint using `client.getEntries()` or by doing initial sync `client.sync({initial: true})`. In case you want to request one entry and benefit from the link resolution you can use the collection end point with query param `'sys.id': '<your-entry-id>'`.
**e.g.** assuming that you have a contentType `post` that has a reference field `author`
```js
const contentful = require('contentful')
const client = contentful.createClient({
accessToken:'<you-access-token>',
space: '<your-space-id>',
})
// getting a specific Post
client.getEntries({'sys.id': '<entry-id>'}).then((response) => {
// output the author name
console.log(response.items[0].fields.author.fields.name)
})
```
The link resolution resolves, by default, one level deep. If you need more you can specify the `include` param in the query when fetching your entries like so `client.getEntries({include: <value>})`, you can specify up to 10.
### Sync
The Sync API allows you to keep a local copy of all content in a space up-to-date via delta updates, or content that has changed.
Whenever you perform a sync operation the endpoint will send back a `syncToken` which you can use in a subsequent sync to get only the changed data (update, deletion etc..).
**e.g.**
```js
const contentful = require('contentful')
const client = contentful.createClient({
accessToken:'<you-access-token>',
space: '<your-space-id>',
})
// first time you are syncing make sure to spcify `initial: true`
client.sync({initial: true}).then((response) => {
// You should save the `nextSyncToken` to use in the following sync
console.log(response.nextSyncToken)
})
```
The SDK will go through all the pages for you and gives you back a response object with the full data so you don't need to handle pagination.
### Querying & Search parameters
You can pass your query params as `key: value` pairs in the query object whenever request a resource.
**e.g.**
```js
const contentful = require('contentful')
const client = contentful.createClient({
accessToken:'<you-access-token>',
space: '<your-space-id>',
})
// getting a specific Post
client.getEntries({'sys.id': '<entry-id>'}).then((response) => {
// output the author name
console.log(response.items[0].fields.author.fields.name)
})
// You can pass a query when requesting a single entity
client.getEntry('<entry-id>', {key: value})
```
for more infos about the search paramaters check the [documentation](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters)
## Troubleshooting
- **I can't import contentful into react native projects**
- You can check this boilerplate project [here](https://github.com/Khaledgarbaya/ContentfulReactNative-boilerplate) to help getting started
- **Link resolution does not work when using `client.getEntry('<entry-id>')`**
- Link resolution does not work with the single entity endpoint, you can use `client.getEntries({'sys.id': '<entry-id>'})` to link an entry with resolved links
- **I Can't Install the package via npm**
- Check your internet connection
- It is called `contentful` and not `contenful` ¯\_(ツ)_/¯
- **Can I use it with typescript?**
- Yes, there is also a type definition file
- **Is there a caching done by the SDK ?**
- No, check this [issue](https://github.com/contentful/contentful.js/issues/83) for more infos
- 😱 **something is wrong what should I do?**
- If it is a bug related to the code create a Github issue and make sure to remove any credential for your code before sharing it.
- If you need to share your credentials, for example you have an issue with your space, please create a support ticket.
## Documentation/References

@@ -146,4 +249,7 @@

## Migration from contentful.js 3.x
From version 4.0.0 and up contenful.js is exported as a single `umd` bundle the cdn distribution has changed, there is no more `browser-dist`. the new link format is https://unpkg.com/contentful@version/dist/contentful.min.js instead of https://unpkg.com/contentful@version/browser-dist/contentful.min.js. to access version 3 you can still use https://unpkg.com/contentful@3.0.0/browser-dist/contentful.min.js
## Migration from contentful.js 2.x and older
contentful.js 3.x was a major rewrite, with some API changes. While the base functionality remains the same, some method names have changed, as well as some internal behaviors.

@@ -150,0 +256,0 @@

@@ -1,1 +0,1 @@

module.exports = '4.1.0'
module.exports = '4.1.1'

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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