@cosyte/mllp 0.1.15 → 0.1.16

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/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
- import { W as WarningCode, M as MllpWarning } from './registry-CyGU_l8N.cjs';
2
- export { c as createWarning } from './registry-CyGU_l8N.cjs';
3
- import { T as Transport } from './index-CD8V2Mtk.cjs';
4
- import { EventEmitter } from 'node:events';
1
+ import { W as WarningCode, M as MllpWarning } from './registry-BPOSRmcX.cjs';
2
+ export { c as createWarning } from './registry-BPOSRmcX.cjs';
3
+ import { Buffer } from 'node:buffer';
4
+ import { T as Transport } from './transport-2Zo_VBmG.cjs';
5
5
  import { Socket } from 'node:net';
6
6
  import { TLSSocket } from 'node:tls';
7
+ import { EventEmitter } from 'node:events';
7
8
 
8
9
  /**
9
10
  * Typed framing error class for unrecoverable MLLP wire-format violations.
@@ -109,7 +110,7 @@ interface EncoderOptions {
109
110
  *
110
111
  * Default: `false` (strict, throws on delimiter bytes).
111
112
  */
112
- allowDelimiterBytesInPayload?: boolean;
113
+ readonly allowDelimiterBytesInPayload?: boolean;
113
114
  /**
114
115
  * Called for each offending delimiter byte when `allowDelimiterBytesInPayload` is `true`.
115
116
  * Invocation is wrapped in try/catch, a throwing handler does not interrupt encoding.
@@ -122,7 +123,7 @@ interface EncoderOptions {
122
123
  * });
123
124
  * ```
124
125
  */
125
- onWarning?: (w: MllpWarning) => void;
126
+ readonly onWarning?: (w: MllpWarning) => void;
126
127
  }
127
128
  /**
128
129
  * Encode `payload` in canonical MLLP framing: `VT (0x0B) + payload + FS (0x1C) + CR (0x0D)`.
@@ -154,7 +155,7 @@ interface EncoderOptions {
154
155
  * });
155
156
  * ```
156
157
  */
157
- declare function encodeFrame(payload: Buffer, opts?: EncoderOptions): Buffer;
158
+ declare function encodeFrame(payload: Buffer, options?: EncoderOptions): Buffer;
158
159
 
159
160
  /**
160
161
  * MLLP frame decoder, stateful 3-state FSM for chunked byte-stream parsing.
@@ -214,29 +215,29 @@ interface FrameReaderOptions {
214
215
  * @param warnings - Framing warnings emitted during decoding of this specific frame.
215
216
  * Empty array when no tolerance deviations were detected.
216
217
  */
217
- onFrame: (payload: Buffer, byteOffset: number, warnings: readonly MllpWarning[]) => void;
218
+ readonly onFrame: (payload: Buffer, byteOffset: number, warnings: readonly MllpWarning[]) => void;
218
219
  /**
219
220
  * Called for each tolerated framing deviation. Wrapped in try/catch.
220
221
  * A throwing handler will not corrupt FSM state.
221
222
  */
222
- onWarning?: (w: MllpWarning) => void;
223
+ readonly onWarning?: (w: MllpWarning) => void;
223
224
  /**
224
225
  * Maximum accumulated payload bytes before `MllpFramingError('MLLP_FRAME_TOO_LARGE')`.
225
226
  * Default: 16 MiB (DoS prevention).
226
227
  */
227
- maxFrameSizeBytes?: number;
228
+ readonly maxFrameSizeBytes?: number;
228
229
  /**
229
230
  * Tolerate FS without trailing CR when the next frame's VT follows it; emits
230
231
  * `MLLP_FS_WITHOUT_CR`. Any other byte after the FS means the FS sat inside the frame, and the
231
232
  * frame is refused whole with `MLLP_PAYLOAD_CONTAINS_FS`.
232
233
  */
233
- allowFsOnly?: boolean;
234
+ readonly allowFsOnly?: boolean;
234
235
  /** Tolerate FS+LF instead of FS+CR; emits `MLLP_LF_AFTER_FS`. */
235
- allowLfAfterFs?: boolean;
236
+ readonly allowLfAfterFs?: boolean;
236
237
  /** Tolerate missing leading VT; emits `MLLP_MISSING_LEADING_VT`. */
237
- allowMissingLeadingVt?: boolean;
238
+ readonly allowMissingLeadingVt?: boolean;
238
239
  /** Tolerate SP/TAB/LF/CR before VT; emits `MLLP_LEADING_WHITESPACE`. */
