fastify-hl7 3.1.0 → 3.2.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.
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.HL7Client = void 0;
27
37
  const node_hl7_client_1 = __importStar(require("node-hl7-client"));
@@ -44,7 +54,7 @@ class HL7Client {
44
54
  }
45
55
  /**
46
56
  * Build a HL7 Batch
47
- *@remarks Create a properly formatted HL7 Batch.
57
+ * @remarks Create a properly formatted HL7 Batch.
48
58
  * @since 1.0.0
49
59
  * @param props
50
60
  */
@@ -56,7 +66,7 @@ class HL7Client {
56
66
  }
57
67
  /**
58
68
  * Build Date
59
- *@remarks Build a date string based off HL7 Standards
69
+ * @remarks Build a date string based off HL7 Standards
60
70
  * @since 2.1.0
61
71
  * @param date
62
72
  * @param length Options are 8, 12, or 14 (default)
@@ -66,7 +76,7 @@ class HL7Client {
66
76
  }
67
77
  /**
68
78
  * Build a HL7 File Batch
69
- *@remarks Create a properly formatted HL7 File Batch.
79
+ * @remarks Create a properly formatted HL7 File Batch.
70
80
  * @since 1.0.0
71
81
  * @param props
72
82
  */
@@ -80,7 +90,7 @@ class HL7Client {
80
90
  }
81
91
  /**
82
92
  * Build a HL7 Message
83
- *@remarks Create a properly formatted HL7 message.
93
+ * @remarks Create a properly formatted HL7 message.
84
94
  * @since 1.0.0
85
95
  * @param props
86
96
  */
@@ -122,7 +132,7 @@ class HL7Client {
122
132
  }
123
133
  /**
124
134
  * Create an HL7 Outbound Connection
125
- *@remarks Connect to an HL7 Server/Broker
135
+ * @remarks Connect to an HL7 Server/Broker
126
136
  * @since 1.0.0
127
137
  * @param name The name stored within created client connections.
128
138
  * @param props
@@ -183,7 +193,7 @@ class HL7Client {
183
193
  }
184
194
  /**
185
195
  * Process a HL7
186
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
196
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
187
197
  * @since 1.0.0
188
198
  * @param text Raw HL& String
189
199
  */
@@ -197,7 +207,7 @@ class HL7Client {
197
207
  }
198
208
  /**
199
209
  * Read File
200
- *@remarks Pass the correct path of the file you want to read.
210
+ * @remarks Pass the correct path of the file you want to read.
201
211
  * @since 1.0.0
202
212
  * @param fullFilePath
203
213
  * @returns FileBatch
@@ -211,7 +221,7 @@ class HL7Client {
211
221
  }
212
222
  /**
213
223
  * Read a File Buffer
214
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
224
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
215
225
  * @since 1.0.0
216
226
  * @param fileBuffer
217
227
  * @returns FileBatch
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HL7Server = void 0;
4
+ const node_events_1 = require("node:events");
4
5
  const node_hl7_server_1 = require("node-hl7-server");
5
6
  const errors_js_1 = require("../errors.js");
6
- class HL7Server {
7
+ class HL7Server extends node_events_1.EventEmitter {
7
8
  constructor(server) {
9
+ super();
8
10
  this._server = server;
9
11
  this._serverInboundConnections = [];
10
12
  }
@@ -48,6 +50,7 @@ class HL7Server {
48
50
  port: props.port.toString(),
49
51
  server: inbound,
50
52
  });
53
+ this.emit("inbound", props.port.toString());
51
54
  return inbound;
52
55
  }
53
56
  /**
package/lib/cjs/index.js CHANGED
@@ -56,6 +56,9 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
56
56
  if (typeof serverInstance !== "undefined") {
57
57
  // Server Functions
58
58
  server = new hL7Server_js_1.HL7Server(serverInstance);
59
+ server.on("inbound", (port) => {
60
+ fastify.log.info("HL7 Inbound Server Listening on Port %s", port);
61
+ });
59
62
  // before we close fastify, make sure all server instances are closed
60
63
  fastify.addHook("preClose", async () => {
61
64
  if (typeof server !== "undefined") {
@@ -10,14 +10,14 @@ export declare class HL7Client {
10
10
  closeAll(): Promise<boolean>;
11
11
  /**
12
12
  * Build a HL7 Batch
13
- *@remarks Create a properly formatted HL7 Batch.
13
+ * @remarks Create a properly formatted HL7 Batch.
14
14
  * @since 1.0.0
15
15
  * @param props
16
16
  */
