@openfn/language-dhis2 8.1.0 → 8.2.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 +1 -3
- package/dist/index.cjs +7 -8
- package/dist/index.js +7 -8
- package/package.json +4 -4
- package/types/tracker.d.ts +6 -3
package/dist/index.cjs
CHANGED
|
@@ -154,15 +154,15 @@ function prefixVersionToPath(configuration, options, resourceType, path = null)
|
|
|
154
154
|
return urlPath;
|
|
155
155
|
}
|
|
156
156
|
var configureAuth = (auth, headers = {}) => {
|
|
157
|
-
if (
|
|
157
|
+
if (auth.pat) {
|
|
158
158
|
Object.assign(headers, {
|
|
159
159
|
Authorization: `ApiToken ${auth.pat}`
|
|
160
160
|
});
|
|
161
|
-
} else if (
|
|
161
|
+
} else if (auth.username && auth.password) {
|
|
162
162
|
Object.assign(headers, (0, import_util.makeBasicAuthHeader)(auth.username, auth.password));
|
|
163
163
|
} else {
|
|
164
164
|
throw new Error(
|
|
165
|
-
"Invalid authorization credentials. Include
|
|
165
|
+
"Invalid authorization credentials. Include a PAT or a username and password in state.configuration"
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
return headers;
|
|
@@ -669,7 +669,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
669
669
|
return async (state) => {
|
|
670
670
|
console.log("Preparing tracker import operation...");
|
|
671
671
|
const [resolvedStrategy, resolvedPayload, resolvedOptions] = (0, import_util6.expandReferences)(state, strategy, payload, options);
|
|
672
|
-
const { apiVersion, parseAs, ...query } = resolvedOptions;
|
|
672
|
+
const { apiVersion, parseAs, async = false, ...query } = resolvedOptions;
|
|
673
673
|
const response = await request(state.configuration, {
|
|
674
674
|
method: "POST",
|
|
675
675
|
path: prefixVersionToPath(
|
|
@@ -685,7 +685,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
685
685
|
parseAs,
|
|
686
686
|
query: {
|
|
687
687
|
...query,
|
|
688
|
-
async
|
|
688
|
+
async
|
|
689
689
|
}
|
|
690
690
|
},
|
|
691
691
|
data: resolvedPayload
|
|
@@ -693,7 +693,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
693
693
|
return handleHttpResponse(response, state);
|
|
694
694
|
};
|
|
695
695
|
}
|
|
696
|
-
function _export(path, query, options = {}) {
|
|
696
|
+
function _export(path, query = {}, options = {}) {
|
|
697
697
|
return async (state) => {
|
|
698
698
|
console.log("Preparing tracker export operation...");
|
|
699
699
|
const [resolvedPath, resolvedQuery, resolvedOptions] = (0, import_util6.expandReferences)(
|
|
@@ -712,8 +712,7 @@ function _export(path, query, options = {}) {
|
|
|
712
712
|
options: {
|
|
713
713
|
...resolvedOptions,
|
|
714
714
|
query: {
|
|
715
|
-
...resolvedQuery
|
|
716
|
-
async: false
|
|
715
|
+
...resolvedQuery
|
|
717
716
|
}
|
|
718
717
|
}
|
|
719
718
|
});
|
package/dist/index.js
CHANGED
|
@@ -105,15 +105,15 @@ function prefixVersionToPath(configuration, options, resourceType, path = null)
|
|
|
105
105
|
return urlPath;
|
|
106
106
|
}
|
|
107
107
|
var configureAuth = (auth, headers = {}) => {
|
|
108
|
-
if (
|
|
108
|
+
if (auth.pat) {
|
|
109
109
|
Object.assign(headers, {
|
|
110
110
|
Authorization: `ApiToken ${auth.pat}`
|
|
111
111
|
});
|
|
112
|
-
} else if (
|
|
112
|
+
} else if (auth.username && auth.password) {
|
|
113
113
|
Object.assign(headers, makeBasicAuthHeader(auth.username, auth.password));
|
|
114
114
|
} else {
|
|
115
115
|
throw new Error(
|
|
116
|
-
"Invalid authorization credentials. Include
|
|
116
|
+
"Invalid authorization credentials. Include a PAT or a username and password in state.configuration"
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
return headers;
|
|
@@ -639,7 +639,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
639
639
|
return async (state) => {
|
|
640
640
|
console.log("Preparing tracker import operation...");
|
|
641
641
|
const [resolvedStrategy, resolvedPayload, resolvedOptions] = expandReferences3(state, strategy, payload, options);
|
|
642
|
-
const { apiVersion, parseAs, ...query } = resolvedOptions;
|
|
642
|
+
const { apiVersion, parseAs, async = false, ...query } = resolvedOptions;
|
|
643
643
|
const response = await request(state.configuration, {
|
|
644
644
|
method: "POST",
|
|
645
645
|
path: prefixVersionToPath(
|
|
@@ -655,7 +655,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
655
655
|
parseAs,
|
|
656
656
|
query: {
|
|
657
657
|
...query,
|
|
658
|
-
async
|
|
658
|
+
async
|
|
659
659
|
}
|
|
660
660
|
},
|
|
661
661
|
data: resolvedPayload
|
|
@@ -663,7 +663,7 @@ function _import(strategy, payload, options = {}) {
|
|
|
663
663
|
return handleHttpResponse(response, state);
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
|
-
function _export(path, query, options = {}) {
|
|
666
|
+
function _export(path, query = {}, options = {}) {
|
|
667
667
|
return async (state) => {
|
|
668
668
|
console.log("Preparing tracker export operation...");
|
|
669
669
|
const [resolvedPath, resolvedQuery, resolvedOptions] = expandReferences3(
|
|
@@ -682,8 +682,7 @@ function _export(path, query, options = {}) {
|
|
|
682
682
|
options: {
|
|
683
683
|
...resolvedOptions,
|
|
684
684
|
query: {
|
|
685
|
-
...resolvedQuery
|
|
686
|
-
async: false
|
|
685
|
+
...resolvedQuery
|
|
687
686
|
}
|
|
688
687
|
}
|
|
689
688
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-dhis2",
|
|
3
3
|
"label": "DHIS2",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.2.0",
|
|
5
5
|
"description": "OpenFn adaptor for DHIS2",
|
|
6
6
|
"homepage": "https://docs.openfn.org",
|
|
7
7
|
"repository": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"configuration-schema.json"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"axios": "^1.
|
|
29
|
+
"axios": "^1.15.2",
|
|
30
30
|
"lodash": "^4.18.1",
|
|
31
|
-
"qs": "^6.
|
|
32
|
-
"@openfn/language-common": "3.3.
|
|
31
|
+
"qs": "^6.15.2",
|
|
32
|
+
"@openfn/language-common": "3.3.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"assertion-error": "2.0.0",
|
package/types/tracker.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export type TrackerOptions = {
|
|
|
55
55
|
* @param {string} strategy - The effect the import should have. Can either be CREATE, UPDATE, CREATE_AND_UPDATE and DELETE.
|
|
56
56
|
* @param {object} payload - The data to be imported.
|
|
57
57
|
* @param {TrackerOptions} [options] - An optional object containing parseAs, and apiVersion, and queries for the request
|
|
58
|
+
* @param {boolean} [options.async=false] - Whether to perform the import asynchronously. Defaults to false. See [Sync and async imports](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html#sync-and-async)
|
|
58
59
|
* @state {DHIS2State}
|
|
59
60
|
* @returns {Operation}
|
|
60
61
|
*/
|
|
@@ -68,13 +69,15 @@ declare function _import(strategy: string, payload: object, options?: TrackerOpt
|
|
|
68
69
|
* @example <caption>Export all enrollment resources</caption>
|
|
69
70
|
* tracker.export('enrollments', {orgUnit: 'TSyzvBiovKh'});
|
|
70
71
|
* @example <caption>Export all events</caption>
|
|
71
|
-
* tracker.export('events')
|
|
72
|
+
* tracker.export('events', { paging: false})
|
|
73
|
+
* @example <caption>Export the first page of events with pagination metadata</caption>
|
|
74
|
+
* tracker.export('events', { totalPages: true, pageSize: 1000, page: 1 })
|
|
72
75
|
* @function
|
|
73
76
|
* @param {string} path - Path to the resource, relative to the /tracker endpoint
|
|
74
|
-
* @param {object} query - An object of query parameters to be encoded into the URL
|
|
77
|
+
* @param {object} query - An object of query parameters to be encoded into the URL. Can include [pagination parameters](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html#request-parameters-for-pagination), filters, etc.
|
|
75
78
|
* @param {TrackerOptions} [options] - An optional object containing parseAs, and apiVersion for the request
|
|
76
79
|
* @state {DHIS2State}
|
|
77
80
|
* @returns {Operation}
|
|
78
81
|
*/
|
|
79
|
-
declare function _export(path: string, query
|
|
82
|
+
declare function _export(path: string, query?: object, options?: TrackerOptions): Operation;
|
|
80
83
|
export { _import as import, _import as import, _export as export, _export as export };
|