@rethinkhealth/hl7v2-utils 0.2.21 → 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 +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -35
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/dist/report.d.ts +0 -18
- package/dist/report.d.ts.map +0 -1
- package/dist/types.d.ts +0 -44
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -14
- package/dist/utils.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { Nodes } from "@rethinkhealth/hl7v2-ast";
|
|
2
|
+
export declare const DEFAULT_DELIMITERS: {
|
|
3
|
+
field: string;
|
|
4
|
+
component: string;
|
|
5
|
+
repetition: string;
|
|
6
|
+
subcomponent: string;
|
|
7
|
+
escape: string;
|
|
8
|
+
segment: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Utility: check if a node is semantically empty
|
|
12
|
+
*/
|
|
13
|
+
export declare function isEmptyNode(node: Nodes | null | undefined): boolean;
|
|
5
14
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAMtD,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAMF;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CA2BnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
function report(file, rule, options) {
|
|
3
|
-
if (!file) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
const ruleId = `${rule.type}:${rule.namespace}:${rule.code}`;
|
|
7
|
-
const context = options?.context ?? {};
|
|
8
|
-
const message = rule.message(context);
|
|
9
|
-
const vfileMessage = file.message(message, options?.node);
|
|
10
|
-
vfileMessage.ruleId = ruleId;
|
|
11
|
-
vfileMessage.url = rule.helpUrl;
|
|
12
|
-
vfileMessage.note = rule.description;
|
|
13
|
-
vfileMessage.source = rule.namespace;
|
|
14
|
-
switch (rule.severity) {
|
|
15
|
-
case "error":
|
|
16
|
-
vfileMessage.fatal = true;
|
|
17
|
-
break;
|
|
18
|
-
case "warning":
|
|
19
|
-
vfileMessage.fatal = false;
|
|
20
|
-
break;
|
|
21
|
-
case "info":
|
|
22
|
-
vfileMessage.fatal = null;
|
|
23
|
-
break;
|
|
24
|
-
case null:
|
|
25
|
-
vfileMessage.fatal = null;
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
vfileMessage.fatal = void 0;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/utils.ts
|
|
1
|
+
// src/index.ts
|
|
34
2
|
var DEFAULT_DELIMITERS = {
|
|
35
3
|
field: "|",
|
|
36
4
|
component: "^",
|
|
@@ -59,7 +27,6 @@ function isEmptyNode(node) {
|
|
|
59
27
|
}
|
|
60
28
|
export {
|
|
61
29
|
DEFAULT_DELIMITERS,
|
|
62
|
-
isEmptyNode
|
|
63
|
-
report
|
|
30
|
+
isEmptyNode
|
|
64
31
|
};
|
|
65
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Nodes } from \"@rethinkhealth/hl7v2-ast\";\n\n// -------------\n// Delimiters\n// -------------\n\nexport const DEFAULT_DELIMITERS = {\n field: \"|\",\n component: \"^\",\n repetition: \"~\",\n subcomponent: \"&\",\n escape: \"\\\\\",\n segment: \"\\r\",\n};\n\n// -------------\n// General\n// -------------\n\n/**\n * Utility: check if a node is semantically empty\n */\nexport function isEmptyNode(node: Nodes | null | undefined): boolean {\n if (!node) {\n return true;\n }\n\n // If node has a \"value\" property (Subcomponent, maybe Component)\n if (\"value\" in node) {\n return !node.value || node.value.trim() === \"\";\n }\n\n // If node has children (Field, Component, Repetition, Segment, Root, etc.)\n if (\"children\" in node) {\n if (!node.children || node.children.length === 0) {\n return true;\n }\n\n // If node has more than one child, then it is considered non-empty\n if (node.children.length > 1) {\n return false;\n }\n\n // If node has only one child, then it is considered empty if the child is also empty\n return isEmptyNode(node.children[0]);\n }\n\n // Fallback: consider unknown node as non-empty\n return false;\n}\n"],"mappings":";AAMO,IAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,SAAS;AACX;AASO,SAAS,YAAY,MAAyC;AACnE,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,MAAM;AACnB,WAAO,CAAC,KAAK,SAAS,KAAK,MAAM,KAAK,MAAM;AAAA,EAC9C;AAGA,MAAI,cAAc,MAAM;AACtB,QAAI,CAAC,KAAK,YAAY,KAAK,SAAS,WAAW,GAAG;AAChD,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,SAAS,SAAS,GAAG;AAC5B,aAAO;AAAA,IACT;AAGA,WAAO,YAAY,KAAK,SAAS,CAAC,CAAC;AAAA,EACrC;AAGA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rethinkhealth/hl7v2-utils",
|
|
3
3
|
"description": "hl7v2 utilities",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.24",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Melek Somai",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
".": "./dist/index.js"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "24.
|
|
19
|
+
"@types/node": "24.9.2",
|
|
20
20
|
"@types/unist": "^3.0.3",
|
|
21
|
-
"@vitest/coverage-v8": "^
|
|
21
|
+
"@vitest/coverage-v8": "^4.0.5",
|
|
22
22
|
"tsup": "8.5.0",
|
|
23
|
-
"typescript": "^5.
|
|
23
|
+
"typescript": "^5.9.3",
|
|
24
24
|
"unist-builder": "^4.0.0",
|
|
25
25
|
"vfile": "^6.0.3",
|
|
26
|
-
"vitest": "^
|
|
27
|
-
"@rethinkhealth/
|
|
28
|
-
"@rethinkhealth/
|
|
26
|
+
"vitest": "^4.0.6",
|
|
27
|
+
"@rethinkhealth/testing": "0.0.2",
|
|
28
|
+
"@rethinkhealth/hl7v2-ast": "0.2.24",
|
|
29
29
|
"@rethinkhealth/tsconfig": "0.0.1"
|
|
30
30
|
},
|
|
31
31
|
"repository": "rethinkhealth/hl7v2.git",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"nodejs",
|
|
39
39
|
"typescript"
|
|
40
40
|
],
|
|
41
|
-
"packageManager": "pnpm@10.14.0",
|
|
42
41
|
"publishConfig": {
|
|
43
42
|
"access": "public"
|
|
44
43
|
},
|
package/dist/report.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Node } from "@rethinkhealth/hl7v2-ast";
|
|
2
|
-
import type { VFile } from "vfile";
|
|
3
|
-
import type { Diagnostic } from "./types";
|
|
4
|
-
export type ReportOptions = {
|
|
5
|
-
node?: Node;
|
|
6
|
-
context?: Record<string, unknown>;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Report a diagnostic to a vfile.
|
|
10
|
-
*
|
|
11
|
-
* Calls the diagnostic's message function with context and wires to vfile.
|
|
12
|
-
*
|
|
13
|
-
* @param file - The VFile to report to
|
|
14
|
-
* @param rule - The diagnostic rule definition
|
|
15
|
-
* @param options - Position and context data
|
|
16
|
-
*/
|
|
17
|
-
export declare function report(file: VFile | null | undefined, rule: Diagnostic, options?: ReportOptions): void;
|
|
18
|
-
//# sourceMappingURL=report.d.ts.map
|
package/dist/report.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC9B,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,IAAI,CA4CN"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagnostic definition.
|
|
3
|
-
*
|
|
4
|
-
* A diagnostic is a message about a problem in the HL7v2 message. It is used to report issues to the user.
|
|
5
|
-
*
|
|
6
|
-
* Diagnostics are defined per-package with type, namespace, and code that compose the `ruleId`.
|
|
7
|
-
*
|
|
8
|
-
* Diagnostics are used in conjunction with the `report()` function to report issues to the user.
|
|
9
|
-
*/
|
|
10
|
-
export type Diagnostic = Readonly<{
|
|
11
|
-
/**
|
|
12
|
-
* Tool/plugin category
|
|
13
|
-
*/
|
|
14
|
-
type: "validator" | "lint" | "annotator" | "transformer" | "parser" | string;
|
|
15
|
-
/**
|
|
16
|
-
* Domain/concern (order, field, conformance, segment, group, datatype, etc.)
|
|
17
|
-
*/
|
|
18
|
-
namespace: string;
|
|
19
|
-
/**
|
|
20
|
-
* Specific issue code (transition, required, acceptance, mismatch, etc.)
|
|
21
|
-
*/
|
|
22
|
-
code: string;
|
|
23
|
-
/**
|
|
24
|
-
* Full description of the rule
|
|
25
|
-
*/
|
|
26
|
-
description?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Default severity
|
|
29
|
-
*
|
|
30
|
-
* @defaultValue 'info'
|
|
31
|
-
*/
|
|
32
|
-
severity?: "error" | "warning" | "info" | null | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Message formatter function.
|
|
35
|
-
* Takes context and returns the formatted message.
|
|
36
|
-
* The function signature is self-documenting: it shows what context is required.
|
|
37
|
-
*/
|
|
38
|
-
message: (context: Record<string, unknown>) => string;
|
|
39
|
-
/**
|
|
40
|
-
* Optional URL to documentation
|
|
41
|
-
*/
|
|
42
|
-
helpUrl?: string;
|
|
43
|
-
}>;
|
|
44
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,MAAM,CAAC;IAE7E;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE3D;;;;OAIG;IACH,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;IAEtD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Nodes } from "@rethinkhealth/hl7v2-ast";
|
|
2
|
-
export declare const DEFAULT_DELIMITERS: {
|
|
3
|
-
field: string;
|
|
4
|
-
component: string;
|
|
5
|
-
repetition: string;
|
|
6
|
-
subcomponent: string;
|
|
7
|
-
escape: string;
|
|
8
|
-
segment: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Utility: check if a node is semantically empty
|
|
12
|
-
*/
|
|
13
|
-
export declare function isEmptyNode(node: Nodes | null | undefined): boolean;
|
|
14
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAMtD,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAMF;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CA2BnE"}
|