17
17
  buildBatch(props?: ClientBuilderOptions): Batch;
18
18
  /**
19
19
  * Build Date
20
- *@remarks Build a date string based off HL7 Standards
20
+ * @remarks Build a date string based off HL7 Standards
21
21
  * @since 2.1.0
22
22
  * @param date
23
23
  * @param length Options are 8, 12, or 14 (default)
@@ -25,14 +25,14 @@ export declare class HL7Client {
25
25
  buildDate(date: Date, length?: string): string;
26
26
  /**
27
27
  * Build a HL7 File Batch
28
- *@remarks Create a properly formatted HL7 File Batch.
28
+ * @remarks Create a properly formatted HL7 File Batch.
29
29
  * @since 1.0.0
30
30
  * @param props
31
31
  */
32
32
  buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
33
33
  /**
34
34
  * Build a HL7 Message
35
- *@remarks Create a properly formatted HL7 message.
35
+ * @remarks Create a properly formatted HL7 message.
36
36
  * @since 1.0.0
37
37
  * @param props
38
38
  */
@@ -45,7 +45,7 @@ export declare class HL7Client {
45
45
  createClient(name: string, props: ClientOptions): Client;
46
46
  /**
47
47
  * Create an HL7 Outbound Connection
48
- *@remarks Connect to an HL7 Server/Broker
48
+ * @remarks Connect to an HL7 Server/Broker
49
49
  * @since 1.0.0
50
50
  * @param name The name stored within created client connections.
51
51
  * @param props
@@ -66,14 +66,14 @@ export declare class HL7Client {
66
66
  getClientConnectionByPort(port: string): Connection | undefined;
67
67
  /**
68
68
  * Process a HL7
69
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
69
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
70
70
  * @since 1.0.0
71
71
  * @param text Raw HL& String
72
72
  */
73
73
  processHL7(text: string): Message | Batch;
74
74
  /**
75
75
  * Read File
76
- *@remarks Pass the correct path of the file you want to read.
76
+ * @remarks Pass the correct path of the file you want to read.
77
77
  * @since 1.0.0
78
78
  * @param fullFilePath
79
79
  * @returns FileBatch
@@ -85,7 +85,7 @@ export declare class HL7Client {
85
85
  readFile(fullFilePath: string): FileBatch;
86
86
  /**
87
87
  * Read a File Buffer
88
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
88
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
89
89
  * @since 1.0.0
90
90
  * @param fileBuffer
91
91
  * @returns FileBatch
@@ -18,7 +18,7 @@ export class HL7Client {
18
18
  }
19
19
  /**
20
20
  * Build a HL7 Batch
21
- *@remarks Create a properly formatted HL7 Batch.
21
+ * @remarks Create a properly formatted HL7 Batch.
22
22
  * @since 1.0.0
23
23
  * @param props
24
24
  */
@@ -30,7 +30,7 @@ export class HL7Client {
30
30
  }
31
31
  /**
32
32
  * Build Date
33
- *@remarks Build a date string based off HL7 Standards
33
+ * @remarks Build a date string based off HL7 Standards
34
34
  * @since 2.1.0
35
35
  * @param date
36
36
  * @param length Options are 8, 12, or 14 (default)
@@ -40,7 +40,7 @@ export class HL7Client {
40
40
  }
41
41
  /**
42
42
  * Build a HL7 File Batch
43
- *@remarks Create a properly formatted HL7 File Batch.
43
+ * @remarks Create a properly formatted HL7 File Batch.
44
44
  * @since 1.0.0
45
45
  * @param props
46
46
  */
@@ -54,7 +54,7 @@ export class HL7Client {
54
54
  }
55
55
  /**
56
56
  * Build a HL7 Message
57
- *@remarks Create a properly formatted HL7 message.
57
+ * @remarks Create a properly formatted HL7 message.
58
58
  * @since 1.0.0
59
59
  * @param props
60
60
  */
@@ -96,7 +96,7 @@ export class HL7Client {
96
96
  }
97
97
  /**
98
98
  * Create an HL7 Outbound Connection
99
- *@remarks Connect to an HL7 Server/Broker
99
+ * @remarks Connect to an HL7 Server/Broker
100
100
  * @since 1.0.0
101
101
  * @param name The name stored within created client connections.
102
102
  * @param props
@@ -157,7 +157,7 @@ export class HL7Client {
157
157
  }
158
158
  /**
159
159
  * Process a HL7
160
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
160
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
161
161
  * @since 1.0.0
162
162
  * @param text Raw HL& String
163
163
  */
@@ -171,7 +171,7 @@ export class HL7Client {
171
171
  }
172
172
  /**
173
173
  * Read File
174
- *@remarks Pass the correct path of the file you want to read.
174
+ * @remarks Pass the correct path of the file you want to read.
175
175
  * @since 1.0.0
176
176
  * @param fullFilePath
177
177
  * @returns FileBatch
@@ -185,7 +185,7 @@ export class HL7Client {
185
185
  }
186
186
  /**
187
187
  * Read a File Buffer
188
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
188
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
189
189
  * @since 1.0.0
190
190
  * @param fileBuffer
191
191
  * @returns FileBatch
@@ -1,5 +1,6 @@
1
+ import { EventEmitter } from "node:events";
1
2
  import Server, { Inbound, InboundHandler, ListenerOptions } from "node-hl7-server";
2
- export declare class HL7Server {
3
+ export declare class HL7Server extends EventEmitter {
3
4
  private readonly _server;
4
5
  private readonly _serverInboundConnections;
5
6
  constructor(server: Server);
@@ -1,7 +1,9 @@
1
+ import { EventEmitter } from "node:events";
1
2
  import { Inbound, } from "node-hl7-server";
2
3
  import { errors } from "../errors.js";
3
- export class HL7Server {
4
+ export class HL7Server extends EventEmitter {
4
5
  constructor(server) {
6
+ super();
5
7
  this._server = server;
6
8
  this._serverInboundConnections = [];
7
9
  }
@@ -45,6 +47,7 @@ export class HL7Server {
45
47
  port: props.port.toString(),
46
48
  server: inbound,
47
49
  });
50
+ this.emit("inbound", props.port.toString());
48
51
  return inbound;
49
52
  }
50
53
  /**
package/lib/esm/index.js CHANGED
@@ -37,6 +37,9 @@ const fastifyHL7 = fp(async (fastify, opts) => {
37
37
  if (typeof serverInstance !== "undefined") {
38
38
  // Server Functions
39
39
  server = new HL7Server(serverInstance);
40
+ server.on("inbound", (port) => {
41
+ fastify.log.info("HL7 Inbound Server Listening on Port %s", port);
42
+ });
40
43
  // before we close fastify, make sure all server instances are closed
41
44
  fastify.addHook("preClose", async () => {
42
45
  if (typeof server !== "undefined") {
@@ -25,14 +25,14 @@ declare module "fastify" {
25
25
  * @since 1.0.0 */
26
26
  closeServerAll: () => Promise<boolean>;
27
27
  /** Create Client
28
- *@remarks Connecting to a remote server/broker that accepts connections.
28
+ * @remarks Connecting to a remote server/broker that accepts connections.
29
29
  * @since 1.0.0 */
30
30
  createClient: (name: string, props: ClientOptions) => Client;
31
31
  /** Create an incoming port connection on the server.
32
32
  * @since 1.0.0 */
33
33
  createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
34
34
  /** Create Outgoing Client Port
35
- *@remarks This is on the established client that we are already a part off.
35
+ * @remarks This is on the established client that we are already a part off.
36
36
  * @since 1.0.0 */
37
37
  createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
38
38
  /** Get Client (Outbound) connection by name.
@@ -59,7 +59,7 @@ declare module "fastify" {
59
59
  }
60
60
  interface FastifyInstance {
61
61
  /** Main Decorator for Fastify
62
- *@remarks hl7 is the decorator that everything hangs off.
62
+ * @remarks hl7 is the decorator that everything hangs off.
63
63
  * @since 1.0.0 **/
64
64
  hl7: HL7;
65
65
  }
