fastify-hl7 1.2.0 → 2.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.
package/README.md CHANGED
@@ -69,7 +69,7 @@ Within your code now you can use the fastify context and access the ```hl7``` de
69
69
  and create an outbound connection.
70
70
 
71
71
  ```ts
72
- const client = fastify.hl7.createOutbound(
72
+ const client = fastify.hl7.createConnection(
73
73
  'ob_adt',
74
74
  {port: 3001},
75
75
  async (res) => {
@@ -101,9 +101,7 @@ If this is not set, enableServer will be set to ```true```. You need to set this
101
101
  ### ```serverOptions```
102
102
 
103
103
  Set this using the options from the [node-hl7-serer](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) library ServerOptions values to override server creation.
104
- This could be enabling IPv4 or IPv6 and other server options including TLS. SInce you can not set this after run time, it has to be set during registration.
105
-
106
-
104
+ This could be enabling IPv4 or IPv6 and other server options including TLS. Since you cannot set this after run time, it has to be set during registration.
107
105
 
108
106
  ### External Libraries
109
107
 
@@ -113,6 +113,16 @@ var HL7Client = /** @class */ (function () {
113
113
  }
114
114
  return new node_hl7_client_1.Batch(__assign({}, props));
115
115
  };
116
+ /**
117
+ * Build Date
118
+ * @description Build a date string based off HL7 Standards
119
+ * @since 2.1.0
120
+ * @param date
121
+ * @param length Options are 8, 12, or 14 (default)
122
+ */
123
+ HL7Client.prototype.buildDate = function (date, length) {
124
+ return (0, node_hl7_client_1.createHL7Date)(date, length);
125
+ };
116
126
  /**
117
127
  * Build a HL7 File Batch
118
128
  * @description Create a properly formatted HL7 File Batch.
@@ -175,7 +185,7 @@ var HL7Client = /** @class */ (function () {
175
185
  * @param props
176
186
  * @param handler
177
187
  */
178
- HL7Client.prototype.createOutbound = function (name, props, handler) {
188
+ HL7Client.prototype.createConnection = function (name, props, handler) {
179
189
  var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
180
190
  if (nameFormat.test(name)) {
181
191
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
@@ -189,7 +199,7 @@ var HL7Client = /** @class */ (function () {
189
199
  }
190
200
  });
191
201
  // create outbound port to the server in getConnection.client
192
- var outbound = new node_hl7_client_1.HL7Outbound(getConnection.client, props, handler);
202
+ var outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
193
203
  // add it to the array of known ports. need to know this, so we can get it later if needed.
194
204
  getConnection.ports.push({ port: props.port.toString(), connection: outbound });
195
205
  // return it right away. the user might do something with it.
@@ -98,7 +98,7 @@ var HL7Server = /** @class */ (function () {
98
98
  if (nameFormat.test(name)) {
99
99
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
100
100
  }
101
- var inbound = new node_hl7_server_1.HL7Inbound(this._server, props, handler);
101
+ var inbound = new node_hl7_server_1.Inbound(this._server, props, handler);
102
102
  this._serverInboundConnections.push({
103
103
  name: name,
104
104
  port: props.port.toString(),
package/lib/cjs/index.js CHANGED
@@ -133,6 +133,9 @@ var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return
133
133
  buildBatch: function (props) {
134
134
  return client.buildBatch(props);
135
135
  },
136
+ buildDate: function (date, length) {
137
+ return client.buildDate(date, length);
138
+ },
136
139
  buildFileBatch: function (props) {
137
140
  return client.buildFileBatch(props);
138
141
  },
@@ -172,8 +175,8 @@ var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return
172
175
  }
173
176
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
174
177
  },
175
- createOutbound: function (name, props, handler) {
176
- return client.createOutbound(name, props, handler);
178
+ createConnection: function (name, props, handler) {
179
+ return client.createConnection(name, props, handler);
177
180
  },
178
181
  getClientByName: function (name) {
179
182
  return client.getClientByName(name);
@@ -1,4 +1,4 @@
1
- import Client, { Batch, FileBatch, HL7Outbound, isBatch, Message } from 'node-hl7-client';
1
+ import Client, { Batch, FileBatch, Connection, isBatch, Message, createHL7Date } from 'node-hl7-client';
2
2
  import { errors } from '../errors.js';
3
3
  export class HL7Client {
4
4
  /** @internal */
@@ -30,6 +30,16 @@ export class HL7Client {
30
30
  }
31
31
  return new Batch({ ...props });
32
32
  }
33
+ /**
34
+ * Build Date
35
+ * @description Build a date string based off HL7 Standards
36
+ * @since 2.1.0
37
+ * @param date
38
+ * @param length Options are 8, 12, or 14 (default)
39
+ */
40
+ buildDate(date, length) {
41
+ return createHL7Date(date, length);
42
+ }
33
43
  /**
34
44
  * Build a HL7 File Batch
35
45
  * @description Create a properly formatted HL7 File Batch.
@@ -92,7 +102,7 @@ export class HL7Client {
92
102
  * @param props
93
103
  * @param handler
94
104
  */
95
- createOutbound(name, props, handler) {
105
+ createConnection(name, props, handler) {
96
106
  const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
97
107
  if (nameFormat.test(name)) {
98
108
  throw new errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
@@ -106,7 +116,7 @@ export class HL7Client {
106
116
  }
107
117
  });
108
118
  // create outbound port to the server in getConnection.client
109
- const outbound = new HL7Outbound(getConnection.client, props, handler);
119
+ const outbound = new Connection(getConnection.client, props, handler);
110
120
  // add it to the array of known ports. need to know this, so we can get it later if needed.
111
121
  getConnection.ports.push({ port: props.port.toString(), connection: outbound });
112
122
  // return it right away. the user might do something with it.
@@ -1,4 +1,4 @@
1
- import { HL7Inbound } from 'node-hl7-server';
1
+ import { Inbound } from 'node-hl7-server';
2
2
  import { errors } from '../errors.js';
3
3
  export class HL7Server {
4
4
  _server;
@@ -41,7 +41,7 @@ export class HL7Server {
41
41
  if (nameFormat.test(name)) {
42
42
  throw new errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
43
43
  }
44
- const inbound = new HL7Inbound(this._server, props, handler);
44
+ const inbound = new Inbound(this._server, props, handler);
45
45
  this._serverInboundConnections.push({
46
46
  name,
47
47
  port: props.port.toString(),
package/lib/esm/index.js CHANGED
@@ -55,6 +55,9 @@ const fastifyHL7 = fp(async (fastify, opts) => {
55
55
  buildBatch: function (props) {
56
56
  return client.buildBatch(props);
57
57
  },
58
+ buildDate: function (date, length) {
59
+ return client.buildDate(date, length);
60
+ },
58
61
  buildFileBatch: function (props) {
59
62
  return client.buildFileBatch(props);
60
63
  },
@@ -82,8 +85,8 @@ const fastifyHL7 = fp(async (fastify, opts) => {
82
85
  }
83
86
  throw new errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
84
87
  },
85
- createOutbound: function (name, props, handler) {
86
- return client.createOutbound(name, props, handler);
88
+ createConnection: function (name, props, handler) {
89
+ return client.createConnection(name, props, handler);
87
90
  },
88
91
  getClientByName: function (name) {
89
92
  return client.getClientByName(name);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
2
+ import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from 'node-hl7-client';
3
3
  export declare class HL7Client {
4
4
  constructor();
5
5
  /**
@@ -14,6 +14,14 @@ export declare class HL7Client {
14
14
  * @param props
15
15
  */
16
16
  buildBatch(props?: ClientBuilderOptions): Batch;
17
+ /**
18
+ * Build Date
19
+ * @description Build a date string based off HL7 Standards
20
+ * @since 2.1.0
21
+ * @param date
22
+ * @param length Options are 8, 12, or 14 (default)
23
+ */
24
+ buildDate(date: Date, length?: string): string;
17
25
  /**
18
26
  * Build a HL7 File Batch
19
27
  * @description Create a properly formatted HL7 File Batch.
@@ -42,7 +50,7 @@ export declare class HL7Client {
42
50
  * @param props
43
51
  * @param handler
44
52
  */
45
- createOutbound(name: string, props: ClientListenerOptions, handler: OutboundHandler): HL7Outbound;
53
+ createConnection(name: string, props: ClientListenerOptions, handler: OutboundHandler): Connection;
46
54
  /**
47
55
  * Get Client by the name
48
56
  * @since 1.0.0
@@ -54,7 +62,7 @@ export declare class HL7Client {
54
62
  * @since 1.0.0
55
63
  * @param port
56
64
  */
57
- getClientConnectionByPort(port: string): HL7Outbound | undefined;
65
+ getClientConnectionByPort(port: string): Connection | undefined;
58
66
  /**
59
67
  * Process a HL7
60
68
  * @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
@@ -1,4 +1,4 @@
1
- import Server, { HL7Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
1
+ import Server, { Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
2
2
  export declare class HL7Server {
3
3
  private readonly _server;
4
4
  private readonly _serverInboundConnections;
@@ -21,17 +21,17 @@ export declare class HL7Server {
21
21
  * @param props
22
22
  * @param handler
23
23
  */
24
- createInbound(name: string, props: ListenerOptions, handler: InboundHandler): HL7Inbound;
24
+ createInbound(name: string, props: ListenerOptions, handler: InboundHandler): Inbound;
25
25
  /**
26
26
  * Get Server Inbound Connection by Name
27
27
  * @since 1.0.0
28
28
  * @param name
29
29
  */
30
- getServerByName(name: string): HL7Inbound | undefined;
30
+ getServerByName(name: string): Inbound | undefined;
31
31
  /**
32
32
  * Get Server Inbound Connection by Port
33
33
  * @since 1.0.0
34
34
  * @param port
35
35
  */
36
- getServerByPort(port: string): HL7Inbound | undefined;
36
+ getServerByPort(port: string): Inbound | undefined;
37
37
  }
@@ -1,5 +1,5 @@
1
- import Client, { HL7Outbound } from 'node-hl7-client';
2
- import { HL7Inbound, ServerOptions } from 'node-hl7-server';
1
+ import Client, { Connection } from 'node-hl7-client';
2
+ import { Inbound, ServerOptions } from 'node-hl7-server';
3
3
  /**
4
4
  * @since 1.0.0
5
5
  */
@@ -17,7 +17,7 @@ export interface FastifyHL7Options {
17
17
  */
18
18
  interface AClientPorts {
19
19
  port: string;
20
- connection: HL7Outbound;
20
+ connection: Connection;
21
21
  }
22
22
  /**
23
23
  * @since 1.0.0
@@ -33,6 +33,6 @@ export interface AClients {
33
33
  export interface AServers {
34
34
  name: string;
35
35
  port: string;
36
- server: HL7Inbound;
36
+ server: Inbound;
37
37
  }
38
38
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import Server, { HL7Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
3
- import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
2
+ import Server, { Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
3
+ import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from 'node-hl7-client';
4
4
  declare module 'fastify' {
5
5
  interface HL7 {
6
6
  /** Server Instance
@@ -9,6 +9,10 @@ declare module 'fastify' {
9
9
  /** Build HL7 Batch
10
10
  * @since 1.0.0 */
11
11
  buildBatch: (props?: ClientBuilderOptions) => Batch;
12
+ /** BBuild Date
13
+ * @since 2.1.0
14
+ */
15
+ buildDate: (date: Date, length?: string) => string;
12
16
  /** Build HL7 File Batch
13
17
  * @since 1.0.0 */
14
18
  buildFileBatch: (props?: ClientBuilderFileOptions) => FileBatch;
@@ -27,23 +31,23 @@ declare module 'fastify' {
27
31
  createClient: (name: string, props: ClientOptions) => Client;
28
32
  /** Create an incoming port connection on the server.
29
33
  * @since 1.0.0 */
30
- createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => HL7Inbound;
34
+ createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
31
35
  /** Create Outgoing Client Port
32
36
  * @description This is on the established client that we are already a part off.
33
37
  * @since 1.0.0 */
34
- createOutbound: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => HL7Outbound;
38
+ createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
35
39
  /** Get Client (Outbound) connection by name.
36
40
  * @since 1.0.0 */
37
41
  getClientByName: (name: string) => Client | undefined;
38
42
  /** Get Client Connection (Outbound) connection by port.
39
43
  * @since 1.0.0 */
40
- getClientConnectionByPort: (port: string) => HL7Outbound | undefined;
44
+ getClientConnectionByPort: (port: string) => Connection | undefined;
41
45
  /** Get Server (Inbound) connection by port.
42
46
  * @since 1.0.0 */
43
- getServerByPort: (port: string) => HL7Inbound | undefined;
47
+ getServerByPort: (port: string) => Inbound | undefined;
44
48
  /** Get Server (Inbound) connection by name.
45
49
  * @since 1.0.0 */
46
- getServerByName: (name: string) => HL7Inbound | undefined;
50
+ getServerByName: (name: string) => Inbound | undefined;
47
51
  /** Process an HL7 string.
48
52
  * @since 1.0.0 */
49
53
  processHL7: (text: string) => Message | Batch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-hl7",
3
- "version": "1.2.0",
3
+ "version": "2.1.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",
@@ -17,10 +17,10 @@
17
17
  "lib/"
18
18
  ],
19
19
  "engines": {
20
- "node": "^18 || ^20"
20
+ "node": ">=20.0.0"
21
21
  },
22
22
  "scripts": {
23
- "clean": "rm -rf lib coverage",
23
+ "clean": "rm -rf lib coverage docs",
24
24
  "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
25
25
  "build:watch": "tsc -p tsconfig.esm.json -w",
26
26
  "npmPkgJsonLint": "npmPkgJsonLint .",
@@ -28,17 +28,16 @@
28
28
  "lint:fix": "npmPkgJsonLint . && ts-standard --fix | snazzy",
29
29
  "pack": "npm pack",
30
30
  "prepublishOnly": "npm run clean && npm run build && npm run pack",
31
- "test": "jest",
32
- "test:open": "jest --detectOpenHandles",
33
- "test:ci": "jest --ci",
34
- "test:coverage": "jest --coverage",
35
- "test:coverage:watch": "jest --coverage --watch",
31
+ "test": "vitest run",
32
+ "test:verbose": "vitest run --reporter verbose",
33
+ "test:watch": "vitest watch",
34
+ "test:coverage": "vitest --coverage",
36
35
  "typedoc": "typedoc",
37
36
  "typedoc:watch": "typedoc -watch",
38
37
  "semantic-release": "semantic-release",
39
38
  "semantic-release:dry-run": "semantic-release --dry-run",
40
- "update": "npx npm-check-updates -u && npm run update:post-update",
41
- "update:post-update": "npm install && npm run test:ci"
39
+ "update": "npx npm-check-updates -u --enginesNode && npm run update:post-update",
40
+ "update:post-update": "npm install && npm run test"
42
41
  },
43
42
  "repository": {
44
43
  "type": "git",
@@ -60,37 +59,39 @@
60
59
  "dependencies": {
61
60
  "@fastify/error": "^3.4.1",
62
61
  "fastify-plugin": "^4.5.1",
63
- "node-hl7-client": "^1.1.2",
64
- "node-hl7-server": "^1.2.3"
62
+ "node-hl7-client": "^2.0.0",
63
+ "node-hl7-server": "^2.0.0"
65
64
  },
66
65
  "devDependencies": {
67
66
  "@semantic-release/changelog": "^6.0.3",
68
67
  "@semantic-release/commit-analyzer": "^11.1.0",
69
68
  "@semantic-release/git": "^10.0.1",
70
69
  "@semantic-release/release-notes-generator": "^12.1.0",
71
- "@the-rabbit-hole/semantic-release-config": "^1.4.0",
72
- "@types/jest": "^29.5.11",
73
- "@types/node": "^20.10.8",
70
+ "@the-rabbit-hole/semantic-release-config": "^1.5.0",
71
+ "@types/node": "^20.11.19",
74
72
  "@types/randomstring": "^1.1.11",
75
73
  "@types/tcp-port-used": "^1.0.4",
76
- "@typescript-eslint/parser": "^6.18.1",
74
+ "@typescript-eslint/parser": "^7.0.2",
75
+ "@vitest/coverage-v8": "^1.3.1",
76
+ "@vitest/ui": "^1.3.1",
77
77
  "clean-publish": "^4.2.0",
78
- "fastify": "^4.25.2",
79
- "jest": "^29.7.0",
80
- "jest-ts-webcompat-resolver": "^1.0.0",
81
- "npm-check-updates": "^16.14.12",
78
+ "fastify": "^4.26.1",
79
+ "npm-check-updates": "^16.14.15",
82
80
  "npm-package-json-lint": "^7.1.0",
83
81
  "portfinder": "^1.0.32",
84
82
  "pre-commit": "^1.2.2",
85
83
  "semantic-release": "^22.0.12",
86
84
  "snazzy": "^9.0.0",
87
85
  "tcp-port-used": "^1.0.2",
88
- "ts-jest": "^29.1.1",
89
86
  "ts-node": "^10.9.2",
90
87
  "ts-standard": "^12.0.2",
91
- "tsd": "^0.30.3",
92
- "typedoc": "^0.25.7",
93
- "typescript": "^5.3.3"
88
+ "tsd": "^0.30.5",
89
+ "typedoc": "^0.25.8",
90
+ "typescript": "^5.3.3",
91
+ "vitest": "^1.3.1"
94
92
  },
95
- "pre-commit": []
93
+ "precommit": [
94
+ "lint:fix",
95
+ "build"
96
+ ]
96
97
  }