ibm-connections-blogs
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -41,11 +41,14 @@ 'use strict'; | ||
const formatUrlTemplateOptions = _.merge({ | ||
valuesMap: { | ||
authType: { | ||
basic: '', | ||
saml: '', | ||
cookie: '', | ||
const formatUrlTemplateOptions = _.merge( | ||
{ | ||
valuesMap: { | ||
authType: { | ||
basic: '', | ||
saml: '', | ||
cookie: '', | ||
}, | ||
}, | ||
}, | ||
}, plugins.formatUrlTemplate || {}); | ||
plugins.formatUrlTemplate || {} | ||
); | ||
@@ -71,19 +74,23 @@ httpClient.use(formatUrlTemplatePlugin(formatUrlTemplateOptions)); | ||
// construct the request options | ||
const requestOptions = _.merge({ | ||
// defining defaults in here | ||
qs: { | ||
// despite the fact that the documentation for IBM Connections Cloud Blogs (6.0.0) says default value would be "1", it only works with "0" | ||
// https://www-10.lotus.com/ldd/appdevwiki.nsf/xpAPIViewer.xsp?lookupName=API+Reference#action=openDocument&res_title=Getting_a_feed_of_recent_posts_for_a_blog_ic50&content=apicontent | ||
page: 0, | ||
ps: 10, // max is 50 | ||
lang: 'en_us', | ||
const requestOptions = _.merge( | ||
{ | ||
// defining defaults in here | ||
qs: { | ||
// despite the fact that the documentation for IBM Connections Cloud Blogs (6.0.0) says default value would be "1", it only works with "0" | ||
// https://www-10.lotus.com/ldd/appdevwiki.nsf/xpAPIViewer.xsp?lookupName=API+Reference#action=openDocument&res_title=Getting_a_feed_of_recent_posts_for_a_blog_ic50&content=apicontent | ||
page: 0, | ||
ps: 10, // max is 50 | ||
lang: 'en_us', | ||
}, | ||
}, | ||
}, omitDefaultRequestParams(options), { | ||
qs: _.pick(query, qsValidParameters), | ||
headers: { | ||
accept: 'application/atom+xml', | ||
}, | ||
ttl: params.ttl.blogPosts, | ||
uri: `{ authType }/${query.handle}/feed/entries/atom`, | ||
}); | ||
omitDefaultRequestParams(options), | ||
{ | ||
qs: _.pick(query, qsValidParameters), | ||
headers: { | ||
accept: 'application/atom+xml', | ||
}, | ||
ttl: params.ttl.blogPosts, | ||
uri: `{ authType }/${query.handle}/feed/entries/atom`, | ||
} | ||
); | ||
@@ -122,15 +129,19 @@ httpClient.makeRequest(requestOptions, (requestError, response, body) => { | ||
// construct the request options | ||
const requestOptions = _.merge({ | ||
// defining defaults in here | ||
qs: { | ||
lang: 'en_us', | ||
const requestOptions = _.merge( | ||
{ | ||
// defining defaults in here | ||
qs: { | ||
lang: 'en_us', | ||
}, | ||
}, | ||
}, omitDefaultRequestParams(options), { | ||
qs: _.pick(query, qsValidParameters), | ||
headers: { | ||
accept: 'application/atom+xml', | ||
}, | ||
ttl: params.ttl.blogPost, | ||
uri: `{ authType }/${query.handle}/api/entries/${query.entryId}`, | ||
}); | ||
omitDefaultRequestParams(options), | ||
{ | ||
qs: _.pick(query, qsValidParameters), | ||
headers: { | ||
accept: 'application/atom+xml', | ||
}, | ||
ttl: params.ttl.blogPost, | ||
uri: `{ authType }/${query.handle}/api/entries/${query.entryId}`, | ||
} | ||
); | ||
@@ -137,0 +148,0 @@ httpClient.makeRequest(requestOptions, (requestError, response, body) => { |
@@ -29,20 +29,29 @@ 'use strict'; | ||
const parseUserInfo = node => node && { | ||
name: xpathSelect('string(atom:name/text())', node, true), | ||
userId: xpathSelect('string(snx:userid/text())', node, true), | ||
state: xpathSelect('string(snx:userState/text())', node, true), | ||
external: xpathSelect('boolean(snx:isExternal/text())', node, true), | ||
}; | ||
const parseUserInfo = node => | ||
node && { | ||
name: xpathSelect('string(atom:name/text())', node, true), | ||
userId: xpathSelect('string(snx:userid/text())', node, true), | ||
state: xpathSelect('string(snx:userState/text())', node, true), | ||
external: xpathSelect('boolean(snx:isExternal/text())', node, true), | ||
}; | ||
const parseRecommendations = (entry, collection) => entry && collection && { | ||
title: xpathSelect('string(atom:title/text())', collection, true), | ||
href: xpathSelect('string(@href)', collection, true), | ||
count: xpathSelect('number(snx:rank[@scheme="http://www.ibm.com/xmlns/prod/sn/recommendations"]/text())', entry, true), | ||
}; | ||
const parseRecommendations = (entry, collection) => | ||
entry && | ||
collection && { | ||
title: xpathSelect('string(atom:title/text())', collection, true), | ||
href: xpathSelect('string(@href)', collection, true), | ||
count: xpathSelect( | ||
'number(snx:rank[@scheme="http://www.ibm.com/xmlns/prod/sn/recommendations"]/text())', | ||
entry, | ||
true | ||
), | ||
}; | ||
const parseComments = (entry, collection) => entry && collection && { | ||
title: xpathSelect('string(atom:title/text())', collection, true), | ||
href: xpathSelect('string(@href)', collection, true), | ||
count: xpathSelect('number(snx:rank[@scheme="http://www.ibm.com/xmlns/prod/sn/comment"]/text())', entry, true), | ||
}; | ||
const parseComments = (entry, collection) => | ||
entry && | ||
collection && { | ||
title: xpathSelect('string(atom:title/text())', collection, true), | ||
href: xpathSelect('string(@href)', collection, true), | ||
count: xpathSelect('number(snx:rank[@scheme="http://www.ibm.com/xmlns/prod/sn/comment"]/text())', entry, true), | ||
}; | ||
@@ -73,3 +82,4 @@ module.exports = (stringOrXMLDoc, isEntryNode) => { | ||
'app:collection[atom:category[@term="recommend" and @scheme="http://www.ibm.com/xmlns/prod/sn/collection"]]', | ||
entryNode, true | ||
entryNode, | ||
true | ||
) | ||
@@ -82,3 +92,4 @@ ); | ||
'app:collection[atom:category[@term="comments" and @scheme="http://www.ibm.com/xmlns/prod/sn/collection"]]', | ||
entryNode, true | ||
entryNode, | ||
true | ||
) | ||
@@ -89,14 +100,18 @@ ); | ||
// link nodes are transformed into an object literal with properties "href" and "type" | ||
const links = _.reduce(linkSelectors, (result, selector, key) => { | ||
const linkNode = xpathSelect(selector, entryNode, true); | ||
if (linkNode) { | ||
Object.assign(result, { | ||
[key]: { | ||
href: linkNode.getAttribute('href'), | ||
type: linkNode.getAttribute('type'), | ||
}, | ||
}); | ||
} | ||
return result; | ||
}, {}); | ||
const links = _.reduce( | ||
linkSelectors, | ||
(result, selector, key) => { | ||
const linkNode = xpathSelect(selector, entryNode, true); | ||
if (linkNode) { | ||
Object.assign(result, { | ||
[key]: { | ||
href: linkNode.getAttribute('href'), | ||
type: linkNode.getAttribute('type'), | ||
}, | ||
}); | ||
} | ||
return result; | ||
}, | ||
{} | ||
); | ||
@@ -115,3 +130,5 @@ const author = parseUserInfo(xpathSelect('atom:author', entryNode, true)); | ||
return Object.assign(post, { recommendations, comments, links, author, contributor }); | ||
return Object.assign(post, { | ||
recommendations, comments, links, author, contributor, | ||
}); | ||
}; |
@@ -16,4 +16,3 @@ 'use strict'; | ||
return _.map(xpathSelect('/atom:feed/atom:entry', xmlDoc), entryNode => | ||
blogPostParser(entryNode, true)); | ||
return _.map(xpathSelect('/atom:feed/atom:entry', xmlDoc), entryNode => blogPostParser(entryNode, true)); | ||
}; |
{ | ||
"name": "ibm-connections-blogs", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "An IBM Connections Blogs API Wrapper", | ||
@@ -13,21 +13,21 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"async": "2.5.0", | ||
"lodash": "4.17.4", | ||
"oniyi-http-client": "1.1.1", | ||
"oniyi-http-plugin-credentials": "0.2.1", | ||
"oniyi-http-plugin-format-url-template": "1.0.2", | ||
"oniyi-logger": "1.0.0", | ||
"oniyi-utils-xml": "1.0.0" | ||
"async": "^2.5.0", | ||
"lodash": "^4.17.4", | ||
"oniyi-http-client": "^1.2.0", | ||
"oniyi-http-plugin-credentials": "^0.2.1", | ||
"oniyi-http-plugin-format-url-template": "^1.0.2", | ||
"oniyi-logger": "^1.0.0", | ||
"oniyi-utils-xml": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.21.0", | ||
"eslint": "3.15.0", | ||
"eslint-config-oniyi": "4.4.0", | ||
"eslint-plugin-ava": "4.2.1", | ||
"nock": "9.0.14", | ||
"nyc": "11.0.3" | ||
"ava": "^0.22.0", | ||
"eslint": "^4.8.0", | ||
"eslint-config-oniyi": "^5.0.2", | ||
"eslint-plugin-ava": "^4.2.2", | ||
"nock": "^9.0.22", | ||
"nyc": "^11.2.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/benkroeger/ibm-connections-blogs.git" | ||
"url": "git+ssh://git@github.com/benkroeger/ibm-connections-blogs.git" | ||
}, | ||
@@ -44,4 +44,4 @@ "author": "Benjamin Kroeger <benjamin.kroeger@gmail.com>", | ||
"files": [ | ||
"lib" | ||
"lib/" | ||
] | ||
} |
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
14199
299
+ Addedasync@2.6.4(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedlodash@4.17.154.17.21(transitive)
+ Addedms@2.1.3(transitive)
+ Addedoniyi-http-client@1.2.0(transitive)
+ Addedoniyi-http-plugin-credentials@0.2.2(transitive)
+ Addedoniyi-http-plugin-format-url-template@1.1.0(transitive)
+ Addedoniyi-utils-xml@1.1.2(transitive)
+ Addedxmldom@0.1.27(transitive)
+ Addedxpath@0.0.27(transitive)
- Removedasync@2.0.12.5.0(transitive)
- Removedlodash@4.15.04.17.4(transitive)
- Removedlodash.isstring@4.0.1(transitive)
- Removedoniyi-http-client@1.1.1(transitive)
- Removedoniyi-http-plugin-credentials@0.2.1(transitive)
- Removedoniyi-http-plugin-format-url-template@1.0.2(transitive)
- Removedoniyi-utils-xml@1.0.0(transitive)
- Removedxmldom@0.1.19(transitive)
- Removedxpath@0.0.24(transitive)
Updatedasync@^2.5.0
Updatedlodash@^4.17.4
Updatedoniyi-http-client@^1.2.0
Updatedoniyi-logger@^1.0.0
Updatedoniyi-utils-xml@^1.1.0