239
- allowLeadingWhitespace?: boolean;
240
+ readonly allowLeadingWhitespace?: boolean;
240
241
  /**
241
242
  * When `true`, escalates the following tolerances to thrown `MllpFramingError`
242
243
  * even if individual opt-ins (`allowFsOnly`, `allowLfAfterFs`, `allowMissingLeadingVt`,
@@ -254,7 +255,7 @@ interface FrameReaderOptions {
254
255
  * const reader = new FrameReader({ onFrame: fn, strict: true });
255
256
  * ```
256
257
  */
257
- strict?: boolean;
258
+ readonly strict?: boolean;
258
259
  }
259
260
  /**
260
261
  * Stateful MLLP frame decoder. Feed raw TCP byte chunks via `push(chunk)`.
@@ -615,6 +616,7 @@ interface SecurityWarning {
615
616
  *
616
617
  * @packageDocumentation
617
618
  */
619
+
618
620
  /**
619
621
  * A PEM-encoded credential (certificate, key, or CA), matching Node's
620
622
  * `tls.connect`/`tls.createServer` input shape, a single PEM string/Buffer,
@@ -1163,9 +1165,9 @@ declare class MllpTlsConfigurationError extends Error {
1163
1165
  * Construct a TLS configuration error.
1164
1166
  *
1165
1167
  * @param code - The stable configuration-error code; also selects the message.
1166
- * @param opts - Optional underlying `cause` from the TLS library.
1168
+ * @param options - Optional underlying `cause` from the TLS library.
1167
1169
  */
