gatsby-teamtailor-users
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,16 +0,37 @@ | ||
const fetch = require('node-fetch'); | ||
const crypto = require('crypto') | ||
const fetch = require("node-fetch"); | ||
const crypto = require("crypto"); | ||
exports.sourceNodes = async ({ boundActionCreators, createNodeId }, configOptions) => { | ||
const { createNode } = boundActionCreators; | ||
delete configOptions.plugins | ||
const { data: users } = await fetch("https://api.teamtailor.com/v1/users", { | ||
const getTeamtailorUsers = async ({ token, url }) => { | ||
const { data, links } = await fetch(url, { | ||
headers: { | ||
"Authorization": `Token token=${configOptions.token}`, | ||
Authorization: `Token token=${token}`, | ||
"X-Api-Version": "20161108" | ||
} | ||
}).then(response => response.json()) | ||
}) | ||
.then(response => response.json()) | ||
.catch(() => { | ||
throw new Error("Failed to fetch teamtailor users"); | ||
}); | ||
if (links.next) { | ||
const nextData = await getTeamtailorUsers({ token, url: links.next }); | ||
return [...data, ...nextData]; | ||
} | ||
return data; | ||
}; | ||
exports.sourceNodes = async ( | ||
{ boundActionCreators, createNodeId }, | ||
configOptions | ||
) => { | ||
const { createNode } = boundActionCreators; | ||
delete configOptions.plugins; | ||
const users = await getTeamtailorUsers({ | ||
token: configOptions.token, | ||
url: "https://api.teamtailor.com/v1/users" | ||
}); | ||
const transformedUsers = users.map(({ id, attributes }) => ({ | ||
@@ -22,5 +43,9 @@ teamtailorId: id, | ||
standard: attributes.picture ? attributes.picture.standard : null, | ||
large: attributes.picture ? attributes.picture.standard.replace("h_160", "h_1024").replace("w_160", "w_1024") : null | ||
large: attributes.picture | ||
? attributes.picture.standard | ||
.replace("h_160", "h_1024") | ||
.replace("w_160", "w_1024") | ||
: null | ||
} | ||
})) | ||
})); | ||
@@ -35,5 +60,5 @@ return transformedUsers.map(user => | ||
contentDigest: crypto | ||
.createHash('md5') | ||
.createHash("md5") | ||
.update(JSON.stringify(user)) | ||
.digest('hex'), | ||
.digest("hex"), | ||
content: JSON.stringify(user), | ||
@@ -43,3 +68,3 @@ type: "TeamtailorUser" | ||
}) | ||
);; | ||
); | ||
}; |
{ | ||
"name": "gatsby-teamtailor-users", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A plugin for getting teamtailor users in gatsby", | ||
@@ -5,0 +5,0 @@ "main": "gatsby-node.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11061
5
59
1