fhir-validator-wrapper 1.2.0 → 1.2.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/fhir-validator.js +42 -1
- package/package.json +1 -1
- package/readme.md +13 -1
package/fhir-validator.js
CHANGED
|
@@ -24,6 +24,15 @@ class FhirValidator {
|
|
|
24
24
|
|
|
25
25
|
// Version tracking file sits alongside the JAR
|
|
26
26
|
this.versionFilePath = validatorJarPath + '.version';
|
|
27
|
+
this.version = undefined;
|
|
28
|
+
this.lastStderr = '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns what version the validator jar reports that it is
|
|
33
|
+
*/
|
|
34
|
+
jarVersion() {
|
|
35
|
+
return this.version;
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
/**
|
|
@@ -369,6 +378,10 @@ class FhirValidator {
|
|
|
369
378
|
|
|
370
379
|
this.process.on('exit', (code, signal) => {
|
|
371
380
|
this.log('info', `Validator process exited with code ${code} and signal ${signal}`);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
this.process.on('close', (code, signal) => {
|
|
384
|
+
this.log('info', `Validator process closed`);
|
|
372
385
|
this.cleanup();
|
|
373
386
|
});
|
|
374
387
|
|
|
@@ -379,6 +392,7 @@ class FhirValidator {
|
|
|
379
392
|
// Remove ANSI escape sequences (color codes, etc.)
|
|
380
393
|
const cleanLine = line.replace(/\u001b\[[0-9;]*m/g, '').trim();
|
|
381
394
|
if (cleanLine.length > 1) {
|
|
395
|
+
this.checkForVersion(cleanLine);
|
|
382
396
|
this.log('info', `Validator: ${cleanLine}`);
|
|
383
397
|
}
|
|
384
398
|
});
|
|
@@ -388,8 +402,26 @@ class FhirValidator {
|
|
|
388
402
|
this.log('error', `Validator-err: ${data}`);
|
|
389
403
|
});
|
|
390
404
|
|
|
405
|
+
this.lastStderr = '';
|
|
406
|
+
|
|
407
|
+
this.process.stderr.on('data', (data) => {
|
|
408
|
+
const text = data.toString();
|
|
409
|
+
this.lastStderr += text;
|
|
410
|
+
this.log('error', `Validator-err: ${text}`);
|
|
411
|
+
});
|
|
412
|
+
|
|
391
413
|
// Wait for the service to be ready
|
|
392
|
-
await
|
|
414
|
+
await Promise.race([
|
|
415
|
+
this.waitForReady(timeout),
|
|
416
|
+
new Promise((_, reject) => {
|
|
417
|
+
this.process.on('close', (code) => {
|
|
418
|
+
if (code !== 0) {
|
|
419
|
+
reject(new Error(`Validator exited with code ${code}:\n${this.lastStderr.slice(-2000)}`));
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
})
|
|
423
|
+
]);
|
|
424
|
+
|
|
393
425
|
this.log('info', 'FHIR validator service is ready');
|
|
394
426
|
}
|
|
395
427
|
|
|
@@ -805,6 +837,15 @@ class FhirValidator {
|
|
|
805
837
|
isRunning() {
|
|
806
838
|
return this.process !== null && this.isReady;
|
|
807
839
|
}
|
|
840
|
+
|
|
841
|
+
checkForVersion(cleanLine) {
|
|
842
|
+
if (!this.version) {
|
|
843
|
+
if (cleanLine.startsWith('FHIR Validation tool Version')) {
|
|
844
|
+
let parts = cleanLine.split(' ');
|
|
845
|
+
this.version = parts[4];
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
808
849
|
}
|
|
809
850
|
|
|
810
851
|
module.exports = FhirValidator;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -538,4 +538,16 @@ validator.setLogger(logger);
|
|
|
538
538
|
## Support
|
|
539
539
|
|
|
540
540
|
For issues with this wrapper, please file a GitHub issue.
|
|
541
|
-
For FHIR validator issues, see the [official FHIR validator documentation](https://confluence.hl7.org/spaces/FHIR/pages/35718580/Using+the+FHIR+Validator).
|
|
541
|
+
For FHIR validator issues, see the [official FHIR validator documentation](https://confluence.hl7.org/spaces/FHIR/pages/35718580/Using+the+FHIR+Validator).
|
|
542
|
+
|
|
543
|
+
## Release Process
|
|
544
|
+
|
|
545
|
+
Check that there's an entry in CHANGELOG.md, and then:
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
npm login
|
|
549
|
+
npm version patch ## or minor
|
|
550
|
+
git push && git push --tags
|
|
551
|
+
|
|
552
|
+
```
|
|
553
|
+
|