@cosyte/mllp 0.1.6 → 0.1.8
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/CHANGELOG.md +24 -0
- package/README.md +29 -16
- package/dist/ack-from-hl7/index.cjs +48 -27
- package/dist/ack-from-hl7/index.cjs.map +1 -1
- package/dist/ack-from-hl7/index.d.cts +1 -1
- package/dist/ack-from-hl7/index.d.ts +1 -1
- package/dist/ack-from-hl7/index.mjs +48 -27
- package/dist/ack-from-hl7/index.mjs.map +1 -1
- package/dist/arbitraries/index.cjs +282 -0
- package/dist/arbitraries/index.cjs.map +1 -0
- package/dist/arbitraries/index.d.cts +245 -0
- package/dist/arbitraries/index.d.ts +245 -0
- package/dist/arbitraries/index.mjs +271 -0
- package/dist/arbitraries/index.mjs.map +1 -0
- package/dist/index.cjs +276 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -103
- package/dist/index.d.ts +74 -103
- package/dist/index.mjs +276 -82
- package/dist/index.mjs.map +1 -1
- package/dist/registry-CyGU_l8N.d.cts +86 -0
- package/dist/registry-CyGU_l8N.d.ts +86 -0
- package/package.json +23 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MLLP warning code registry and `MllpWarning` factory.
|
|
3
|
+
*
|
|
4
|
+
* `WarningCode` is a **stable public API**. Renaming or removing a code is a breaking change.
|
|
5
|
+
* New codes may only be added in minor versions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createWarning, type MllpWarning, type WarningCode } from '@cosyte/mllp';
|
|
10
|
+
* const w: MllpWarning = createWarning('MLLP_EMPTY_PAYLOAD', 128, 'Empty payload between VT and FS');
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Union of all stable MLLP warning codes.
|
|
17
|
+
*
|
|
18
|
+
* These codes are a **public API**, they appear in `onWarning` handlers, log pipelines,
|
|
19
|
+
* monitoring dashboards, and error messages. Renaming is a breaking change.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const code: WarningCode = 'MLLP_FS_WITHOUT_CR';
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
type WarningCode = "MLLP_MISSING_LEADING_VT" | "MLLP_FS_WITHOUT_CR" | "MLLP_LF_AFTER_FS" | "MLLP_LEADING_WHITESPACE" | "MLLP_TRAILING_BYTES" | "MLLP_PAYLOAD_CONTAINS_VT" | "MLLP_PAYLOAD_CONTAINS_FS" | "MLLP_EMPTY_PAYLOAD" | "MLLP_FRAME_TOO_LARGE" | "MLLP_ACK_UNMATCHED_CONTROL_ID" | "MLLP_ACK_AFTER_TIMEOUT";
|
|
27
|
+
/**
|
|
28
|
+
* A frozen warning object emitted when the decoder tolerates a framing deviation.
|
|
29
|
+
*
|
|
30
|
+
* `connectionId` is `undefined` when emitted by a standalone `FrameReader`.
|
|
31
|
+
* `Connection` enriches it to the real UUIDv4 before forwarding upstream.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const reader = new FrameReader({
|
|
36
|
+
* onFrame: (p) => process(p),
|
|
37
|
+
* onWarning: (w: MllpWarning) => logger.warn(w),
|
|
38
|
+
* allowFsOnly: true,
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
interface MllpWarning {
|
|
43
|
+
readonly code: WarningCode;
|
|
44
|
+
/**
|
|
45
|
+
* Stable human-readable description. It carries structural facts (a byte
|
|
46
|
+
* offset, an accumulated size) and **never a run of payload content**.
|
|
47
|
+
*
|
|
48
|
+
* Two codes carry exactly one input byte, and it is worth knowing which:
|
|
49
|
+
* `MLLP_MISSING_LEADING_VT` and `MLLP_FS_WITHOUT_CR` render the hex of the
|
|
50
|
+
* single byte found where a framing byte was expected, and on a stream that
|
|
51
|
+
* omits its leading `VT` that byte is the first byte of the unframed content.
|
|
52
|
+
* One byte, never a run, the same bound `MllpFramingError.snippet` carries. If
|
|
53
|
+
* that is more than your threat model allows, log `code` and `byteOffset`
|
|
54
|
+
* rather than `message`.
|
|
55
|
+
*
|
|
56
|
+
* The ACK-correlation codes are stricter: their text comes from a frozen
|
|
57
|
+
* registry and does not vary with the wire at all.
|
|
58
|
+
*/
|
|
59
|
+
readonly message: string;
|
|
60
|
+
/** Absolute stream byte offset where the anomaly was detected. */
|
|
61
|
+
readonly byteOffset: number;
|
|
62
|
+
/**
|
|
63
|
+
* Connection identifier. `undefined` at the framing layer;
|
|
64
|
+
* enriched by `Connection` before emitting upstream.
|
|
65
|
+
*/
|
|
66
|
+
readonly connectionId: string | undefined;
|
|
67
|
+
/** Wall-clock time at point of emission. */
|
|
68
|
+
readonly timestamp: Date;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a frozen `MllpWarning` object. The returned object is `Object.freeze()`'d
|
|
72
|
+
* so subscribers cannot mutate shared warning state.
|
|
73
|
+
*
|
|
74
|
+
* `connectionId` is always `undefined` here; `Connection` enriches it via
|
|
75
|
+
* `{ ...w, connectionId: this.connectionId }` then re-freezes.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const w = createWarning('MLLP_EMPTY_PAYLOAD', 64, 'Empty payload between VT and FS');
|
|
80
|
+
* // w.connectionId === undefined
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
declare function createWarning(code: WarningCode, byteOffset: number, message: string): MllpWarning;
|
|
84
|
+
|
|
85
|
+
export { createWarning as c };
|
|
86
|
+
export type { MllpWarning as M, WarningCode as W };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MLLP warning code registry and `MllpWarning` factory.
|
|
3
|
+
*
|
|
4
|
+
* `WarningCode` is a **stable public API**. Renaming or removing a code is a breaking change.
|
|
5
|
+
* New codes may only be added in minor versions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createWarning, type MllpWarning, type WarningCode } from '@cosyte/mllp';
|
|
10
|
+
* const w: MllpWarning = createWarning('MLLP_EMPTY_PAYLOAD', 128, 'Empty payload between VT and FS');
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Union of all stable MLLP warning codes.
|
|
17
|
+
*
|
|
18
|
+
* These codes are a **public API**, they appear in `onWarning` handlers, log pipelines,
|
|
19
|
+
* monitoring dashboards, and error messages. Renaming is a breaking change.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const code: WarningCode = 'MLLP_FS_WITHOUT_CR';
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
type WarningCode = "MLLP_MISSING_LEADING_VT" | "MLLP_FS_WITHOUT_CR" | "MLLP_LF_AFTER_FS" | "MLLP_LEADING_WHITESPACE" | "MLLP_TRAILING_BYTES" | "MLLP_PAYLOAD_CONTAINS_VT" | "MLLP_PAYLOAD_CONTAINS_FS" | "MLLP_EMPTY_PAYLOAD" | "MLLP_FRAME_TOO_LARGE" | "MLLP_ACK_UNMATCHED_CONTROL_ID" | "MLLP_ACK_AFTER_TIMEOUT";
|
|
27
|
+
/**
|
|
28
|
+
* A frozen warning object emitted when the decoder tolerates a framing deviation.
|
|
29
|
+
*
|
|
30
|
+
* `connectionId` is `undefined` when emitted by a standalone `FrameReader`.
|
|
31
|
+
* `Connection` enriches it to the real UUIDv4 before forwarding upstream.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const reader = new FrameReader({
|
|
36
|
+
* onFrame: (p) => process(p),
|
|
37
|
+
* onWarning: (w: MllpWarning) => logger.warn(w),
|
|
38
|
+
* allowFsOnly: true,
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
interface MllpWarning {
|
|
43
|
+
readonly code: WarningCode;
|
|
44
|
+
/**
|
|
45
|
+
* Stable human-readable description. It carries structural facts (a byte
|
|
46
|
+
* offset, an accumulated size) and **never a run of payload content**.
|
|
47
|
+
*
|
|
48
|
+
* Two codes carry exactly one input byte, and it is worth knowing which:
|
|
49
|
+
* `MLLP_MISSING_LEADING_VT` and `MLLP_FS_WITHOUT_CR` render the hex of the
|
|
50
|
+
* single byte found where a framing byte was expected, and on a stream that
|
|
51
|
+
* omits its leading `VT` that byte is the first byte of the unframed content.
|
|
52
|
+
* One byte, never a run, the same bound `MllpFramingError.snippet` carries. If
|
|
53
|
+
* that is more than your threat model allows, log `code` and `byteOffset`
|
|
54
|
+
* rather than `message`.
|
|
55
|
+
*
|
|
56
|
+
* The ACK-correlation codes are stricter: their text comes from a frozen
|
|
57
|
+
* registry and does not vary with the wire at all.
|
|
58
|
+
*/
|
|
59
|
+
readonly message: string;
|
|
60
|
+
/** Absolute stream byte offset where the anomaly was detected. */
|
|
61
|
+
readonly byteOffset: number;
|
|
62
|
+
/**
|
|
63
|
+
* Connection identifier. `undefined` at the framing layer;
|
|
64
|
+
* enriched by `Connection` before emitting upstream.
|
|
65
|
+
*/
|
|
66
|
+
readonly connectionId: string | undefined;
|
|
67
|
+
/** Wall-clock time at point of emission. */
|
|
68
|
+
readonly timestamp: Date;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a frozen `MllpWarning` object. The returned object is `Object.freeze()`'d
|
|
72
|
+
* so subscribers cannot mutate shared warning state.
|
|
73
|
+
*
|
|
74
|
+
* `connectionId` is always `undefined` here; `Connection` enriches it via
|
|
75
|
+
* `{ ...w, connectionId: this.connectionId }` then re-freezes.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const w = createWarning('MLLP_EMPTY_PAYLOAD', 64, 'Empty payload between VT and FS');
|
|
80
|
+
* // w.connectionId === undefined
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
declare function createWarning(code: WarningCode, byteOffset: number, message: string): MllpWarning;
|
|
84
|
+
|
|
85
|
+
export { createWarning as c };
|
|
86
|
+
export type { MllpWarning as M, WarningCode as W };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosyte/mllp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "MLLP transport for HL7 v2 in Node.js and TypeScript: client and server, framing, ACK correlation, auto-reconnect, TLS, and an in-memory transport for tests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -69,6 +69,16 @@
|
|
|
69
69
|
"default": "./dist/ack-from-hl7/index.cjs"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
+
"./arbitraries": {
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./dist/arbitraries/index.d.ts",
|
|
75
|
+
"default": "./dist/arbitraries/index.mjs"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./dist/arbitraries/index.d.cts",
|
|
79
|
+
"default": "./dist/arbitraries/index.cjs"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
72
82
|
"./package.json": "./package.json"
|
|
73
83
|
},
|
|
74
84
|
"publishConfig": {
|
|
@@ -77,20 +87,25 @@
|
|
|
77
87
|
},
|
|
78
88
|
"prettier": "@cosyte/prettier-config",
|
|
79
89
|
"peerDependencies": {
|
|
80
|
-
"@cosyte/hl7": ">=0.0.0"
|
|
90
|
+
"@cosyte/hl7": ">=0.0.0",
|
|
91
|
+
"fast-check": "^4.0.0"
|
|
81
92
|
},
|
|
82
93
|
"peerDependenciesMeta": {
|
|
83
94
|
"@cosyte/hl7": {
|
|
84
95
|
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"fast-check": {
|
|
98
|
+
"optional": true
|
|
85
99
|
}
|
|
86
100
|
},
|
|
87
101
|
"devDependencies": {
|
|
88
102
|
"@arethetypeswrong/cli": "0.18.5",
|
|
89
103
|
"@changesets/cli": "2.31.0",
|
|
104
|
+
"@cosyte/bench": "^0.1.1",
|
|
90
105
|
"@cosyte/eslint-config": "^0.1.4",
|
|
91
106
|
"@cosyte/hl7": "^0.1.0",
|
|
92
107
|
"@cosyte/prettier-config": "^0.1",
|
|
93
|
-
"@cosyte/process": "^0.1.
|
|
108
|
+
"@cosyte/process": "^0.1.7",
|
|
94
109
|
"@cosyte/script-utils": "^0.1.8",
|
|
95
110
|
"@cosyte/test-utils": "^0.1.3",
|
|
96
111
|
"@cosyte/tsconfig": "^0.1",
|
|
@@ -129,8 +144,13 @@
|
|
|
129
144
|
"test": "cosyte-process test",
|
|
130
145
|
"test:watch": "cosyte-process test --watch",
|
|
131
146
|
"test:coverage": "cosyte-process test --coverage",
|
|
147
|
+
"test:perf": "vitest run --config vitest.perf.config.ts",
|
|
132
148
|
"fuzz": "vitest run test/property/fuzz.property.test.ts test/property/transport-fuzz.property.test.ts test/property/ack-fuzz.property.test.ts",
|
|
133
149
|
"examples": "tsx scripts/run-examples.ts",
|
|
150
|
+
"bench:reading": "cosyte-bench run --suite bench/mllp.bench.mjs --target dist/index.mjs",
|
|
151
|
+
"bench:compare": "cosyte-bench compare --suite bench/mllp.bench.mjs",
|
|
152
|
+
"bench:profile": "node bench/profile.mjs",
|
|
153
|
+
"bench:socket": "node --expose-gc bench/socket.mjs",
|
|
134
154
|
"certs:gen": "node scripts/generate-test-certs.mjs",
|
|
135
155
|
"clean": "rm -rf dist coverage",
|
|
136
156
|
"attw": "cosyte-attw",
|