@openfn/language-dhis2 3.2.5 → 3.2.7

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/README.md CHANGED
@@ -24,18 +24,12 @@ the main
24
24
  [Adaptor docs](https://docs.openfn.org/adaptors/packages/dhis2-docs#modules)
25
25
  page.
26
26
 
27
- ## Sample State
28
-
29
- ```json
30
- {
31
- "configuration": {
32
- "username": "admin",
33
- "password": "district",
34
- "hostUrl": "https://play.dhis2.org/2.36.6"
35
- },
36
- "data": { "a": 1, "b": 2 }
37
- }
38
- ```
27
+ ### Configuration
28
+
29
+ View all the required and optional properties for `state.configuration` in the
30
+ official
31
+ [configuration-schema](https://docs.openfn.org/adaptors/packages/dhis2-configuration-schema/)
32
+ definition.
39
33
 
40
34
  ## Development
41
35
 
package/ast.json CHANGED
@@ -30,12 +30,16 @@
30
30
  },
31
31
  "name": "resourceType"
32
32
  },
33
+ {
34
+ "title": "magic",
35
+ "description": "resourceType $.children.resourceTypes[*]"
36
+ },
33
37
  {
34
38
  "title": "param",
35
- "description": "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.",
39
+ "description": "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.",
36
40
  "type": {
37
41
  "type": "NameExpression",
38
- "name": "Object"
42
+ "name": "Dhis2Data"
39
43
  },
40
44
  "name": "data"
41
45
  },
package/dist/index.cjs CHANGED
@@ -344,9 +344,7 @@ function discover(httpMethod, endpoint) {
344
344
  let param = tempData.components.parameters[paramRef];
345
345
  if (param.schema["$ref"]) {
346
346
  let schemaRefIndex = param.schema["$ref"].lastIndexOf("/") + 1;
347
- let schemaRef = param.schema["$ref"].slice(
348
- schemaRefIndex
349
- );
347
+ let schemaRef = param.schema["$ref"].slice(schemaRefIndex);
350
348
  param.schema = tempData.components.schemas[schemaRef];
351
349
  }
352
350
  param.schema = JSON.stringify(param.schema);
package/dist/index.js CHANGED
@@ -312,9 +312,7 @@ function discover(httpMethod, endpoint) {
312
312
  let param = tempData.components.parameters[paramRef];
313
313
  if (param.schema["$ref"]) {
314
314
  let schemaRefIndex = param.schema["$ref"].lastIndexOf("/") + 1;
315
- let schemaRef = param.schema["$ref"].slice(
316
- schemaRefIndex
317
- );
315
+ let schemaRef = param.schema["$ref"].slice(schemaRefIndex);
318
316
  param.schema = tempData.components.schemas[schemaRef];
319
317
  }
320
318
  param.schema = JSON.stringify(param.schema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-dhis2",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "description": "DHIS2 Language Pack for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -28,16 +28,19 @@
28
28
  "@openfn/language-common": "^1.7.5",
29
29
  "axios": "^0.24.0",
30
30
  "lodash": "^4.17.19",
31
- "qs": "^6.10.3"
31
+ "qs": "^6.11.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@openfn/buildtools": "^1.0.2",
35
+ "@openfn/metadata": "^1.0.0",
36
+ "@openfn/parse-jsdoc": "^1.0.0",
35
37
  "@openfn/simple-ast": "0.4.1",
36
38
  "assertion-error": "2.0.0",
37
39
  "chai": "4.3.6",
38
40
  "chai-http": "4.3.0",
39
41
  "deep-eql": "4.1.1",
40
42
  "esno": "^0.16.3",
43
+ "jsonpath": "^1.1.1",
41
44
  "mocha": "7.2.0",
42
45
  "nock": "13.2.9",
43
46
  "rimraf": "3.0.2"
@@ -47,9 +50,9 @@
47
50
  "scripts": {
48
51
  "build": "pnpm clean && build-adaptor dhis2",
49
52
  "clean": "rimraf dist types docs",
50
- "integration-test": "mocha --experimental-specifier-resolution=node --no-warnings test/integration.js",
53
+ "integration-test": "mocha --experimental-specifier-resolution=node --no-warnings test/integration.cjs",
51
54
  "pack": "pnpm pack --pack-destination ../../dist",
52
- "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings test/index.js",
53
- "test": "mocha --experimental-specifier-resolution=node --no-warnings test/index.js"
55
+ "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings --exclude test/integration.cjs --recursive --timeout 10000",
56
+ "test": "mocha --experimental-specifier-resolution=node --no-warnings --exclude test/integration.cjs --recursive --timeout 10000"
54
57
  }
55
58
  }
@@ -16,7 +16,8 @@ export function execute(...operations: Operations): Operation;
16
16
  * @public
17
17
  * @function
18
18
  * @param {string} resourceType - Type of resource to create. E.g. `trackedEntityInstances`, `programs`, `events`, ...
19
- * @param {Object} data - 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.
19
+ * @magic resourceType $.children.resourceTypes[*]
20
+ * @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.
20
21
  * @param {Object} [options] - Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion.
21
22
  * @param {function} [callback] - Optional callback to handle the response
22
23
  * @returns {Operation}
@@ -111,7 +112,7 @@ export function execute(...operations: Operations): Operation;
111
112
  * incidentDate: '2013-09-17',
112
113
  * });
113
114
  */
114
- export function create(resourceType: string, data: any, options?: any, callback?: Function): Operation;
115
+ export function create(resourceType: string, data: Dhis2Data, options?: any, callback?: Function): Operation;
115
116
  /**
116
117
  * Update data. A generic helper function to update a resource object of any type.
117
118
  * Updating an object requires to send `all required fields` or the `full body`
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import './types';
2
+ import * as Adaptor from './Adaptor';
1
3
  export default Adaptor;
2
- export * from "./Adaptor";
3
- import * as Adaptor from "./Adaptor";
4
+ export * from './Adaptor';
@@ -0,0 +1,28 @@
1
+ export declare type Dhis2Attribute = {
2
+ /**
3
+ * The attribute id
4
+ * @magic $.children.attributes[*]
5
+ */
6
+ attribute: string;
7
+ value: any;
8
+ };
9
+ export declare type Dhis2Data = {
10
+ /**
11
+ * The id of an organisation unit
12
+ * @magic $.children.orgUnits[*]
13
+ */
14
+ orgUnit?: string;
15
+ /**
16
+ * Tracked instance id
17
+ */
18
+ trackedEntityInstance?: string;
19
+ /**
20
+ * Tracked instance type
21
+ * @magic $.children.trackedEntityTypes[*]
22
+ */
23
+ trackedEntityType?: string;
24
+ /**
25
+ * List of attributes
26
+ */
27
+ attributes?: Dhis2Attribute[];
28
+ };