Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uuidv5 v1 #3683

Merged
merged 4 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/gatsby-source-lever/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"deep-map": "^1.5.0",
"deep-map-keys": "^1.2.0",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.4",
"uuid": "^3.1.0"
"lodash": "^4.17.4"
},
"deprecated": false,
"description": "Gatsby source plugin for building websites using the Lever.co Recruitment Software as a data source.",
Expand Down

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/gatsby-source-lever/src/__tests__/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe(`Process Lever data`, () => {
expect(entities).toMatchSnapshot()
})
it(`creates Gatsby IDs for each entity`, () => {
entities = normalize.createGatsbyIds(entities)
const createNodeId = jest.fn()
createNodeId.mockReturnValue(`uuid-from-gatsby`)
entities = normalize.createGatsbyIds(createNodeId, entities)
expect(entities).toMatchSnapshot()
})
it(`creates nodes for each entry`, () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-lever/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const normalize = require(`./normalize`)
const typePrefix = `lever__`

exports.sourceNodes = async (
{ boundActionCreators, getNode, store, cache },
{ boundActionCreators, getNode, store, cache, createNodeId },
{ site, verboseOutput }
) => {
const { createNode } = boundActionCreators
Expand All @@ -27,7 +27,7 @@ exports.sourceNodes = async (
entities = normalize.standardizeDates(entities)

// creates Gatsby IDs for each entity
entities = normalize.createGatsbyIds(entities)
entities = normalize.createGatsbyIds(createNodeId, entities)

// creates nodes for each entry
normalize.createNodesFromEntities({ entities, createNode })
Expand Down
6 changes: 2 additions & 4 deletions packages/gatsby-source-lever/src/normalize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const crypto = require(`crypto`)
const deepMapKeys = require(`deep-map-keys`)
const uuidv5 = require(`uuid/v5`)
const stringify = require(`json-stringify-safe`)

const conflictFieldPrefix = `lever_`
Expand Down Expand Up @@ -129,10 +128,9 @@ exports.standardizeDates = entities =>
return e
})

const seedConstant = `c2012db8-fafc-5a03-915f-e6016ff32086`
exports.createGatsbyIds = entities =>
exports.createGatsbyIds = (createNodeId, entities) =>
entities.map(e => {
e.id = uuidv5(e.lever_id.toString(), uuidv5(`lever`, seedConstant))
e.id = createNodeId(e.lever_id.toString())
return e
})

Expand Down
3 changes: 1 addition & 2 deletions packages/gatsby-source-wordpress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"gatsby-source-filesystem": "^1.5.14",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.4",
"qs": "^6.4.0",
"uuid": "^3.1.0"
"qs": "^6.4.0"
},
"deprecated": false,
"devDependencies": {
Expand Down
Loading