@glion/annotate-profile-fields 0.15.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.
Files changed (2) hide show
  1. package/README.md +20 -75
  2. package/package.json +13 -9
package/README.md CHANGED
@@ -1,31 +1,10 @@
1
1
  # @glion/annotate-profile-fields
2
2
 
3
- **[unified](https://github.com/unifiedjs/unified)** plugin to annotate HL7v2 field nodes with profile metadata.
3
+ Unified plugin to annotate HL7v2 field nodes with profile metadata.
4
4
 
5
- ## Contents
5
+ ## What it does
6
6
 
7
- - [What is this?](#what-is-this)
8
- - [When should I use this?](#when-should-i-use-this)
9
- - [Install](#install)
10
- - [Use](#use)
11
- - [API](#api)
12
- - [Examples](#examples)
13
- - [Compatibility](#compatibility)
14
- - [Related](#related)
15
-
16
- ## What is this?
17
-
18
- This package is a [unified](https://github.com/unifiedjs/unified) plugin that enriches Field AST nodes with metadata from HL7v2 profile definitions. After running this plugin, each field carries its profile information directly on `field.data` — making the AST self-describing.
19
-
20
- The plugin reads the message version from MSH-12, loads the corresponding field definitions from `@glion/profiles`, and spreads the profile properties onto each field node. Unknown segments (Z-segments) and unsupported versions are silently skipped.
21
-
22
- ## When should I use this?
23
-
24
- Use this plugin when:
25
-
26
- - You want to inspect a parsed AST and see field names, datatypes, and constraints without loading profiles yourself
27
- - Building tools (serializers, debuggers, IDE integrations) that need field-level metadata
28
- - Creating custom processors that need to know which fields are required, repeatable, or coded
7
+ Enriches every `field` node in a parsed HL7v2 tree with metadata drawn from the HL7v2 specification profile — field name, datatype, required/repeatable flags, maximum length, and table reference — so the AST becomes self-describing. The plugin reads the message version from MSH-12, loads the matching field definitions from `@glion/profiles`, and spreads the profile properties onto `field.data`. Unknown segments (Z-segments) and unsupported versions are silently skipped.
29
8
 
30
9
  ## Install
31
10
 
@@ -35,10 +14,10 @@ npm install @glion/annotate-profile-fields
35
14
 
36
15
  ## Use
37
16
 
38
- ```typescript
39
- import { unified } from "unified";
40
- import { hl7v2Parser } from "@glion/parser";
17
+ ```ts
41
18
  import { hl7v2AnnotateProfileFields } from "@glion/annotate-profile-fields";
19
+ import { hl7v2Parser } from "@glion/parser";
20
+ import { unified } from "unified";
42
21
 
43
22
  const processor = unified().use(hl7v2Parser).use(hl7v2AnnotateProfileFields);
44
23
 
@@ -54,23 +33,21 @@ await processor.run(tree);
54
33
 
55
34
  ## API
56
35
 
57
- This package exports the identifier `hl7v2AnnotateProfileFields`. The default export is `hl7v2AnnotateProfileFields`.
36
+ This package exports the named constant `hl7v2AnnotateProfileFields`. The default export is the plugin itself.
58
37
 
59
38
  ### `unified().use(hl7v2AnnotateProfileFields)`
60
39
 
61
- Annotate Field nodes with profile metadata.
62
-
63
- This plugin:
40
+ Annotate Field nodes with profile metadata. The plugin:
64
41
 
65
- 1. Reads the HL7v2 version from MSH-12
66
- 2. Loads field definitions for all segments in the message
67
- 3. Visits each Field node and spreads the matching profile properties onto `field.data`
42
+ 1. Reads the HL7v2 version from MSH-12.
43
+ 2. Loads field definitions for all segments in the message from `@glion/profiles`.
44
+ 3. Visits each Field node and spreads the matching profile properties onto `field.data`.
68
45
 
69
46
  ###### Returns
70
47
 
71
- Async transformer (`async function (Root) => Root`)
48
+ Async transformer (`async function (Root) => Root`).
72
49
 
73
- ### Augmented `FieldData`
50
+ ## What it annotates
74
51
 
75
52
  Importing this package augments the `FieldData` interface from `@glion/ast`:
76
53
 
@@ -87,15 +64,13 @@ Importing this package augments the `FieldData` interface from `@glion/ast`:
87
64
 
88
65
  All properties are optional (`undefined` when not available in the profile).
89
66
 
90
- ## Examples
91
-
92
67
  ### Accessing field metadata
93
68
 
94
- ```typescript
69
+ ```ts
95
70
  import { visit } from "@glion/util-visit";
96
71
 
97
72
  // After running the annotator...
98
- visit(tree, "field", (node, ancestors, info) => {
73
+ visit(tree, "field", (node) => {
99
74
  if (node.data?.required && node.data?.name) {
100
75
  console.log(`Required field: ${node.data.id} (${node.data.name})`);
101
76
  }
@@ -104,7 +79,7 @@ visit(tree, "field", (node, ancestors, info) => {
104
79
 
105
80
  ### Finding coded fields
106
81
 
107
- ```typescript
82
+ ```ts
108
83
  visit(tree, "field", (node) => {
109
84
  if (node.data?.table) {
110
85
  console.log(`${node.data.id} uses table ${node.data.table}`);
@@ -112,39 +87,9 @@ visit(tree, "field", (node) => {
112
87
  });
113
88
  ```
114
89
 
115
- ## Compatibility
116
-
117
- - **Node.js**: 18+
118
- - **TypeScript**: 5.0+
119
- - **unified**: 11.0+
120
-
121
- ## Related
122
-
123
- - [`@glion/annotate-profile-datatypes`](../hl7v2-annotate-profile-datatypes) — Annotate components with datatype metadata
124
- - [`@glion/annotate-profile-code-systems`](../hl7v2-annotate-profile-code-systems) — Annotate coded values with UTG display names
125
- - [`@glion/preset-annotate-profile-recommended`](../hl7v2-preset-annotate-profile-recommended) — Preset bundling all profile annotators
126
- - [`@glion/profiles`](../hl7v2-profiles) — Profile data source
127
-
128
- ## Contributing
129
-
130
- We welcome contributions! Please see our [Contributing Guide][github-contributing] for more details.
131
-
132
- 1. Fork the repository
133
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
134
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
135
- 4. Push to the branch (`git push origin feature/amazing-feature`)
136
- 5. Open a Pull Request
137
-
138
- ## Code of Conduct
139
-
140
- 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.
141
-
142
- ## License
143
-
144
- Copyright 2025 Rethink Health, SUARL. All rights reserved.
90
+ ## Part of Glion
145
91
 
146
- 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.
92
+ `@glion/annotate-profile-fields` is part of **[Glion]**, the application framework for HL7v2. See the [Glion README] for the full package catalog and architecture.
147
93
 
148
- [github-code-of-conduct]: https://github.com/rethinkhealth/glion/blob/main/CODE_OF_CONDUCT.md
149
- [github-license]: https://github.com/rethinkhealth/glion/blob/main/LICENSE
150
- [github-contributing]: https://github.com/rethinkhealth/glion/blob/main/CONTRIBUTING.md
94
+ [Glion]: https://github.com/rethinkhealth/glion#readme
95
+ [Glion README]: https://github.com/rethinkhealth/glion#readme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/annotate-profile-fields",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Unified plugin to annotate HL7v2 field nodes with profile metadata",
5
5
  "keywords": [
6
6
  "annotate",
@@ -39,20 +39,22 @@
39
39
  "dependencies": {
40
40
  "unified": "11.0.5",
41
41
  "vfile": "6.0.3",
42
- "@glion/ast": "0.15.1",
43
- "@glion/util-visit": "0.15.1"
42
+ "@glion/ast": "0.15.2",
43
+ "@glion/util-visit": "0.15.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.5.0",
47
47
  "@vitest/coverage-v8": "4.1.2",
48
+ "publint": "0.3.18",
48
49
  "tsdown": "0.21.7",
49
50
  "typescript": "^5.9.3",
50
51
  "vitest": "4.1.2",
51
- "@glion/annotate-profile-context": "0.15.1",
52
- "@glion/builder": "0.15.1",
53
- "@glion/testing": "0.15.1",
54
- "@glion/profiles": "0.15.1",
55
- "@glion/tsconfig": "0.15.1"
52
+ "@glion/builder": "0.15.2",
53
+ "@glion/annotate-profile-context": "0.15.2",
54
+ "@glion/check-readme": "0.15.2",
55
+ "@glion/profiles": "0.15.2",
56
+ "@glion/testing": "0.15.2",
57
+ "@glion/tsconfig": "0.15.2"
56
58
  },
57
59
  "engines": {
58
60
  "node": ">=18"
@@ -61,9 +63,11 @@
61
63
  "scripts": {
62
64
  "build": "tsdown && tsc --emitDeclarationOnly",
63
65
  "check-types": "tsc --noEmit",
66
+ "check:readme": "glion-check-readme",
64
67
  "bench": "vitest bench --run",
65
68
  "test": "vitest run",
66
69
  "test:coverage": "vitest run --coverage",
67
- "test:watch": "vitest"
70
+ "test:watch": "vitest",
71
+ "publint": "publint --strict"
68
72
  }
69
73
  }