fastify-hl7 1.2.0 → 2.0.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 +2 -4
- package/lib/cjs/class/hL7Client.js +2 -2
- package/lib/cjs/class/hL7Server.js +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/esm/class/hL7Client.js +3 -3
- package/lib/esm/class/hL7Server.js +2 -2
- package/lib/esm/index.js +2 -2
- package/lib/types/class/hL7Client.d.ts +3 -3
- package/lib/types/class/hL7Server.d.ts +4 -4
- package/lib/types/decorate.d.ts +4 -4
- package/lib/types/types.d.ts +7 -7
- package/package.json +25 -24
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.
|
|
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.
|
|
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
|
|
|
@@ -175,7 +175,7 @@ var HL7Client = /** @class */ (function () {
|
|
|
175
175
|
* @param props
|
|
176
176
|
* @param handler
|
|
177
177
|
*/
|
|
178
|
-
HL7Client.prototype.
|
|
178
|
+
HL7Client.prototype.createConnection = function (name, props, handler) {
|
|
179
179
|
var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
180
180
|
if (nameFormat.test(name)) {
|
|
181
181
|
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
|
|
@@ -189,7 +189,7 @@ var HL7Client = /** @class */ (function () {
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
// create outbound port to the server in getConnection.client
|
|
192
|
-
var outbound = new node_hl7_client_1.
|
|
192
|
+
var outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
|
|
193
193
|
// add it to the array of known ports. need to know this, so we can get it later if needed.
|
|
194
194
|
getConnection.ports.push({ port: props.port.toString(), connection: outbound });
|
|
195
195
|
// 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.
|
|
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
|
@@ -172,8 +172,8 @@ var fastifyHL7 = (0, fastify_plugin_1.default)(function (fastify, opts) { return
|
|
|
172
172
|
}
|
|
173
173
|
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
174
174
|
},
|
|
175
|
-
|
|
176
|
-
return client.
|
|
175
|
+
createConnection: function (name, props, handler) {
|
|
176
|
+
return client.createConnection(name, props, handler);
|
|
177
177
|
},
|
|
178
178
|
getClientByName: function (name) {
|
|
179
179
|
return client.getClientByName(name);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Client, { Batch, FileBatch,
|
|
1
|
+
import Client, { Batch, FileBatch, Connection, isBatch, Message } from 'node-hl7-client';
|
|
2
2
|
import { errors } from '../errors.js';
|
|
3
3
|
export class HL7Client {
|
|
4
4
|
/** @internal */
|
|
@@ -92,7 +92,7 @@ export class HL7Client {
|
|
|
92
92
|
* @param props
|
|
93
93
|
* @param handler
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
createConnection(name, props, handler) {
|
|
96
96
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
97
97
|
if (nameFormat.test(name)) {
|
|
98
98
|
throw new errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
|
|
@@ -106,7 +106,7 @@ export class HL7Client {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
// create outbound port to the server in getConnection.client
|
|
109
|
-
const outbound = new
|
|
109
|
+
const outbound = new Connection(getConnection.client, props, handler);
|
|
110
110
|
// add it to the array of known ports. need to know this, so we can get it later if needed.
|
|
111
111
|
getConnection.ports.push({ port: props.port.toString(), connection: outbound });
|
|
112
112
|
// return it right away. the user might do something with it.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
@@ -82,8 +82,8 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
82
82
|
}
|
|
83
83
|
throw new errors.FASTIFY_HL7_ERR_USAGE('server was not started. re-register plugin with enableServer set to true.');
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
return client.
|
|
85
|
+
createConnection: function (name, props, handler) {
|
|
86
|
+
return client.createConnection(name, props, handler);
|
|
87
87
|
},
|
|
88
88
|
getClientByName: function (name) {
|
|
89
89
|
return client.getClientByName(name);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch,
|
|
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
|
/**
|
|
@@ -42,7 +42,7 @@ export declare class HL7Client {
|
|
|
42
42
|
* @param props
|
|
43
43
|
* @param handler
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
createConnection(name: string, props: ClientListenerOptions, handler: OutboundHandler): Connection;
|
|
46
46
|
/**
|
|
47
47
|
* Get Client by the name
|
|
48
48
|
* @since 1.0.0
|
|
@@ -54,7 +54,7 @@ export declare class HL7Client {
|
|
|
54
54
|
* @since 1.0.0
|
|
55
55
|
* @param port
|
|
56
56
|
*/
|
|
57
|
-
getClientConnectionByPort(port: string):
|
|
57
|
+
getClientConnectionByPort(port: string): Connection | undefined;
|
|
58
58
|
/**
|
|
59
59
|
* Process a HL7
|
|
60
60
|
* @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import 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):
|
|
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):
|
|
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):
|
|
36
|
+
getServerByPort(port: string): Inbound | undefined;
|
|
37
37
|
}
|
package/lib/types/decorate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Client, {
|
|
2
|
-
import {
|
|
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:
|
|
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:
|
|
36
|
+
server: Inbound;
|
|
37
37
|
}
|
|
38
38
|
export {};
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import Server, {
|
|
3
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions,
|
|
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
|
|
@@ -27,23 +27,23 @@ declare module 'fastify' {
|
|
|
27
27
|
createClient: (name: string, props: ClientOptions) => Client;
|
|
28
28
|
/** Create an incoming port connection on the server.
|
|
29
29
|
* @since 1.0.0 */
|
|
30
|
-
createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) =>
|
|
30
|
+
createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
|
|
31
31
|
/** Create Outgoing Client Port
|
|
32
32
|
* @description This is on the established client that we are already a part off.
|
|
33
33
|
* @since 1.0.0 */
|
|
34
|
-
|
|
34
|
+
createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
|
|
35
35
|
/** Get Client (Outbound) connection by name.
|
|
36
36
|
* @since 1.0.0 */
|
|
37
37
|
getClientByName: (name: string) => Client | undefined;
|
|
38
38
|
/** Get Client Connection (Outbound) connection by port.
|
|
39
39
|
* @since 1.0.0 */
|
|
40
|
-
getClientConnectionByPort: (port: string) =>
|
|
40
|
+
getClientConnectionByPort: (port: string) => Connection | undefined;
|
|
41
41
|
/** Get Server (Inbound) connection by port.
|
|
42
42
|
* @since 1.0.0 */
|
|
43
|
-
getServerByPort: (port: string) =>
|
|
43
|
+
getServerByPort: (port: string) => Inbound | undefined;
|
|
44
44
|
/** Get Server (Inbound) connection by name.
|
|
45
45
|
* @since 1.0.0 */
|
|
46
|
-
getServerByName: (name: string) =>
|
|
46
|
+
getServerByName: (name: string) => Inbound | undefined;
|
|
47
47
|
/** Process an HL7 string.
|
|
48
48
|
* @since 1.0.0 */
|
|
49
49
|
processHL7: (text: string) => Message | Batch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-hl7",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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": "
|
|
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": "
|
|
32
|
-
"test:
|
|
33
|
-
"test:
|
|
34
|
-
"test: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
|
|
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": "^
|
|
64
|
-
"node-hl7-server": "^
|
|
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.
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/node": "^20.10.8",
|
|
70
|
+
"@the-rabbit-hole/semantic-release-config": "^1.5.0",
|
|
71
|
+
"@types/node": "^20.11.16",
|
|
74
72
|
"@types/randomstring": "^1.1.11",
|
|
75
73
|
"@types/tcp-port-used": "^1.0.4",
|
|
76
|
-
"@typescript-eslint/parser": "^6.
|
|
74
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
75
|
+
"@vitest/coverage-v8": "^1.2.2",
|
|
76
|
+
"@vitest/ui": "^1.2.2",
|
|
77
77
|
"clean-publish": "^4.2.0",
|
|
78
|
-
"fastify": "^4.
|
|
79
|
-
"
|
|
80
|
-
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
81
|
-
"npm-check-updates": "^16.14.12",
|
|
78
|
+
"fastify": "^4.26.0",
|
|
79
|
+
"npm-check-updates": "^16.14.14",
|
|
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.
|
|
88
|
+
"tsd": "^0.30.4",
|
|
92
89
|
"typedoc": "^0.25.7",
|
|
93
|
-
"typescript": "^5.3.3"
|
|
90
|
+
"typescript": "^5.3.3",
|
|
91
|
+
"vitest": "^1.2.2"
|
|
94
92
|
},
|
|
95
|
-
"
|
|
93
|
+
"precommit": [
|
|
94
|
+
"lint:fix",
|
|
95
|
+
"build"
|
|
96
|
+
]
|
|
96
97
|
}
|