@openfn/language-dhis2 8.0.2 → 8.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfn/language-dhis2",
3
3
  "label": "DHIS2",
4
- "version": "8.0.2",
4
+ "version": "8.0.4",
5
5
  "description": "OpenFn adaptor for DHIS2",
6
6
  "homepage": "https://docs.openfn.org",
7
7
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "axios": "^1.8.2",
30
30
  "lodash": "^4.17.21",
31
31
  "qs": "^6.11.0",
32
- "@openfn/language-common": "3.1.0"
32
+ "@openfn/language-common": "3.1.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "assertion-error": "2.0.0",
@@ -0,0 +1,137 @@
1
+ /**
2
+ * State object
3
+ * @typedef {Object} DHIS2HttpState
4
+ * @private
5
+ * @property data - The response body (as JSON)
6
+ * @property response - The HTTP response from the DHIS2 server (excluding the body)
7
+ * @property references - An array of all previous data objects used in the Job
8
+ */
9
+ /**
10
+ * Options object
11
+ * @typedef {Object} RequestOptions
12
+ * @property {object} query - An object of query parameters to be encoded into the URL
13
+ * @property {object} headers - An object of all request headers
14
+ * @property {string} [parseAs='json'] - The response format to parse (e.g., 'json', 'text', 'stream', or 'base64'. Defaults to `json`
15
+ * @property {string} [apiVersion=42] - The apiVersion of the request. Defaults to 42.
16
+ */
17
+ /**
18
+ * Make a GET request to any DHIS2 endpoint.
19
+ * @public
20
+ * @example <caption>Get with query parameters</caption>
21
+ * http.get('dataValueSets', {
22
+ * query:{
23
+ * dataSet: 'pBOMPrpg1QX',
24
+ * orgUnit: 'DiszpKrYNg8',
25
+ * period: '201401',
26
+ * fields: '*',
27
+ * }
28
+ * });
29
+ * @example <caption>Get an image from a trackedEntityInstance.</caption>
30
+ * http.get('trackedEntityInstances/qHVDKszQmdx/BqaEWTBG3RB/image', {
31
+ * headers:{
32
+ * Accept: 'image/*'
33
+ * },
34
+ * parseAs: 'base64',
35
+ * });
36
+ * @function
37
+ * @param {string} path - Path to resource.
38
+ * @param {RequestOptions} [options] - An optional object containing query, parseAs,and headers for the request
39
+ * @state {DHIS2HttpState}
40
+ * @returns {Operation}
41
+ */
42
+ export function get(path: string, options?: RequestOptions): Operation;
43
+ /**
44
+ * Make a POST request to any DHIS2 endpoint.
45
+ * @public
46
+ * @example <caption>Call the tracker endpoint with a JSON payload</caption>
47
+ * http.post("tracker", {
48
+ * events: [
49
+ * {
50
+ * program: "eBAyeGv0exc",
51
+ * orgUnit: "DiszpKrYNg8",
52
+ * status: "COMPLETED",
53
+ * },
54
+ * ],
55
+ * });
56
+ * @function
57
+ * @param {string} path - Path to resource.
58
+ * @magic path $.children.resourceTypes[*]
59
+ * @param {DHIS2Data} data - Object which defines data that will be used to create a given instance of resource. To create a single instance of a resource, `data` must be a javascript object, and to create multiple instances of a resources, `data` must be an array of javascript objects.
60
+ * @param {RequestOptions} [options] - An optional object containing query, parseAs,and headers for the request.
61
+ * @state {DHIS2HttpState}
62
+ * @returns {Operation}
63
+ */
64
+ export function post(path: string, data: DHIS2Data, options?: RequestOptions): Operation;
65
+ /**
66
+ * Make a PATCH request to any DHIS2 endpoint.
67
+ * @public
68
+ * @example <caption>Update a resource</caption>
69
+ * patch('dataElements', 'FTRrcoaog83', { name: 'New Name' });
70
+ * @function
71
+ * @param {string} resourceType - The type of resource to be updated.
72
+ * @param {string} path - The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}`
73
+ * @param {Object} data - Data to update. Include only the fields you want to update. E.g. `{name: "New Name"}`
74
+ * @param {RequestOptions} [options] - An optional object containing query, parseAs,and headers for the request.
75
+ * @state {DHIS2HttpState}
76
+ * @returns {Operation}
77
+ */
78
+ export function patch(resourceType: string, path: string, data: any, options?: RequestOptions): Operation;
79
+ /**
80
+ * Make a HTTP request to any DHIS2 endpoint
81
+ * @public
82
+ * @example <caption>GET request with a URL params</caption>
83
+ * http.request("GET",
84
+ * "tracker/relationships", {
85
+ * query:{
86
+ * trackedEntity: ['F8yKM85NbxW']
87
+ * },
88
+ * });
89
+ * @example <caption>Upsert a tracker resource </caption>
90
+ * http.request('POST', 'tracker', {
91
+ * data: {
92
+ * orgUnit: 'TSyzvBiovKh',
93
+ * trackedEntityType: 'nEenWmSyUEp',
94
+ * attributes: [
95
+ * {
96
+ * attribute: 'w75KJ2mc4zz',
97
+ * value: 'Qassime',
98
+ * },
99
+ * ],
100
+ * },
101
+ * query:{
102
+ * importStrategy: 'CREATE_AND_UPDATE'
103
+ * }
104
+ * });
105
+ * @function
106
+ * @param {string} method - HTTP method to use
107
+ * @param {string} path - Path to resource
108
+ * @param {RequestOptions} [options] - An optional object containing query, requestConfig, and data for the request
109
+ * @returns {Operation}
110
+ * @state {DHIS2HttpState}
111
+ */
112
+ export function request(method: string, path: string, options?: RequestOptions): Operation;
113
+ /**
114
+ * State object
115
+ */
116
+ export type DHIS2HttpState = any;
117
+ /**
118
+ * Options object
119
+ */
120
+ export type RequestOptions = {
121
+ /**
122
+ * - An object of query parameters to be encoded into the URL
123
+ */
124
+ query: object;
125
+ /**
126
+ * - An object of all request headers
127
+ */
128
+ headers: object;
129
+ /**
130
+ * - The response format to parse (e.g., 'json', 'text', 'stream', or 'base64'. Defaults to `json`
131
+ */
132
+ parseAs?: string;
133
+ /**
134
+ * - The apiVersion of the request. Defaults to 42.
135
+ */
136
+ apiVersion?: string;
137
+ };
package/types/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import './types';
2
- import * as Adaptor from './Adaptor';
2
+ import * as Adaptor from './Adaptor.js';
3
3
  export default Adaptor;
4
- export * from './Adaptor';
5
- export * as util from './util';
6
- export * as tracker from './tracker';
4
+ export * from './Adaptor.js';
5
+ export * as http from './http.js';
6
+ export * as util from './util.js';
7
+ export * as tracker from './tracker.js';