@glion/lint-message-version 0.14.1 → 0.15.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/README.md +65 -42
- package/package.json +18 -9
package/README.md
CHANGED
|
@@ -1,80 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
# @glion/lint-message-version
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lint rule that checks an HL7v2 message's `MSH-12` version satisfies a semver range expression.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Reads `MSH-12.1` from the tree and evaluates it against the configured `expression` using `@glion/util-semver`. Reports a message when `MSH-12` is missing or empty, when the value is not a valid semver-like version, or when it falls outside the allowed range. The default expression (`"<3.0.0 >=2.3"`) accepts HL7v2 versions 2.3 through 2.9 and excludes future v3 values.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
|
|
12
|
+
npm install @glion/lint-message-version
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
## Use
|
|
12
16
|
|
|
13
|
-
```
|
|
14
|
-
import { unified } from "unified";
|
|
17
|
+
```ts
|
|
15
18
|
import { hl7v2Parser } from "@glion/parser";
|
|
16
19
|
import hl7v2LintMessageVersion from "@glion/lint-message-version";
|
|
20
|
+
import { unified } from "unified";
|
|
21
|
+
import { reporter } from "vfile-reporter";
|
|
17
22
|
|
|
18
|
-
const message =
|
|
23
|
+
const message =
|
|
24
|
+
"MSH|^~\\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.5";
|
|
19
25
|
|
|
20
|
-
const
|
|
26
|
+
const file = await unified()
|
|
21
27
|
.use(hl7v2Parser)
|
|
22
|
-
|
|
23
|
-
.
|
|
28
|
+
.use(hl7v2LintMessageVersion, { expression: "<3.0.0 >=2.3" })
|
|
29
|
+
.process(message);
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
console.error(reporter([file]));
|
|
26
32
|
```
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
## API
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
- A semver-like range expression evaluated against `MSH-12`.
|
|
32
|
-
- Defaults to `"<3.0.0 >=2.3"`.
|
|
36
|
+
### `unified().use(hl7v2LintMessageVersion[, options])`
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
A `unified` lint rule plugin.
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
```ts
|
|
41
|
+
import type { Plugin } from "unified";
|
|
42
|
+
import type { Root } from "@glion/ast";
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
export interface MessageVersionLintOptions {
|
|
45
|
+
/** Semver range expression to evaluate against `MSH-12.1`. Default: "<3.0.0 >=2.3". */
|
|
46
|
+
expression: string;
|
|
47
|
+
}
|
|
39
48
|
|
|
49
|
+
declare const hl7v2LintMessageVersion: Plugin<
|
|
50
|
+
[MessageVersionLintOptions?],
|
|
51
|
+
Root
|
|
52
|
+
>;
|
|
53
|
+
export default hl7v2LintMessageVersion;
|
|
40
54
|
```
|
|
55
|
+
|
|
56
|
+
Expressions are parsed and evaluated by `@glion/util-semver`.
|
|
57
|
+
|
|
58
|
+
## What it checks
|
|
59
|
+
|
|
60
|
+
The value of `MSH-12.1` must be present and must satisfy the configured semver expression.
|
|
61
|
+
|
|
62
|
+
### Valid
|
|
63
|
+
|
|
64
|
+
`MSH-12` is `2.5`, within the default range `<3.0.0 >=2.3`:
|
|
65
|
+
|
|
66
|
+
```hl7
|
|
41
67
|
MSH|^~\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.5
|
|
42
68
|
```
|
|
43
69
|
|
|
44
|
-
|
|
70
|
+
### Invalid
|
|
45
71
|
|
|
46
|
-
|
|
72
|
+
`MSH-12` is `2.2`, below the default minimum:
|
|
73
|
+
|
|
74
|
+
```hl7
|
|
47
75
|
MSH|^~\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.2
|
|
48
76
|
```
|
|
49
77
|
|
|
50
|
-
|
|
78
|
+
Reported message:
|
|
51
79
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
.use(hl7v2Parser)
|
|
55
|
-
.use(hl7v2LintMessageVersion, { expression: "<3.0.0 >=2.2" });
|
|
80
|
+
```
|
|
81
|
+
MSH-12 (version) field value '2.2' does not satisfy expression '<3.0.0 >=2.3'
|
|
56
82
|
```
|
|
57
83
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
We welcome contributions! Please see our [Contributing Guide][github-contributing] for more details.
|
|
84
|
+
`MSH-12` is missing:
|
|
61
85
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
66
|
-
5. Open a Pull Request
|
|
86
|
+
```
|
|
87
|
+
Required MSH-12 (version) field is missing or empty
|
|
88
|
+
```
|
|
67
89
|
|
|
68
|
-
|
|
90
|
+
`MSH-12` contains a value that cannot be parsed as semver:
|
|
69
91
|
|
|
70
|
-
|
|
92
|
+
```
|
|
93
|
+
MSH-12 (version) field value 'abc' is not valid
|
|
94
|
+
```
|
|
71
95
|
|
|
72
|
-
|
|
96
|
+
Both the offending value and the configured expression are interpolated into the message. The rule reports at most one message per tree and exits as soon as the first problem is detected.
|
|
73
97
|
|
|
74
|
-
|
|
98
|
+
## Part of Glion
|
|
75
99
|
|
|
76
|
-
|
|
100
|
+
`@glion/lint-message-version` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
|
|
77
101
|
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[github-contributing]: https://github.com/rethinkhealth/glion/blob/main/CONTRIBUTING.md
|
|
102
|
+
[Glion]: https://github.com/rethinkhealth/glion#readme
|
|
103
|
+
[Glion README]: https://github.com/rethinkhealth/glion#readme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-message-version",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "hl7v2-lint rule to warn when message version is not supported",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"definition",
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
"name": "Melek Somai",
|
|
21
21
|
"email": "melek@rethinkhealth.io"
|
|
22
22
|
},
|
|
23
|
-
"repository":
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/rethinkhealth/glion.git",
|
|
26
|
+
"directory": "packages/lint-message-version"
|
|
27
|
+
},
|
|
24
28
|
"files": [
|
|
25
29
|
"dist"
|
|
26
30
|
],
|
|
@@ -35,31 +39,36 @@
|
|
|
35
39
|
"dependencies": {
|
|
36
40
|
"ensure-error": "5.0.0",
|
|
37
41
|
"unified-lint-rule": "3.0.1",
|
|
38
|
-
"@glion/util-query": "0.
|
|
39
|
-
"@glion/util-semver": "0.
|
|
42
|
+
"@glion/util-query": "0.15.2",
|
|
43
|
+
"@glion/util-semver": "0.15.2"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "^25.5.0",
|
|
43
47
|
"@types/unist": "^3.0.3",
|
|
44
48
|
"@vitest/coverage-v8": "4.1.2",
|
|
49
|
+
"publint": "0.3.18",
|
|
45
50
|
"tsdown": "0.21.7",
|
|
46
51
|
"typescript": "^5.9.3",
|
|
47
52
|
"unified": "^11.0.5",
|
|
48
53
|
"vfile": "^6.0.3",
|
|
49
54
|
"vitest": "4.1.2",
|
|
50
|
-
"@glion/
|
|
51
|
-
"@glion/
|
|
52
|
-
"@glion/
|
|
53
|
-
"@glion/
|
|
55
|
+
"@glion/tsconfig": "0.15.2",
|
|
56
|
+
"@glion/check-readme": "0.15.2",
|
|
57
|
+
"@glion/ast": "0.15.2",
|
|
58
|
+
"@glion/testing": "0.15.2",
|
|
59
|
+
"@glion/builder": "0.15.2"
|
|
54
60
|
},
|
|
55
61
|
"engines": {
|
|
56
62
|
"node": ">=18"
|
|
57
63
|
},
|
|
64
|
+
"packageManager": "pnpm@10.14.0",
|
|
58
65
|
"scripts": {
|
|
59
66
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
60
67
|
"check-types": "tsc --noEmit",
|
|
68
|
+
"check:readme": "glion-check-readme",
|
|
61
69
|
"test": "vitest run",
|
|
62
70
|
"test:coverage": "vitest run --coverage",
|
|
63
|
-
"test:watch": "vitest"
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"publint": "publint --strict"
|
|
64
73
|
}
|
|
65
74
|
}
|