cht-conf 3.13.0 → 3.14.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.14.0](https://github.com/medic/cht-conf/compare/v3.13.0...v3.14.0) (2022-08-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **#494:** validate notes are not required in forms ([#496](https://github.com/medic/cht-conf/issues/496)) ([a5a8e09](https://github.com/medic/cht-conf/commit/a5a8e096a478373a43e63f0f606a2919bade8982)), closes [#494](https://github.com/medic/cht-conf/issues/494)
7
+
1
8
  # [3.13.0](https://github.com/medic/cht-conf/compare/v3.12.0...v3.13.0) (2022-07-12)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cht-conf",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Configure CHT deployments",
5
5
  "main": "./src/lib/main.js",
6
6
  "engines": {
@@ -5,10 +5,15 @@ const fs = require('../lib/sync-fs');
5
5
  const { info } = require('../lib/log');
6
6
 
7
7
  const LAYOUT = {
8
- 'contact-summary.js': '',
8
+ 'contact-summary.templated.js': `module.exports = {
9
+ fields: [],
10
+ cards: [],
11
+ context: {}
12
+ };`,
9
13
  'privacy-policies.json': {},
10
14
  'privacy-policies': {},
11
15
  'resources.json': {},
16
+ 'harness.defaults.json': {},
12
17
  resources: {},
13
18
  'targets.js': 'module.exports = [];',
14
19
  'tasks.js': 'module.exports = [];',
@@ -32,6 +37,12 @@ const LAYOUT = {
32
37
  'forms.json': {},
33
38
  'schedules.json': [],
34
39
  },
40
+ test: {
41
+ forms: {},
42
+ 'contact-summary': {},
43
+ tasks: {},
44
+ targets: {}
45
+ }
35
46
  };
36
47
 
37
48
  function createRecursively(dir, layout) {
@@ -0,0 +1,23 @@
1
+ const { getBindNodes } = require('../../forms-utils');
2
+
3
+ module.exports = {
4
+ requiresInstance: false,
5
+ skipFurtherValidation: false,
6
+ execute: async({ xformPath, xmlDoc }) => {
7
+ const errors = [];
8
+
9
+ const requiredNotes = getBindNodes(xmlDoc)
10
+ .filter(bind => bind.getAttribute('readonly') === 'true()') // Notes will not be conditionally readonly
11
+ .filter(bind => {
12
+ const required = bind.getAttribute('required');
13
+ return required && required !== 'false()';
14
+ })
15
+ .filter(bind => bind.getAttribute('type') === 'string')
16
+ .filter(bind => !bind.getAttribute('calculate'))
17
+ .map(bind => bind.getAttribute('nodeset'));
18
+ if(requiredNotes.length) {
19
+ errors.push(`Form at ${xformPath} contains the following note fields with 'required' expressions: [${requiredNotes.join(', ')}]`);
20
+ }
21
+ return { errors, warnings: [] };
22
+ }
23
+ };