cht-conf 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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/lib/forms-utils.js +7 -0
- package/src/lib/upload-forms.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [6.0.2](https://github.com/medic/cht-conf/compare/v6.0.1...v6.0.2) (2026-01-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **#787:** upload forms with correct `internalId` property ([#788](https://github.com/medic/cht-conf/issues/788)) ([3a28dce](https://github.com/medic/cht-conf/commit/3a28dce3499c7cc2aac7ad5c8a7327303288986f)), closes [#787](https://github.com/medic/cht-conf/issues/787)
|
|
7
|
+
|
|
1
8
|
## [6.0.1](https://github.com/medic/cht-conf/compare/v6.0.0...v6.0.1) (2026-01-14)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/lib/forms-utils.js
CHANGED
|
@@ -127,6 +127,13 @@ module.exports = {
|
|
|
127
127
|
readTitleFrom: xml =>
|
|
128
128
|
xml.substring(xml.indexOf('<h:title>') + 9, xml.indexOf('</h:title>')),
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Get the ID of the form
|
|
132
|
+
* @param {string} xml the XML string
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
readIdFrom: xml => /<model.*?>[^]*?<instance>[^]*?id="([^"]*)"[^]*?<\/instance>[^]*?<\/model>/.exec(xml)?.[1],
|
|
136
|
+
|
|
130
137
|
/**
|
|
131
138
|
* Escape whitespaces in a path.
|
|
132
139
|
* @param {string} path the path string
|
package/src/lib/upload-forms.js
CHANGED
|
@@ -10,7 +10,7 @@ const warnUploadOverwrite = require('./warn-upload-overwrite');
|
|
|
10
10
|
const {
|
|
11
11
|
getFormDir,
|
|
12
12
|
getFormFilePaths,
|
|
13
|
-
readTitleFrom,
|
|
13
|
+
readTitleFrom, readIdFrom,
|
|
14
14
|
} = require('./forms-utils');
|
|
15
15
|
|
|
16
16
|
const SUPPORTED_PROPERTIES = ['context', 'icon', 'title', 'xml2sms', 'subject_key', 'hidden_fields'];
|
|
@@ -59,7 +59,7 @@ const execute = async (projectDir, subDirectory, options) => {
|
|
|
59
59
|
log.info(`Preparing form for upload: ${fileName}…`);
|
|
60
60
|
|
|
61
61
|
const { baseFileName, mediaDir, xformPath, filePath } = getFormFilePaths(formsDir, fileName);
|
|
62
|
-
const
|
|
62
|
+
const baseDocId = (options.id_prefix || '') + baseFileName.replaceAll('-', ':');
|
|
63
63
|
|
|
64
64
|
const mediaDirExists = fs.exists(mediaDir);
|
|
65
65
|
if (!mediaDirExists) {
|
|
@@ -74,7 +74,14 @@ const execute = async (projectDir, subDirectory, options) => {
|
|
|
74
74
|
sha256: hashSum.digest('hex'),
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const internalId = readIdFrom(xml);
|
|
78
|
+
if (internalId.replaceAll('-', ':') !== baseDocId) {
|
|
79
|
+
throw new Error(`The file name for the form [${baseFileName}] does not match the id in the xml [${
|
|
80
|
+
internalId
|
|
81
|
+
}]. Rename the form xlsx/xml files to match the id.`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const docId = `form:${baseDocId}`;
|
|
78
85
|
const doc = {
|
|
79
86
|
_id: docId,
|
|
80
87
|
type: 'form',
|