@glion/lint-message-version 0.26.0 → 0.27.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/LICENSE +1 -1
- package/README.md +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ MSH|^~\&|SENDER|FAC|RCVR|FAC|20250101010101||ADT^A01^ADT_A01|MSG00001|P|2.2
|
|
|
78
78
|
Reported message:
|
|
79
79
|
|
|
80
80
|
```
|
|
81
|
-
The version
|
|
81
|
+
The version is outside the supported range; it must satisfy `<3.0.0 >=2.3`.
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
`MSH-12` is missing:
|
|
@@ -90,13 +90,13 @@ The message has no `MSH-12` (Version ID); a message must declare its HL7v2 versi
|
|
|
90
90
|
`MSH-12` is present but empty:
|
|
91
91
|
|
|
92
92
|
```
|
|
93
|
-
The version
|
|
93
|
+
The version is empty; a message must declare its HL7v2 version.
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
`MSH-12` contains a value that cannot be parsed as semver:
|
|
97
97
|
|
|
98
98
|
```
|
|
99
|
-
The version
|
|
99
|
+
The version is not a version number; a version must be numbers separated by dots, such as `2.5` or `2.5.1`.
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
Each report on a value sets `actual` to that value; a version outside the range also sets `expected` to the configured expression. The rule reports at most one message per tree and exits as soon as the first problem is detected.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Node } from "@glion/ast";
|
|
2
2
|
export interface MessageVersionLintOptions {
|
|
3
3
|
expression: string;
|
|
4
4
|
}
|
|
5
|
-
declare const hl7v2LintMessageVersion: import("unified-lint-rule").Plugin<
|
|
5
|
+
declare const hl7v2LintMessageVersion: import("unified-lint-rule").Plugin<Node, MessageVersionLintOptions>;
|
|
6
6
|
export default hl7v2LintMessageVersion;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,YAAY,CAAC;AAM7C,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB;AAqBD,QAAA,MAAM,uBAAuB,qEA8D5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,13 @@ import { lintRule } from "unified-lint-rule";
|
|
|
5
5
|
//#region src/index.ts
|
|
6
6
|
const defaultOptions = { expression: "<3.0.0 >=2.3" };
|
|
7
7
|
const messages = {
|
|
8
|
-
emptyVersion: "The version
|
|
8
|
+
emptyVersion: "The version is empty; a message must declare its HL7v2 version.",
|
|
9
9
|
missingVersion: "The message has no `MSH-12` (Version ID); a message must declare its HL7v2 version.",
|
|
10
10
|
notMessage: (kind) => `The input is a ${kind}; the version can be read only from \`MSH-12\` (Version ID) of a whole message.`,
|
|
11
|
-
unparsableVersion:
|
|
12
|
-
unsupportedVersion: (
|
|
11
|
+
unparsableVersion: "The version is not a version number; a version must be numbers separated by dots, such as `2.5` or `2.5.1`.",
|
|
12
|
+
unsupportedVersion: (expression) => `The version is outside the supported range; it must satisfy \`${expression}\`.`
|
|
13
13
|
};
|
|
14
|
+
const isMessage = (node) => node.type === "root";
|
|
14
15
|
const hl7v2LintMessageVersion = lintRule({
|
|
15
16
|
origin: "hl7v2-lint:message-version",
|
|
16
17
|
url: "https://github.com/rethinkhealth/glion/tree/main/packages/lint-message-version#readme"
|
|
@@ -19,14 +20,14 @@ const hl7v2LintMessageVersion = lintRule({
|
|
|
19
20
|
...defaultOptions,
|
|
20
21
|
...opts
|
|
21
22
|
};
|
|
22
|
-
if (tree
|
|
23
|
+
if (!isMessage(tree)) {
|
|
23
24
|
file.message(messages.notMessage(tree.type), {
|
|
24
25
|
ancestors: [tree],
|
|
25
26
|
place: tree.position
|
|
26
27
|
});
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
const field = select(tree, "MSH
|
|
30
|
+
const field = select(tree, "MSH.12");
|
|
30
31
|
if (!field) {
|
|
31
32
|
file.message(messages.missingVersion, {
|
|
32
33
|
ancestors: [tree],
|
|
@@ -34,31 +35,31 @@ const hl7v2LintMessageVersion = lintRule({
|
|
|
34
35
|
});
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
const result = value(tree, "MSH
|
|
38
|
+
const result = value(tree, "MSH.12.1");
|
|
38
39
|
if (!result?.value) {
|
|
39
40
|
const message = file.message(messages.emptyVersion, {
|
|
40
41
|
ancestors: [...field.ancestors, field.node],
|
|
41
|
-
place: field.node.position
|
|
42
|
+
place: field.node.position
|
|
42
43
|
});
|
|
43
44
|
message.actual = "";
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
const ancestors = [...result.ancestors, result.node];
|
|
47
|
-
const place = result.node.position
|
|
48
|
-
let isValid
|
|
48
|
+
const place = result.node.position;
|
|
49
|
+
let isValid;
|
|
49
50
|
try {
|
|
50
51
|
isValid = satisfies(result.value, options.expression);
|
|
51
52
|
} catch (caughtError) {
|
|
52
|
-
const message = file.message(messages.unparsableVersion
|
|
53
|
+
const message = file.message(messages.unparsableVersion, {
|
|
53
54
|
ancestors,
|
|
54
55
|
cause: ensureError(caughtError),
|
|
55
|
-
place
|
|
56
|
+
place
|
|
56
57
|
});
|
|
57
58
|
message.actual = result.value;
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
if (!isValid) {
|
|
61
|
-
const message = file.message(messages.unsupportedVersion(
|
|
62
|
+
const message = file.message(messages.unsupportedVersion(options.expression), {
|
|
62
63
|
ancestors,
|
|
63
64
|
place
|
|
64
65
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Node, Root } from \"@glion/ast\";\nimport { select, value } from \"@glion/util-query\";\nimport { satisfies } from \"@glion/util-semver\";\nimport ensureError from \"ensure-error\";\nimport { lintRule } from \"unified-lint-rule\";\n\nexport interface MessageVersionLintOptions {\n expression: string;\n}\n\nconst defaultOptions = {\n expression: \"<3.0.0 >=2.3\",\n} as const;\n\nconst messages = {\n emptyVersion:\n \"The version is empty; a message must declare its HL7v2 version.\",\n missingVersion:\n \"The message has no `MSH-12` (Version ID); a message must declare its HL7v2 version.\",\n notMessage: (kind: string) =>\n `The input is a ${kind}; the version can be read only from \\`MSH-12\\` (Version ID) of a whole message.`,\n unparsableVersion:\n \"The version is not a version number; a version must be numbers separated by dots, such as `2.5` or `2.5.1`.\",\n unsupportedVersion: (expression: string) =>\n `The version is outside the supported range; it must satisfy \\`${expression}\\`.`,\n} as const;\n\nconst isMessage = (node: Node): node is Root => node.type === \"root\";\n\nconst hl7v2LintMessageVersion = lintRule<Node, MessageVersionLintOptions>(\n {\n origin: \"hl7v2-lint:message-version\",\n url: \"https://github.com/rethinkhealth/glion/tree/main/packages/lint-message-version#readme\",\n },\n (tree, file, opts) => {\n const options = { ...defaultOptions, ...opts };\n\n if (!isMessage(tree)) {\n file.message(messages.notMessage(tree.type), {\n ancestors: [tree],\n place: tree.position,\n });\n return;\n }\n\n const field = select(tree, \"MSH.12\");\n\n if (!field) {\n file.message(messages.missingVersion, {\n ancestors: [tree],\n place: tree.position,\n });\n return;\n }\n\n const result = value(tree, \"MSH.12.1\");\n\n if (!result?.value) {\n const message = file.message(messages.emptyVersion, {\n ancestors: [...field.ancestors, field.node],\n place: field.node.position,\n });\n message.actual = \"\";\n return;\n }\n\n const ancestors = [...result.ancestors, result.node];\n const place = result.node.position;\n\n let isValid: boolean;\n try {\n isValid = satisfies(result.value, options.expression);\n } catch (caughtError) {\n const message = file.message(messages.unparsableVersion, {\n ancestors,\n cause: ensureError(caughtError),\n place,\n });\n message.actual = result.value;\n return;\n }\n\n if (!isValid) {\n const message = file.message(\n messages.unsupportedVersion(options.expression),\n { ancestors, place }\n );\n message.actual = result.value;\n message.expected = [options.expression];\n }\n }\n);\n\nexport default hl7v2LintMessageVersion;\n"],"mappings":";;;;;AAUA,MAAM,iBAAiB,EACrB,YAAY,gBACb;AAED,MAAM,WAAW;CACf,cACE;CACF,gBACE;CACF,aAAa,SACX,kBAAkB,KAAK;CACzB,mBACE;CACF,qBAAqB,eACnB,iEAAiE,WAAW;CAC/E;AAED,MAAM,aAAa,SAA6B,KAAK,SAAS;AAE9D,MAAM,0BAA0B,SAC9B;CACE,QAAQ;CACR,KAAK;CACN,GACA,MAAM,MAAM,SAAS;CACpB,MAAM,UAAU;EAAE,GAAG;EAAgB,GAAG;EAAM;AAE9C,KAAI,CAAC,UAAU,KAAK,EAAE;AACpB,OAAK,QAAQ,SAAS,WAAW,KAAK,KAAK,EAAE;GAC3C,WAAW,CAAC,KAAK;GACjB,OAAO,KAAK;GACb,CAAC;AACF;;CAGF,MAAM,QAAQ,OAAO,MAAM,SAAS;AAEpC,KAAI,CAAC,OAAO;AACV,OAAK,QAAQ,SAAS,gBAAgB;GACpC,WAAW,CAAC,KAAK;GACjB,OAAO,KAAK;GACb,CAAC;AACF;;CAGF,MAAM,SAAS,MAAM,MAAM,WAAW;AAEtC,KAAI,CAAC,QAAQ,OAAO;EAClB,MAAM,UAAU,KAAK,QAAQ,SAAS,cAAc;GAClD,WAAW,CAAC,GAAG,MAAM,WAAW,MAAM,KAAK;GAC3C,OAAO,MAAM,KAAK;GACnB,CAAC;AACF,UAAQ,SAAS;AACjB;;CAGF,MAAM,YAAY,CAAC,GAAG,OAAO,WAAW,OAAO,KAAK;CACpD,MAAM,QAAQ,OAAO,KAAK;CAE1B,IAAI;AACJ,KAAI;AACF,YAAU,UAAU,OAAO,OAAO,QAAQ,WAAW;UAC9C,aAAa;EACpB,MAAM,UAAU,KAAK,QAAQ,SAAS,mBAAmB;GACvD;GACA,OAAO,YAAY,YAAY;GAC/B;GACD,CAAC;AACF,UAAQ,SAAS,OAAO;AACxB;;AAGF,KAAI,CAAC,SAAS;EACZ,MAAM,UAAU,KAAK,QACnB,SAAS,mBAAmB,QAAQ,WAAW,EAC/C;GAAE;GAAW;GAAO,CACrB;AACD,UAAQ,SAAS,OAAO;AACxB,UAAQ,WAAW,CAAC,QAAQ,WAAW;;EAG5C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glion/lint-message-version",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "hl7v2-lint rule to warn when message version is not supported",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"definition",
|
|
@@ -39,10 +39,12 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"ensure-error": "5.0.0",
|
|
41
41
|
"unified-lint-rule": "3.0.1",
|
|
42
|
-
"@glion/util-query": "0.
|
|
43
|
-
"@glion/util-semver": "0.
|
|
42
|
+
"@glion/util-query": "0.27.0",
|
|
43
|
+
"@glion/util-semver": "0.27.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
+
"@stryker-mutator/core": "10.0.0",
|
|
47
|
+
"@stryker-mutator/vitest-runner": "10.0.0",
|
|
46
48
|
"@types/node": "25.6.0",
|
|
47
49
|
"@types/unist": "^3.0.3",
|
|
48
50
|
"@vitest/coverage-v8": "4.1.11",
|
|
@@ -52,8 +54,8 @@
|
|
|
52
54
|
"unified": "^11.0.5",
|
|
53
55
|
"vfile": "^6.0.3",
|
|
54
56
|
"vitest": "4.1.11",
|
|
55
|
-
"@glion/ast": "0.
|
|
56
|
-
"@glion/builder": "0.
|
|
57
|
+
"@glion/ast": "0.27.0",
|
|
58
|
+
"@glion/builder": "0.27.0",
|
|
57
59
|
"@glion/check-readme": "0.18.0",
|
|
58
60
|
"@glion/testing": "0.18.0",
|
|
59
61
|
"@glion/tsconfig": "0.18.0"
|
|
@@ -65,9 +67,10 @@
|
|
|
65
67
|
"build": "tsdown && tsc --emitDeclarationOnly",
|
|
66
68
|
"check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
|
|
67
69
|
"check:readme": "glion-check-readme",
|
|
70
|
+
"mutate": "stryker run",
|
|
71
|
+
"publint": "publint --strict",
|
|
68
72
|
"test": "vitest run",
|
|
69
73
|
"test:coverage": "vitest run --coverage",
|
|
70
|
-
"test:watch": "vitest"
|
|
71
|
-
"publint": "publint --strict"
|
|
74
|
+
"test:watch": "vitest"
|
|
72
75
|
}
|
|
73
76
|
}
|