-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from nishant-jain-94/dev
Added plugin to transform value of type string to map with supporting config file
- Loading branch information
Showing
14 changed files
with
190 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
# Changelog | ||
|
||
## v1.0.0 | ||
## v1.1.0 | ||
|
||
#### :rocket: Features | ||
#### :rocket: Added Features | ||
|
||
- Added options to convert transform string values into map using a pluginType named `transformPropertyToMap` | ||
|
||
#### :fire: Removed | ||
- Removed files `mergeUsers.js` and `mergeGroups.js` which was being unused | ||
|
||
- Merge all the `CSV` files and convert into single `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` object, assign it to a `JSON field` an then store it in a `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field and then store it to a `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field, assign the object to a `JSON` field and then store it to a `JSON` file. | ||
|
||
## v1.0.1 | ||
|
||
#### :bug: Bug Fixes | ||
|
||
- Removed the code which was trying to read a file which didn't existed, a junk which creeped during the development cycle. | ||
|
||
## v1.0.0 | ||
|
||
#### :rocket: Features | ||
|
||
- Merge all the `CSV` files and convert into single `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` object, assign it to a `JSON field` an then store it in a `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field and then store it to a `JSON` file. | ||
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field, assign the object to a `JSON` field and then store it to a `JSON` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
const { transformPropertyToMap } = require('../../lib/transformPropertyToMap.js'); | ||
|
||
test('Should be able to convert value of type string to map', (done) => { | ||
const transformerConfig = { | ||
pluginType: 'transformPropertyToMap', | ||
keyValueSplitter: ':', | ||
propertySplitter: ',', | ||
keyIndex: '0', | ||
valueIndex: '1', | ||
field: 'groups_access', | ||
}; | ||
|
||
const data = [ | ||
{ | ||
username: 'john.doe', | ||
email: 'john.doe@northwind.in', | ||
password: 'password@123', | ||
groups_access: 'northwind-group:guest,northwind-auditors:guest', | ||
}, | ||
]; | ||
|
||
const expected = [ | ||
{ | ||
username: 'john.doe', | ||
email: 'john.doe@northwind.in', | ||
password: 'password@123', | ||
groups_access: { | ||
'northwind-group': 'guest', | ||
'northwind-auditors': 'guest', | ||
}, | ||
}, | ||
]; | ||
|
||
transformPropertyToMap(transformerConfig, data, (err, transformedData) => { | ||
expect(transformedData).toMatchObject(expected); | ||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
const async = require('async'); | ||
|
||
const { getLogger } = require('./logger'); | ||
const { csvToJson } = require('./csvToJson'); | ||
|
||
const log = getLogger('concatFiles'); | ||
|
||
const concatFilesCb = (callback) => (err, values) => callback(err, values); | ||
|
||
const concatFiles = (files) => (callback) => { | ||
const concatFiles = (files, iteratee) => (callback) => { | ||
log.trace('Resolved to the following files:'); | ||
files.forEach((file) => log.trace(file)); | ||
return async | ||
.concat(files, csvToJson, concatFilesCb(callback)); | ||
.concat(files, iteratee, concatFilesCb(callback)); | ||
}; | ||
|
||
module.exports = { concatFiles, concatFilesCb }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const async = require('async'); | ||
// const async = require('async'); | ||
|
||
const { concatFiles } = require('./concatFiles'); | ||
const { keyBy } = require('./keyBy'); | ||
const { writeToFile } = require('./writeToFile'); | ||
// const { concatFiles } = require('./concatFiles'); | ||
// const { keyBy } = require('./keyBy'); | ||
// const { writeToFile } = require('./writeToFile'); | ||
// const { csvToJson } = require('./csvToJson'); | ||
|
||
const mergeGroups = (groupFiles, mergedGroupsFilePath, cb) => async.waterfall([ | ||
concatFiles(groupFiles), | ||
keyBy('group_name'), | ||
writeToFile(mergedGroupsFilePath), | ||
], cb); | ||
// const mergeGroups = (groupFiles, mergedGroupsFilePath, cb) => async.waterfall([ | ||
// concatFiles(groupFiles, csvToJson), | ||
// keyBy('group_name'), | ||
// writeToFile(mergedGroupsFilePath), | ||
// ], cb); | ||
|
||
module.exports = { mergeGroups }; | ||
// module.exports = { mergeGroups }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const async = require('async'); | ||
// const async = require('async'); | ||
|
||
const { concatFiles } = require('./concatFiles'); | ||
const { keyBy } = require('./keyBy'); | ||
const { writeToFile } = require('./writeToFile'); | ||
// const { concatFiles } = require('./concatFiles'); | ||
// const { keyBy } = require('./keyBy'); | ||
// const { writeToFile } = require('./writeToFile'); | ||
// const { csvToJson } = require('./csvToJson'); | ||
|
||
const mergeUsers = (userFiles, mergedUsersFilePath, cb) => async.waterfall([ | ||
concatFiles(userFiles), | ||
keyBy('email'), | ||
writeToFile(mergedUsersFilePath), | ||
], cb); | ||
// const mergeUsers = (userFiles, mergedUsersFilePath, cb) => async.waterfall([ | ||
// concatFiles(userFiles, csvToJson), | ||
// keyBy('email'), | ||
// writeToFile(mergedUsersFilePath), | ||
// ], cb); | ||
|
||
module.exports = { mergeUsers }; | ||
// module.exports = { mergeUsers }; |
Oops, something went wrong.