@velocitycareerlabs/data-loader 1.21.0-dev-build.116437e4c → 1.21.0-dev-build.1a4a52f69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@velocitycareerlabs/data-loader",
|
3
|
-
"version": "1.21.0-dev-build.
|
3
|
+
"version": "1.21.0-dev-build.1a4a52f69",
|
4
4
|
"description": "A tool for uploading data to the different target systems.",
|
5
5
|
"repository": "https://github.com/velocitycareerlabs/packages",
|
6
6
|
"main": "src/index.js",
|
@@ -38,7 +38,8 @@
|
|
38
38
|
"handlebars": "~4.7.7",
|
39
39
|
"inquirer": "^8.0.0",
|
40
40
|
"lodash": "~4.17.20",
|
41
|
-
"nanoid": "3.3.1"
|
41
|
+
"nanoid": "3.3.1",
|
42
|
+
"strip-bom-stream": "^4.0.0"
|
42
43
|
},
|
43
|
-
"gitHead": "
|
44
|
+
"gitHead": "a3ee6110e07a97077a2b8060a41b67f730d2a664"
|
44
45
|
}
|
package/src/helpers/load-csv.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
const csv = require('csv-parser');
|
3
|
+
const stripBom = require('strip-bom-stream');
|
3
4
|
const { isString, indexOf } = require('lodash/fp');
|
4
5
|
|
5
6
|
const loadCsv = (fileName) => {
|
@@ -7,6 +8,7 @@ const loadCsv = (fileName) => {
|
|
7
8
|
const csvRows = [];
|
8
9
|
let csvHeaders;
|
9
10
|
fs.createReadStream(fileName)
|
11
|
+
.pipe(stripBom())
|
10
12
|
.pipe(csv())
|
11
13
|
.on('headers', (headers) => {
|
12
14
|
// eslint-disable-next-line better-mutation/no-mutation
|
@@ -1095,6 +1095,95 @@ describe('batch issuing test', () => {
|
|
1095
1095
|
});
|
1096
1096
|
});
|
1097
1097
|
|
1098
|
+
it('should handle csv with BOM characters', async () => {
|
1099
|
+
const options = {
|
1100
|
+
csvFilename: path.join(__dirname, 'data/with-bom.csv'),
|
1101
|
+
offerTemplateFilename: path.join(
|
1102
|
+
__dirname,
|
1103
|
+
'data/email-offer.template.json'
|
1104
|
+
),
|
1105
|
+
termsUrl: 'http://example.com/terms.html',
|
1106
|
+
did: 'did:ion:sap123',
|
1107
|
+
idCredentialType: 'EmailV1.0',
|
1108
|
+
vendorUseridColumn: 'email',
|
1109
|
+
new: true,
|
1110
|
+
dryrun: true,
|
1111
|
+
};
|
1112
|
+
|
1113
|
+
const updates = await runBatchIssuing(options);
|
1114
|
+
expect(
|
1115
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
1116
|
+
).toBeLessThan(Date.now());
|
1117
|
+
|
1118
|
+
expect(updates).toEqual({
|
1119
|
+
disclosureRequest: {
|
1120
|
+
configurationType: 'issuing',
|
1121
|
+
vendorEndpoint: 'integrated-issuing-identification',
|
1122
|
+
types: [
|
1123
|
+
{
|
1124
|
+
type: 'EmailV1.0',
|
1125
|
+
},
|
1126
|
+
],
|
1127
|
+
identityMatchers: {
|
1128
|
+
rules: [
|
1129
|
+
{
|
1130
|
+
valueIndex: 0,
|
1131
|
+
path: ['$.emails'],
|
1132
|
+
rule: 'pick',
|
1133
|
+
},
|
1134
|
+
],
|
1135
|
+
vendorUserIdIndex: 2,
|
1136
|
+
},
|
1137
|
+
vendorDisclosureId: expect.any(Number),
|
1138
|
+
setIssuingDefault: true,
|
1139
|
+
duration: '1h', // 1 hour by default
|
1140
|
+
offerMode: 'preloaded',
|
1141
|
+
purpose: 'Issuing Career Credential', // by default have a generic message
|
1142
|
+
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
1143
|
+
termsUrl: 'http://example.com/terms.html',
|
1144
|
+
authTokenExpiresIn: 525600,
|
1145
|
+
},
|
1146
|
+
newExchangeOffers: [
|
1147
|
+
{
|
1148
|
+
newOffer: {
|
1149
|
+
type: ['EmailV1.0'],
|
1150
|
+
issuer: {
|
1151
|
+
id: 'did:ion:sap123',
|
1152
|
+
},
|
1153
|
+
credentialSubject: {
|
1154
|
+
vendorUserId: 'joan.lee@sap.com',
|
1155
|
+
email: 'joan.lee@sap.com',
|
1156
|
+
},
|
1157
|
+
|
1158
|
+
offerId: expect.any(String),
|
1159
|
+
},
|
1160
|
+
newExchange: {
|
1161
|
+
type: 'ISSUING',
|
1162
|
+
identityMatcherValues: ['joan.lee@sap.com'],
|
1163
|
+
},
|
1164
|
+
},
|
1165
|
+
{
|
1166
|
+
newOffer: {
|
1167
|
+
type: ['EmailV1.0'],
|
1168
|
+
issuer: {
|
1169
|
+
id: 'did:ion:sap123',
|
1170
|
+
},
|
1171
|
+
credentialSubject: {
|
1172
|
+
vendorUserId: 'john.smith@sap.com',
|
1173
|
+
email: 'john.smith@sap.com',
|
1174
|
+
},
|
1175
|
+
|
1176
|
+
offerId: expect.any(String),
|
1177
|
+
},
|
1178
|
+
newExchange: {
|
1179
|
+
type: 'ISSUING',
|
1180
|
+
identityMatcherValues: ['john.smith@sap.com'],
|
1181
|
+
},
|
1182
|
+
},
|
1183
|
+
],
|
1184
|
+
});
|
1185
|
+
});
|
1186
|
+
|
1098
1187
|
it('should load the templates and csv with vars', async () => {
|
1099
1188
|
const options = {
|
1100
1189
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|