@glion/jsonify 0.15.0 → 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.
Files changed (2) hide show
  1. package/README.md +23 -68
  2. package/package.json +15 -7
package/README.md CHANGED
@@ -1,44 +1,27 @@
1
1
  # @glion/jsonify
2
2
 
3
- **[unified](https://unifiedjs.com/)** plugin to transform HL7v2 message ASTs into a simplified JSON representation.
3
+ Serialize an HL7v2 AST into a compact, structured JSON document.
4
4
 
5
- ## What is this?
5
+ ## What it does
6
6
 
7
- `@glion/jsonify` is a [unified](https://unifiedjs.com/) plugin that takes an HL7v2 syntax tree (produced by a parser such as [`@glion/ast`][https://github.com/rethinkhealth/glion/tree/main/packages/hl7v2-parser]) and compiles it to a clean, structured JSON format.
8
-
9
- It strips away [unist](https://github.com/syntax-tree/unist) metadata and preserves only meaningful HL7v2 properties such as segment type, field indexes, and values.
10
-
11
- ## When should I use this?
12
-
13
- Use this plugin when you need:
14
-
15
- - A minimal JSON representation of HL7v2 messages for downstream processing.
16
- - To serialize HL7v2 ASTs into a format suitable for APIs or storage.
17
-
18
- If you need to parse raw HL7v2 messages first, use [`@glion/ast`](https://github.com/rethinkhealth/glion/tree/main/packages/hl7v2-parser) before applying this plugin.
7
+ `@glion/jsonify` takes an HL7v2 AST — typically produced by `@glion/parser` — and emits a JSON representation that strips `unist` metadata (position, raw, type discriminators) and keeps only the meaningful HL7v2 shape: segment names, field indexes, values, and children. The result is a clean payload for downstream APIs, message queues, and analytics stores that want structured HL7v2 without the parser's internal tree representation.
19
8
 
20
9
  ## Install
21
10
 
22
- This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
23
-
24
- In Node.js (version 16+), install with [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm):
25
-
26
- ```sh
11
+ ```bash
27
12
  npm install @glion/jsonify
28
13
  ```
29
14
 
30
15
  ## Use
31
16
 
32
- Say we have an HL7v2 message and want to convert it to JSON:
33
-
34
- ```js
35
- import { unified } from "unified";
36
- import { hl7v2Parse } from "@glion/ast";
17
+ ```ts
18
+ import { hl7v2Parser } from "@glion/parser";
37
19
  import { hl7v2Jsonify } from "@glion/jsonify";
20
+ import { unified } from "unified";
38
21
 
39
22
  const msg = `MSH|^~\\&|HIS|RIH|EKG|EKG|200202150930||ADT^A01|MSG00001|P|2.4\rPID|||555-44-4444||DOE^JOHN`;
40
23
 
41
- const file = await unified().use(hl7v2Parse).use(hl7v2Jsonify).process(msg);
24
+ const file = await unified().use(hl7v2Parser).use(hl7v2Jsonify).process(msg);
42
25
 
43
26
  console.log(String(file));
44
27
  ```
@@ -54,8 +37,7 @@ Yields:
54
37
  "name": "MSH",
55
38
  "children": [
56
39
  { "type": "Field", "name": "MSH-1", "value": "|" },
57
- { "type": "Field", "name": "MSH-2", "value": "^~\\&" },
58
- ...
40
+ { "type": "Field", "name": "MSH-2", "value": "^~\\&" }
59
41
  ]
60
42
  },
61
43
  {
@@ -74,55 +56,28 @@ Yields:
74
56
 
75
57
  ### `unified().use(hl7v2Jsonify)`
76
58
 
77
- Transform an HL7v2 AST into JSON.
59
+ Register the plugin as the compiler of a `unified` processor. The processor's `process()` call returns a file whose stringified contents is the JSON document. No options.
78
60
 
79
- ###### Parameters
61
+ ## JSON shape
80
62
 
81
- There are no options.
82
-
83
- ###### Returns
84
-
85
- Nothing (`undefined`). The unified compiler returns a stringified JSON document.
86
-
87
- ## JSON Schema
88
-
89
- The output JSON has the following shape:
63
+ Every node in the output has the following shape:
90
64
 
91
65
  ```ts
92
66
  interface HL7v2JsonNode {
93
- type: string;
94
- name?: string;
95
- index?: number;
96
- value?: string;
97
- delimiter?: string;
98
- children?: HL7v2JsonNode[];
67
+ type: string; // "Message", "Segment", "Field", "Component", ...
68
+ name?: string; // segment name (e.g. "MSH") or field id (e.g. "PID-3")
69
+ index?: number; // positional index where relevant
70
+ value?: string; // leaf value for Field / Component / Subcomponent
71
+ delimiter?: string; // delimiter character when it is meaningful to preserve
72
+ children?: HL7v2JsonNode[]; // recursive shape for composite nodes
99
73
  }
100
74
  ```
101
75
 
102
- ## Security
103
-
104
- This plugin only transforms AST nodes and does not execute code. Ensure you trust the source of HL7v2 messages before processing.
105
-
106
- ## Contributing
107
-
108
- We welcome contributions! Please see our [Contributing Guide][github-contributing] for more details.
109
-
110
- 1. Fork the repository
111
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
112
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
113
- 4. Push to the branch (`git push origin feature/amazing-feature`)
114
- 5. Open a Pull Request
115
-
116
- ## Code of Conduct
117
-
118
- To ensure a welcoming and positive environment, we have a [Code of Conduct][github-code-of-conduct] that all contributors and participants are expected to adhere to.
119
-
120
- ## License
76
+ Only the fields relevant to a given node appear in the output — `Field` nodes carry `name` and `value`, composite nodes carry `name` and `children`, and so on.
121
77
 
122
- Copyright 2025 Rethink Health, SUARL. All rights reserved.
78
+ ## Part of Glion
123
79
 
124
- This program is licensed to you under the terms of the [MIT License](https://opensource.org/licenses/MIT). This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [LICENSE][github-license] file for details.
80
+ `@glion/jsonify` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
125
81
 
126
- [github-code-of-conduct]: https://github.com/rethinkhealth/glion/blob/main/CODE_OF_CONDUCT.md
127
- [github-license]: https://github.com/rethinkhealth/glion/blob/main/LICENSE
128
- [github-contributing]: https://github.com/rethinkhealth/glion/blob/main/CONTRIBUTING.md
82
+ [Glion]: https://github.com/rethinkhealth/glion#readme
83
+ [Glion README]: https://github.com/rethinkhealth/glion#readme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/jsonify",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "hl7v2 plugin to transform hl7v2 messages to a simplified JSON representation",
5
5
  "keywords": [
6
6
  "health",
@@ -16,7 +16,11 @@
16
16
  "name": "Melek Somai",
17
17
  "email": "melek@rethinkhealth.io"
18
18
  },
19
- "repository": "rethinkhealth/glion.git",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/rethinkhealth/glion.git",
22
+ "directory": "packages/jsonify"
23
+ },
20
24
  "files": [
21
25
  "dist"
22
26
  ],
@@ -30,18 +34,20 @@
30
34
  },
31
35
  "dependencies": {
32
36
  "unified": "11.0.5",
33
- "@glion/ast": "0.15.0"
37
+ "@glion/ast": "0.15.2"
34
38
  },
35
39
  "devDependencies": {
36
40
  "@types/node": "^25.5.0",
37
41
  "@types/unist": "^3.0.3",
38
42
  "@vitest/coverage-v8": "4.1.2",
43
+ "publint": "0.3.18",
39
44
  "tsdown": "0.21.7",
40
45
  "typescript": "^5.9.3",
41
46
  "vitest": "4.1.2",
42
- "@glion/builder": "0.15.0",
43
- "@glion/testing": "0.15.0",
44
- "@glion/tsconfig": "0.15.0"
47
+ "@glion/check-readme": "0.15.2",
48
+ "@glion/tsconfig": "0.15.2",
49
+ "@glion/builder": "0.15.2",
50
+ "@glion/testing": "0.15.2"
45
51
  },
46
52
  "engines": {
47
53
  "node": ">=18"
@@ -50,8 +56,10 @@
50
56
  "scripts": {
51
57
  "build": "tsdown && tsc --emitDeclarationOnly",
52
58
  "check-types": "tsc --noEmit",
59
+ "check:readme": "glion-check-readme",
53
60
  "test": "vitest run",
54
61
  "test:coverage": "vitest run --coverage",
55
- "test:watch": "vitest"
62
+ "test:watch": "vitest",
63
+ "publint": "publint --strict"
56
64
  }
57
65
  }