@velocitycareerlabs/data-loader 1.19.0-dev-build.11b7cc7b6

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.
Files changed (51) hide show
  1. package/LICENSE +248 -0
  2. package/jest.config.js +7 -0
  3. package/package.json +43 -0
  4. package/src/batch-issuing/README.md +95 -0
  5. package/src/batch-issuing/constants.js +8 -0
  6. package/src/batch-issuing/fetchers.js +100 -0
  7. package/src/batch-issuing/file-readers.js +15 -0
  8. package/src/batch-issuing/file-writers.js +37 -0
  9. package/src/batch-issuing/index.js +115 -0
  10. package/src/batch-issuing/orchestrators.js +258 -0
  11. package/src/batch-issuing/prepare-data.js +208 -0
  12. package/src/batch-issuing/prompts.js +47 -0
  13. package/src/batch-issuing/validate-directory-exists.js +11 -0
  14. package/src/data-loader.js +14 -0
  15. package/src/helpers/common.js +30 -0
  16. package/src/helpers/compute-activation-date.js +12 -0
  17. package/src/helpers/index.js +6 -0
  18. package/src/helpers/load-csv.js +29 -0
  19. package/src/helpers/load-handlebars-template.js +9 -0
  20. package/src/index.js +3 -0
  21. package/src/vendor-credentials/README.md +32 -0
  22. package/src/vendor-credentials/execute-update.js +32 -0
  23. package/src/vendor-credentials/index.js +53 -0
  24. package/src/vendor-credentials/prepare-data.js +40 -0
  25. package/test/batch-issuing.test.js +916 -0
  26. package/test/data/badge-offer.template.json +22 -0
  27. package/test/data/batch-vars-offerids.csv +3 -0
  28. package/test/data/batch-vars.csv +3 -0
  29. package/test/data/batchissuing-variables.csv +3 -0
  30. package/test/data/driver-license-offer.template.json +10 -0
  31. package/test/data/driver-license-variables.csv +3 -0
  32. package/test/data/email-offer.template.json +10 -0
  33. package/test/data/email-variables.csv +3 -0
  34. package/test/data/id-document-offer.template.json +10 -0
  35. package/test/data/id-document-variables.csv +3 -0
  36. package/test/data/national-id-card-offer.template.json +10 -0
  37. package/test/data/national-id-card-variables.csv +3 -0
  38. package/test/data/offer.template.json +22 -0
  39. package/test/data/passport-offer.template.json +10 -0
  40. package/test/data/passport-variables.csv +3 -0
  41. package/test/data/person.template.json +15 -0
  42. package/test/data/phone-offer.template.json +10 -0
  43. package/test/data/phone-variables.csv +2 -0
  44. package/test/data/phones-batch-vars-offerids.csv +3 -0
  45. package/test/data/proof-of-age-offer.template.json +10 -0
  46. package/test/data/proof-of-age-variables.csv +3 -0
  47. package/test/data/resident-permit-offer.template.json +10 -0
  48. package/test/data/resident-permit-variables.csv +3 -0
  49. package/test/data/variables-no-did.csv +3 -0
  50. package/test/data/variables.csv +3 -0
  51. package/test/vendor-credentials.test.js +225 -0