@@ -10,14 +10,14 @@ export declare class HL7Client {
10
10
  closeAll(): Promise<boolean>;
11
11
  /**
12
12
  * Build a HL7 Batch
13
- *@remarks Create a properly formatted HL7 Batch.
13
+ * @remarks Create a properly formatted HL7 Batch.
14
14
  * @since 1.0.0
15
15
  * @param props
16
16
  */
17
17
  buildBatch(props?: ClientBuilderOptions): Batch;
18
18
  /**
19
19
  * Build Date
20
- *@remarks Build a date string based off HL7 Standards
20
+ * @remarks Build a date string based off HL7 Standards
21
21
  * @since 2.1.0
22
22
  * @param date
23
23
  * @param length Options are 8, 12, or 14 (default)
@@ -25,14 +25,14 @@ export declare class HL7Client {
25
25
  buildDate(date: Date, length?: string): string;
26
26
  /**
27
27
  * Build a HL7 File Batch
28
- *@remarks Create a properly formatted HL7 File Batch.
28
+ * @remarks Create a properly formatted HL7 File Batch.
29
29
  * @since 1.0.0
30
30
  * @param props
31
31
  */
32
32
  buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
33
33
  /**
34
34
  * Build a HL7 Message
35
- *@remarks Create a properly formatted HL7 message.
35
+ * @remarks Create a properly formatted HL7 message.
36
36
  * @since 1.0.0
37
37
  * @param props
38
38
  */
@@ -45,7 +45,7 @@ export declare class HL7Client {
45
45
  createClient(name: string, props: ClientOptions): Client;
46
46
  /**
47
47
  * Create an HL7 Outbound Connection
48
- *@remarks Connect to an HL7 Server/Broker
48
+ * @remarks Connect to an HL7 Server/Broker
49
49
  * @since 1.0.0
50
50
  * @param name The name stored within created client connections.
51
51
  * @param props
@@ -66,14 +66,14 @@ export declare class HL7Client {
66
66
  getClientConnectionByPort(port: string): Connection | undefined;
67
67
  /**
68
68
  * Process a HL7
69
- *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
69
+ * @remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
70
70
  * @since 1.0.0
71
71
  * @param text Raw HL& String
72
72
  */
73
73
  processHL7(text: string): Message | Batch;
74
74
  /**
75
75
  * Read File
76
- *@remarks Pass the correct path of the file you want to read.
76
+ * @remarks Pass the correct path of the file you want to read.
77
77
  * @since 1.0.0
78
78
  * @param fullFilePath
79
79
  * @returns FileBatch
@@ -85,7 +85,7 @@ export declare class HL7Client {
85
85
  readFile(fullFilePath: string): FileBatch;
86
86
  /**
87
87
  * Read a File Buffer
88
- *@remarks Translate an already Buffered HL7 FHS segment to decode it.
88
+ * @remarks Translate an already Buffered HL7 FHS segment to decode it.
89
89
  * @since 1.0.0
90
90
  * @param fileBuffer
91
91
  * @returns FileBatch
@@ -1,5 +1,6 @@
1
+ import { EventEmitter } from "node:events";
1
2
  import Server, { Inbound, InboundHandler, ListenerOptions } from "node-hl7-server";
2
- export declare class HL7Server {
3
+ export declare class HL7Server extends EventEmitter {
3
4
  private readonly _server;
4
5
  private readonly _serverInboundConnections;
5
6
  constructor(server: Server);
@@ -25,14 +25,14 @@ declare module "fastify" {
25
25
  * @since 1.0.0 */
26
26
  closeServerAll: () => Promise<boolean>;
27
27
  /** Create Client
28
- *@remarks Connecting to a remote server/broker that accepts connections.
28
+ * @remarks Connecting to a remote server/broker that accepts connections.
29
29
  * @since 1.0.0 */
30
30
  createClient: (name: string, props: ClientOptions) => Client;
31
31
  /** Create an incoming port connection on the server.
32
32
  * @since 1.0.0 */
33
33
  createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
34
34
  /** Create Outgoing Client Port
35
- *@remarks This is on the established client that we are already a part off.
35
+ * @remarks This is on the established client that we are already a part off.
36
36
  * @since 1.0.0 */
37
37
  createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
38
38
  /** Get Client (Outbound) connection by name.
@@ -59,7 +59,7 @@ declare module "fastify" {
59
59
  }
60
60
  interface FastifyInstance {
61
61
  /** Main Decorator for Fastify
62
- *@remarks hl7 is the decorator that everything hangs off.
62
+ * @remarks hl7 is the decorator that everything hangs off.
63
63
  * @since 1.0.0 **/
64
64
  hl7: HL7;
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-hl7",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "A Fastify HL7 Plugin Developed in Pure TypeScript.",
5
5
  "module": "./lib/esm/index.js",
6
6
  "main": "./lib/cjs/index.js",
@@ -27,7 +27,7 @@
27
27
  "build:watch": "tsc -p src/tsconfig.esm.json -w",
28
28
  "build:watch:cjs": "tsc -p src/tsconfig.cjs.json -w",
29
29
  "npm:lint": "npmPkgJsonLint .",
30
- "format": "prettier --write 'README.md' 'src/**/*.ts' '__tests__/**/*.ts'",
30
+ "format": "prettier --write 'README.md' 'src/**/*.ts' '__tests__/**/*.ts' '*.{mts,mjs}'",
31
31
  "lint": "npm run npm:lint && eslint | snazzy",
32
32
  "lint:fix": "npm run npm:lint && eslint --fix | snazzy",
33
33
  "pack": "npm pack",
@@ -65,15 +65,16 @@
65
65
  "node-hl7-server": "^3.1.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@eslint/js": "^9.15.0",
68
+ "@eslint/js": "^9.16.0",
69
+ "@shipgirl/typedoc-plugin-versions": "^0.2.8",
69
70
  "@types/eslint__js": "^8.42.3",
70
- "@types/node": "^22.9.0",
71
+ "@types/node": "^22.10.1",
71
72
  "@types/tcp-port-used": "^1.0.4",
72
- "@typescript-eslint/eslint-plugin": "^8.14.0",
73
- "@typescript-eslint/parser": "^8.14.0",
74
- "@vitest/coverage-v8": "^2.1.5",
75
- "@vitest/ui": "^2.1.5",
76
- "eslint": "^9.14.0",
73
+ "@typescript-eslint/eslint-plugin": "^8.17.0",
74
+ "@typescript-eslint/parser": "^8.17.0",
75
+ "@vitest/coverage-v8": "^2.1.8",
76
+ "@vitest/ui": "^2.1.8",
77
+ "eslint": "^9.16.0",
77
78
  "eslint-config-prettier": "^9.1.0",
78
79
  "eslint-plugin-prettier": "^5.2.1",
79
80
  "fastify": "^5.1.0",
@@ -85,12 +86,13 @@
85
86
  "tcp-port-used": "^1.0.2",
86
87
  "ts-node": "^10.9.2",
87
88
  "tsd": "^0.31.2",
88
- "typedoc": "^0.26.11",
89
- "typescript": "^5.6.3",
90
- "typescript-eslint": "^8.14.0",
91
- "vitest": "^2.1.5"
89
+ "typedoc": "^0.27.4",
90
+ "typescript": "^5.7.2",
91
+ "typescript-eslint": "^8.17.0",
92
+ "vitest": "^2.1.8"
92
93
  },
93
94
  "precommit": [
95
+ "format",
94
96
  "lint:fix",
95
97
  "build"
96
98
  ]