fastify-hl7 2.1.0 → 3.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.
@@ -0,0 +1,38 @@
1
+ import Client, { Connection } from 'node-hl7-client';
2
+ import { Inbound, ServerOptions } from 'node-hl7-server';
3
+ /**
4
+ * @since 1.0.0
5
+ */
6
+ export interface FastifyHL7Options {
7
+ /** Enable Server Instance for Inbound
8
+ * @since 1.0.0
9
+ * @default true */
10
+ enableServer?: boolean;
11
+ /** Override Server Options
12
+ * @default From node-hl7-server */
13
+ serverOptions?: ServerOptions;
14
+ }
15
+ /**
16
+ * @since 1.0.0
17
+ */
18
+ interface AClientPorts {
19
+ port: string;
20
+ connection: Connection;
21
+ }
22
+ /**
23
+ * @since 1.0.0
24
+ */
25
+ export interface AClients {
26
+ name: string;
27
+ client: Client;
28
+ ports: AClientPorts[];
29
+ }
30
+ /**
31
+ * @since 1.0.0
32
+ */
33
+ export interface AServers {
34
+ name: string;
35
+ port: string;
36
+ server: Inbound;
37
+ }
38
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const errors: {
2
+ /** Error if there is an setup error of the plugin itself. */
3
+ FASTIFY_HL7_ERR_SETUP_ERRORS: import("@fastify/error").FastifyErrorConstructor<{
4
+ code: "FASTIFY_HL7_ERR_SETUP_ERRORS";
5
+ }, [any?, any?, any?]>;
6
+ /** If an invalid usage error was done, this error would pop up. */
7
+ FASTIFY_HL7_ERR_USAGE: import("@fastify/error").FastifyErrorConstructor<{
8
+ code: "FASTIFY_HL7_ERR_USAGE";
9
+ }, [any?, any?, any?]>;
10
+ };
@@ -0,0 +1,5 @@
1
+ import { FastifyHL7Options } from './decorate.js';
2
+ export * from './types.js';
3
+ declare const fastifyHL7: import("fastify").FastifyPluginCallback<FastifyHL7Options, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
4
+ export default fastifyHL7;
5
+ export { FastifyHL7Options };
package/lib/esm/index.js CHANGED
@@ -27,7 +27,7 @@ const fastifyHL7 = fp(async (fastify, opts) => {
27
27
  // Since there can only be one server per IP address
28
28
  // (i.e., the host this is running on.) There can only be more than one.
29
29
  // A server can host many HL7 Inbound connections via different ports, this is fine.
30
- // Clients are different as a app could talk to different servers, on many ports.
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
32
  const serverInstance = (typeof opts.enableServer !== 'undefined' && opts.enableServer) ? new Server(opts.serverOptions) : undefined;
33
33
  // Server Functions
@@ -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
+ *@remarks 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
+ *@remarks 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
+ *@remarks hl7 is the decorator that everything hangs off.
63
+ * @since 1.0.0 **/
64
+ hl7: HL7;
65
+ }
66
+ }
@@ -0,0 +1,6 @@
1
+ import { FastifyHL7Options } from './decorate.js';
2
+ /**
3
+ * @since 1.0.0
4
+ * @param opts
5
+ */
6
+ export declare const validateOpts: (opts: FastifyHL7Options) => Promise<FastifyHL7Options>;
@@ -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
@@ -9,14 +10,14 @@ export declare class HL7Client {
9
10
  closeAll(): Promise<boolean>;
10
11
  /**
11
12
  * Build a HL7 Batch
12
- * @description Create a properly formatted HL7 Batch.
13
+ *@remarks Create a properly formatted HL7 Batch.
13
14
  * @since 1.0.0
14
15
  * @param props
15
16
  */
16
17
  buildBatch(props?: ClientBuilderOptions): Batch;
17
18
  /**
18
19
  * Build Date
19
- * @description Build a date string based off HL7 Standards
20
+ *@remarks Build a date string based off HL7 Standards
20
21
  * @since 2.1.0
21
22
  * @param date
22
23
  * @param length Options are 8, 12, or 14 (default)
@@ -24,14 +25,14 @@ export declare class HL7Client {
24
25
  buildDate(date: Date, length?: string): string;
25
26
  /**
26
27
  * Build a HL7 File Batch
27
- * @description Create a properly formatted HL7 File Batch.
28
+ *@remarks Create a properly formatted HL7 File Batch.
28
29
  * @since 1.0.0
29
30
  * @param props
30
31
  */
31
32
  buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
32
33
  /**
33
34
  * Build a HL7 Message
34
- * @description Create a properly formatted HL7 message.
35
+ *@remarks Create a properly formatted HL7 message.
35
36
  * @since 1.0.0
36
37
  * @param props
37
38
  */
@@ -44,7 +45,7 @@ export declare class HL7Client {
44
45
  createClient(name: string, props: ClientOptions): Client;
45
46
  /**
46
47
  * Create an HL7 Outbound Connection
47
- * @description Connect to an HL7 Server/Broker
48
+ *@remarks Connect to an HL7 Server/Broker
48
49
  * @since 1.0.0
49
50
  * @param name The name stored within created client connections.
50
51
  * @param props
@@ -65,34 +66,34 @@ export declare class HL7Client {
65
66
  getClientConnectionByPort(port: string): Connection | undefined;
66
67
  /**
67
68
  * Process a HL7
68
- * @description 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)
69
70
  * @since 1.0.0
70
71
  * @param text Raw HL& String
71
72
  */
72
73
  processHL7(text: string): Message | Batch;
73
74
  /**
74
75
  * Read File
75
- * @description Pass the correct path of the file you want to read.
76
+ *@remarks Pass the correct path of the file you want to read.
76
77
  * @since 1.0.0
77
78
  * @param fullFilePath
78
79
  * @returns FileBatch
79
80
  * @example
80
- *
81
+ * ```ts
81
82
  * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
82
- *
83
+ * ```
83
84
  */
84
85
  readFile(fullFilePath: string): FileBatch;
85
86
  /**
86
87
  * Read a File Buffer
87
- * @description Translate an already Buffered HL7 FHS segment to decode it.
88
+ *@remarks Translate an already Buffered HL7 FHS segment to decode it.
88
89
  * @since 1.0.0
89
90
  * @param fileBuffer
90
91
  * @returns FileBatch
91
92
  * @example
92
- *
93
+ * ```ts
93
94
  * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
94
95
  * fastify.hl7.readFileBuffer(fileBuffer)
95
- *
96
+ * ```
96
97
  */
97
98
  readFileBuffer(fileBuffer: Buffer): FileBatch;
98
99
  }
@@ -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' {
@@ -26,14 +25,14 @@ declare module 'fastify' {
26
25
  * @since 1.0.0 */
27
26
  closeServerAll: () => Promise<boolean>;
28
27
  /** Create Client
29
- * @description Connecting to a remote server/broker that accepts connections.
28
+ *@remarks Connecting to a remote server/broker that accepts connections.
30
29
  * @since 1.0.0 */
31
30
  createClient: (name: string, props: ClientOptions) => Client;
32
31
  /** Create an incoming port connection on the server.
33
32
  * @since 1.0.0 */
34
33
  createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => Inbound;
35
34
  /** Create Outgoing Client Port
36
- * @description 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.
37
36
  * @since 1.0.0 */
38
37
  createConnection: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => Connection;
39
38
  /** Get Client (Outbound) connection by name.
@@ -60,7 +59,7 @@ declare module 'fastify' {
60
59
  }
61
60
  interface FastifyInstance {
62
61
  /** Main Decorator for Fastify
63
- * @description hl7 is the decorator that everything hangs off.
62
+ *@remarks hl7 is the decorator that everything hangs off.
64
63
  * @since 1.0.0 **/
65
64
  hl7: HL7;
66
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-hl7",
3
- "version": "2.1.0",
3
+ "version": "3.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,15 +17,15 @@
17
17
  "lib/"
18
18
  ],
19
19
  "engines": {
20
- "node": ">=20.0.0"
20
+ "node": ">=20.15.0"
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,38 +57,38 @@
57
57
  },
58
58
  "homepage": "https://github.com/Bugs5382/fastify-hl7#readme",
59
59
  "dependencies": {
60
- "@fastify/error": "^3.4.1",
61
- "fastify-plugin": "^4.5.1",
62
- "node-hl7-client": "^2.0.0",
63
- "node-hl7-server": "^2.0.0"
60
+ "@fastify/error": "^4.0.0",
61
+ "fastify-plugin": "^5.0.1",
62
+ "node-hl7-client": "^2.3.1",
63
+ "node-hl7-server": "^3.0.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@semantic-release/changelog": "^6.0.3",
67
- "@semantic-release/commit-analyzer": "^11.1.0",
67
+ "@semantic-release/commit-analyzer": "^13.0.0",
68
68
  "@semantic-release/git": "^10.0.1",
69
- "@semantic-release/release-notes-generator": "^12.1.0",
69
+ "@semantic-release/release-notes-generator": "^14.0.1",
70
+ "@shipgirl/typedoc-plugin-versions": "^0.2.7",
70
71
  "@the-rabbit-hole/semantic-release-config": "^1.5.0",
71
- "@types/node": "^20.11.19",
72
- "@types/randomstring": "^1.1.11",
72
+ "@types/node": "^22.8.6",
73
+ "@types/randomstring": "^1.3.0",
73
74
  "@types/tcp-port-used": "^1.0.4",
74
- "@typescript-eslint/parser": "^7.0.2",
75
- "@vitest/coverage-v8": "^1.3.1",
76
- "@vitest/ui": "^1.3.1",
77
- "clean-publish": "^4.2.0",
78
- "fastify": "^4.26.1",
79
- "npm-check-updates": "^16.14.15",
80
- "npm-package-json-lint": "^7.1.0",
75
+ "@typescript-eslint/parser": "^8.12.2",
76
+ "@vitest/coverage-v8": "^2.1.4",
77
+ "@vitest/ui": "^2.1.4",
78
+ "fastify": "^5.0.0",
79
+ "npm-check-updates": "^17.1.9",
80
+ "npm-package-json-lint": "^8.0.0",
81
81
  "portfinder": "^1.0.32",
82
82
  "pre-commit": "^1.2.2",
83
- "semantic-release": "^22.0.12",
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
87
  "ts-standard": "^12.0.2",
88
- "tsd": "^0.30.5",
89
- "typedoc": "^0.25.8",
90
- "typescript": "^5.3.3",
91
- "vitest": "^1.3.1"
88
+ "tsd": "^0.31.2",
89
+ "typedoc": "^0.26.10",
90
+ "typescript": "^5.6.3",
91
+ "vitest": "^2.1.4"
92
92
  },
93
93
  "precommit": [
94
94
  "lint:fix",