dataverse-utils 2.0.10 → 2.1.1
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/CHANGELOG.json +281 -0
- package/CHANGELOG.md +134 -0
- package/lib/assemblyDeploy.js +18 -11
- package/lib/auth.js +11 -7
- package/lib/cachePlugin.js +23 -16
- package/lib/dataverse.service.js +16 -10
- package/lib/deploy.js +24 -18
- package/lib/generate.js +28 -22
- package/lib/index.js +45 -0
- package/lib/logger.js +26 -0
- package/lib/models/pluginAssembly.js +27 -20
- package/lib/models/pluginImage.js +12 -8
- package/lib/models/pluginStep.js +20 -16
- package/lib/models/pluginType.js +14 -10
- package/lib/models/webResource.js +26 -19
- package/lib/webResourceDeploy.js +18 -11
- package/package.json +6 -6
- package/lib/assemblyDeploy.d.ts +0 -3
- package/lib/auth.d.ts +0 -2
- package/lib/cachePlugin.d.ts +0 -2
- package/lib/dataverse-utils.d.ts +0 -2
- package/lib/dataverse-utils.js +0 -38
- package/lib/dataverse.service.d.ts +0 -34
- package/lib/deploy.d.ts +0 -1
- package/lib/generate.d.ts +0 -1
- package/lib/models/pluginAssembly.d.ts +0 -13
- package/lib/models/pluginImage.d.ts +0 -10
- package/lib/models/pluginStep.d.ts +0 -20
- package/lib/models/pluginType.d.ts +0 -11
- package/lib/models/webResource.d.ts +0 -10
- package/lib/webResourceDeploy.d.ts +0 -3
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dataverse-utils",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Sun, 16 Jan 2022 22:41:36 GMT",
|
|
6
|
+
"tag": "dataverse-utils_v2.1.1",
|
|
7
|
+
"version": "2.1.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
12
|
+
"package": "dataverse-utils",
|
|
13
|
+
"commit": "b1658649d8258e68522e6eadd79a2bbf3a4733d8",
|
|
14
|
+
"comment": "Fix logging"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Sun, 16 Jan 2022 21:30:27 GMT",
|
|
21
|
+
"tag": "dataverse-utils_v2.1.0",
|
|
22
|
+
"version": "2.1.0",
|
|
23
|
+
"comments": {
|
|
24
|
+
"minor": [
|
|
25
|
+
{
|
|
26
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
27
|
+
"package": "dataverse-utils",
|
|
28
|
+
"commit": "bb36663768d27bdffc3165129865f8bdce4ea3c0",
|
|
29
|
+
"comment": "Remove dependencies; Fix plop dependency"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Tue, 07 Dec 2021 20:03:45 GMT",
|
|
36
|
+
"tag": "dataverse-utils_v2.0.12",
|
|
37
|
+
"version": "2.0.12",
|
|
38
|
+
"comments": {
|
|
39
|
+
"patch": [
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "dataverse-utils",
|
|
43
|
+
"comment": "Bump dataverse-webapi to v2.0.3",
|
|
44
|
+
"commit": "6a5b71a6c0a60ca12b3866e521639c16f170da41"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"date": "Tue, 07 Dec 2021 19:52:53 GMT",
|
|
51
|
+
"tag": "dataverse-utils_v2.0.11",
|
|
52
|
+
"version": "2.0.11",
|
|
53
|
+
"comments": {
|
|
54
|
+
"patch": [
|
|
55
|
+
{
|
|
56
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
57
|
+
"package": "dataverse-utils",
|
|
58
|
+
"commit": "7ada3bfbcf286db81f5fba616560cc4f56dd9b2a",
|
|
59
|
+
"comment": "Switch to commonjs"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"date": "Tue, 07 Dec 2021 19:41:36 GMT",
|
|
66
|
+
"tag": "dataverse-utils_v2.0.10",
|
|
67
|
+
"version": "2.0.10",
|
|
68
|
+
"comments": {
|
|
69
|
+
"patch": [
|
|
70
|
+
{
|
|
71
|
+
"author": "beachball",
|
|
72
|
+
"package": "dataverse-utils",
|
|
73
|
+
"comment": "Bump dataverse-webapi to v2.0.2",
|
|
74
|
+
"commit": "def26173ed0d1454365703f801c31a686f5bc380"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"date": "Tue, 07 Dec 2021 18:53:08 GMT",
|
|
81
|
+
"tag": "dataverse-utils_v2.0.9",
|
|
82
|
+
"version": "2.0.9",
|
|
83
|
+
"comments": {
|
|
84
|
+
"none": [
|
|
85
|
+
{
|
|
86
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
87
|
+
"package": "dataverse-utils",
|
|
88
|
+
"commit": "8f6412e011f27a8c7b9da6c7247f4f4c38919a0d",
|
|
89
|
+
"comment": "Add descriptions"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"date": "Tue, 07 Dec 2021 18:44:10 GMT",
|
|
96
|
+
"tag": "dataverse-utils_v2.0.9",
|
|
97
|
+
"version": "2.0.9",
|
|
98
|
+
"comments": {
|
|
99
|
+
"none": [
|
|
100
|
+
{
|
|
101
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
102
|
+
"package": "dataverse-utils",
|
|
103
|
+
"commit": "b679eab6b9aa175842736c5f451f6b42a718b23c",
|
|
104
|
+
"comment": "Add license"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"date": "Tue, 07 Dec 2021 16:11:56 GMT",
|
|
111
|
+
"tag": "dataverse-utils_v2.0.9",
|
|
112
|
+
"version": "2.0.9",
|
|
113
|
+
"comments": {
|
|
114
|
+
"patch": [
|
|
115
|
+
{
|
|
116
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
117
|
+
"package": "dataverse-utils",
|
|
118
|
+
"commit": "65e96cce1a649a1a10214d8dfd7331fdc2367366",
|
|
119
|
+
"comment": "Fix glob package"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"date": "Thu, 02 Dec 2021 20:50:52 GMT",
|
|
126
|
+
"tag": "dataverse-utils_v2.0.8",
|
|
127
|
+
"version": "2.0.8",
|
|
128
|
+
"comments": {
|
|
129
|
+
"patch": [
|
|
130
|
+
{
|
|
131
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
132
|
+
"package": "dataverse-utils",
|
|
133
|
+
"commit": "ca4c93ee6ee9ab4b9ea567120f0af5e162542998",
|
|
134
|
+
"comment": "Fix node-plop"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"date": "Sat, 13 Nov 2021 04:59:34 GMT",
|
|
141
|
+
"tag": "dataverse-utils_v2.0.7",
|
|
142
|
+
"version": "2.0.7",
|
|
143
|
+
"comments": {
|
|
144
|
+
"patch": [
|
|
145
|
+
{
|
|
146
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
147
|
+
"package": "dataverse-utils",
|
|
148
|
+
"commit": "615b4f15124a34b46a2508de44f1524f5e94678c",
|
|
149
|
+
"comment": "Fix error handling on creates"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"date": "Wed, 03 Nov 2021 15:06:58 GMT",
|
|
156
|
+
"tag": "dataverse-utils_v2.0.6",
|
|
157
|
+
"version": "2.0.6",
|
|
158
|
+
"comments": {
|
|
159
|
+
"patch": [
|
|
160
|
+
{
|
|
161
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
162
|
+
"package": "dataverse-utils",
|
|
163
|
+
"commit": "a190400c57bc04abc65cf28a87ba10707d37566c",
|
|
164
|
+
"comment": "Force update package version"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"date": "Wed, 03 Nov 2021 14:55:25 GMT",
|
|
171
|
+
"tag": "dataverse-utils_v2.0.5",
|
|
172
|
+
"version": "2.0.5",
|
|
173
|
+
"comments": {
|
|
174
|
+
"patch": [
|
|
175
|
+
{
|
|
176
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
177
|
+
"package": "dataverse-utils",
|
|
178
|
+
"commit": "3ebf5be6fd6e5bbb1fbfdb163d97f10c59a3db85",
|
|
179
|
+
"comment": "Add catch to create calls"
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"date": "Tue, 02 Nov 2021 16:20:01 GMT",
|
|
186
|
+
"tag": "dataverse-utils_v2.0.4",
|
|
187
|
+
"version": "2.0.4",
|
|
188
|
+
"comments": {
|
|
189
|
+
"patch": [
|
|
190
|
+
{
|
|
191
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
192
|
+
"package": "dataverse-utils",
|
|
193
|
+
"commit": "f8cfe1e4a4d4becf82b91fcae9a1749365053ab3",
|
|
194
|
+
"comment": "Update error handling"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"author": "beachball",
|
|
198
|
+
"package": "dataverse-utils",
|
|
199
|
+
"comment": "Bump dataverse-webapi to v2.0.1",
|
|
200
|
+
"commit": "f8cfe1e4a4d4becf82b91fcae9a1749365053ab3"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"date": "Fri, 17 Sep 2021 05:34:12 GMT",
|
|
207
|
+
"tag": "dataverse-utils_v2.0.3",
|
|
208
|
+
"version": "2.0.3",
|
|
209
|
+
"comments": {
|
|
210
|
+
"patch": [
|
|
211
|
+
{
|
|
212
|
+
"comment": "Fix encryption",
|
|
213
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
214
|
+
"commit": "96923c83bf0e9b6e93c15fea5453b45494bb5611",
|
|
215
|
+
"package": "dataverse-utils"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"date": "Thu, 16 Sep 2021 21:30:04 GMT",
|
|
222
|
+
"tag": "dataverse-utils_v2.0.2",
|
|
223
|
+
"version": "2.0.2",
|
|
224
|
+
"comments": {
|
|
225
|
+
"patch": [
|
|
226
|
+
{
|
|
227
|
+
"comment": "Fix first time auth",
|
|
228
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
229
|
+
"commit": "d13f2f05e702a82bb127dbac7f9f33daf027ea64",
|
|
230
|
+
"package": "dataverse-utils"
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"date": "Thu, 16 Sep 2021 20:57:31 GMT",
|
|
237
|
+
"tag": "dataverse-utils_v2.0.1",
|
|
238
|
+
"version": "2.0.1",
|
|
239
|
+
"comments": {
|
|
240
|
+
"patch": [
|
|
241
|
+
{
|
|
242
|
+
"comment": "Update wording for entering table",
|
|
243
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
244
|
+
"commit": "963c071a39980f4cef59a3ab24c1f749504d0584",
|
|
245
|
+
"package": "dataverse-utils"
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"date": "Thu, 16 Sep 2021 20:49:48 GMT",
|
|
252
|
+
"tag": "dataverse-utils_v2.0.0",
|
|
253
|
+
"version": "2.0.0",
|
|
254
|
+
"comments": {
|
|
255
|
+
"major": [
|
|
256
|
+
{
|
|
257
|
+
"comment": "Switch to device-code auth",
|
|
258
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
259
|
+
"commit": "b1c526bdddb59fe2f4a3eb61096909ebbb2379d7",
|
|
260
|
+
"package": "dataverse-utils"
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"date": "Thu, 02 Sep 2021 16:22:00 GMT",
|
|
267
|
+
"tag": "dataverse-utils_v1.0.1",
|
|
268
|
+
"version": "1.0.1",
|
|
269
|
+
"comments": {
|
|
270
|
+
"patch": [
|
|
271
|
+
{
|
|
272
|
+
"comment": "Add generate command; Rename project",
|
|
273
|
+
"author": "derek.finlinson@journeyteam.com",
|
|
274
|
+
"commit": "d1c26f12e1e58b86cc3cfe26274f0dbd35d5ad70",
|
|
275
|
+
"package": "dataverse-utils"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Change Log - dataverse-utils
|
|
2
|
+
|
|
3
|
+
This log was last generated on Sun, 16 Jan 2022 22:41:36 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 2.1.1
|
|
8
|
+
|
|
9
|
+
Sun, 16 Jan 2022 22:41:36 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Fix logging (derek.finlinson@journeyteam.com)
|
|
14
|
+
|
|
15
|
+
## 2.1.0
|
|
16
|
+
|
|
17
|
+
Sun, 16 Jan 2022 21:30:27 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Remove dependencies; Fix plop dependency (derek.finlinson@journeyteam.com)
|
|
22
|
+
|
|
23
|
+
## 2.0.12
|
|
24
|
+
|
|
25
|
+
Tue, 07 Dec 2021 20:03:45 GMT
|
|
26
|
+
|
|
27
|
+
### Patches
|
|
28
|
+
|
|
29
|
+
- Bump dataverse-webapi to v2.0.3
|
|
30
|
+
|
|
31
|
+
## 2.0.11
|
|
32
|
+
|
|
33
|
+
Tue, 07 Dec 2021 19:52:53 GMT
|
|
34
|
+
|
|
35
|
+
### Patches
|
|
36
|
+
|
|
37
|
+
- Switch to commonjs (derek.finlinson@journeyteam.com)
|
|
38
|
+
|
|
39
|
+
## 2.0.10
|
|
40
|
+
|
|
41
|
+
Tue, 07 Dec 2021 19:41:36 GMT
|
|
42
|
+
|
|
43
|
+
### Patches
|
|
44
|
+
|
|
45
|
+
- Bump dataverse-webapi to v2.0.2
|
|
46
|
+
|
|
47
|
+
## 2.0.9
|
|
48
|
+
|
|
49
|
+
Tue, 07 Dec 2021 16:11:56 GMT
|
|
50
|
+
|
|
51
|
+
### Patches
|
|
52
|
+
|
|
53
|
+
- Fix glob package (derek.finlinson@journeyteam.com)
|
|
54
|
+
|
|
55
|
+
## 2.0.8
|
|
56
|
+
|
|
57
|
+
Thu, 02 Dec 2021 20:50:52 GMT
|
|
58
|
+
|
|
59
|
+
### Patches
|
|
60
|
+
|
|
61
|
+
- Fix node-plop (derek.finlinson@journeyteam.com)
|
|
62
|
+
|
|
63
|
+
## 2.0.7
|
|
64
|
+
|
|
65
|
+
Sat, 13 Nov 2021 04:59:34 GMT
|
|
66
|
+
|
|
67
|
+
### Patches
|
|
68
|
+
|
|
69
|
+
- Fix error handling on creates (derek.finlinson@journeyteam.com)
|
|
70
|
+
|
|
71
|
+
## 2.0.6
|
|
72
|
+
|
|
73
|
+
Wed, 03 Nov 2021 15:06:58 GMT
|
|
74
|
+
|
|
75
|
+
### Patches
|
|
76
|
+
|
|
77
|
+
- Force update package version (derek.finlinson@journeyteam.com)
|
|
78
|
+
|
|
79
|
+
## 2.0.5
|
|
80
|
+
|
|
81
|
+
Wed, 03 Nov 2021 14:55:25 GMT
|
|
82
|
+
|
|
83
|
+
### Patches
|
|
84
|
+
|
|
85
|
+
- Add catch to create calls (derek.finlinson@journeyteam.com)
|
|
86
|
+
|
|
87
|
+
## 2.0.4
|
|
88
|
+
|
|
89
|
+
Tue, 02 Nov 2021 16:20:01 GMT
|
|
90
|
+
|
|
91
|
+
### Patches
|
|
92
|
+
|
|
93
|
+
- Update error handling (derek.finlinson@journeyteam.com)
|
|
94
|
+
- Bump dataverse-webapi to v2.0.1
|
|
95
|
+
|
|
96
|
+
## 2.0.3
|
|
97
|
+
|
|
98
|
+
Fri, 17 Sep 2021 05:34:12 GMT
|
|
99
|
+
|
|
100
|
+
### Patches
|
|
101
|
+
|
|
102
|
+
- Fix encryption (derek.finlinson@journeyteam.com)
|
|
103
|
+
|
|
104
|
+
## 2.0.2
|
|
105
|
+
|
|
106
|
+
Thu, 16 Sep 2021 21:30:04 GMT
|
|
107
|
+
|
|
108
|
+
### Patches
|
|
109
|
+
|
|
110
|
+
- Fix first time auth (derek.finlinson@journeyteam.com)
|
|
111
|
+
|
|
112
|
+
## 2.0.1
|
|
113
|
+
|
|
114
|
+
Thu, 16 Sep 2021 20:57:31 GMT
|
|
115
|
+
|
|
116
|
+
### Patches
|
|
117
|
+
|
|
118
|
+
- Update wording for entering table (derek.finlinson@journeyteam.com)
|
|
119
|
+
|
|
120
|
+
## 2.0.0
|
|
121
|
+
|
|
122
|
+
Thu, 16 Sep 2021 20:49:48 GMT
|
|
123
|
+
|
|
124
|
+
### Major changes
|
|
125
|
+
|
|
126
|
+
- Switch to device-code auth (derek.finlinson@journeyteam.com)
|
|
127
|
+
|
|
128
|
+
## 1.0.1
|
|
129
|
+
|
|
130
|
+
Thu, 02 Sep 2021 16:22:00 GMT
|
|
131
|
+
|
|
132
|
+
### Patches
|
|
133
|
+
|
|
134
|
+
- Add generate command; Rename project (derek.finlinson@journeyteam.com)
|
package/lib/assemblyDeploy.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deployAssembly = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const pluginAssembly_1 = require("./models/pluginAssembly");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
async function deployAssembly(creds, apiConfig) {
|
|
6
12
|
const currentPath = '.';
|
|
7
|
-
const configFile =
|
|
13
|
+
const configFile = fs_1.default.readFileSync(path_1.default.resolve(currentPath, 'dataverse.config.json'), 'utf8');
|
|
8
14
|
if (configFile == null) {
|
|
9
|
-
logger.warn('unable to find dataverse.config.json file');
|
|
15
|
+
logger_1.logger.warn('unable to find dataverse.config.json file');
|
|
10
16
|
return;
|
|
11
17
|
}
|
|
12
18
|
const config = JSON.parse(configFile);
|
|
13
|
-
logger.info('deploy assembly');
|
|
19
|
+
logger_1.logger.info('deploy assembly');
|
|
14
20
|
try {
|
|
15
|
-
await deploy(config, apiConfig, creds.solution);
|
|
21
|
+
await (0, pluginAssembly_1.deploy)(config, apiConfig, creds.solution);
|
|
16
22
|
}
|
|
17
23
|
catch (error) {
|
|
18
|
-
logger.error(error.message);
|
|
24
|
+
logger_1.logger.error(error.message);
|
|
19
25
|
return;
|
|
20
26
|
}
|
|
21
|
-
logger.info(`deployed assembly ${config.name}\r\n`);
|
|
27
|
+
logger_1.logger.info(`deployed assembly ${config.name}\r\n`);
|
|
22
28
|
}
|
|
29
|
+
exports.deployAssembly = deployAssembly;
|
package/lib/auth.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccessToken = void 0;
|
|
4
|
+
const cachePlugin_1 = require("./cachePlugin");
|
|
5
|
+
const msal_node_1 = require("@azure/msal-node");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
4
7
|
const clientId = '51f81489-12ee-4a9e-aaae-a2591f45987d';
|
|
5
|
-
|
|
8
|
+
const getAccessToken = async (tenant, url) => {
|
|
6
9
|
const config = {
|
|
7
10
|
auth: {
|
|
8
11
|
clientId: clientId,
|
|
9
12
|
authority: `https://login.microsoftonline.com/${tenant}/`
|
|
10
13
|
},
|
|
11
14
|
cache: {
|
|
12
|
-
cachePlugin: cachePlugin(url.replace('https://', '').split('.')[0])
|
|
15
|
+
cachePlugin: (0, cachePlugin_1.cachePlugin)(url.replace('https://', '').split('.')[0])
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
|
-
const pca = new PublicClientApplication(config);
|
|
18
|
+
const pca = new msal_node_1.PublicClientApplication(config);
|
|
16
19
|
const cache = pca.getTokenCache();
|
|
17
20
|
const accounts = await cache?.getAllAccounts().catch(ex => {
|
|
18
21
|
throw new Error(ex.message);
|
|
@@ -32,9 +35,10 @@ export const getAccessToken = async (tenant, url) => {
|
|
|
32
35
|
// Acquire token by device code
|
|
33
36
|
const token = await pca.acquireTokenByDeviceCode({
|
|
34
37
|
scopes: [`${url}/.default`],
|
|
35
|
-
deviceCodeCallback: (response) => logger.info(response.message)
|
|
38
|
+
deviceCodeCallback: (response) => logger_1.logger.info(response.message)
|
|
36
39
|
}).catch(ex => {
|
|
37
40
|
throw new Error(ex.message);
|
|
38
41
|
});
|
|
39
42
|
return token;
|
|
40
43
|
};
|
|
44
|
+
exports.getAccessToken = getAccessToken;
|
package/lib/cachePlugin.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cachePlugin = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const cryptr_1 = __importDefault(require("cryptr"));
|
|
5
11
|
const encrypt = (text) => {
|
|
6
|
-
const user =
|
|
7
|
-
const cryptr = new
|
|
12
|
+
const user = os_1.default.userInfo().username;
|
|
13
|
+
const cryptr = new cryptr_1.default(user);
|
|
8
14
|
const encrypted = cryptr.encrypt(text);
|
|
9
15
|
return encrypted;
|
|
10
16
|
};
|
|
11
17
|
const decrypt = (text) => {
|
|
12
|
-
const user =
|
|
13
|
-
const cryptr = new
|
|
18
|
+
const user = os_1.default.userInfo().username;
|
|
19
|
+
const cryptr = new cryptr_1.default(user);
|
|
14
20
|
const decrypted = cryptr.decrypt(text);
|
|
15
21
|
return decrypted;
|
|
16
22
|
};
|
|
17
|
-
|
|
23
|
+
function cachePlugin(org) {
|
|
18
24
|
const getCachePath = () => {
|
|
19
|
-
if (!
|
|
20
|
-
|
|
25
|
+
if (!fs_1.default.existsSync(path_1.default.join(os_1.default.homedir(), './.dataverse-utils/'))) {
|
|
26
|
+
fs_1.default.mkdirSync(path_1.default.join(os_1.default.homedir(), './.dataverse-utils/'));
|
|
21
27
|
}
|
|
22
|
-
return
|
|
28
|
+
return path_1.default.join(os_1.default.homedir(), `./.dataverse-utils/${org}.json`);
|
|
23
29
|
};
|
|
24
30
|
const cacheLocation = getCachePath();
|
|
25
31
|
const beforeCacheAccess = (tokenCacheContext) => {
|
|
26
32
|
return new Promise((resolve, reject) => {
|
|
27
|
-
if (
|
|
28
|
-
|
|
33
|
+
if (fs_1.default.existsSync(cacheLocation)) {
|
|
34
|
+
fs_1.default.readFile(cacheLocation, 'utf-8', (err, data) => {
|
|
29
35
|
if (err) {
|
|
30
36
|
reject();
|
|
31
37
|
}
|
|
@@ -38,7 +44,7 @@ export function cachePlugin(org) {
|
|
|
38
44
|
}
|
|
39
45
|
else {
|
|
40
46
|
const encrypted = encrypt(tokenCacheContext.tokenCache.serialize());
|
|
41
|
-
|
|
47
|
+
fs_1.default.writeFile(cacheLocation, encrypted, (err) => {
|
|
42
48
|
if (err) {
|
|
43
49
|
reject();
|
|
44
50
|
}
|
|
@@ -53,7 +59,7 @@ export function cachePlugin(org) {
|
|
|
53
59
|
return new Promise((resolve, reject) => {
|
|
54
60
|
if (tokenCacheContext.cacheHasChanged) {
|
|
55
61
|
const encrypted = encrypt(tokenCacheContext.tokenCache.serialize());
|
|
56
|
-
|
|
62
|
+
fs_1.default.writeFile(cacheLocation, encrypted, (err) => {
|
|
57
63
|
if (err) {
|
|
58
64
|
reject(err);
|
|
59
65
|
}
|
|
@@ -70,3 +76,4 @@ export function cachePlugin(org) {
|
|
|
70
76
|
afterCacheAccess
|
|
71
77
|
};
|
|
72
78
|
}
|
|
79
|
+
exports.cachePlugin = cachePlugin;
|
package/lib/dataverse.service.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTableMetadata = exports.publish = exports.addToSolution = exports.ComponentType = void 0;
|
|
4
|
+
const node_1 = require("dataverse-webapi/lib/node");
|
|
5
|
+
var ComponentType;
|
|
3
6
|
(function (ComponentType) {
|
|
4
7
|
ComponentType[ComponentType["WebResource"] = 61] = "WebResource";
|
|
5
8
|
ComponentType[ComponentType["PluginType"] = 90] = "PluginType";
|
|
6
9
|
ComponentType[ComponentType["PluginAssembly"] = 91] = "PluginAssembly";
|
|
7
10
|
ComponentType[ComponentType["SDKMessageProcessingStep"] = 92] = "SDKMessageProcessingStep";
|
|
8
11
|
ComponentType[ComponentType["SDKMessageProcessingStepImage"] = 93] = "SDKMessageProcessingStepImage";
|
|
9
|
-
})(ComponentType || (ComponentType = {}));
|
|
10
|
-
|
|
12
|
+
})(ComponentType = exports.ComponentType || (exports.ComponentType = {}));
|
|
13
|
+
async function addToSolution(id, solution, type, apiConfig) {
|
|
11
14
|
const data = {
|
|
12
15
|
ComponentId: id,
|
|
13
16
|
ComponentType: type,
|
|
@@ -15,20 +18,22 @@ export async function addToSolution(id, solution, type, apiConfig) {
|
|
|
15
18
|
AddRequiredComponents: false,
|
|
16
19
|
IncludedComponentSettingsValues: null
|
|
17
20
|
};
|
|
18
|
-
await unboundAction(apiConfig, 'AddSolutionComponent', data);
|
|
21
|
+
await (0, node_1.unboundAction)(apiConfig, 'AddSolutionComponent', data);
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
exports.addToSolution = addToSolution;
|
|
24
|
+
async function publish(publishXml, apiConfig) {
|
|
21
25
|
const data = {
|
|
22
26
|
ParameterXml: `<importexportxml><webresources>${publishXml}</webresources></importexportxml>`
|
|
23
27
|
};
|
|
24
|
-
await unboundAction(apiConfig, 'PublishXml', data);
|
|
28
|
+
await (0, node_1.unboundAction)(apiConfig, 'PublishXml', data);
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
exports.publish = publish;
|
|
31
|
+
async function getTableMetadata(table, apiConfig) {
|
|
27
32
|
const options = [
|
|
28
33
|
'?$select=DisplayName,LogicalName,EntitySetName,SchemaName',
|
|
29
34
|
'&$expand=Attributes($select=LogicalName,SchemaName)'
|
|
30
35
|
].join('');
|
|
31
|
-
const metadata = await retrieveMultiple(apiConfig, `EntityDefinitions(LogicalName='${table}')`, options);
|
|
36
|
+
const metadata = await (0, node_1.retrieveMultiple)(apiConfig, `EntityDefinitions(LogicalName='${table}')`, options);
|
|
32
37
|
if (metadata == null) {
|
|
33
38
|
throw Error(`Table ${table} not found in metadata cache`);
|
|
34
39
|
}
|
|
@@ -36,7 +41,7 @@ export async function getTableMetadata(table, apiConfig) {
|
|
|
36
41
|
'?$select=attributevalue,value,attributename',
|
|
37
42
|
`&$filter=objecttypecode eq '${table}'`
|
|
38
43
|
].join('');
|
|
39
|
-
const choiceMetadata = await retrieveMultiple(apiConfig, 'stringmaps', choiceOptions);
|
|
44
|
+
const choiceMetadata = await (0, node_1.retrieveMultiple)(apiConfig, 'stringmaps', choiceOptions);
|
|
40
45
|
const tableMetadata = {
|
|
41
46
|
logicalName: metadata.LogicalName,
|
|
42
47
|
schemaName: metadata.SchemaName,
|
|
@@ -60,3 +65,4 @@ export async function getTableMetadata(table, apiConfig) {
|
|
|
60
65
|
});
|
|
61
66
|
return tableMetadata;
|
|
62
67
|
}
|
|
68
|
+
exports.getTableMetadata = getTableMetadata;
|