Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-resolve-response

Package Overview
Dependencies
Maintainers
5
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-resolve-response - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

CHANGELOG.md

23

index.js

@@ -71,2 +71,15 @@ const cloneDeep = require('lodash/cloneDeep');

const makeEntryObject = (item, itemEntryPoints) => {
if (!Array.isArray(itemEntryPoints)) {
return item;
}
const entryPoints = Object.keys(item).filter((ownKey) => itemEntryPoints.includes(ownKey));
return entryPoints.reduce((entryObj, entryPoint) => {
entryObj[entryPoint] = item[entryPoint];
return entryObj;
}, {});
};
/**

@@ -78,2 +91,3 @@ * resolveResponse Function

* @param {Boolean} options.removeUnresolved - Remove unresolved links default:false
* @param {Array<String>} options.itemEntryPoints - Resolve links only in those item properties
* @return {Object}

@@ -94,5 +108,8 @@ */

.forEach((item) => {
Object.assign(item, {
fields: walkMutate(item.fields, isLink, (link) => normalizeLink(allEntries, link, options.removeUnresolved))
});
const entryObject = makeEntryObject(item, options.itemEntryPoints);
Object.assign(
item,
walkMutate(entryObject, isLink, (link) => normalizeLink(allEntries, link, options.removeUnresolved))
);
});

@@ -99,0 +116,0 @@

14

package.json
{
"name": "contentful-resolve-response",
"version": "1.0.2",
"version": "1.1.0",
"description": "",

@@ -9,4 +9,7 @@ "main": "index.js",

"test": "npm run lint && npm run test-unit",
"test-unit": "mocha 'test/**/*-test.js'",
"test-watch": "npm run test-unit -- --watch"
"test-unit": "nyc mocha 'test/**/*-test.js'",
"test-watch": "npm run test-unit -- --watch",
"test-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"precommit": "npm run lint",
"prepush": "npm run test"
},

@@ -20,2 +23,3 @@ "repository": {

"chai": "^4.1.1",
"codecov": "^3.0.0",
"dirty-chai": "^2.0.1",

@@ -28,3 +32,5 @@ "eslint": "^4.4.1",

"eslint-plugin-standard": "^3.0.1",
"mocha": "^4.1.0"
"husky": "^0.14.3",
"mocha": "^4.1.0",
"nyc": "^11.4.1"
},

@@ -31,0 +37,0 @@ "author": "Contentful GmbH",

# contentful-resolve-response
[![Build Status](https://travis-ci.org/contentful/contentful-resolve-response.svg?branch=master)](https://travis-ci.org/contentful/contentful-resolve-response)
[![codecov](https://codecov.io/gh/contentful/contentful-resolve-response/branch/master/graph/badge.svg)](https://codecov.io/gh/contentful/contentful-resolve-response)
Suppose you have a Contentful query's response JSON. The links are

@@ -37,3 +40,3 @@ nice, but what we really usually need is the response with a resolved

someValue: 'wow',
// Link gets replaced by the actual object from `includes.Entry`

@@ -40,0 +43,0 @@ someLink: {sys: {type: 'Entry', id: 'suchId'}, very: 'doge'}

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