fastify-hl7 1.0.0-beta.1

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,78 @@
1
+ /// <reference types="node" />
2
+ import { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
3
+ export declare class HL7Client {
4
+ constructor();
5
+ /**
6
+ * Close All Connections for this Client
7
+ * @since 1.0.0
8
+ */
9
+ closeAll(): Promise<boolean>;
10
+ /**
11
+ * Build a HL7 Batch
12
+ * @description Create a properly formatted HL7 Batch.
13
+ * @since 1.0.0
14
+ * @param props
15
+ */
16
+ buildBatch(props?: ClientBuilderOptions): Batch;
17
+ /**
18
+ * Build a HL7 File Batch
19
+ * @description Create a properly formatted HL7 File Batch.
20
+ * @since 1.0.0
21
+ * @param props
22
+ */
23
+ buildFileBatch(props?: ClientBuilderFileOptions): FileBatch;
24
+ /**
25
+ * Build a HL7 Message
26
+ * @description Create a properly formatted HL7 message.
27
+ * @since 1.0.0
28
+ * @param props
29
+ */
30
+ buildMessage(props?: ClientBuilderMessageOptions): Message;
31
+ /**
32
+ *
33
+ * @param name
34
+ * @param props
35
+ */
36
+ createClient(name: string, props: ClientOptions): void;
37
+ /**
38
+ * Create an HL7 Outbound Connection
39
+ * @description Connect to an HL7 Server/Broker
40
+ * @since 1.0.0
41
+ * @param name The name stored within created client connections.
42
+ * @param props
43
+ * @param handler
44
+ */
45
+ createOutbound(name: string, props: ClientListenerOptions, handler: OutboundHandler): HL7Outbound;
46
+ /**
47
+ * Process a HL7
48
+ * @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
49
+ * @since 1.0.0
50
+ * @param text Raw HL& String
51
+ */
52
+ processHL7(text: string): Message | Batch;
53
+ /**
54
+ * Read File
55
+ * @description Pass the correct path of the file you want to read.
56
+ * @since 1.0.0
57
+ * @param fullFilePath
58
+ * @returns FileBatch
59
+ * @example
60
+ *
61
+ * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
62
+ *
63
+ */
64
+ readFile(fullFilePath: string): FileBatch;
65
+ /**
66
+ * Read a File Buffer
67
+ * @description Translate an already Buffered HL7 FHS segment to decode it.
68
+ * @since 1.0.0
69
+ * @param fileBuffer
70
+ * @returns FileBatch
71
+ * @example
72
+ *
73
+ * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
74
+ * fastify.hl7.readFileBuffer(fileBuffer)
75
+ *
76
+ */
77
+ readFileBuffer(fileBuffer: Buffer): FileBatch;
78
+ }
@@ -0,0 +1,25 @@
1
+ import Server, { HL7Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
2
+ export declare class HL7Server {
3
+ private readonly _server;
4
+ private readonly _serverInboundConnections;
5
+ constructor(server: Server);
6
+ /**
7
+ * Close Inbound connection.
8
+ * @since 1.0.0
9
+ * @param port
10
+ */
11
+ close(port: string): Promise<boolean>;
12
+ /**
13
+ * Close all Inbound connections.
14
+ * @since 1.0.0
15
+ */
16
+ closeAll(): Promise<boolean>;
17
+ /**
18
+ * Create Inbound connection.
19
+ * @since 1.0.0
20
+ * @param name
21
+ * @param props
22
+ * @param handler
23
+ */
24
+ createInbound(name: string, props: ListenerOptions, handler: InboundHandler): HL7Inbound;
25
+ }
@@ -0,0 +1,29 @@
1
+ import Client, { HL7Outbound } from 'node-hl7-client';
2
+ import { HL7Inbound, 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
+ interface AClientPorts {
16
+ port: string;
17
+ connection: HL7Outbound;
18
+ }
19
+ export interface AClients {
20
+ name: string;
21
+ client: Client;
22
+ ports: AClientPorts[];
23
+ }
24
+ export interface AServers {
25
+ name: string;
26
+ port: string;
27
+ server: HL7Inbound;
28
+ }
29
+ 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,4 @@
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;
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import Server, { HL7Inbound, InboundHandler, ListenerOptions } from 'node-hl7-server';
3
+ import { Batch, ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuilderOptions, ClientListenerOptions, ClientOptions, FileBatch, HL7Outbound, Message, OutboundHandler } from 'node-hl7-client';
4
+ declare module 'fastify' {
5
+ interface HL7 {
6
+ /** Server Instance **/
7
+ _serverInstance?: Server;
8
+ /** */
9
+ buildBatch: (props?: ClientBuilderOptions) => Batch;
10
+ /** */
11
+ buildFileBatch: (props?: ClientBuilderFileOptions) => FileBatch;
12
+ /** */
13
+ buildMessage: (props?: ClientBuilderMessageOptions) => Message;
14
+ /** */
15
+ closeServer: (port: string) => Promise<boolean>;
16
+ /** */
17
+ closeServerAll: () => Promise<boolean>;
18
+ /** Create Client */
19
+ createClient: (name: string, props: ClientOptions) => void;
20
+ /** */
21
+ createInbound: (name: string, props: ListenerOptions, handler: InboundHandler) => HL7Inbound;
22
+ /** Create Outgoing Client Port */
23
+ createOutbound: (name: string, props: ClientListenerOptions, handler: OutboundHandler) => HL7Outbound;
24
+ /** */
25
+ processHL7: (text: string) => Message | Batch;
26
+ /** */
27
+ readFile: (fullFilePath: string) => FileBatch;
28
+ /** */
29
+ readFileBuffer: (fileBuffer: Buffer) => FileBatch;
30
+ }
31
+ interface FastifyInstance {
32
+ /** Main Decorator for Fastify **/
33
+ hl7: HL7;
34
+ }
35
+ }
@@ -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>;
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "fastify-hl7",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "A Fastify HL7 Plugin Developed in Pure TypeScript.",
5
+ "module": "./lib/esm/index.js",
6
+ "main": "./lib/cjs/index.js",
7
+ "types": "./lib/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "import": "./lib/esm/index.js",
12
+ "require": "./lib/cjs/index.js",
13
+ "default": "./lib/cjs/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "lib/"
18
+ ],
19
+ "engines": {
20
+ "node": "^18 || ^20"
21
+ },
22
+ "scripts": {
23
+ "clean": "rm -rf lib coverage",
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",
26
+ "npmPkgJsonLint": "npmPkgJsonLint .",
27
+ "lint": "npmPkgJsonLint . && ts-standard | snazzy",
28
+ "lint:fix": "npmPkgJsonLint . && ts-standard --fix | snazzy",
29
+ "pack": "npm pack",
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",
36
+ "typedoc": "typedoc",
37
+ "typedoc:watch": "typedoc -watch",
38
+ "semantic-release": "semantic-release",
39
+ "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"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/Bugs5382/fastify-hl7.git"
46
+ },
47
+ "keywords": [
48
+ "node-hl7-client",
49
+ "node-hl7-server",
50
+ "hl7",
51
+ "fastify",
52
+ "fastify-plugin"
53
+ ],
54
+ "author": "Shane Froebel",
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https://github.com/Bugs5382/fastify-hl7/issues"
58
+ },
59
+ "homepage": "https://github.com/Bugs5382/fastify-hl7#readme",
60
+ "dependencies": {
61
+ "@fastify/error": "^3.4.1",
62
+ "fastify-plugin": "^4.5.1",
63
+ "node-hl7-client": "^1.1.0-beta.3",
64
+ "node-hl7-server": "^1.0.1-beta.3"
65
+ },
66
+ "devDependencies": {
67
+ "@semantic-release/changelog": "^6.0.3",
68
+ "@semantic-release/commit-analyzer": "^11.1.0",
69
+ "@semantic-release/git": "^10.0.1",
70
+ "@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.5",
74
+ "@types/randomstring": "^1.1.11",
75
+ "@types/tcp-port-used": "^1.0.4",
76
+ "@typescript-eslint/parser": "^6.16.0",
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",
82
+ "npm-package-json-lint": "^7.1.0",
83
+ "portfinder": "^1.0.32",
84
+ "pre-commit": "^1.2.2",
85
+ "semantic-release": "^22.0.12",
86
+ "snazzy": "^9.0.0",
87
+ "tcp-port-used": "^1.0.2",
88
+ "ts-jest": "^29.1.1",
89
+ "ts-node": "^10.9.2",
90
+ "ts-standard": "^12.0.2",
91
+ "tsd": "^0.30.1",
92
+ "typedoc": "^0.25.4",
93
+ "typescript": "^5.3.3"
94
+ },
95
+ "pre-commit": []
96
+ }