1168
- constructor(code: TlsConfigurationErrorCode, opts?: {
1170
+ constructor(code: TlsConfigurationErrorCode, options?: {
1169
1171
  cause?: Error;
1170
1172
  });
1171
1173
  }
@@ -1199,6 +1201,7 @@ declare class MllpTlsConfigurationError extends Error {
1199
1201
  *
1200
1202
  * @packageDocumentation
1201
1203
  */
1204
+
1202
1205
  /**
1203
1206
  * The four TLS 1.2 cipher suites ITI TF-2 §3.19.6.2.3 names, in the OpenSSL
1204
1207
  * spelling a cipher-list string is written in. Their IANA spellings, which are
@@ -1535,15 +1538,15 @@ interface ConnectionStats {
1535
1538
  */
1536
1539
  interface ConnectionOptions {
1537
1540
  /** The transport this Connection will drive. */
1538
- transport: Transport;
1541
+ readonly transport: Transport;
1539
1542
  /** Called for each decoded MLLP frame (raw payload bytes, framing stripped). */
1540
- onMessage?: (payload: Buffer) => void;
1543
+ readonly onMessage?: (payload: Buffer) => void;
1541
1544
  /** Per-connection warning subscriber. Replaces previous subscription. */
1542
- onWarning?: (w: MllpWarning) => void;
1545
+ readonly onWarning?: (w: MllpWarning) => void;
1543
1546
  /** Drain timeout used by close() (default: 30_000 ms). */
1544
- drainTimeoutMs?: number;
1547
+ readonly drainTimeoutMs?: number;
1545
1548
  /** FrameReader options (tolerance, maxFrameSizeBytes). onFrame/onWarning are managed internally. */
1546
- framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
1549
+ readonly framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
1547
1550
  }
1548
1551
  /**
1549
1552
  * A single MLLP connection wrapping a {@link Transport} with a 6-state FSM,
@@ -1696,14 +1699,14 @@ declare class Connection extends EventEmitter {
1696
1699
  * `destroy()` during a long drain therefore ends the wait at once, not at the drain timeout.
1697
1700
  * - If `CLOSED` or `DISCONNECTED`: no-op.
1698
1701
  *
1699
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
1702
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
1700
1703
  *
1701
1704
  * @example
1702
1705
  * ```typescript
1703
1706
  * await conn.close({ drainTimeoutMs: 5_000 });
1704
1707
  * ```
1705
1708
  */
1706
- close(opts?: {
1709
+ close(options?: {
1707
1710
  drainTimeoutMs?: number;
1708
1711
  }): Promise<void>;
1709
1712
  /**
@@ -2320,17 +2323,17 @@ interface ServerOptions {
2320
2323
  *
2321
2324
  * May be sync or async; an async handler is awaited in commit-gated mode.
2322
2325
  */
2323
- onMessage?: (payload: Buffer, meta: MessageMeta, conn: Connection) => void | Promise<void>;
2326
+ readonly onMessage?: (payload: Buffer, meta: MessageMeta, conn: Connection) => void | Promise<void>;
2324
2327
  /**
2325
2328
  * FrameReader tolerance options applied to every accepted connection.
2326
2329
  * Merged with SERVER_DEFAULT_FRAMING, caller-supplied values override defaults.
2327
2330
  * `onFrame` and `onWarning` are managed internally and must not be supplied here.
2328
2331
  */
2329
- framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
2332
+ readonly framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">;
2330
2333
  /**
2331
2334
  * Per-connection warning subscriber. Called for every framing warning on every connection.
2332
2335
  */
2333
- onWarning?: (w: MllpWarning) => void;
2336
+ readonly onWarning?: (w: MllpWarning) => void;
2334
2337
  /**
2335
2338
  * Auto-ACK mode. When set, the server builds and sends the ACK for each message.
2336
2339
  *
@@ -2350,14 +2353,14 @@ interface ServerOptions {
2350
2353
  * The `'message'` event always fires BEFORE the ACK is sent. Do NOT call
2351
2354
  * `conn.send()` in `onMessage` when `autoAck` is set, this results in two ACKs.
2352
2355
  */
2353
- autoAck?: "AA" | ((payload: Buffer, meta: MessageMeta, conn: Connection) => Buffer | Promise<Buffer>);
2356
+ readonly autoAck?: "AA" | ((payload: Buffer, meta: MessageMeta, conn: Connection) => Buffer | Promise<Buffer>);
2354
2357
  /**
2355
2358
  * TCP keepalive probe interval in ms.
2356
2359
  * Calls `socket.setKeepAlive(true, ms)` on each accepted socket.
2357
2360
  * Uses OS TCP stack to detect dead peers (half-open, network partitions).
2358
2361
  * Distinct from `deadPeerTimeoutMs` (application-level idle close).
2359
2362
  */
2360
- keepaliveIntervalMs?: number;
2363
+ readonly keepaliveIntervalMs?: number;
2361
2364
  /**
2362
2365
  * Whether to turn off Nagle's algorithm (`socket.setNoDelay(noDelay)`) on each accepted
2363
2366
  * socket. With it on (`false` here), an ACK written while an earlier one is still
@@ -2366,14 +2369,14 @@ interface ServerOptions {
2366
2369
  *
2367
2370
  * @default true
2368
2371
  */
2369
- noDelay?: boolean;
2372
+ readonly noDelay?: boolean;
2370
2373
  /**
2371
2374
  * Application-level idle close timeout in ms.
2372
2375
  * If no HL7 messages are received on a connection for this interval, the connection
2373
2376
  * is destroyed via `conn.destroy(new Error('idle timeout'))`.
2374
2377
  * Resets on every `'message'` event. Distinct from `keepaliveIntervalMs` (OS TCP probe).
2375
2378
  */
2376
- deadPeerTimeoutMs?: number;
2379
+ readonly deadPeerTimeoutMs?: number;
2377
2380
  /**
2378
2381
  * Graceful drain timeout passed to `conn.close()` during `server.close()`: the longest
2379
2382
  * `close()` waits for the handlers still running and their acknowledgements. A handler still
@@ -2386,7 +2389,7 @@ interface ServerOptions {
2386
2389
  * are still answered, and a connection waits at most this long for their handlers before it is
2387
2390
  * destroyed.
2388
2391
  */
2389
- drainTimeoutMs?: number;
2392
+ readonly drainTimeoutMs?: number;
2390
2393
  /**
2391
2394
  * Enable TLS (MLLPS) for this server. When set, the server binds a
2392
2395
  * `tls.Server` instead of a plain `net.Server`, consumes `'secureConnection'`
@@ -2405,7 +2408,7 @@ interface ServerOptions {
2405
2408
  *
2406
2409
  * @default undefined (plaintext TCP)
2407
2410
  */
2408
- tls?: ServerTlsOptions;
2411
+ readonly tls?: ServerTlsOptions;
2409
2412
  /**
2410
2413
  * Opt-in required to bind a wildcard host, a bind-safety guardrail.
2411
2414
  * Without this flag, `listen()` rejects a wildcard host in
@@ -2422,7 +2425,7 @@ interface ServerOptions {
2422
2425
  *
2423
2426
  * @default false
2424
2427
  */
2425
- allowWildcardBind?: boolean;
2428
+ readonly allowWildcardBind?: boolean;
2426
2429
  /**
2427
2430
  * The most connections this server holds at once. A connection that arrives while the server
2428
2431
  * already holds this many is closed at accept: it never reaches `onMessage` or the
@@ -2443,7 +2446,7 @@ interface ServerOptions {
2443
2446
  *
2444
2447
  * @default undefined (no cap)
2445
2448
  */
2446
- maxConnections?: number;
2449
+ readonly maxConnections?: number;
2447
2450
  }
2448
2451
  /**
2449
2452
  * Options for `createStarterServer()`, the "three lines of code" factory.
@@ -2467,13 +2470,13 @@ interface ServerOptions {
2467
2470
  */
2468
2471
  interface StarterServerOptions extends ServerOptions {
2469
2472
  /** Port to listen on. */
2470
- port: number;
2473
+ readonly port: number;
2471
2474
  /**
2472
2475
  * Host to bind to. Default `'127.0.0.1'` (bind-safety hardening,
2473
2476
  * was `'0.0.0.0'`; binding all interfaces now requires
2474
2477
  * `ServerOptions.allowWildcardBind: true`).
2475
2478
  */
2476
- host?: string;
2479
+ readonly host?: string;
2477
2480
  /**
2478
2481
  * Register `process.once('SIGTERM')` and `process.once('SIGINT')` handlers that
2479
2482
  * call `server.close()` then `process.exit(0)`. Default: `false`.
@@ -2482,7 +2485,7 @@ interface StarterServerOptions extends ServerOptions {
2482
2485
  * `process.listenerCount('SIGTERM') === 0` after close() completes, preventing
2483
2486
  * handler accumulation across test instances or multiple server restarts.
2484
2487
  */
2485
- handleSignals?: boolean;
2488
+ readonly handleSignals?: boolean;
2486
2489
  }
2487
2490
  /**
2488
2491
  * MLLP TCP server, wraps `net.Server` without extending it.
@@ -2696,8 +2699,8 @@ declare class MllpServer extends EventEmitter {
2696
2699
  * the server and does NOT settle the in-flight `listen()`, which simply
2697
2700
  * continues and settles on its own bind outcome.
2698
2701
  *
2699
- * @param opts.drainTimeoutMs - Override drain timeout (default: `opts.drainTimeoutMs ?? 30_000`).
2700
- * @param opts.signal - AbortSignal to cancel the close operation. On abort, all
2702
+ * @param options.drainTimeoutMs - Override drain timeout (default: `options.drainTimeoutMs ?? 30_000`).
2703
+ * @param options.signal - AbortSignal to cancel the close operation. On abort, all
2701
2704
  * active connections are destroyed and the promise rejects with AbortError.
2702
2705
  *
2703
2706
  * @example
@@ -2705,7 +2708,7 @@ declare class MllpServer extends EventEmitter {
2705
2708
  * await server.close({ drainTimeoutMs: 5_000 });
2706
2709
  * ```
2707
2710
  */
2708
- close(opts?: {
2711
+ close(options?: {
2709
2712
  drainTimeoutMs?: number;
2710
2713
  signal?: AbortSignal;
2711
2714
  }): Promise<void>;
@@ -2992,10 +2995,10 @@ declare class MllpAckError extends Error {
2992
2995
  readonly ackCode: NegativeAckCode;
2993
2996
  /**
2994
2997
  * @param message - Diagnostic text for the thrower. Never placed on the wire (may carry PHI).
2995
- * @param opts.ackCode - Negative code to return. Default `'AE'`.
2996
- * @param opts.cause - Underlying error, preserved on `.cause`.
2998
+ * @param options.ackCode - Negative code to return. Default `'AE'`.
2999
+ * @param options.cause - Underlying error, preserved on `.cause`.
2997
3000
  */
2998
- constructor(message: string, opts?: {
3001
+ constructor(message: string, options?: {
2999
3002
  ackCode?: NegativeAckCode;
3000
3003
  cause?: unknown;
3001
3004
  });
@@ -3105,7 +3108,7 @@ declare function rawAckUncorrelatable(payload: Buffer): boolean;
3105
3108
  * degrading the side that had been **right**: `buildRawAck` began emitting a positive `AA`
3106
3109
  * with an empty MSA-2, silently, for a message whose MSH-10 was plainly present. Agreement
3107
3110
  * is not the goal; agreeing on the *correct*, *tolerant* answer is. A lenient reader may
3108
- * never drop data that is there (Postel's Law, CLAUDE.md).
3111
+ * never drop data that is there (Postel's Law).
3109
3112
  *
3110
3113
  * **The fail-safe downgrade: never a positive `AA`/`CA` it cannot correlate**
3111
3114
  *
@@ -3746,8 +3749,9 @@ interface ClientOptions {
3746
3749
  * friendly.
3747
3750
  *
3748
3751
  * `warningsByCode` keys are constrained to the public {@link WarningCode}
3749
- * union, adding/removing a code is a breaking change (CLAUDE.md
3750
- * stable-codes guardrail enforced at the type boundary).
3752
+ * union, held at the type boundary. The set may grow in any release, so
3753
+ * keep a default branch; removing or renaming a code is a change a caller
3754
+ * must act on.
3751
3755
  *
3752
3756
  * @example
3753
3757
  * ```typescript
@@ -4022,7 +4026,7 @@ declare class MllpClient extends EventEmitter {
4022
4026
  * await client.connect({ signal: ac.signal });
4023
4027
  * ```
4024
4028
  */
4025
- connect(opts?: {
4029
+ connect(options?: {
4026
4030
  signal?: AbortSignal;
4027
4031
  }): Promise<void>;
4028
4032
  /**
@@ -4281,16 +4285,16 @@ declare class MllpClient extends EventEmitter {
4281
4285
  * ```
4282
4286
  *
4283
4287
  * @param payload Raw bytes; MLLP framing is added internally via `encodeFrame`.
4284
- * @param opts.signal AbortSignal, aborting cancels the ACK wait.
4285
- * @param opts.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4288
+ * @param options.signal AbortSignal, aborting cancels the ACK wait.
4289
+ * @param options.ackTimeoutMs This send's bound on the wait for its acknowledgement, from the
4286
4290
  * moment its bytes are flushed, in place of the client's `ackTimeoutMs`. Under
4287
4291
  * `onBackpressure: "wait"` it also bounds the wait for queue room, and the
4288
4292
  * acknowledgement wait then starts afresh once the send is written.
4289
- * @param opts.applicationAckTimeoutMs Per-send override of the second wait's bound.
4290
- * @param opts.onCommitAck Called with the commit disposition when the peer commits the
4293
+ * @param options.applicationAckTimeoutMs Per-send override of the second wait's bound.
4294
+ * @param options.onCommitAck Called with the commit disposition when the peer commits the
4291
4295
  * message ahead of its application acknowledgement. See {@link CommitAckReport}.
4292
4296
  */
4293
- send(payload: Buffer, opts?: {
4297
+ send(payload: Buffer, options?: {
4294
4298
  signal?: AbortSignal;
4295
4299
  ackTimeoutMs?: number;
4296
4300
  applicationAckTimeoutMs?: number;
@@ -4483,7 +4487,7 @@ declare class MllpClient extends EventEmitter {
4483
4487
  * await client.close({ drainTimeoutMs: 5_000 });
4484
4488
  * ```
4485
4489
  */
4486
- close(opts?: {
4490
+ close(options?: {
4487
4491
  drainTimeoutMs?: number;
4488
4492
  signal?: AbortSignal;
4489
4493
  }): Promise<void>;
@@ -5178,6 +5182,7 @@ declare class MllpBackpressureError extends Error {
5178
5182
  *
5179
5183
  * @packageDocumentation
5180
5184
  */
5185
+
5181
5186
  /**
5182
5187
  * One send-and-await-response pair the harness runs against a peer.
5183
5188
  *
@@ -5712,8 +5717,8 @@ declare function runDifferential(options?: DifferentialRunOptions): Promise<Diff
5712
5717
  /**
5713
5718
  * Package version marker exported from the `@cosyte/mllp` root.
5714
5719
  *
5715
- * Kept in lockstep with `package.json` by `scripts/sync-version.mjs`, which the `version` script
5716
- * runs immediately after `changeset version`. The `: string` annotation is deliberate, without it
5720
+ * Kept in lockstep with `package.json` by `cosyte-process sync-version`, which the `version`
5721
+ * script runs immediately after `changeset version`. The `: string` annotation is deliberate, without it
5717
5722
  * TypeScript infers the *literal* type (`declare const VERSION = "0.0.0"`), which leaks the current
5718
5723
  * release into consumers' types and makes an equality check against any other version a compile
5719
5724
  * error.