@openfn/language-dhis2 6.0.3 → 6.1.0
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/configuration-schema.json +9 -0
- package/dist/index.cjs +18 -9
- package/dist/index.js +18 -9
- package/package.json +2 -2
- package/types/Client.d.ts +2 -2
|
@@ -46,6 +46,15 @@
|
|
|
46
46
|
"examples": [
|
|
47
47
|
"v2"
|
|
48
48
|
]
|
|
49
|
+
},
|
|
50
|
+
"pat": {
|
|
51
|
+
"title": "Personal Access Token",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "Personal access token",
|
|
54
|
+
"minLength": 1,
|
|
55
|
+
"examples": [
|
|
56
|
+
"d2pat_vreYExmi0yh92Soy8CCF2zHG0wRjID494035128247"
|
|
57
|
+
]
|
|
49
58
|
}
|
|
50
59
|
},
|
|
51
60
|
"type": "object",
|
package/dist/index.cjs
CHANGED
|
@@ -243,7 +243,7 @@ var import_lodash = __toESM(require("lodash"), 1);
|
|
|
243
243
|
// src/Client.js
|
|
244
244
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
245
245
|
var import_qs = __toESM(require("qs"), 1);
|
|
246
|
-
function request({ username, password }, axiosRequest) {
|
|
246
|
+
function request({ username, password, pat }, axiosRequest) {
|
|
247
247
|
const { method, url, params } = axiosRequest;
|
|
248
248
|
console.log(`Sending ${method} request to ${url}`);
|
|
249
249
|
if (params)
|
|
@@ -251,14 +251,23 @@ function request({ username, password }, axiosRequest) {
|
|
|
251
251
|
const safeRedirect = ["get", "head", "options", "trace"].includes(
|
|
252
252
|
method.toLowerCase()
|
|
253
253
|
);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
254
|
+
const headers = { "Content-Type": "application/json" };
|
|
255
|
+
let auth;
|
|
256
|
+
if (pat) {
|
|
257
|
+
headers.Authorization = `ApiToken ${pat}`;
|
|
258
|
+
} else {
|
|
259
|
+
auth = { username, password };
|
|
260
|
+
}
|
|
261
|
+
return (0, import_axios2.default)(
|
|
262
|
+
{
|
|
263
|
+
headers,
|
|
264
|
+
responseType: "json",
|
|
265
|
+
auth,
|
|
266
|
+
maxRedirects: safeRedirect ? 5 : 0,
|
|
267
|
+
paramsSerializer: (params2) => import_qs.default.stringify(params2, { arrayFormat: "repeat" }),
|
|
268
|
+
...axiosRequest
|
|
269
|
+
}
|
|
270
|
+
);
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
// src/Adaptor.js
|
package/dist/index.js
CHANGED
|
@@ -190,7 +190,7 @@ import _ from "lodash";
|
|
|
190
190
|
// src/Client.js
|
|
191
191
|
import axios2 from "axios";
|
|
192
192
|
import Qs from "qs";
|
|
193
|
-
function request({ username, password }, axiosRequest) {
|
|
193
|
+
function request({ username, password, pat }, axiosRequest) {
|
|
194
194
|
const { method, url, params } = axiosRequest;
|
|
195
195
|
console.log(`Sending ${method} request to ${url}`);
|
|
196
196
|
if (params)
|
|
@@ -198,14 +198,23 @@ function request({ username, password }, axiosRequest) {
|
|
|
198
198
|
const safeRedirect = ["get", "head", "options", "trace"].includes(
|
|
199
199
|
method.toLowerCase()
|
|
200
200
|
);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
const headers = { "Content-Type": "application/json" };
|
|
202
|
+
let auth;
|
|
203
|
+
if (pat) {
|
|
204
|
+
headers.Authorization = `ApiToken ${pat}`;
|
|
205
|
+
} else {
|
|
206
|
+
auth = { username, password };
|
|
207
|
+
}
|
|
208
|
+
return axios2(
|
|
209
|
+
{
|
|
210
|
+
headers,
|
|
211
|
+
responseType: "json",
|
|
212
|
+
auth,
|
|
213
|
+
maxRedirects: safeRedirect ? 5 : 0,
|
|
214
|
+
paramsSerializer: (params2) => Qs.stringify(params2, { arrayFormat: "repeat" }),
|
|
215
|
+
...axiosRequest
|
|
216
|
+
}
|
|
217
|
+
);
|
|
209
218
|
}
|
|
210
219
|
|
|
211
220
|
// src/Adaptor.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-dhis2",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "DHIS2 Language Pack for OpenFn",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"axios": "^1.7.7",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"qs": "^6.11.0",
|
|
31
|
-
"@openfn/language-common": "2.
|
|
31
|
+
"@openfn/language-common": "2.3.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"assertion-error": "2.0.0",
|
package/types/Client.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* before spreading the rest of the axios configuration, and (3) executes an
|
|
5
5
|
* axios request.
|
|
6
6
|
* @function
|
|
7
|
-
* @param {object} configuration - configuration
|
|
7
|
+
* @param {object} configuration - configuration can either be a username and password OR a personal access token
|
|
8
8
|
* @param {object} axiosRequest - the axiosRequest contains valid axios params: https://axios-http.com/docs/req_config
|
|
9
9
|
* @returns {Promise} a promise that will resolve to either a response object or an error object.
|
|
10
10
|
*/
|
|
11
|
-
export function request({ username, password }: object, axiosRequest: object): Promise<any>;
|
|
11
|
+
export function request({ username, password, pat }: object, axiosRequest: object): Promise<any>;
|