Skip to content

Commit

Permalink
feat: minor code cleanups (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 authored Jun 23, 2024
2 parents 75f625f + 6b884ff commit da37ee1
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 39 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy Typedoc to GitHub Pages

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Generate Typedoc documentation
run: npm run typedoc
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./docs
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ They might be sans uppercase throughout the documentation, but they would have t

## Documentation

It's way too extensive to include on this README alone. Please [read this](pages/index.md) to gain more information.
It's way too extensive to include on this README alone.
Please [read this](pages/index.md) to gain more information.
GitHub pages now has mostly full listing of all methods, classes, etc., but only for the most recent release.

## Acknowledgements

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"ts-node": "^10.9.2",
"ts-standard": "^12.0.2",
"tsd": "^0.31.1",
"typedoc": "^0.26.0",
"typedoc": "^0.26.1",
"typescript": "5.5.2",
"vitest": "^1.6.0"
},
Expand Down
9 changes: 6 additions & 3 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export class Client extends EventEmitter {
}

/**
* This creates a new client to a new server connection.
* This is the remote side in which we will connect.
* Then using the {@link createConnection} method, you establish a connection to the port.
* @since 1.0.0
* @param props
* @example
Expand Down Expand Up @@ -71,11 +74,11 @@ export class Client extends EventEmitter {
createConnection (props: ClientListenerOptions, cb: OutboundHandler): Connection {
const outbound = new Connection(this, props, cb)

outbound.on('client.acknowledged', (total) => {
outbound.on('client.acknowledged', (total: number) => {
this.stats._totalAck = this.stats._totalAck + total
})

outbound.on('client.sent', (total) => {
outbound.on('client.sent', (total: number) => {
this.stats._totalSent = this.stats._totalSent + total
})

Expand All @@ -87,7 +90,7 @@ export class Client extends EventEmitter {
}

/**
* Get the host that we will connect to.
* Get the host that we will connect to.
* The port might be different from each different "connection"
* @since 1.1.0
*/
Expand Down
4 changes: 2 additions & 2 deletions src/client/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Client } from './client.js'
import { InboundResponse } from './module/inboundResponse.js'

/* eslint-disable */
export interface Connection extends EventEmitter {
export interface IConnection extends EventEmitter {
/** The connection has been closed manually. You have to start the connection again. */
on(name: 'close', cb: () => void): this;
/** The connection is made. */
Expand All @@ -37,7 +37,7 @@ export interface Connection extends EventEmitter {
/** Connection Class
* @description Create a connection customer that will listen to result send to the particular port.
* @since 1.0.0 */
export class Connection extends EventEmitter implements Connection {
export class Connection extends EventEmitter implements IConnection {
/** @internal */
_handler: OutboundHandler
/** @internal */
Expand Down
3 changes: 2 additions & 1 deletion src/client/module/inboundResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class InboundResponse {

/**
* Process the Inbound Response from the Server
* @description This takes the string of the response from the server and makes it a message. A response from a broker SHOULD always be a
* @description This takes the string of the response from the server and makes it a message.
* A response from a broker SHOULD always be a properly formated Hl7 message, we hope.
* @since 1.0.0
* @param data
*/
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client } from './client/client.js'
import { Message } from './builder/message.js'
import { Batch } from './builder/batch.js'
import { FileBatch } from './builder/fileBatch.js'
import { Connection } from './client/connection.js'
import { Connection, IConnection } from './client/connection.js'
import { Delimiters, ReadyState } from './utils/enum.js'
import { OutboundHandler } from './utils/normalizedClient.js'
import { InboundResponse } from './client/module/inboundResponse.js'
Expand All @@ -18,4 +18,4 @@ export type { ClientBuilderFileOptions, ClientBuilderMessageOptions, ClientBuild
export type { HL7Error, HL7FatalError, HL7ParserError } from './utils/exception.js'

export default Client
export { Client, Connection, OutboundHandler, InboundResponse, FileBatch, Batch, Message, ReadyState, NodeBase, EmptyNode, Segment, Delimiters, HL7Node }
export { Client, Connection, IConnection, OutboundHandler, InboundResponse, FileBatch, Batch, Message, ReadyState, NodeBase, EmptyNode, Segment, Delimiters, HL7Node }
2 changes: 1 addition & 1 deletion src/utils/normalizedBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import { HL7_2_7 } from '../specification/2.7.js'
import { MSH } from '../specification/specification'
import { MSH } from '../specification/specification.js'
import { HL7FatalError } from './exception.js'
import { ParserPlan } from './parserPlan.js'
import { isBatch } from './utils.js'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const validIPv6 = (ip: string): boolean => {
}

/**
* Generate a random String
* Generate a random string
* @since 1.0.0
* @param length
*/
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "./tsconfig.build.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": false,
"sourceMap": false,
"module": "commonjs",
"outDir": "./lib/cjs"
"outDir": "./lib/cjs",
"declaration": false,
"sourceMap": false
}
}
14 changes: 5 additions & 9 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"extends": "./tsconfig.build.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": false,
"sourceMap": false,
"target": "ES2022",
"lib": [
"es2021"
],
"module": "es6",
"outDir": "./lib/esm"
"module": "ESNext",
"outDir": "./lib/esm",
"declaration": true,
"sourceMap": true
}
}
28 changes: 15 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"compilerOptions": {
"allowJs": false,
"stripInternal": true,
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"alwaysStrict": true,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"typeRoots": ["./node_modules/@types"],
"moduleResolution": "node",
"strictNullChecks": true,
"typeRoots": [
"./node_modules/@types",
"./@types"
],
"esModuleInterop": true
"sourceMap": true,
"declaration": true
},
"compileOnSave": true
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"entryPoints": ["src/api.ts"],
"excludeExternals": true,
"excludeInternal": true,
"includeVersion": false,
"includeVersion": true,
"githubPages": false,
"out": "./docs",
"name": "Node HL7 Client",
Expand Down

0 comments on commit da37ee1

Please sign in to comment.