fastify-hl7 2.0.0 → 2.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.
- package/lib/cjs/api.js +3 -3
- package/lib/cjs/class/hL7Client.js +66 -116
- package/lib/cjs/class/hL7Server.js +28 -85
- package/lib/cjs/errors.js +1 -1
- package/lib/cjs/index.js +102 -173
- package/lib/cjs/validation.js +7 -45
- package/lib/esm/api.d.ts +7 -0
- package/lib/esm/class/hL7Client.d.ts +99 -0
- package/lib/esm/class/hL7Client.js +15 -7
- package/lib/esm/class/hL7Server.d.ts +37 -0
- package/lib/esm/class/hL7Server.js +0 -2
- package/lib/esm/decorate.d.ts +38 -0
- package/lib/esm/errors.d.ts +10 -0
- package/lib/esm/index.d.ts +5 -0
- package/lib/esm/index.js +4 -1
- package/lib/esm/types.d.ts +66 -0
- package/lib/esm/validation.d.ts +6 -0
- package/lib/types/class/hL7Client.d.ts +14 -5
- package/lib/types/types.d.ts +4 -1
- package/package.json +20 -21
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
interface HL7 {
|
|
5
|
+
/** Server Instance
|
|
6
|
+
* @since 1.0.0 **/
|
|
7
|
+
_serverInstance?: Server;
|
|
8
|
+
/** Build HL7 Batch
|
|
9
|
+
* @since 1.0.0 */
|
|
10
|
+
buildBatch: (props?: ClientBuilderOptions) => Batch;
|
|
11
|
+
/** BBuild Date
|
|
12
|
+
* @since 2.1.0
|
|
13
|
+
*/
|
|
14
|
+
buildDate: (date: Date, length?: string) => string;
|
|
15
|
+
/** Build HL7 File Batch
|
|
16
|
+
* @since 1.0.0 */
|
|
17
|
+
buildFileBatch: (props?: ClientBuilderFileOptions) => FileBatch;
|
|
18
|
+
/** Build HL7 Message
|
|
19
|
+
* @since 1.0.0 */
|
|
20
|
+
buildMessage: (props?: ClientBuilderMessageOptions) => Message;
|
|
21
|
+
/** Close a incoming HL7 port.
|
|
22
|
+
* @since 1.0.0 */
|
|
23
|
+
closeServer: (port: string) => Promise<boolean>;
|
|
24
|
+
/** Close all incoming HL7 ports.
|
|
25
|
+
* @since 1.0.0 */
|
|
26
|
+
closeServerAll: () => Promise<boolean>;
|
|
27
|
+
/** Create Client
|
|
28
|
+
* @description Connecting to a remote server/broker that accepts connections.
|
|
29
|
+
* @since 1.0.0 */
|
|
30
|
+
createClient: (name: string, props: ClientOptions) => Client;
|
|
31
|
+
/** Create an incoming port connection on the server.
|
|
32
|
+
* @since 1.0.0 */
|
|
33
|
+
createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
|
|
34
|
+
/** Create Outgoing Client Port
|
|
35
|
+
* @description This is on the established client that we are already a part off.
|
|
36
|
+
* @since 1.0.0 */
|
|
37
|
+
createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
|
|
38
|
+
/** Get Client (Outbound) connection by name.
|
|
39
|
+
* @since 1.0.0 */
|
|
40
|
+
getClientByName: (name: string) => Client | undefined;
|
|
41
|
+
/** Get Client Connection (Outbound) connection by port.
|
|
42
|
+
* @since 1.0.0 */
|
|
43
|
+
getClientConnectionByPort: (port: string) => Connection | undefined;
|
|
44
|
+
/** Get Server (Inbound) connection by port.
|
|
45
|
+
* @since 1.0.0 */
|
|
46
|
+
getServerByPort: (port: string) => Inbound | undefined;
|
|
47
|
+
/** Get Server (Inbound) connection by name.
|
|
48
|
+
* @since 1.0.0 */
|
|
49
|
+
getServerByName: (name: string) => Inbound | undefined;
|
|
50
|
+
/** Process an HL7 string.
|
|
51
|
+
* @since 1.0.0 */
|
|
52
|
+
processHL7: (text: string) => Message | Batch;
|
|
53
|
+
/** Read a file from a path.
|
|
54
|
+
* @since 1.0.0 */
|
|
55
|
+
readFile: (fullFilePath: string) => FileBatch;
|
|
56
|
+
/** Read a buffer that was a file batch.
|
|
57
|
+
* @since 1.0.0 */
|
|
58
|
+
readFileBuffer: (fileBuffer: Buffer) => FileBatch;
|
|
59
|
+
}
|
|
60
|
+
interface FastifyInstance {
|
|
61
|
+
/** Main Decorator for Fastify
|
|
62
|
+
* @description hl7 is the decorator that everything hangs off.
|
|
63
|
+
* @since 1.0.0 **/
|
|
64
|
+
hl7: HL7;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, Connection, Message, OutboundHandler } from 'node-hl7-client';
|
|
3
2
|
export declare class HL7Client {
|
|
3
|
+
/** @internal */
|
|
4
|
+
private readonly _clientConnections;
|
|
4
5
|
constructor();
|
|
5
6
|
/**
|
|
6
7
|
* Close All Connections for this Client
|
|
@@ -14,6 +15,14 @@ export declare class HL7Client {
|
|
|
14
15
|
* @param props
|
|
15
16
|
*/
|
|
16
17
|
buildBatch(props?: ClientBuilderOptions): Batch;
|
|
18
|
+
/**
|
|
19
|
+
* Build Date
|
|
20
|
+
* @description Build a date string based off HL7 Standards
|
|
21
|
+
* @since 2.1.0
|
|
22
|
+
* @param date
|
|
23
|
+
* @param length Options are 8, 12, or 14 (default)
|
|
24
|
+
*/
|
|
25
|
+
buildDate(date: Date, length?: string): string;
|
|
17
26
|
/**
|
|
18
27
|
* Build a HL7 File Batch
|
|
19
28
|
* @description Create a properly formatted HL7 File Batch.
|
|
@@ -69,9 +78,9 @@ export declare class HL7Client {
|
|
|
69
78
|
* @param fullFilePath
|
|
70
79
|
* @returns FileBatch
|
|
71
80
|
* @example
|
|
72
|
-
*
|
|
81
|
+
* ```ts
|
|
73
82
|
* fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
|
|
74
|
-
*
|
|
83
|
+
* ```
|
|
75
84
|
*/
|
|
76
85
|
readFile(fullFilePath: string): FileBatch;
|
|
77
86
|
/**
|
|
@@ -81,10 +90,10 @@ export declare class HL7Client {
|
|
|
81
90
|
* @param fileBuffer
|
|
82
91
|
* @returns FileBatch
|
|
83
92
|
* @example
|
|
84
|
-
*
|
|
93
|
+
* ```ts
|
|
85
94
|
* const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
|
|
86
95
|
* fastify.hl7.readFileBuffer(fileBuffer)
|
|
87
|
-
*
|
|
96
|
+
* ```
|
|
88
97
|
*/
|
|
89
98
|
readFileBuffer(fileBuffer: Buffer): FileBatch;
|
|
90
99
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import Server, { Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
|
|
3
2
|
import Client, { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, Connection, FileBatch, Message, OutboundHandler } from 'node-hl7-client';
|
|
4
3
|
declare module 'fastify' {
|
|
@@ -9,6 +8,10 @@ declare module 'fastify' {
|
|
|
9
8
|
/** Build HL7 Batch
|
|
10
9
|
* @since 1.0.0 */
|
|
11
10
|
buildBatch: (props?: ClientBuilderOptions) => Batch;
|
|
11
|
+
/** BBuild Date
|
|
12
|
+
* @since 2.1.0
|
|
13
|
+
*/
|
|
14
|
+
buildDate: (date: Date, length?: string) => string;
|
|
12
15
|
/** Build HL7 File Batch
|
|
13
16
|
* @since 1.0.0 */
|
|
14
17
|
buildFileBatch: (props?: ClientBuilderFileOptions) => FileBatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-hl7",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.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",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"clean": "rm -rf lib coverage docs",
|
|
24
|
-
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
|
|
25
|
-
"build:watch": "tsc -p tsconfig.esm.json -w",
|
|
24
|
+
"build": "tsc -p src/tsconfig.esm.json && tsc -p src/tsconfig.cjs.json && tsc -p src/tsconfig.types.json && ./bin/build-types.sh",
|
|
25
|
+
"build:watch": "tsc -p src/tsconfig.esm.json -w",
|
|
26
26
|
"npmPkgJsonLint": "npmPkgJsonLint .",
|
|
27
|
-
"lint": "npmPkgJsonLint . && ts-standard | snazzy",
|
|
28
|
-
"lint:fix": "npmPkgJsonLint . && ts-standard --fix | snazzy",
|
|
27
|
+
"lint": "npmPkgJsonLint . && ts-standard -p src/tsconfig.esm.json | snazzy",
|
|
28
|
+
"lint:fix": "npmPkgJsonLint . && ts-standard -p src/tsconfig.esm.json --fix | snazzy",
|
|
29
29
|
"pack": "npm pack",
|
|
30
30
|
"prepublishOnly": "npm run clean && npm run build && npm run pack",
|
|
31
31
|
"test": "vitest run",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
},
|
|
58
58
|
"homepage": "https://github.com/Bugs5382/fastify-hl7#readme",
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@fastify/error": "^
|
|
60
|
+
"@fastify/error": "^4.0.0",
|
|
61
61
|
"fastify-plugin": "^4.5.1",
|
|
62
|
-
"node-hl7-client": "^2.
|
|
63
|
-
"node-hl7-server": "^2.
|
|
62
|
+
"node-hl7-client": "^2.3.0",
|
|
63
|
+
"node-hl7-server": "^2.4.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -68,16 +68,15 @@
|
|
|
68
68
|
"@semantic-release/git": "^10.0.1",
|
|
69
69
|
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
70
70
|
"@the-rabbit-hole/semantic-release-config": "^1.5.0",
|
|
71
|
-
"@types/node": "^20.
|
|
72
|
-
"@types/randomstring": "^1.
|
|
71
|
+
"@types/node": "^20.14.8",
|
|
72
|
+
"@types/randomstring": "^1.3.0",
|
|
73
73
|
"@types/tcp-port-used": "^1.0.4",
|
|
74
|
-
"@typescript-eslint/parser": "^
|
|
75
|
-
"@vitest/coverage-v8": "^1.
|
|
76
|
-
"@vitest/ui": "^1.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"npm-
|
|
80
|
-
"npm-package-json-lint": "^7.1.0",
|
|
74
|
+
"@typescript-eslint/parser": "^7.14.1",
|
|
75
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
76
|
+
"@vitest/ui": "^1.6.0",
|
|
77
|
+
"fastify": "^4.28.0",
|
|
78
|
+
"npm-check-updates": "^16.14.20",
|
|
79
|
+
"npm-package-json-lint": "^8.0.0",
|
|
81
80
|
"portfinder": "^1.0.32",
|
|
82
81
|
"pre-commit": "^1.2.2",
|
|
83
82
|
"semantic-release": "^22.0.12",
|
|
@@ -85,10 +84,10 @@
|
|
|
85
84
|
"tcp-port-used": "^1.0.2",
|
|
86
85
|
"ts-node": "^10.9.2",
|
|
87
86
|
"ts-standard": "^12.0.2",
|
|
88
|
-
"tsd": "^0.
|
|
89
|
-
"typedoc": "^0.
|
|
90
|
-
"typescript": "^5.
|
|
91
|
-
"vitest": "^1.
|
|
87
|
+
"tsd": "^0.31.1",
|
|
88
|
+
"typedoc": "^0.26.2",
|
|
89
|
+
"typescript": "^5.5.2",
|
|
90
|
+
"vitest": "^1.6.0"
|
|
92
91
|
},
|
|
93
92
|
"precommit": [
|
|
94
93
|
"lint:fix",
|