@rethinkhealth/hl7v2-lint-message-version 0.2.22 → 0.2.24
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -31
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Nodes } from "@rethinkhealth/hl7v2-ast";
|
|
2
2
|
export type 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<Nodes, 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,KAAK,EAAQ,MAAM,0BAA0B,CAAC;AAK5D,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAMF,QAAA,MAAM,uBAAuB,sEAuD5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,48 +14,38 @@ var hl7v2LintMessageVersion = lintRule(
|
|
|
14
14
|
const options = { ...defaultOptions, ...opts };
|
|
15
15
|
if (tree.type !== "root") {
|
|
16
16
|
file.fail(
|
|
17
|
-
`The root node is expected to be a
|
|
18
|
-
{
|
|
19
|
-
ancestors: [tree],
|
|
20
|
-
place: tree.position
|
|
21
|
-
}
|
|
17
|
+
`The root node is expected to be a Root node. Received ${tree.type} instead.`
|
|
22
18
|
);
|
|
23
|
-
return;
|
|
24
19
|
}
|
|
25
20
|
const msh12 = find(tree, "MSH-12");
|
|
26
|
-
const place = msh12?.position ?? tree.position;
|
|
27
21
|
if (!msh12) {
|
|
28
|
-
file.fail("
|
|
29
|
-
ancestors: [tree],
|
|
30
|
-
place
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
22
|
+
file.fail("MSH-12 segment is missing.");
|
|
33
23
|
}
|
|
34
24
|
const versionStr = value(tree, "MSH-12");
|
|
35
25
|
if (!versionStr) {
|
|
36
26
|
file.fail(
|
|
37
|
-
"
|
|
38
|
-
{
|
|
39
|
-
ancestors: [tree, msh12],
|
|
40
|
-
place
|
|
41
|
-
}
|
|
27
|
+
"MSH-12 segment value is required. Received empty string instead."
|
|
42
28
|
);
|
|
43
|
-
return;
|
|
44
29
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
30
|
+
try {
|
|
31
|
+
parse(versionStr ?? "");
|
|
32
|
+
} catch (_err) {
|
|
33
|
+
file.fail(
|
|
34
|
+
`MSH-12 segment value is invalid. Received '${versionStr}' instead.`
|
|
35
|
+
);
|
|
52
36
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
let isValid = false;
|
|
38
|
+
try {
|
|
39
|
+
isValid = satisfies(versionStr ?? "", options.expression);
|
|
40
|
+
} catch (_err) {
|
|
41
|
+
file.fail(
|
|
42
|
+
`MSH-12 segment value is not supported. Received '${versionStr}' instead.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
file.fail(
|
|
47
|
+
`MSH-12 segment value is not supported. Received '${versionStr}' instead.`
|
|
48
|
+
);
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
51
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Nodes, Root } from \"@rethinkhealth/hl7v2-ast\";\nimport { find, value } from \"@rethinkhealth/hl7v2-util-query\";\nimport { parse, satisfies } from \"@rethinkhealth/hl7v2-util-semver\";\nimport { lintRule } from \"unified-lint-rule\";\n\nexport type MessageVersionLintOptions = {\n expression: string;\n};\n\nconst defaultOptions: Required<MessageVersionLintOptions> = {\n expression: \"<3.0.0 >=2.3\",\n};\n\nconst hl7v2LintMessageVersion = lintRule<Nodes, MessageVersionLintOptions>(\n {\n origin: \"hl7v2-lint:message-version\",\n url: \"https://github.com/rethinkhealth/hl7v2/tree/main/packages/hl7v2-lint-message-version#readme\",\n },\n (tree, file, opts) => {\n const options = { ...defaultOptions, ...opts };\n\n // 1. Ensure the root node is a Root node.\n if (tree.type !== \"root\") {\n file.fail(\n `The root node is expected to be a Root node. Received ${tree.type} instead.`\n );\n }\n\n // 2. Ensure the MSH-12 segment is present.\n const msh12 = find(tree as Root, \"MSH-12\");\n\n if (!msh12) {\n file.fail(\"MSH-12 segment is missing.\");\n }\n\n const versionStr = value(tree as Root, \"MSH-12\");\n\n if (!versionStr) {\n file.fail(\n \"MSH-12 segment value is required. Received empty string instead.\"\n );\n }\n\n // 3. Ensure the MSH-12 segment value is a valid version.\n try {\n parse(versionStr ?? \"\");\n } catch (_err) {\n file.fail(\n `MSH-12 segment value is invalid. Received '${versionStr}' instead.`\n );\n }\n\n // 4. Ensure the MSH-12 segment value satisfies the expression.\n let isValid = false;\n try {\n isValid = satisfies(versionStr ?? \"\", options.expression);\n } catch (_err) {\n file.fail(\n `MSH-12 segment value is not supported. Received '${versionStr}' instead.`\n );\n }\n\n if (!isValid) {\n file.fail(\n `MSH-12 segment value is not supported. Received '${versionStr}' instead.`\n );\n }\n }\n);\n\nexport default hl7v2LintMessageVersion;\n"],"mappings":";AACA,SAAS,MAAM,aAAa;AAC5B,SAAS,OAAO,iBAAiB;AACjC,SAAS,gBAAgB;AAMzB,IAAM,iBAAsD;AAAA,EAC1D,YAAY;AACd;AAEA,IAAM,0BAA0B;AAAA,EAC9B;AAAA,IACE,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,CAAC,MAAM,MAAM,SAAS;AACpB,UAAM,UAAU,EAAE,GAAG,gBAAgB,GAAG,KAAK;AAG7C,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK;AAAA,QACH,yDAAyD,KAAK,IAAI;AAAA,MACpE;AAAA,IACF;AAGA,UAAM,QAAQ,KAAK,MAAc,QAAQ;AAEzC,QAAI,CAAC,OAAO;AACV,WAAK,KAAK,4BAA4B;AAAA,IACxC;AAEA,UAAM,aAAa,MAAM,MAAc,QAAQ;AAE/C,QAAI,CAAC,YAAY;AACf,WAAK;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAGA,QAAI;AACF,YAAM,cAAc,EAAE;AAAA,IACxB,SAAS,MAAM;AACb,WAAK;AAAA,QACH,8CAA8C,UAAU;AAAA,MAC1D;AAAA,IACF;AAGA,QAAI,UAAU;AACd,QAAI;AACF,gBAAU,UAAU,cAAc,IAAI,QAAQ,UAAU;AAAA,IAC1D,SAAS,MAAM;AACb,WAAK;AAAA,QACH,oDAAoD,UAAU;AAAA,MAChE;AAAA,IACF;AAEA,QAAI,CAAC,SAAS;AACZ,WAAK;AAAA,QACH,oDAAoD,UAAU;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rethinkhealth/hl7v2-lint-message-version",
|
|
3
3
|
"description": "hl7v2-lint rule to warn when message version is not supported",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.24",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Melek Somai",
|
|
@@ -17,23 +17,22 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"unified-lint-rule": "3.0.1",
|
|
20
|
-
"@rethinkhealth/hl7v2-util-
|
|
21
|
-
"@rethinkhealth/hl7v2-util-
|
|
20
|
+
"@rethinkhealth/hl7v2-util-query": "0.2.24",
|
|
21
|
+
"@rethinkhealth/hl7v2-util-semver": "0.2.24"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/node": "24.
|
|
24
|
+
"@types/node": "24.9.2",
|
|
25
25
|
"@types/unist": "^3.0.3",
|
|
26
|
-
"@vitest/coverage-v8": "^
|
|
26
|
+
"@vitest/coverage-v8": "^4.0.5",
|
|
27
27
|
"tsup": "8.5.0",
|
|
28
28
|
"typescript": "^5.9.3",
|
|
29
29
|
"unified": "^11.0.5",
|
|
30
30
|
"vfile": "^6.0.3",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"@rethinkhealth/
|
|
34
|
-
"@rethinkhealth/hl7v2-
|
|
35
|
-
"@rethinkhealth/
|
|
36
|
-
"@rethinkhealth/tsconfig": "0.0.1"
|
|
31
|
+
"vitest": "^4.0.6",
|
|
32
|
+
"@rethinkhealth/testing": "0.0.2",
|
|
33
|
+
"@rethinkhealth/tsconfig": "0.0.1",
|
|
34
|
+
"@rethinkhealth/hl7v2-builder": "0.2.24",
|
|
35
|
+
"@rethinkhealth/hl7v2-ast": "0.2.24"
|
|
37
36
|
},
|
|
38
37
|
"repository": "rethinkhealth/hl7v2.git",
|
|
39
38
|
"homepage": "https://www.rethinkhealth.io/hl7v2/docs",
|