fastify-hl7 3.0.0 → 3.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 +26 -23
- package/lib/cjs/class/hL7Client.js +24 -19
- package/lib/cjs/class/hL7Server.js +8 -8
- package/lib/cjs/errors.js +2 -2
- package/lib/cjs/index.js +24 -22
- package/lib/cjs/validation.js +1 -1
- package/lib/esm/api.d.ts +5 -5
- package/lib/esm/api.js +3 -3
- package/lib/esm/class/hL7Client.d.ts +1 -1
- package/lib/esm/class/hL7Client.js +26 -21
- package/lib/esm/class/hL7Server.d.ts +1 -1
- package/lib/esm/class/hL7Server.js +10 -10
- package/lib/esm/decorate.d.ts +2 -2
- package/lib/esm/errors.js +3 -3
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +31 -29
- package/lib/esm/types.d.ts +3 -3
- package/lib/esm/validation.d.ts +1 -1
- package/lib/esm/validation.js +1 -1
- package/lib/types/api.d.ts +5 -5
- package/lib/types/class/hL7Client.d.ts +1 -1
- package/lib/types/class/hL7Server.d.ts +1 -1
- package/lib/types/decorate.d.ts +2 -2
- package/lib/types/index.d.ts +2 -2
- package/lib/types/types.d.ts +3 -3
- package/lib/types/validation.d.ts +1 -1
- package/package.json +27 -27
package/README.md
CHANGED
|
@@ -34,48 +34,51 @@ npm install fastify-hl7
|
|
|
34
34
|
Register this as a plugin.
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
-
await fastify.register(fastifyHL7)
|
|
37
|
+
await fastify.register(fastifyHL7);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Server Quick Start
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
43
|
const listener = fastify.hl7.createInbound(
|
|
44
|
-
|
|
45
|
-
{port: 3001},
|
|
44
|
+
"ib_adt",
|
|
45
|
+
{ port: 3001 },
|
|
46
46
|
async (req, res) => {
|
|
47
|
-
const messageReq = req.getMessage()
|
|
48
|
-
const messageType = req.getType()
|
|
47
|
+
const messageReq = req.getMessage();
|
|
48
|
+
const messageType = req.getType();
|
|
49
49
|
// your logic here
|
|
50
|
-
await res.sendResponse(
|
|
51
|
-
}
|
|
50
|
+
await res.sendResponse("AA");
|
|
51
|
+
},
|
|
52
|
+
);
|
|
52
53
|
```
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.
|
|
54
56
|
|
|
55
57
|
### Client Quick Start
|
|
56
58
|
|
|
57
59
|
```ts
|
|
58
60
|
import fastify from "fastify";
|
|
59
61
|
|
|
60
|
-
fastify.hl7.createClient(
|
|
62
|
+
fastify.hl7.createClient("localhost", { host: "0.0.0.0" });
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
This will create a "client" class that will then allow you to attach different outbound connections.
|
|
64
|
-
The name
|
|
66
|
+
The name `localhost` in a unique identifier to this host, so it can be used to attach different outbound connections to this server/broker.
|
|
65
67
|
|
|
66
68
|
There might be times when your HL7 messages need to cross-over to different hosts/server/inbound endpoints and this is how you would get them.
|
|
67
69
|
|
|
68
|
-
Within your code now you can use the fastify context and access the
|
|
70
|
+
Within your code now you can use the fastify context and access the `hl7` decorator,
|
|
69
71
|
and create an outbound connection.
|
|
70
72
|
|
|
71
73
|
```ts
|
|
72
74
|
const client = fastify.hl7.createConnection(
|
|
73
|
-
|
|
74
|
-
{port: 3001},
|
|
75
|
+
"ob_adt",
|
|
76
|
+
{ port: 3001 },
|
|
75
77
|
async (res) => {
|
|
76
|
-
const messageRes = res.getMessage()
|
|
78
|
+
const messageRes = res.getMessage();
|
|
77
79
|
// Your code here. Either a failure or a success, but still do your work here.
|
|
78
|
-
}
|
|
80
|
+
},
|
|
81
|
+
);
|
|
79
82
|
|
|
80
83
|
// building a HL7 Message Segment
|
|
81
84
|
const message = app.hl7.buildMessage({
|
|
@@ -83,10 +86,10 @@ const message = app.hl7.buildMessage({
|
|
|
83
86
|
msh_9_1: "ADT",
|
|
84
87
|
msh_9_2: "A01",
|
|
85
88
|
msh_11_1: "D",
|
|
86
|
-
}
|
|
87
|
-
})
|
|
89
|
+
},
|
|
90
|
+
});
|
|
88
91
|
|
|
89
|
-
await client.sendMessage(message)
|
|
92
|
+
await client.sendMessage(message);
|
|
90
93
|
```
|
|
91
94
|
|
|
92
95
|
## Full Documentation
|
|
@@ -95,17 +98,17 @@ await client.sendMessage(message)
|
|
|
95
98
|
|
|
96
99
|
### `enableServer`
|
|
97
100
|
|
|
98
|
-
If this is not set, enableServer will be set to
|
|
101
|
+
If this is not set, enableServer will be set to `true`. You need to set this to `false` will turn off the server capabilities.
|
|
99
102
|
|
|
100
|
-
###
|
|
103
|
+
### `serverOptions`
|
|
101
104
|
|
|
102
105
|
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.
|
|
103
106
|
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.
|
|
104
107
|
|
|
105
108
|
### External Libraries Options
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
- [node-hl7-client](https://github.com/Bugs5382/node-hl7-client/blob/main/README.md) - For the Client, Parser, and Builder to review their options that can be passed as props.
|
|
111
|
+
- [node-hl7-server](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) - For the Server to the options that can be passed as props.
|
|
109
112
|
|
|
110
113
|
Please review the libraries for more complete documentation.
|
|
111
114
|
|
|
@@ -115,4 +118,4 @@ Please review the libraries for more complete documentation.
|
|
|
115
118
|
|
|
116
119
|
## License
|
|
117
120
|
|
|
118
|
-
Licensed under [MIT](./LICENSE).
|
|
121
|
+
Licensed under [MIT](./LICENSE).
|
|
@@ -35,7 +35,7 @@ class HL7Client {
|
|
|
35
35
|
* @since 1.0.0
|
|
36
36
|
*/
|
|
37
37
|
async closeAll() {
|
|
38
|
-
this._clientConnections.forEach(outbound => {
|
|
38
|
+
this._clientConnections.forEach((outbound) => {
|
|
39
39
|
outbound.ports.map(async (port) => {
|
|
40
40
|
await port.connection.close();
|
|
41
41
|
});
|
|
@@ -49,8 +49,8 @@ class HL7Client {
|
|
|
49
49
|
* @param props
|
|
50
50
|
*/
|
|
51
51
|
buildBatch(props) {
|
|
52
|
-
if (typeof props !==
|
|
53
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
52
|
+
if (typeof props !== "undefined" && typeof props.text !== "undefined") {
|
|
53
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
|
|
54
54
|
}
|
|
55
55
|
return new node_hl7_client_1.Batch({ ...props });
|
|
56
56
|
}
|
|
@@ -71,8 +71,10 @@ class HL7Client {
|
|
|
71
71
|
* @param props
|
|
72
72
|
*/
|
|
73
73
|
buildFileBatch(props) {
|
|
74
|
-
if (typeof props !==
|
|
75
|
-
|
|
74
|
+
if (typeof props !== "undefined" &&
|
|
75
|
+
(typeof props.fullFilePath !== "undefined" ||
|
|
76
|
+
typeof props.fileBuffer !== "undefined")) {
|
|
77
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use readFile or readFileBuffer method. This is for building.");
|
|
76
78
|
}
|
|
77
79
|
return new node_hl7_client_1.FileBatch({ ...props });
|
|
78
80
|
}
|
|
@@ -83,8 +85,8 @@ class HL7Client {
|
|
|
83
85
|
* @param props
|
|
84
86
|
*/
|
|
85
87
|
buildMessage(props) {
|
|
86
|
-
if (typeof props !==
|
|
87
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
88
|
+
if (typeof props !== "undefined" && typeof props.text !== "undefined") {
|
|
89
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
|
|
88
90
|
}
|
|
89
91
|
return new node_hl7_client_1.Message({ ...props });
|
|
90
92
|
}
|
|
@@ -96,12 +98,12 @@ class HL7Client {
|
|
|
96
98
|
createClient(name, props) {
|
|
97
99
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
98
100
|
if (nameFormat.test(name)) {
|
|
99
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
101
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
100
102
|
}
|
|
101
103
|
// make sure that this does not exist already...
|
|
102
104
|
this._clientConnections.forEach((connections) => {
|
|
103
105
|
if (connections.name === name) {
|
|
104
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
106
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must be unique.");
|
|
105
107
|
}
|
|
106
108
|
// nto in the Client class yet
|
|
107
109
|
// if (client.getHost() === props.host) {
|
|
@@ -114,7 +116,7 @@ class HL7Client {
|
|
|
114
116
|
this._clientConnections.push({
|
|
115
117
|
name,
|
|
116
118
|
client,
|
|
117
|
-
ports: []
|
|
119
|
+
ports: [],
|
|
118
120
|
});
|
|
119
121
|
return client;
|
|
120
122
|
}
|
|
@@ -129,10 +131,10 @@ class HL7Client {
|
|
|
129
131
|
createConnection(name, props, handler) {
|
|
130
132
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
131
133
|
if (nameFormat.test(name)) {
|
|
132
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
134
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
133
135
|
}
|
|
134
|
-
const getConnection = this._clientConnections.find(client => client.name === name);
|
|
135
|
-
if (typeof getConnection !==
|
|
136
|
+
const getConnection = this._clientConnections.find((client) => client.name === name);
|
|
137
|
+
if (typeof getConnection !== "undefined") {
|
|
136
138
|
// make sure port is not used all ready
|
|
137
139
|
getConnection.ports.forEach((outbound) => {
|
|
138
140
|
if (outbound.port === props.port.toString()) {
|
|
@@ -142,11 +144,14 @@ class HL7Client {
|
|
|
142
144
|
// create outbound port to the server in getConnection.client
|
|
143
145
|
const outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
|
|
144
146
|
// add it to the array of known ports. need to know this, so we can get it later if needed.
|
|
145
|
-
getConnection.ports.push({
|
|
147
|
+
getConnection.ports.push({
|
|
148
|
+
port: props.port.toString(),
|
|
149
|
+
connection: outbound,
|
|
150
|
+
});
|
|
146
151
|
// return it right away. the user might do something with it.
|
|
147
152
|
return outbound;
|
|
148
153
|
}
|
|
149
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
154
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("No valid client. Improper setup of a outbound connection.");
|
|
150
155
|
}
|
|
151
156
|
/**
|
|
152
157
|
* Get Client by the name
|
|
@@ -154,8 +159,8 @@ class HL7Client {
|
|
|
154
159
|
* @param name
|
|
155
160
|
*/
|
|
156
161
|
getClientByName(name) {
|
|
157
|
-
const connection = this._clientConnections.find(connection => connection.name === name);
|
|
158
|
-
if (typeof connection !==
|
|
162
|
+
const connection = this._clientConnections.find((connection) => connection.name === name);
|
|
163
|
+
if (typeof connection !== "undefined") {
|
|
159
164
|
return connection.client;
|
|
160
165
|
}
|
|
161
166
|
return undefined;
|
|
@@ -167,8 +172,8 @@ class HL7Client {
|
|
|
167
172
|
*/
|
|
168
173
|
getClientConnectionByPort(port) {
|
|
169
174
|
let connection;
|
|
170
|
-
this._clientConnections.forEach(outbound => {
|
|
171
|
-
outbound.ports.forEach(aPort => {
|
|
175
|
+
this._clientConnections.forEach((outbound) => {
|
|
176
|
+
outbound.ports.forEach((aPort) => {
|
|
172
177
|
if (aPort.port === port) {
|
|
173
178
|
connection = aPort.connection;
|
|
174
179
|
}
|
|
@@ -14,8 +14,8 @@ class HL7Server {
|
|
|
14
14
|
* @param port
|
|
15
15
|
*/
|
|
16
16
|
async close(port) {
|
|
17
|
-
const inbound = this._serverInboundConnections.find(server => server.port === port);
|
|
18
|
-
if (typeof inbound !==
|
|
17
|
+
const inbound = this._serverInboundConnections.find((server) => server.port === port);
|
|
18
|
+
if (typeof inbound !== "undefined") {
|
|
19
19
|
return await inbound.server.close(); // close the server for all inbound connections
|
|
20
20
|
}
|
|
21
21
|
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(`No inbound server listening on port: ${port}`);
|
|
@@ -40,13 +40,13 @@ class HL7Server {
|
|
|
40
40
|
createInbound(name, props, handler) {
|
|
41
41
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
42
42
|
if (nameFormat.test(name)) {
|
|
43
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
43
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
44
44
|
}
|
|
45
45
|
const inbound = new node_hl7_server_1.Inbound(this._server, props, handler);
|
|
46
46
|
this._serverInboundConnections.push({
|
|
47
47
|
name,
|
|
48
48
|
port: props.port.toString(),
|
|
49
|
-
server: inbound
|
|
49
|
+
server: inbound,
|
|
50
50
|
});
|
|
51
51
|
return inbound;
|
|
52
52
|
}
|
|
@@ -56,8 +56,8 @@ class HL7Server {
|
|
|
56
56
|
* @param name
|
|
57
57
|
*/
|
|
58
58
|
getServerByName(name) {
|
|
59
|
-
const inbound = this._serverInboundConnections.find(inbound => inbound.name === name);
|
|
60
|
-
if (typeof inbound !==
|
|
59
|
+
const inbound = this._serverInboundConnections.find((inbound) => inbound.name === name);
|
|
60
|
+
if (typeof inbound !== "undefined") {
|
|
61
61
|
return inbound.server;
|
|
62
62
|
}
|
|
63
63
|
return undefined;
|
|
@@ -68,8 +68,8 @@ class HL7Server {
|
|
|
68
68
|
* @param port
|
|
69
69
|
*/
|
|
70
70
|
getServerByPort(port) {
|
|
71
|
-
const inbound = this._serverInboundConnections.find(inbound => inbound.port === port);
|
|
72
|
-
if (typeof inbound !==
|
|
71
|
+
const inbound = this._serverInboundConnections.find((inbound) => inbound.port === port);
|
|
72
|
+
if (typeof inbound !== "undefined") {
|
|
73
73
|
return inbound.server;
|
|
74
74
|
}
|
|
75
75
|
return undefined;
|
package/lib/cjs/errors.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.errors = void 0;
|
|
|
7
7
|
const error_1 = __importDefault(require("@fastify/error"));
|
|
8
8
|
exports.errors = {
|
|
9
9
|
/** Error if there is an setup error of the plugin itself. */
|
|
10
|
-
FASTIFY_HL7_ERR_SETUP_ERRORS: (0, error_1.default)(
|
|
10
|
+
FASTIFY_HL7_ERR_SETUP_ERRORS: (0, error_1.default)("FASTIFY_HL7_ERR_SETUP_ERRORS", "Setup error: %s"),
|
|
11
11
|
/** If an invalid usage error was done, this error would pop up. */
|
|
12
|
-
FASTIFY_HL7_ERR_USAGE: (0, error_1.default)(
|
|
12
|
+
FASTIFY_HL7_ERR_USAGE: (0, error_1.default)("FASTIFY_HL7_ERR_USAGE", "Usage error: %s"),
|
|
13
13
|
};
|
package/lib/cjs/index.js
CHANGED
|
@@ -31,12 +31,12 @@ __exportStar(require("./types.js"), exports);
|
|
|
31
31
|
* @param connection
|
|
32
32
|
*/
|
|
33
33
|
const decorateFastifyInstance = (fastify, _opts, connection) => {
|
|
34
|
-
if (typeof fastify.hl7 !==
|
|
35
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_SETUP_ERRORS(
|
|
34
|
+
if (typeof fastify.hl7 !== "undefined") {
|
|
35
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_SETUP_ERRORS("Already registered.");
|
|
36
36
|
}
|
|
37
|
-
if (typeof fastify.hl7 ===
|
|
38
|
-
fastify.log.trace(
|
|
39
|
-
fastify.decorate(
|
|
37
|
+
if (typeof fastify.hl7 === "undefined") {
|
|
38
|
+
fastify.log.trace("[fastify-hl7] Decorate Fastify");
|
|
39
|
+
fastify.decorate("hl7", connection);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
@@ -48,15 +48,17 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
|
48
48
|
// A server can host many HL7 Inbound connections via different ports, this is fine.
|
|
49
49
|
// Clients are different as an app could talk to different servers, on many ports.
|
|
50
50
|
// So we need to do something different.
|
|
51
|
-
const serverInstance =
|
|
51
|
+
const serverInstance = typeof opts.enableServer !== "undefined" && opts.enableServer
|
|
52
|
+
? new node_hl7_server_1.default(opts.serverOptions)
|
|
53
|
+
: undefined;
|
|
52
54
|
// Server Functions
|
|
53
55
|
let server;
|
|
54
|
-
if (typeof serverInstance !==
|
|
56
|
+
if (typeof serverInstance !== "undefined") {
|
|
55
57
|
// Server Functions
|
|
56
58
|
server = new hL7Server_js_1.HL7Server(serverInstance);
|
|
57
59
|
// before we close fastify, make sure all server instances are closed
|
|
58
|
-
fastify.addHook(
|
|
59
|
-
if (typeof server !==
|
|
60
|
+
fastify.addHook("preClose", async () => {
|
|
61
|
+
if (typeof server !== "undefined") {
|
|
60
62
|
await server.closeAll();
|
|
61
63
|
}
|
|
62
64
|
});
|
|
@@ -64,8 +66,8 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
|
64
66
|
// Client Functions
|
|
65
67
|
const client = new hL7Client_js_1.HL7Client();
|
|
66
68
|
// run these before fastify closes
|
|
67
|
-
fastify.addHook(
|
|
68
|
-
if (typeof client !==
|
|
69
|
+
fastify.addHook("preClose", async () => {
|
|
70
|
+
if (typeof client !== "undefined") {
|
|
69
71
|
await client.closeAll();
|
|
70
72
|
}
|
|
71
73
|
});
|
|
@@ -84,25 +86,25 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
|
84
86
|
return client.buildMessage(props);
|
|
85
87
|
},
|
|
86
88
|
closeServer: async function (port) {
|
|
87
|
-
if (typeof server !==
|
|
89
|
+
if (typeof server !== "undefined") {
|
|
88
90
|
return await server.close(port);
|
|
89
91
|
}
|
|
90
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
92
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
91
93
|
},
|
|
92
94
|
closeServerAll: async () => {
|
|
93
|
-
if (typeof server !==
|
|
95
|
+
if (typeof server !== "undefined") {
|
|
94
96
|
return await server.closeAll();
|
|
95
97
|
}
|
|
96
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
98
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
97
99
|
},
|
|
98
100
|
createClient: function (name, props) {
|
|
99
101
|
return client.createClient(name, props);
|
|
100
102
|
},
|
|
101
103
|
createInbound: function (name, props, handler) {
|
|
102
|
-
if (typeof server !==
|
|
104
|
+
if (typeof server !== "undefined") {
|
|
103
105
|
return server.createInbound(name, props, handler);
|
|
104
106
|
}
|
|
105
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
107
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
106
108
|
},
|
|
107
109
|
createConnection: function (name, props, handler) {
|
|
108
110
|
return client.createConnection(name, props, handler);
|
|
@@ -114,16 +116,16 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
|
114
116
|
return client.getClientConnectionByPort(port);
|
|
115
117
|
},
|
|
116
118
|
getServerByName: function (name) {
|
|
117
|
-
if (typeof server !==
|
|
119
|
+
if (typeof server !== "undefined") {
|
|
118
120
|
return server.getServerByName(name);
|
|
119
121
|
}
|
|
120
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
122
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
121
123
|
},
|
|
122
124
|
getServerByPort: function (port) {
|
|
123
|
-
if (typeof server !==
|
|
125
|
+
if (typeof server !== "undefined") {
|
|
124
126
|
return server.getServerByPort(port);
|
|
125
127
|
}
|
|
126
|
-
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(
|
|
128
|
+
throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
127
129
|
},
|
|
128
130
|
processHL7: function (text) {
|
|
129
131
|
return client.processHL7(text);
|
|
@@ -133,7 +135,7 @@ const fastifyHL7 = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
|
133
135
|
},
|
|
134
136
|
readFileBuffer: function (fileBuffer) {
|
|
135
137
|
return client.readFileBuffer(fileBuffer);
|
|
136
|
-
}
|
|
138
|
+
},
|
|
137
139
|
});
|
|
138
140
|
});
|
|
139
141
|
exports.default = fastifyHL7;
|
package/lib/cjs/validation.js
CHANGED
package/lib/esm/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HL7 } from
|
|
2
|
-
import fastifyHL7 from
|
|
3
|
-
import { AServers, FastifyHL7Options } from
|
|
4
|
-
import { HL7Client } from
|
|
5
|
-
import { HL7Server } from
|
|
1
|
+
import { HL7 } from "fastify";
|
|
2
|
+
import fastifyHL7 from ".";
|
|
3
|
+
import { AServers, FastifyHL7Options } from "./decorate.js";
|
|
4
|
+
import { HL7Client } from "./class/hL7Client.js";
|
|
5
|
+
import { HL7Server } from "./class/hL7Server.js";
|
|
6
6
|
export default fastifyHL7;
|
|
7
7
|
export { fastifyHL7, HL7, FastifyHL7Options, HL7Client, HL7Server, AServers };
|
package/lib/esm/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fastifyHL7 from
|
|
2
|
-
import { HL7Client } from
|
|
3
|
-
import { HL7Server } from
|
|
1
|
+
import fastifyHL7 from ".";
|
|
2
|
+
import { HL7Client } from "./class/hL7Client.js";
|
|
3
|
+
import { HL7Server } from "./class/hL7Server.js";
|
|
4
4
|
export default fastifyHL7;
|
|
5
5
|
export { fastifyHL7, HL7Client, HL7Server };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from
|
|
1
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from "node-hl7-client";
|
|
2
2
|
export declare class HL7Client {
|
|
3
3
|
/** @internal */
|
|
4
4
|
private readonly _clientConnections;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Client, { Batch, FileBatch, Connection, isBatch, Message, createHL7Date } from
|
|
2
|
-
import { errors } from
|
|
1
|
+
import Client, { Batch, FileBatch, Connection, isBatch, Message, createHL7Date, } from "node-hl7-client";
|
|
2
|
+
import { errors } from "../errors.js";
|
|
3
3
|
export class HL7Client {
|
|
4
4
|
constructor() {
|
|
5
5
|
this._clientConnections = [];
|
|
@@ -9,7 +9,7 @@ export class HL7Client {
|
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
*/
|
|
11
11
|
async closeAll() {
|
|
12
|
-
this._clientConnections.forEach(outbound => {
|
|
12
|
+
this._clientConnections.forEach((outbound) => {
|
|
13
13
|
outbound.ports.map(async (port) => {
|
|
14
14
|
await port.connection.close();
|
|
15
15
|
});
|
|
@@ -23,8 +23,8 @@ export class HL7Client {
|
|
|
23
23
|
* @param props
|
|
24
24
|
*/
|
|
25
25
|
buildBatch(props) {
|
|
26
|
-
if (typeof props !==
|
|
27
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
26
|
+
if (typeof props !== "undefined" && typeof props.text !== "undefined") {
|
|
27
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
|
|
28
28
|
}
|
|
29
29
|
return new Batch({ ...props });
|
|
30
30
|
}
|
|
@@ -45,8 +45,10 @@ export class HL7Client {
|
|
|
45
45
|
* @param props
|
|
46
46
|
*/
|
|
47
47
|
buildFileBatch(props) {
|
|
48
|
-
if (typeof props !==
|
|
49
|
-
|
|
48
|
+
if (typeof props !== "undefined" &&
|
|
49
|
+
(typeof props.fullFilePath !== "undefined" ||
|
|
50
|
+
typeof props.fileBuffer !== "undefined")) {
|
|
51
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("Use readFile or readFileBuffer method. This is for building.");
|
|
50
52
|
}
|
|
51
53
|
return new FileBatch({ ...props });
|
|
52
54
|
}
|
|
@@ -57,8 +59,8 @@ export class HL7Client {
|
|
|
57
59
|
* @param props
|
|
58
60
|
*/
|
|
59
61
|
buildMessage(props) {
|
|
60
|
-
if (typeof props !==
|
|
61
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
62
|
+
if (typeof props !== "undefined" && typeof props.text !== "undefined") {
|
|
63
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("Use processMessage method. This is for building.");
|
|
62
64
|
}
|
|
63
65
|
return new Message({ ...props });
|
|
64
66
|
}
|
|
@@ -70,12 +72,12 @@ export class HL7Client {
|
|
|
70
72
|
createClient(name, props) {
|
|
71
73
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
72
74
|
if (nameFormat.test(name)) {
|
|
73
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
75
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
74
76
|
}
|
|
75
77
|
// make sure that this does not exist already...
|
|
76
78
|
this._clientConnections.forEach((connections) => {
|
|
77
79
|
if (connections.name === name) {
|
|
78
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
80
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("name must be unique.");
|
|
79
81
|
}
|
|
80
82
|
// nto in the Client class yet
|
|
81
83
|
// if (client.getHost() === props.host) {
|
|
@@ -88,7 +90,7 @@ export class HL7Client {
|
|
|
88
90
|
this._clientConnections.push({
|
|
89
91
|
name,
|
|
90
92
|
client,
|
|
91
|
-
ports: []
|
|
93
|
+
ports: [],
|
|
92
94
|
});
|
|
93
95
|
return client;
|
|
94
96
|
}
|
|
@@ -103,10 +105,10 @@ export class HL7Client {
|
|
|
103
105
|
createConnection(name, props, handler) {
|
|
104
106
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
105
107
|
if (nameFormat.test(name)) {
|
|
106
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
108
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
107
109
|
}
|
|
108
|
-
const getConnection = this._clientConnections.find(client => client.name === name);
|
|
109
|
-
if (typeof getConnection !==
|
|
110
|
+
const getConnection = this._clientConnections.find((client) => client.name === name);
|
|
111
|
+
if (typeof getConnection !== "undefined") {
|
|
110
112
|
// make sure port is not used all ready
|
|
111
113
|
getConnection.ports.forEach((outbound) => {
|
|
112
114
|
if (outbound.port === props.port.toString()) {
|
|
@@ -116,11 +118,14 @@ export class HL7Client {
|
|
|
116
118
|
// create outbound port to the server in getConnection.client
|
|
117
119
|
const outbound = new Connection(getConnection.client, props, handler);
|
|
118
120
|
// add it to the array of known ports. need to know this, so we can get it later if needed.
|
|
119
|
-
getConnection.ports.push({
|
|
121
|
+
getConnection.ports.push({
|
|
122
|
+
port: props.port.toString(),
|
|
123
|
+
connection: outbound,
|
|
124
|
+
});
|
|
120
125
|
// return it right away. the user might do something with it.
|
|
121
126
|
return outbound;
|
|
122
127
|
}
|
|
123
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
128
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("No valid client. Improper setup of a outbound connection.");
|
|
124
129
|
}
|
|
125
130
|
/**
|
|
126
131
|
* Get Client by the name
|
|
@@ -128,8 +133,8 @@ export class HL7Client {
|
|
|
128
133
|
* @param name
|
|
129
134
|
*/
|
|
130
135
|
getClientByName(name) {
|
|
131
|
-
const connection = this._clientConnections.find(connection => connection.name === name);
|
|
132
|
-
if (typeof connection !==
|
|
136
|
+
const connection = this._clientConnections.find((connection) => connection.name === name);
|
|
137
|
+
if (typeof connection !== "undefined") {
|
|
133
138
|
return connection.client;
|
|
134
139
|
}
|
|
135
140
|
return undefined;
|
|
@@ -141,8 +146,8 @@ export class HL7Client {
|
|
|
141
146
|
*/
|
|
142
147
|
getClientConnectionByPort(port) {
|
|
143
148
|
let connection;
|
|
144
|
-
this._clientConnections.forEach(outbound => {
|
|
145
|
-
outbound.ports.forEach(aPort => {
|
|
149
|
+
this._clientConnections.forEach((outbound) => {
|
|
150
|
+
outbound.ports.forEach((aPort) => {
|
|
146
151
|
if (aPort.port === port) {
|
|
147
152
|
connection = aPort.connection;
|
|
148
153
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Server, { Inbound, InboundHandler, ListenerOptions } from
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Inbound } from
|
|
2
|
-
import { errors } from
|
|
1
|
+
import { Inbound, } from "node-hl7-server";
|
|
2
|
+
import { errors } from "../errors.js";
|
|
3
3
|
export class HL7Server {
|
|
4
4
|
constructor(server) {
|
|
5
5
|
this._server = server;
|
|
@@ -11,8 +11,8 @@ export class HL7Server {
|
|
|
11
11
|
* @param port
|
|
12
12
|
*/
|
|
13
13
|
async close(port) {
|
|
14
|
-
const inbound = this._serverInboundConnections.find(server => server.port === port);
|
|
15
|
-
if (typeof inbound !==
|
|
14
|
+
const inbound = this._serverInboundConnections.find((server) => server.port === port);
|
|
15
|
+
if (typeof inbound !== "undefined") {
|
|
16
16
|
return await inbound.server.close(); // close the server for all inbound connections
|
|
17
17
|
}
|
|
18
18
|
throw new errors.FASTIFY_HL7_ERR_USAGE(`No inbound server listening on port: ${port}`);
|
|
@@ -37,13 +37,13 @@ export class HL7Server {
|
|
|
37
37
|
createInbound(name, props, handler) {
|
|
38
38
|
const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
|
|
39
39
|
if (nameFormat.test(name)) {
|
|
40
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
40
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~.");
|
|
41
41
|
}
|
|
42
42
|
const inbound = new Inbound(this._server, props, handler);
|
|
43
43
|
this._serverInboundConnections.push({
|
|
44
44
|
name,
|
|
45
45
|
port: props.port.toString(),
|
|
46
|
-
server: inbound
|
|
46
|
+
server: inbound,
|
|
47
47
|
});
|
|
48
48
|
return inbound;
|
|
49
49
|
}
|
|
@@ -53,8 +53,8 @@ export class HL7Server {
|
|
|
53
53
|
* @param name
|
|
54
54
|
*/
|
|
55
55
|
getServerByName(name) {
|
|
56
|
-
const inbound = this._serverInboundConnections.find(inbound => inbound.name === name);
|
|
57
|
-
if (typeof inbound !==
|
|
56
|
+
const inbound = this._serverInboundConnections.find((inbound) => inbound.name === name);
|
|
57
|
+
if (typeof inbound !== "undefined") {
|
|
58
58
|
return inbound.server;
|
|
59
59
|
}
|
|
60
60
|
return undefined;
|
|
@@ -65,8 +65,8 @@ export class HL7Server {
|
|
|
65
65
|
* @param port
|
|
66
66
|
*/
|
|
67
67
|
getServerByPort(port) {
|
|
68
|
-
const inbound = this._serverInboundConnections.find(inbound => inbound.port === port);
|
|
69
|
-
if (typeof inbound !==
|
|
68
|
+
const inbound = this._serverInboundConnections.find((inbound) => inbound.port === port);
|
|
69
|
+
if (typeof inbound !== "undefined") {
|
|
70
70
|
return inbound.server;
|
|
71
71
|
}
|
|
72
72
|
return undefined;
|
package/lib/esm/decorate.d.ts
CHANGED
package/lib/esm/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import createError from
|
|
1
|
+
import createError from "@fastify/error";
|
|
2
2
|
export const errors = {
|
|
3
3
|
/** Error if there is an setup error of the plugin itself. */
|
|
4
|
-
FASTIFY_HL7_ERR_SETUP_ERRORS: createError(
|
|
4
|
+
FASTIFY_HL7_ERR_SETUP_ERRORS: createError("FASTIFY_HL7_ERR_SETUP_ERRORS", "Setup error: %s"),
|
|
5
5
|
/** If an invalid usage error was done, this error would pop up. */
|
|
6
|
-
FASTIFY_HL7_ERR_USAGE: createError(
|
|
6
|
+
FASTIFY_HL7_ERR_USAGE: createError("FASTIFY_HL7_ERR_USAGE", "Usage error: %s"),
|
|
7
7
|
};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FastifyHL7Options } from
|
|
2
|
-
export * from
|
|
1
|
+
import { FastifyHL7Options } from "./decorate.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
3
|
declare const fastifyHL7: import("fastify").FastifyPluginCallback<FastifyHL7Options, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
4
4
|
export default fastifyHL7;
|
|
5
5
|
export { FastifyHL7Options };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fp from
|
|
2
|
-
import Server from
|
|
3
|
-
import { HL7Server } from
|
|
4
|
-
import { HL7Client } from
|
|
5
|
-
import { errors } from
|
|
6
|
-
import { validateOpts } from
|
|
7
|
-
export * from
|
|
1
|
+
import fp from "fastify-plugin";
|
|
2
|
+
import Server from "node-hl7-server";
|
|
3
|
+
import { HL7Server } from "./class/hL7Server.js";
|
|
4
|
+
import { HL7Client } from "./class/hL7Client.js";
|
|
5
|
+
import { errors } from "./errors.js";
|
|
6
|
+
import { validateOpts } from "./validation.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
8
|
/**
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
* @param fastify
|
|
@@ -12,12 +12,12 @@ export * from './types.js';
|
|
|
12
12
|
* @param connection
|
|
13
13
|
*/
|
|
14
14
|
const decorateFastifyInstance = (fastify, _opts, connection) => {
|
|
15
|
-
if (typeof fastify.hl7 !==
|
|
16
|
-
throw new errors.FASTIFY_HL7_ERR_SETUP_ERRORS(
|
|
15
|
+
if (typeof fastify.hl7 !== "undefined") {
|
|
16
|
+
throw new errors.FASTIFY_HL7_ERR_SETUP_ERRORS("Already registered.");
|
|
17
17
|
}
|
|
18
|
-
if (typeof fastify.hl7 ===
|
|
19
|
-
fastify.log.trace(
|
|
20
|
-
fastify.decorate(
|
|
18
|
+
if (typeof fastify.hl7 === "undefined") {
|
|
19
|
+
fastify.log.trace("[fastify-hl7] Decorate Fastify");
|
|
20
|
+
fastify.decorate("hl7", connection);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
const fastifyHL7 = fp(async (fastify, opts) => {
|
|
@@ -29,15 +29,17 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
29
29
|
// A server can host many HL7 Inbound connections via different ports, this is fine.
|
|
30
30
|
// Clients are different as an app could talk to different servers, on many ports.
|
|
31
31
|
// So we need to do something different.
|
|
32
|
-
const serverInstance =
|
|
32
|
+
const serverInstance = typeof opts.enableServer !== "undefined" && opts.enableServer
|
|
33
|
+
? new Server(opts.serverOptions)
|
|
34
|
+
: undefined;
|
|
33
35
|
// Server Functions
|
|
34
36
|
let server;
|
|
35
|
-
if (typeof serverInstance !==
|
|
37
|
+
if (typeof serverInstance !== "undefined") {
|
|
36
38
|
// Server Functions
|
|
37
39
|
server = new HL7Server(serverInstance);
|
|
38
40
|
// before we close fastify, make sure all server instances are closed
|
|
39
|
-
fastify.addHook(
|
|
40
|
-
if (typeof server !==
|
|
41
|
+
fastify.addHook("preClose", async () => {
|
|
42
|
+
if (typeof server !== "undefined") {
|
|
41
43
|
await server.closeAll();
|
|
42
44
|
}
|
|
43
45
|
});
|
|
@@ -45,8 +47,8 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
45
47
|
// Client Functions
|
|
46
48
|
const client = new HL7Client();
|
|
47
49
|
// run these before fastify closes
|
|
48
|
-
fastify.addHook(
|
|
49
|
-
if (typeof client !==
|
|
50
|
+
fastify.addHook("preClose", async () => {
|
|
51
|
+
if (typeof client !== "undefined") {
|
|
50
52
|
await client.closeAll();
|
|
51
53
|
}
|
|
52
54
|
});
|
|
@@ -65,25 +67,25 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
65
67
|
return client.buildMessage(props);
|
|
66
68
|
},
|
|
67
69
|
closeServer: async function (port) {
|
|
68
|
-
if (typeof server !==
|
|
70
|
+
if (typeof server !== "undefined") {
|
|
69
71
|
return await server.close(port);
|
|
70
72
|
}
|
|
71
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
73
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
72
74
|
},
|
|
73
75
|
closeServerAll: async () => {
|
|
74
|
-
if (typeof server !==
|
|
76
|
+
if (typeof server !== "undefined") {
|
|
75
77
|
return await server.closeAll();
|
|
76
78
|
}
|
|
77
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
79
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
78
80
|
},
|
|
79
81
|
createClient: function (name, props) {
|
|
80
82
|
return client.createClient(name, props);
|
|
81
83
|
},
|
|
82
84
|
createInbound: function (name, props, handler) {
|
|
83
|
-
if (typeof server !==
|
|
85
|
+
if (typeof server !== "undefined") {
|
|
84
86
|
return server.createInbound(name, props, handler);
|
|
85
87
|
}
|
|
86
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
88
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
87
89
|
},
|
|
88
90
|
createConnection: function (name, props, handler) {
|
|
89
91
|
return client.createConnection(name, props, handler);
|
|
@@ -95,16 +97,16 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
95
97
|
return client.getClientConnectionByPort(port);
|
|
96
98
|
},
|
|
97
99
|
getServerByName: function (name) {
|
|
98
|
-
if (typeof server !==
|
|
100
|
+
if (typeof server !== "undefined") {
|
|
99
101
|
return server.getServerByName(name);
|
|
100
102
|
}
|
|
101
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
103
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
102
104
|
},
|
|
103
105
|
getServerByPort: function (port) {
|
|
104
|
-
if (typeof server !==
|
|
106
|
+
if (typeof server !== "undefined") {
|
|
105
107
|
return server.getServerByPort(port);
|
|
106
108
|
}
|
|
107
|
-
throw new errors.FASTIFY_HL7_ERR_USAGE(
|
|
109
|
+
throw new errors.FASTIFY_HL7_ERR_USAGE("server was not started. re-register plugin with enableServer set to true.");
|
|
108
110
|
},
|
|
109
111
|
processHL7: function (text) {
|
|
110
112
|
return client.processHL7(text);
|
|
@@ -114,7 +116,7 @@ const fastifyHL7 = fp(async (fastify, opts) => {
|
|
|
114
116
|
},
|
|
115
117
|
readFileBuffer: function (fileBuffer) {
|
|
116
118
|
return client.readFileBuffer(fileBuffer);
|
|
117
|
-
}
|
|
119
|
+
},
|
|
118
120
|
});
|
|
119
121
|
});
|
|
120
122
|
export default fastifyHL7;
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Server, { Inbound, InboundHandler, ListenerOptions } from
|
|
2
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from
|
|
3
|
-
declare module
|
|
1
|
+
import Server, { Inbound, InboundHandler, ListenerOptions } from "node-hl7-server";
|
|
2
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from "node-hl7-client";
|
|
3
|
+
declare module "fastify" {
|
|
4
4
|
interface HL7 {
|
|
5
5
|
/** Server Instance
|
|
6
6
|
* @since 1.0.0 **/
|
package/lib/esm/validation.d.ts
CHANGED
package/lib/esm/validation.js
CHANGED
package/lib/types/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HL7 } from
|
|
2
|
-
import fastifyHL7 from
|
|
3
|
-
import { AServers, FastifyHL7Options } from
|
|
4
|
-
import { HL7Client } from
|
|
5
|
-
import { HL7Server } from
|
|
1
|
+
import { HL7 } from "fastify";
|
|
2
|
+
import fastifyHL7 from ".";
|
|
3
|
+
import { AServers, FastifyHL7Options } from "./decorate.js";
|
|
4
|
+
import { HL7Client } from "./class/hL7Client.js";
|
|
5
|
+
import { HL7Server } from "./class/hL7Server.js";
|
|
6
6
|
export default fastifyHL7;
|
|
7
7
|
export { fastifyHL7, HL7, FastifyHL7Options, HL7Client, HL7Server, AServers };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from
|
|
1
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from "node-hl7-client";
|
|
2
2
|
export declare class HL7Client {
|
|
3
3
|
/** @internal */
|
|
4
4
|
private readonly _clientConnections;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Server, { Inbound, InboundHandler, ListenerOptions } from
|
|
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;
|
package/lib/types/decorate.d.ts
CHANGED
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FastifyHL7Options } from
|
|
2
|
-
export * from
|
|
1
|
+
import { FastifyHL7Options } from "./decorate.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
3
|
declare const fastifyHL7: import("fastify").FastifyPluginCallback<FastifyHL7Options, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
4
4
|
export default fastifyHL7;
|
|
5
5
|
export { FastifyHL7Options };
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Server, { Inbound, InboundHandler, ListenerOptions } from
|
|
2
|
-
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from
|
|
3
|
-
declare module
|
|
1
|
+
import Server, { Inbound, InboundHandler, ListenerOptions } from "node-hl7-server";
|
|
2
|
+
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from "node-hl7-client";
|
|
3
|
+
declare module "fastify" {
|
|
4
4
|
interface HL7 {
|
|
5
5
|
/** Server Instance
|
|
6
6
|
* @since 1.0.0 **/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-hl7",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.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",
|
|
@@ -14,18 +14,22 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"lib/"
|
|
17
|
+
"lib/",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
18
20
|
],
|
|
19
21
|
"engines": {
|
|
20
22
|
"node": ">=20.15.0"
|
|
21
23
|
},
|
|
22
24
|
"scripts": {
|
|
23
|
-
"clean": "rm -rf
|
|
25
|
+
"clean": "rm -rf coverage docs lib temp",
|
|
24
26
|
"build": "tsc -p src/tsconfig.esm.json && tsc -p src/tsconfig.cjs.json && tsc -p src/tsconfig.types.json && ./bin/build-types.sh",
|
|
25
27
|
"build:watch": "tsc -p src/tsconfig.esm.json -w",
|
|
26
|
-
"
|
|
27
|
-
"lint": "npmPkgJsonLint .
|
|
28
|
-
"
|
|
28
|
+
"build:watch:cjs": "tsc -p src/tsconfig.cjs.json -w",
|
|
29
|
+
"npm:lint": "npmPkgJsonLint .",
|
|
30
|
+
"format": "prettier --write 'README.md' 'src/**/*.ts' '__tests__/**/*.ts'",
|
|
31
|
+
"lint": "npm run npm:lint && eslint | snazzy",
|
|
32
|
+
"lint:fix": "npm run npm:lint && eslint --fix | snazzy",
|
|
29
33
|
"pack": "npm pack",
|
|
30
34
|
"prepublishOnly": "npm run clean && npm run build && npm run pack",
|
|
31
35
|
"test": "vitest run",
|
|
@@ -34,8 +38,6 @@
|
|
|
34
38
|
"test:coverage": "vitest --coverage",
|
|
35
39
|
"typedoc": "typedoc",
|
|
36
40
|
"typedoc:watch": "typedoc -watch",
|
|
37
|
-
"semantic-release": "semantic-release",
|
|
38
|
-
"semantic-release:dry-run": "semantic-release --dry-run",
|
|
39
41
|
"update": "npx npm-check-updates -u --enginesNode && npm run update:post-update",
|
|
40
42
|
"update:post-update": "npm install && npm run test"
|
|
41
43
|
},
|
|
@@ -59,36 +61,34 @@
|
|
|
59
61
|
"dependencies": {
|
|
60
62
|
"@fastify/error": "^4.0.0",
|
|
61
63
|
"fastify-plugin": "^5.0.1",
|
|
62
|
-
"node-hl7-client": "^
|
|
63
|
-
"node-hl7-server": "^3.
|
|
64
|
+
"node-hl7-client": "^3.0.0",
|
|
65
|
+
"node-hl7-server": "^3.1.0"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@semantic-release/release-notes-generator": "^14.0.1",
|
|
70
|
-
"@shipgirl/typedoc-plugin-versions": "^0.2.7",
|
|
71
|
-
"@the-rabbit-hole/semantic-release-config": "^1.5.0",
|
|
72
|
-
"@types/node": "^22.8.6",
|
|
73
|
-
"@types/randomstring": "^1.3.0",
|
|
68
|
+
"@eslint/js": "^9.15.0",
|
|
69
|
+
"@types/eslint__js": "^8.42.3",
|
|
70
|
+
"@types/node": "^22.9.0",
|
|
74
71
|
"@types/tcp-port-used": "^1.0.4",
|
|
75
|
-
"@typescript-eslint/
|
|
76
|
-
"@
|
|
77
|
-
"@vitest/
|
|
78
|
-
"
|
|
79
|
-
"
|
|
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",
|
|
77
|
+
"eslint-config-prettier": "^9.1.0",
|
|
78
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
79
|
+
"fastify": "^5.1.0",
|
|
80
|
+
"npm-check-updates": "^17.1.11",
|
|
80
81
|
"npm-package-json-lint": "^8.0.0",
|
|
81
82
|
"portfinder": "^1.0.32",
|
|
82
83
|
"pre-commit": "^1.2.2",
|
|
83
|
-
"semantic-release": "^24.2.0",
|
|
84
84
|
"snazzy": "^9.0.0",
|
|
85
85
|
"tcp-port-used": "^1.0.2",
|
|
86
86
|
"ts-node": "^10.9.2",
|
|
87
|
-
"ts-standard": "^12.0.2",
|
|
88
87
|
"tsd": "^0.31.2",
|
|
89
|
-
"typedoc": "^0.26.
|
|
88
|
+
"typedoc": "^0.26.11",
|
|
90
89
|
"typescript": "^5.6.3",
|
|
91
|
-
"
|
|
90
|
+
"typescript-eslint": "^8.14.0",
|
|
91
|
+
"vitest": "^2.1.5"
|
|
92
92
|
},
|
|
93
93
|
"precommit": [
|
|
94
94
|
"lint:fix",
|