@openfn/language-dhis2 6.0.1 → 6.0.2

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 (2) hide show
  1. package/README.md +86 -73
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,98 +1,107 @@
1
1
  # Language DHIS2
2
2
 
3
- An OpenFn language Pack for building expressions and operations for working with
4
- the
5
- [DHIS2 API](http://dhis2.github.io/dhis2-docs/master/en/developer/html/dhis2_developer_manual.html).
6
- Used most commonly via OpenFn.org or by hand with
7
- [OpenFn/core](https://github.com/OpenFn/core) from the root of this repo:
3
+ An OpenFn language pack for building expressions and operations to work with the
4
+ [DHIS2 API](https://docs.dhis2.org/en/home.html). Commonly used via
5
+ [OpenFn.org](https://app.openfn.org) or manually with
6
+ [OpenFn CLI](https://github.com/OpenFn/kit).
7
+
8
+ ## Table of Contents
9
+
10
+ 1. [Getting Started](#getting-started)
11
+ 2. [Important Note](#important-note)
12
+ 3. [Configuration](#configuration)
13
+ 4. [Helper Functions](#helper-functions)
14
+ 5. [Development](#development)
15
+ - [Running Tests](#running-tests)
16
+ - [Unit Tests](#unit-tests)
17
+ - [Integration Tests](#integration-tests)
18
+ - [Troubleshooting Tests](#troubleshooting-tests)
19
+
20
+ ---
21
+
22
+ ## Getting Started
23
+
24
+ To use this package, execute commands via OpenFn/core from the root of the
25
+ repository:
8
26
 
9
27
  ```sh
10
- core execute \
11
- -l ../language-dhis2 \
12
- -e ./tmp/expression.js \
13
- -s ./tmp/state.json \
14
- -o ./tmp/output.json
28
+ openfn job.js -a dhis2 -s tmp/state.json
15
29
  ```
16
30
 
17
- > **Important Note:**
18
- > This adaptor uses the old tracker version and is only compatible with DHIS2
19
- > API versions before 42 (2.42). For later API versions and the new tracker, use
20
- > adaptor 6.0+. See
21
- > [DHIS2 documentation](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html)
22
- > for more information.
31
+ For installation and usage, see the
32
+ [docs site](https://docs.openfn.org/adaptors/packages/dhis2-docs).
23
33
 
24
- ## Documentation
34
+ ---
25
35
 
26
- View the [docs site](https://docs.openfn.org/adaptors/packages/dhis2-docs) for
27
- full technical documentation.
36
+ ## Important Note
28
37
 
29
- There are lots of **examples** for how to use the various helper functions on
30
- the main
31
- [Adaptor docs](https://docs.openfn.org/adaptors/packages/dhis2-docs#modules)
32
- page.
38
+ - For DHIS2 API versions 2.42+ and the **new tracker**, use **adaptor 6.0+**.
39
+ Refer to the
40
+ [DHIS2 API documentation](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html)
41
+ for details.
42
+ - For **old tracker versions** and DHIS2 API versions **prior to 2.42**, use
43
+ **adaptor 5.0+**. But we highly recommend upgrading to the latest version.
33
44
 
34
- ### Configuration
45
+ ---
35
46
 
36
- View all the required and optional properties for `state.configuration` in the
37
- official
38
- [configuration-schema](https://docs.openfn.org/adaptors/packages/dhis2-configuration-schema/)
39
- definition.
47
+ ## Configuration
40
48
 
41
- ## Development
49
+ All required and optional properties for `state.configuration` are defined in
50
+ the official
51
+ [configuration-schema](https://docs.openfn.org/adaptors/packages/dhis2-configuration-schema/).
42
52
 
43
- Run tests using `pnpm run test` or `pnpm run test:watch`. (NB: that this repo
44
- also contain integration tests which can be run with
45
- `pnpm run integration-test`.)
53
+ Ensure you configure:
46
54
 
47
- ⚠️ NB: Make changes to the files in `src/` and then use `npm run build` to
48
- generate output files in `lib/`.
55
+ - **Username**: DHIS2 admin username
56
+ - **Password**: Corresponding DHIS2 admin password
57
+ - **Host URL**: URL of the DHIS2 instance
49
58
 
50
- The documentation is autogenerated, so please **rebuild the docs** after making
51
- changes by running `pnpm build docs`
59
+ Example configuration:
52
60
 
53
- ### Unit Tests
61
+ ```json
62
+ {
63
+ "username": "admin",
64
+ "password": "district",
65
+ "hostUrl": "https://play.dhis2.org/2.36.6"
66
+ }
67
+ ```
54
68
 
55
- Unit tests allows to test the functionalities of the adaptor helper functions
56
- such as:
69
+ ---
57
70
 
58
- > Does `create('events', payload)` perform a post request to the correct DHIS2
59
- > API?
71
+ ## Helper Functions
60
72
 
61
- To run unit tests execute `pnpm run test` (they're the default tests).
73
+ Helper functions simplify common DHIS2 operations. View the
74
+ [complete function documentation](https://docs.openfn.org/adaptors/packages/dhis2-docs).
62
75
 
63
- Anytime a new functionality is added to the helper functions, more unit tests
64
- needs to be added.
76
+ ## Development
77
+
78
+ ### Running Tests
79
+
80
+ To run unit and integration tests, use the following commands:
81
+
82
+ - **Unit Tests**: `pnpm test`
83
+ - **Integration Tests**: `pnpm test:integration`
65
84
 
66
- ### End-to-end integration tests
85
+ _Note: Integration tests depend on a live DHIS2 instance._
67
86
 
68
- Integration tests allow us to test the end-to-end behavior of the helper
69
- functions and also to test the examples we provide via inline documentation.
87
+ ### Unit Tests
88
+
89
+ Unit tests validate helper functions independently. For example:
70
90
 
71
- For example with integration tests we answer the following question:
91
+ - Does `create('events', payload)` perform a correct POST request?
72
92
 
73
- > Does `create('events', eventPayload)` actually create a new event in a live
74
- > DHIS2 system?
93
+ Add new unit tests whenever helper functions are updated.
75
94
 
76
- To run integration tests, execute `npm run integration-test`. These tests use
77
- network I/O and a public connection to a DHIS2 "play" server so their timing and
78
- performance is unpredictable. Consider adding an increased timeout, and
79
- modifying the orgUnit, program, etc., IDs set in `globalState`.
95
+ ### Integration Tests
80
96
 
81
- #### Troubleshooting the tests
97
+ Integration tests validate end-to-end behavior with a live DHIS2 instance.
98
+ Ensure your test environment includes:
82
99
 
83
- - Depending on your internet strength please consider changing the **global
84
- timeout** in the `test/mocha.opts` file to avoid faillures related to network
85
- timeouts.
100
+ - At least one **organisation unit**.
101
+ - One **program** and a corresponding **program stage**.
102
+ - A **tracked entity instance** enrolled in the program.
86
103
 
87
- - The behavior of the tests in `test/integration.js` is very unpredictable; they
88
- depend on the **configuration of a target DHIS2 instance**. Currently you need
89
- to have at least one organisation unit with one program, one
90
- trackedEntityInstance and one programStage in it. These components need to be
91
- well configured for the integration tests to work. For example: the
92
- trackedEntityInstance need to be enrolled to the program, which should be
93
- created in that organisation unit and contains at least that programStage. If
94
- the tests fail, you must adjust these attributes in the
95
- [before hook](https://github.com/OpenFn/adaptors/tree/main/packages/dhis2/test/integration.js):
104
+ Modify `globalState` in `test/integration.js` as needed:
96
105
 
97
106
  ```javascript
98
107
  before(done => {
@@ -111,10 +120,14 @@ before(done => {
111
120
  });
112
121
  ```
113
122
 
114
- - Make sure the `update` and `upsert` integration tests don't affect those
115
- initial organisation units, programs, programStage and trackedEntityInstance
116
- required. Otherwise the create integration tests would be broken again; and
117
- that's an endless faillure loop :(
123
+ ### Troubleshooting Tests
124
+
125
+ - **Timeout Errors**: Increase the global timeout in `test/mocha.opts`.
126
+ - **Environment Issues**: Ensure DHIS2 components (programs, org units, etc.)
127
+ are correctly configured.
128
+
129
+ ---
118
130
 
119
- Anytime a new example is added in the documentation of a helper function, a new
120
- integration test should be built.
131
+ For further technical details, see the
132
+ [documentation](https://docs.openfn.org/adaptors/packages/dhis2-docs) or contact
133
+ the [OpenFn community](https://community.openfn.org).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-dhis2",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
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.1.1"
31
+ "@openfn/language-common": "2.2.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "assertion-error": "2.0.0",