@rethinkhealth/hl7v2-ast 0.1.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/index.d.ts +57 -0
  3. package/package.json +38 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Rethink Health
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import type { Node, Position } from 'unist';
2
+
3
+ /**
4
+ * HL7v2 Node specification following the Unist spec
5
+ *
6
+ * @see https://github.com/syntax-tree/unist#node
7
+ */
8
+ export interface HL7v2Node extends Node {
9
+ /**
10
+ * The type of the node.
11
+ */
12
+ type:
13
+ | 'message'
14
+ | 'segment'
15
+ | 'header'
16
+ | 'field'
17
+ | 'component'
18
+ | 'subcomponent';
19
+
20
+ /**
21
+ * The name of the node (e.g. "PID", "MSH", "EVN", etc.)
22
+ */
23
+ name?: string;
24
+
25
+ /**
26
+ * The index of the node in the parent.
27
+ *
28
+ * This is valuable in HL7v2 where fields and components' order is
29
+ * relevant.
30
+ */
31
+ index?: number;
32
+
33
+ /**
34
+ * The value of the node. This is the raw value of the node.
35
+ *
36
+ * TODO: We might consider removing this property and use the children
37
+ * property instead.
38
+ */
39
+ value?: string;
40
+
41
+ /**
42
+ * The delimiter of the node.
43
+ */
44
+ delimiter?: string;
45
+
46
+ /**
47
+ * The children of the node.
48
+ */
49
+ children?: HL7v2Node[];
50
+
51
+ /**
52
+ * The position of the node in the source text.
53
+ *
54
+ * This is used for round-tripping the AST back to the original text.
55
+ */
56
+ position?: Position;
57
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@rethinkhealth/hl7v2-ast",
3
+ "description": "HL7v2 is a specification for representing HL7v2 messages as an abstract syntax tree. It implements the unist spec.",
4
+ "version": "0.1.0",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Melek Somai",
8
+ "email": "melek@rethinkhealth.io"
9
+ },
10
+ "type": "module",
11
+ "files": [
12
+ "index.d.ts"
13
+ ],
14
+ "dependencies": {
15
+ "@types/unist": "3.0.3"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "22.15.31",
19
+ "typescript": "^5.8.3",
20
+ "@rethinkhealth/tsconfig": "0.0.0"
21
+ },
22
+ "repository": "rethinkhealth/hl7v2.git",
23
+ "homepage": "https://www.rethinkhealth.io/hl7v2/docs",
24
+ "keywords": [
25
+ "bin",
26
+ "cli",
27
+ "hl7v2",
28
+ "hl7v2ast",
29
+ "unified"
30
+ ],
31
+ "packageManager": "pnpm@10.12.1",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "check-types": "tsc --noEmit"
37
+ }
38
+ }