@@ -0,0 +1,22 @@
1
+ {
2
+ "type": ["OpenBadgeV2.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{email}}",
8
+ "hasCredential": {
9
+ "name" : "Microsoft Inspire Attendance",
10
+ "description" : "Digital Badge for the Conference Attendees",
11
+ "type" : "BadgeClass",
12
+ "issuer" : {
13
+ "type": "Profile",
14
+ "id": "{{did}}",
15
+ "name": "Microsoft",
16
+ "url": "https://microsoft.com"
17
+ },
18
+ "image": "https://example.com/badge-image.png",
19
+ "criteria": "Criteria ABC"
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ email,givenName,familyName,offerId
2
+ joan.lee@sap.com,Joan,Lee,100
3
+ john.smith@sap.com,John,Smith,200
@@ -0,0 +1,3 @@
1
+ email,givenName,familyName
2
+ joan.lee@sap.com,Joan,Lee
3
+ john.smith@sap.com,John,Smith
@@ -0,0 +1,3 @@
1
+ givenName,familyName,email,did
2
+ Joan,Lee,joan.lee@sap.com,did:ion:sap123
3
+ John,Smith,john.smith@sap.com,did:ion:sap123
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["DriversLicenseV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,vm123456,did:ion:sap123
3
+ John,Smith,as4523456,did:ion:sap123
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["EmailV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{email}}",
8
+ "email": "{{email}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,phone,did
2
+ Joan,Lee,+123456,did:ion:sap123
3
+ John,Smith,+4523456,did:ion:sap123
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["IdDocumentV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,BR514345,did:ion:sap123
3
+ John,Smith,BT678543,did:ion:sap321
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["NationalIdCardV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,BR514345,did:ion:sap123
3
+ John,Smith,BT678543,did:ion:sap321
@@ -0,0 +1,22 @@
1
+ {
2
+ "type": ["OpenBadgeV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{email}}",
8
+ "holds": {
9
+ "name" : "SAP Sapphire Attendance",
10
+ "description" : "Digital Badge for the Conference Attendees of SAPs Sapphire Conference",
11
+ "type" : "BadgeClass",
12
+ "issuer" : {
13
+ "type": "Profile",
14
+ "id": "{{did}}",
15
+ "name": "SAP",
16
+ "uri": "https://sap.com"
17
+ },
18
+ "image": "https://example.com/badge-image.png",
19
+ "criteria": "https://example.com/sap/criteria.html"
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["PassportV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,ER514345,did:ion:sap123
3
+ John,Smith,RT678543,did:ion:sap321
@@ -0,0 +1,15 @@
1
+ {
2
+ "emails": [{
3
+ "email": "{{email}}"
4
+ }],
5
+ "firstName": {
6
+ "localized": {
7
+ "en": "{{givenName}}"
8
+ }
9
+ },
10
+ "lastName": {
11
+ "localized": {
12
+ "en": "{{familyName}}"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["PhoneV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{phone}}",
8
+ "phone": "{{phone}}"
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ givenName,familyName,phone,did
2
+ Joan,Lee,+16478275610,did:ion:sap123
@@ -0,0 +1,3 @@
1
+ phone,givenName,familyName,offerId
2
+ +1234567890,Joan,Lee,100
3
+ +2345678901,John,Smith,200
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["ProofOfAgeV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,ER514345,did:ion:sap123
3
+ John,Smith,RT678543,did:ion:sap321
@@ -0,0 +1,10 @@
1
+ {
2
+ "type": ["ResidentPermitV1.0"],
3
+ "issuer": {
4
+ "id": "{{did}}"
5
+ },
6
+ "credentialSubject": {
7
+ "vendorUserId": "{{identifier}}",
8
+ "identifier": "{{identifier}}"
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ givenName,familyName,identifier,did
2
+ Joan,Lee,ER514345,did:ion:sap123
3
+ John,Smith,RT678543,did:ion:sap321
@@ -0,0 +1,3 @@
1
+ givenName,familyName,email
2
+ Joan,Lee,joan.lee@sap.com
3
+ John,Smith,john.smith@sap.com
@@ -0,0 +1,3 @@
1
+ givenName,familyName,email,did
2
+ Joan,Lee,joan.lee@sap.com,did:ion:sap123
3
+ John,Smith,john.smith@sap.com,did:ion:sap123
@@ -0,0 +1,225 @@
1
+ const path = require('path');
2
+ const { prepareData } = require('../src/vendor-credentials/prepare-data');
3
+
4
+ describe('vendor credentials test', () => {
5
+ it('should load the templates and csv', async () => {
6
+ const options = {
7
+ csvFilename: path.join(__dirname, 'data/variables.csv'),
8
+ offerTemplateFilename: path.join(__dirname, 'data/offer.template.json'),
9
+ personTemplateFilename: path.join(__dirname, 'data/person.template.json'),
10
+ };
11
+
12
+ const updates = await prepareData(options);
13
+
14
+ expect(updates).toEqual([
15
+ {
16
+ offer: {
17
+ type: ['OpenBadgeV1.0'],
18
+ issuer: {
19
+ id: 'did:ion:sap123',
20
+ },
21
+ credentialSubject: {
22
+ vendorUserId: 'joan.lee@sap.com',
23
+ holds: {
24
+ name: 'SAP Sapphire Attendance',
25
+ description:
26
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
27
+ type: 'BadgeClass',
28
+ issuer: {
29
+ type: 'Profile',
30
+ id: 'did:ion:sap123',
31
+ name: 'SAP',
32
+ uri: 'https://sap.com',
33
+ },
34
+ image: 'https://example.com/badge-image.png',
35
+ criteria: 'https://example.com/sap/criteria.html',
36
+ },
37
+ },
38
+ },
39
+ person: {
40
+ emails: [{ email: 'joan.lee@sap.com' }],
41
+ firstName: { localized: { en: 'Joan' } },
42
+ lastName: { localized: { en: 'Lee' } },
43
+ },
44
+ },
45
+ {
46
+ offer: {
47
+ type: ['OpenBadgeV1.0'],
48
+ issuer: {
49
+ id: 'did:ion:sap123',
50
+ },
51
+ credentialSubject: {
52
+ vendorUserId: 'john.smith@sap.com',
53
+ holds: {
54
+ name: 'SAP Sapphire Attendance',
55
+ description:
56
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
57
+ type: 'BadgeClass',
58
+ issuer: {
59
+ type: 'Profile',
60
+ id: 'did:ion:sap123',
61
+ name: 'SAP',
62
+ uri: 'https://sap.com',
63
+ },
64
+ image: 'https://example.com/badge-image.png',
65
+ criteria: 'https://example.com/sap/criteria.html',
66
+ },
67
+ },
68
+ },
69
+ person: {
70
+ emails: [{ email: 'john.smith@sap.com' }],
71
+ firstName: { localized: { en: 'John' } },
72
+ lastName: { localized: { en: 'Smith' } },
73
+ },
74
+ },
75
+ ]);
76
+ });
77
+
78
+ it('should load the templates and csv and accept a override value for did', async () => {
79
+ const options = {
80
+ csvFilename: path.join(__dirname, 'data/variables-no-did.csv'),
81
+ offerTemplateFilename: path.join(__dirname, 'data/offer.template.json'),
82
+ personTemplateFilename: path.join(__dirname, 'data/person.template.json'),
83
+ vars: { did: 'did:ion:default' },
84
+ };
85
+
86
+ const updates = await prepareData(options);
87
+
88
+ expect(updates).toEqual([
89
+ {
90
+ offer: {
91
+ type: ['OpenBadgeV1.0'],
92
+ issuer: {
93
+ id: 'did:ion:default',
94
+ },
95
+ credentialSubject: {
96
+ vendorUserId: 'joan.lee@sap.com',
97
+ holds: {
98
+ name: 'SAP Sapphire Attendance',
99
+ description:
100
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
101
+ type: 'BadgeClass',
102
+ issuer: {
103
+ type: 'Profile',
104
+ id: 'did:ion:default',
105
+ name: 'SAP',
106
+ uri: 'https://sap.com',
107
+ },
108
+ image: 'https://example.com/badge-image.png',
109
+ criteria: 'https://example.com/sap/criteria.html',
110
+ },
111
+ },
112
+ },
113
+ person: {
114
+ emails: [{ email: 'joan.lee@sap.com' }],
115
+ firstName: { localized: { en: 'Joan' } },
116
+ lastName: { localized: { en: 'Lee' } },
117
+ },
118
+ },
119
+ {
120
+ offer: {
121
+ type: ['OpenBadgeV1.0'],
122
+ issuer: {
123
+ id: 'did:ion:default',
124
+ },
125
+ credentialSubject: {
126
+ vendorUserId: 'john.smith@sap.com',
127
+ holds: {
128
+ name: 'SAP Sapphire Attendance',
129
+ description:
130
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
131
+ type: 'BadgeClass',
132
+ issuer: {
133
+ type: 'Profile',
134
+ id: 'did:ion:default',
135
+ name: 'SAP',
136
+ uri: 'https://sap.com',
137
+ },
138
+ image: 'https://example.com/badge-image.png',
139
+ criteria: 'https://example.com/sap/criteria.html',
140
+ },
141
+ },
142
+ },
143
+ person: {
144
+ emails: [{ email: 'john.smith@sap.com' }],
145
+ firstName: { localized: { en: 'John' } },
146
+ lastName: { localized: { en: 'Smith' } },
147
+ },
148
+ },
149
+ ]);
150
+ });
151
+
152
+ it('should load the templates and csv and always accept an override value for did', async () => {
153
+ const options = {
154
+ csvFilename: path.join(__dirname, 'data/variables.csv'),
155
+ offerTemplateFilename: path.join(__dirname, 'data/offer.template.json'),
156
+ personTemplateFilename: path.join(__dirname, 'data/person.template.json'),
157
+ vars: { did: 'did:ion:default' },
158
+ };
159
+
160
+ const updates = await prepareData(options);
161
+
162
+ expect(updates).toEqual([
163
+ {
164
+ offer: {
165
+ type: ['OpenBadgeV1.0'],
166
+ issuer: {
167
+ id: 'did:ion:default',
168
+ },
169
+ credentialSubject: {
170
+ vendorUserId: 'joan.lee@sap.com',
171
+ holds: {
172
+ name: 'SAP Sapphire Attendance',
173
+ description:
174
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
175
+ type: 'BadgeClass',
176
+ issuer: {
177
+ type: 'Profile',
178
+ id: 'did:ion:default',
179
+ name: 'SAP',
180
+ uri: 'https://sap.com',
181
+ },
182
+ image: 'https://example.com/badge-image.png',
183
+ criteria: 'https://example.com/sap/criteria.html',
184
+ },
185
+ },
186
+ },
187
+ person: {
188
+ emails: [{ email: 'joan.lee@sap.com' }],
189
+ firstName: { localized: { en: 'Joan' } },
190
+ lastName: { localized: { en: 'Lee' } },
191
+ },
192
+ },
193
+ {
194
+ offer: {
195
+ type: ['OpenBadgeV1.0'],
196
+ issuer: {
197
+ id: 'did:ion:default',
198
+ },
199
+ credentialSubject: {
200
+ vendorUserId: 'john.smith@sap.com',
201
+ holds: {
202
+ name: 'SAP Sapphire Attendance',
203
+ description:
204
+ 'Digital Badge for the Conference Attendees of SAPs Sapphire Conference',
205
+ type: 'BadgeClass',
206
+ issuer: {
207
+ type: 'Profile',
208
+ id: 'did:ion:default',
209
+ name: 'SAP',
210
+ uri: 'https://sap.com',
211
+ },
212
+ image: 'https://example.com/badge-image.png',
213
+ criteria: 'https://example.com/sap/criteria.html',
214
+ },
215
+ },
216
+ },
217
+ person: {
218
+ emails: [{ email: 'john.smith@sap.com' }],
219
+ firstName: { localized: { en: 'John' } },
220
+ lastName: { localized: { en: 'Smith' } },
221
+ },
222
+ },
223
+ ]);
224
+ });
225
+ });