@glion/ack 0.16.0 → 0.20.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.
package/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # @glion/ack
2
2
 
3
- HL7v2 acknowledgment message builder and typed exception classes.
3
+ Typed HL7v2 acknowledgment codes and exceptions.
4
4
 
5
5
  ## What it does
6
6
 
7
- `@glion/ack` builds spec-compliant ACK/NAK response ASTs from a parsed HL7v2 message. The `acknowledge()` function accepts an original message `Root` and returns a new `Root` containing an MSH, MSA, and (when an error is supplied) an ERR segment. Typed exception classes (`AckApplicationError`, `AckApplicationReject`, `AckCommitError`, `AckCommitReject`) carry the HL7v2 error code and severity that the response needs, so callers throw semantic errors and the builder renders them as the correct MSA-1 code.
7
+ `@glion/ack` gives you typed exceptions and constants for HL7v2 acknowledgments. Instead of comparing raw strings like `"AE"` or `"207"`, you throw and catch real error classes and use named constants.
8
+
9
+ - **One class per rejection code.** Throw `AckApplicationError` for AE, `AckApplicationReject` for AR, `AckCommitError` for CE, `AckCommitReject` for CR.
10
+ - **Named constants for the standard tables.** `AckCode`, `Hl7ErrorCode`, and `Severity` replace magic strings, with full TypeScript types.
11
+ - **Works on both sides of a connection.** Throw the exceptions in a server to reject a message. Catch them in a client when a remote system rejects yours.
8
12
 
9
13
  ## Install
10
14
 
@@ -14,83 +18,70 @@ npm install @glion/ack
14
18
 
15
19
  ## Use
16
20
 
17
- Build a successful acknowledgment (AA):
21
+ Reject a message from a server handler — the exception carries the acknowledgment code and error data the server renders into the matching NAK:
18
22
 
19
23
  ```ts
20
- import { acknowledge } from "@glion/ack";
21
- import { toHl7v2 } from "@glion/to-hl7v2";
24
+ import { AckApplicationError, Hl7ErrorCode } from "@glion/ack";
22
25
 
23
- const ack = acknowledge(originalTree);
24
- const raw = toHl7v2(ack);
25
- // MSH|^~\&|RecvApp|RecvFac|SendApp|SendFac|20240115023000||ACK^A01|<auto-id>|P|2.5.1
26
- // MSA|AA|MSG001
26
+ throw new AckApplicationError("Patient 12345 not found", {
27
+ errorCode: Hl7ErrorCode.UnknownKeyIdentifier,
28
+ });
27
29
  ```
28
30
 
29
- Build an application error (AE) or reject (AR):
31
+ Handle a rejection from the client — `@glion/mllp-client` throws the same classes when the remote system NAKs:
30
32
 
31
33
  ```ts
32
- import {
33
- acknowledge,
34
- AckApplicationError,
35
- AckApplicationReject,
36
- } from "@glion/ack";
37
-
38
- const error = new AckApplicationError("Validation failed", {
39
- errorCode: "207",
40
- severity: "E",
41
- });
42
-
43
- const ack = acknowledge(originalTree, { error });
44
- // MSA|AE|MSG001|Validation failed
45
- // ERR|||207|E
34
+ import { AckException } from "@glion/ack";
35
+
36
+ try {
37
+ await client.send(message);
38
+ } catch (error) {
39
+ if (error instanceof AckException) {
40
+ // the remote system said no — error.code is AE, AR, CE, or CR
41
+ }
42
+ }
46
43
  ```
47
44
 
48
- The ACK sender (MSH-3/MSH-4) is derived from the original message's MSH-5/MSH-6 by default.
49
-
50
45
  ## API
51
46
 
52
- ### `acknowledge(origin, options?)`
47
+ ### Exception classes
53
48
 
54
- Builds an ACK/NAK `Root` AST from the original message tree.
49
+ ```ts
50
+ new AckApplicationError(message, options); // AE
51
+ new AckApplicationReject(message, options); // AR
52
+ new AckCommitError(message, options); // CE
53
+ new AckCommitReject(message, options); // CR
54
+ ```
55
55
 
56
- | Parameter | Type | Description |
57
- | --------------------------- | -------------- | ------------------------------------------------------------------ |
58
- | `origin` | `Root` | Parsed AST of the original HL7v2 message |
59
- | `options.id` | `string` | Custom MSH-10 control ID. Auto-generated via `uid()` when omitted |
60
- | `options.sending` | `SendingInfo` | MSH-3/MSH-4 of the ACK. Defaults to original message's MSH-5/MSH-6 |
61
- | `options.processingId` | `string` | MSH-11 processing ID. Defaults to original message's MSH-11 |
62
- | `options.error` | `AckException` | Sets the MSA-1 code and populates MSA-3 with the error message |
63
- | `options.includeErrSegment` | `boolean` | Include ERR segment when an error is provided. Defaults to `true` |
56
+ All four extend `AckException`, which extends `Error`. The `code` property carries the MSA-1 value (`AckNakCode`); `options` is an `AckExceptionOptions`:
64
57
 
65
- Returns a `Root` node containing MSH, MSA, and optionally ERR segments.
58
+ | Option | Type | Description |
59
+ | ----------- | --------- | ------------------------------------------------------ |
60
+ | `errorCode` | `string` | ERR-3 condition code (Table 0357 — see `Hl7ErrorCode`) |
61
+ | `severity` | `string` | ERR-4 severity (Table 0516 — see `Severity`) |
62
+ | `text` | `string` | MSA-3 text message, when derived from a remote NAK |
63
+ | `controlId` | `string` | MSA-2 control ID, when derived from a remote NAK |
64
+ | `cause` | `unknown` | Standard error cause |
66
65
 
67
- ### Exception classes
66
+ Three pre-configured subclasses cover common cases:
68
67
 
69
68
  ```ts
70
- new AckApplicationError(message, { errorCode, severity?, cause? })
71
- new AckApplicationReject(message, { errorCode, severity?, cause? })
72
- new AckCommitError(message, { errorCode, severity?, cause? })
73
- new AckCommitReject(message, { errorCode, severity?, cause? })
69
+ new ApplicationInternalError(message, cause?); // AE, code 207
70
+ new UnsupportedMessageTypeReject(message); // AR, code 200
71
+ new CommitInternalError(message, cause?); // CE, code 207
74
72
  ```
75
73
 
76
- All four extend `AckException`, which extends `Error`. Pre-configured convenience subclasses are exported for common cases: `ApplicationInternalError` (AE, code 207), `UnsupportedMessageTypeReject` (AR, code 200), `CommitInternalError` (CE, code 207). The standard `cause` option supports error chains.
77
-
78
- ### `uid(options?)`
79
-
80
- Generates a unique identifier suitable for MSH-10 control IDs.
74
+ ### Type guards
81
75
 
82
- | Parameter | Type | Default | Description |
83
- | ---------------- | -------- | ------- | -------------------------------- |
84
- | `options.prefix` | `string` | — | Optional prefix for the ID |
85
- | `options.size` | `number` | `20` | Total length of the generated ID |
76
+ `isAckCode(value)` narrows a string to `AckCode` (any of the six Table 0008 codes). `isAckNakCode(value)` narrows to `AckNakCode` (`AE` / `AR` / `CE` / `CR`); on an `AckCode`, the negative branch narrows to `AckSuccessCode` (`AA` / `CA`).
86
77
 
87
78
  ### Constants
88
79
 
89
- `AckCode`, `Hl7ErrorCode`, and `Severity` are exported as const objects with the standard HL7v2 enumeration values.
80
+ `AckCode`, `Hl7ErrorCode`, and `Severity` are const objects with the standard HL7v2 enumeration values. Each name is also the union type of its values — `const code: AckCode = AckCode.ApplicationAccept`.
90
81
 
91
82
  ## Acknowledgment codes
92
83
 
93
- HL7v2 distinguishes two levels of acknowledgment — **application** and **commit** — and each has accept, error, and reject variants. The exception class you throw determines MSA-1 directly.
84
+ HL7v2 distinguishes two levels of acknowledgment — **application** and **commit** — and each has accept, error, and reject variants. The exception class determines MSA-1 directly.
94
85
 
95
86
  | Class | MSA-1 | Meaning |
96
87
  | ---------------------- | ----- | ---------------------------------------------------------------------- |
@@ -100,7 +91,7 @@ HL7v2 distinguishes two levels of acknowledgment — **application** and **commi
100
91
  | `AckCommitError` | CE | Commit error (enhanced mode). Persistence or downstream failure. |
101
92
  | `AckCommitReject` | CR | Commit reject (enhanced mode). Refused at the commit layer. |
102
93
 
103
- When an exception is passed via `options.error`, its `errorCode` and `severity` populate the ERR segment. The error's `message` populates MSA-3 (text message).
94
+ When a server renders the response, the exception's `message` becomes MSA-3 text. `errorCode` and `severity` stay data: the application renders them in whatever ERR shape its HL7v2 version requires.
104
95
 
105
96
  ## Part of Glion
106
97
 
@@ -7,9 +7,11 @@ export declare const AckCode: {
7
7
  readonly CommitError: "CE";
8
8
  readonly CommitReject: "CR";
9
9
  };
10
- export type AckCodeValue = (typeof AckCode)[keyof typeof AckCode];
10
+ export type AckCode = (typeof AckCode)[keyof typeof AckCode];
11
11
  /** Accept codes used as `successCode` in `acknowledge()`. */
12
12
  export type AckSuccessCode = typeof AckCode.ApplicationAccept | typeof AckCode.CommitAccept;
13
+ /** Reject/error codes — the NAK half of Table 0008. */
14
+ export type AckNakCode = typeof AckCode.ApplicationError | typeof AckCode.ApplicationReject | typeof AckCode.CommitError | typeof AckCode.CommitReject;
13
15
  /**
14
16
  * HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across
15
17
  * all versions (v2.1–v2.9).
@@ -29,12 +31,12 @@ export declare const Hl7ErrorCode: {
29
31
  readonly UnsupportedProcessingId: "202";
30
32
  readonly UnsupportedVersionId: "203";
31
33
  };
32
- export type Hl7ErrorCodeValue = (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];
34
+ export type Hl7ErrorCode = (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];
33
35
  /** HL7v2 Table 0516 — Error severity codes used in ERR-4. */
34
36
  export declare const Severity: {
35
37
  readonly Error: "E";
36
38
  readonly Info: "I";
37
39
  readonly Warning: "W";
38
40
  };
39
- export type SeverityValue = (typeof Severity)[keyof typeof Severity];
41
+ export type Severity = (typeof Severity)[keyof typeof Severity];
40
42
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAElE,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GACtB,OAAO,OAAO,CAAC,iBAAiB,GAChC,OAAO,OAAO,CAAC,YAAY,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcf,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEnD,6DAA6D;AAC7D,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GACtB,OAAO,OAAO,CAAC,iBAAiB,GAChC,OAAO,OAAO,CAAC,YAAY,CAAC;AAEhC,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAClB,OAAO,OAAO,CAAC,gBAAgB,GAC/B,OAAO,OAAO,CAAC,iBAAiB,GAChC,OAAO,OAAO,CAAC,WAAW,GAC1B,OAAO,OAAO,CAAC,YAAY,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,6DAA6D;AAC7D,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
@@ -3,8 +3,7 @@ import { AckApplicationError } from "../exception";
3
3
  * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).
4
4
  *
5
5
  * Used to wrap unexpected/unknown errors that don't map to a specific
6
- * HL7v2 error condition. This is the default error produced by
7
- * `ackMiddleware` when a handler throws an unrecognized exception.
6
+ * HL7v2 error condition.
8
7
  */
9
8
  export declare class ApplicationInternalError extends AckApplicationError {
10
9
  constructor(message: string, cause?: Error);
@@ -1 +1 @@
1
- {"version":3,"file":"application-internal-error.d.ts","sourceRoot":"","sources":["../../src/errors/application-internal-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,mBAAmB;gBACnD,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAQ3C"}
1
+ {"version":3,"file":"application-internal-error.d.ts","sourceRoot":"","sources":["../../src/errors/application-internal-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,mBAAmB;gBACnD,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAQ3C"}
@@ -1,40 +1,56 @@
1
- import type { Segment } from "@glion/ast";
2
- import type { AckCodeValue, Hl7ErrorCodeValue, SeverityValue } from "./constants";
1
+ import type { AckNakCode } from "./constants";
3
2
  export interface AckExceptionOptions extends ErrorOptions {
4
- errorCode: Hl7ErrorCodeValue;
5
- severity?: SeverityValue;
6
3
  /**
7
- * The raw HL7v2 ACK message associated with this exception, when one
8
- * exists. Set when the exception is derived from an existing ACK;
9
- * left undefined when no ACK has been produced yet.
4
+ * ERR-3 condition code (Table 0357 — see {@link Hl7ErrorCode}). A known
5
+ * code when building an outbound rejection; an arbitrary peer-supplied
6
+ * string — or absent — when derived from an inbound ACK that may carry a
7
+ * non-standard code or no ERR segment at all.
10
8
  */
11
- raw?: string;
9
+ errorCode?: string;
10
+ /**
11
+ * ERR-4 severity (Table 0516 — see `Severity`); optional for inbound
12
+ * ACKs.
13
+ */
14
+ severity?: string;
15
+ /**
16
+ * MSA-3 text message — the remote system's own diagnostic sentence, when
17
+ * the NAK carried one. Exceptions deliberately do not carry the full ACK
18
+ * payload (raw text or AST): message content on an exception ends up in
19
+ * logs and error trackers, and full HL7v2 payloads carry PHI.
20
+ */
21
+ text?: string;
22
+ /**
23
+ * MSA-2 message control ID echoed from the original MSH-10 of the
24
+ * message the receiver is rejecting. Present when the exception is
25
+ * derived from an inbound ACK; absent when synthesised before any
26
+ * acknowledgment exists.
27
+ */
28
+ controlId?: string;
12
29
  }
13
30
  /**
14
31
  * Abstract base class for all HL7v2 acknowledgment exceptions.
15
32
  *
16
33
  * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).
17
34
  * Each exception carries an error code (Table 0357), optional severity
18
- * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.
35
+ * (Table 0516). Building an ERR segment is deliberately left to the
36
+ * implementation: its layout changed across HL7v2 versions (ELD in ERR-1
37
+ * before v2.5, ERR-3/ERR-4 after), so a version-agnostic package carries
38
+ * the data instead of rendering the segment.
19
39
  *
20
40
  * Use `instanceof AckException` to detect any ACK-level error in middleware.
21
41
  */
22
42
  export declare abstract class AckException extends Error {
23
- abstract readonly code: AckCodeValue;
24
- readonly errorCode: Hl7ErrorCodeValue;
25
- readonly severity: SeverityValue | undefined;
43
+ abstract readonly code: AckNakCode;
44
+ readonly errorCode: string | undefined;
45
+ readonly severity: string | undefined;
46
+ /** MSA-3 text message from the remote NAK, when present. */
47
+ readonly text: string | undefined;
26
48
  /**
27
- * The raw HL7v2 ACK message associated with this exception, when one
28
- * exists. Set when the exception is derived from an existing ACK;
29
- * left undefined when no ACK has been produced yet.
49
+ * MSA-2 control ID echoed from the original MSH-10. Present when the
50
+ * exception is derived from an inbound ACK; absent otherwise.
30
51
  */
31
- readonly raw: string | undefined;
52
+ readonly controlId: string | undefined;
32
53
  constructor(message: string, options: AckExceptionOptions);
33
- /**
34
- * Build an ERR segment AST node from this exception's error code and
35
- * severity.
36
- */
37
- toErrSegment(): Segment;
38
54
  }
39
55
  /**
40
56
  * Application-level error (MSA-1 = `AE`).
@@ -1 +1 @@
1
- {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EA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./constants`.
4
+ *
5
+ * @module
6
+ */
7
+ import { AckCode } from "./constants";
8
+ import type { AckNakCode, AckSuccessCode } from "./constants";
9
+ /** Narrow an arbitrary string to a Table 0008 acknowledgment code. */
10
+ export declare function isAckCode(value: string): value is AckCode;
11
+ /**
12
+ * Narrow an arbitrary string to a NAK code — the reject half of Table 0008,
13
+ * defined the way the spec defines it: any acknowledgment code that is not
14
+ * an accept.
15
+ */
16
+ export declare function isAckNakCode(value: string): value is AckNakCode;
17
+ /**
18
+ * Narrow an arbitrary string to an accept code — the accept half of Table
19
+ * 0008, and the complement of {@link isAckNakCode}.
20
+ */
21
+ export declare function isAckSuccessCode(value: string): value is AckSuccessCode;
22
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK9D,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,OAAO,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAM/D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- export { acknowledge } from "./acknowledge";
2
- export type { AcknowledgeOptions, SendingInfo } from "./acknowledge";
3
1
  export { AckCode, Hl7ErrorCode, Severity } from "./constants";
4
- export type { AckCodeValue, AckSuccessCode, Hl7ErrorCodeValue, SeverityValue, } from "./constants";
2
+ export { isAckCode, isAckNakCode, isAckSuccessCode } from "./helper";
3
+ export type { AckNakCode, AckSuccessCode } from "./constants";
5
4
  export { AckApplicationError, AckApplicationReject, AckCommitError, AckCommitReject, AckException, } from "./exception";
6
5
  export type { AckExceptionOptions } from "./exception";
7
6
  export { ApplicationInternalError, CommitInternalError, UnsupportedMessageTypeReject, } from "./errors";
8
- export { uid } from "./uid";
9
- export type { Options as UidOptions } from "./uid";
10
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,3 @@
1
- import { c, f, m, s } from "@glion/builder";
2
- import { value } from "@glion/util-query";
3
- import { Timestamp } from "@glion/util-timestamp";
4
- import { nanoid } from "nanoid";
5
1
  //#region src/constants.ts
6
2
  /** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */
7
3
  const AckCode = {
@@ -38,50 +34,32 @@ const Severity = {
38
34
  Warning: "W"
39
35
  };
40
36
  //#endregion
41
- //#region src/uid.ts
42
- const MAX_LENGTH = 20;
43
- function uid(options = {}) {
44
- const { prefix, size = MAX_LENGTH } = options;
45
- if (!prefix) return nanoid(size);
46
- const remaining = size - prefix.length;
47
- if (remaining <= 0) return prefix.slice(0, size);
48
- return `${prefix}${nanoid(remaining)}`;
49
- }
50
- //#endregion
51
- //#region src/acknowledge.ts
52
- function extractOriginFields(tree) {
53
- return {
54
- controlId: value(tree, "MSH-10")?.value ?? "",
55
- processingId: value(tree, "MSH-11")?.value ?? "P",
56
- receivingApp: value(tree, "MSH-5")?.value ?? "",
57
- receivingFac: value(tree, "MSH-6")?.value ?? "",
58
- sendingApp: value(tree, "MSH-3")?.value ?? "",
59
- sendingFac: value(tree, "MSH-4")?.value ?? "",
60
- triggerEvent: value(tree, "MSH-9.2")?.value ?? "",
61
- version: value(tree, "MSH-12.1")?.value ?? ""
62
- };
63
- }
64
- function buildMsh(origin, options) {
65
- const sendApp = options.sending?.application ?? origin.receivingApp;
66
- const sendFac = options.sending?.facility ?? origin.receivingFac;
67
- const pid = options.processingId ?? origin.processingId;
68
- const controlId = options.id ?? uid();
69
- const msgType = origin.triggerEvent ? f(c("ACK"), c(origin.triggerEvent)) : f("ACK");
70
- return s("MSH", f("|"), f("^~\\&"), f(sendApp), f(sendFac), f(origin.sendingApp), f(origin.sendingFac), f(Timestamp.now().toString()), f(""), msgType, f(controlId), f(pid), f(origin.version));
37
+ //#region src/helper.ts
38
+ /**
39
+ * Type guards over the HL7v2 Table 0008 acknowledgment codes — the runtime
40
+ * half of `./constants`.
41
+ *
42
+ * @module
43
+ */
44
+ const ACK_CODES = new Set(Object.values(AckCode));
45
+ /** Narrow an arbitrary string to a Table 0008 acknowledgment code. */
46
+ function isAckCode(value) {
47
+ return ACK_CODES.has(value);
71
48
  }
72
- function buildMsa(code, controlId, message) {
73
- return message ? s("MSA", f(code), f(controlId), f(message)) : s("MSA", f(code), f(controlId));
49
+ /**
50
+ * Narrow an arbitrary string to a NAK code — the reject half of Table 0008,
51
+ * defined the way the spec defines it: any acknowledgment code that is not
52
+ * an accept.
53
+ */
54
+ function isAckNakCode(value) {
55
+ return isAckCode(value) && value !== AckCode.ApplicationAccept && value !== AckCode.CommitAccept;
74
56
  }
75
- function acknowledge(origin, { id, processingId, sending, error, includeErrSegment = true, successCode = AckCode.ApplicationAccept } = {}) {
76
- const fields = extractOriginFields(origin);
77
- const code = error?.code ?? successCode;
78
- const segments = [buildMsh(fields, {
79
- id,
80
- processingId,
81
- sending
82
- }), buildMsa(code, fields.controlId, error?.message)];
83
- if (error && includeErrSegment) segments.push(error.toErrSegment());
84
- return m(...segments);
57
+ /**
58
+ * Narrow an arbitrary string to an accept code — the accept half of Table
59
+ * 0008, and the complement of {@link isAckNakCode}.
60
+ */
61
+ function isAckSuccessCode(value) {
62
+ return value === AckCode.ApplicationAccept || value === AckCode.CommitAccept;
85
63
  }
86
64
  //#endregion
87
65
  //#region src/exception.ts
@@ -90,31 +68,29 @@ function acknowledge(origin, { id, processingId, sending, error, includeErrSegme
90
68
  *
91
69
  * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).
92
70
  * Each exception carries an error code (Table 0357), optional severity
93
- * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.
71
+ * (Table 0516). Building an ERR segment is deliberately left to the
72
+ * implementation: its layout changed across HL7v2 versions (ELD in ERR-1
73
+ * before v2.5, ERR-3/ERR-4 after), so a version-agnostic package carries
74
+ * the data instead of rendering the segment.
94
75
  *
95
76
  * Use `instanceof AckException` to detect any ACK-level error in middleware.
96
77
  */
97
78
  var AckException = class extends Error {
98
79
  errorCode;
99
80
  severity;
81
+ /** MSA-3 text message from the remote NAK, when present. */
82
+ text;
100
83
  /**
101
- * The raw HL7v2 ACK message associated with this exception, when one
102
- * exists. Set when the exception is derived from an existing ACK;
103
- * left undefined when no ACK has been produced yet.
84
+ * MSA-2 control ID echoed from the original MSH-10. Present when the
85
+ * exception is derived from an inbound ACK; absent otherwise.
104
86
  */
105
- raw;
87
+ controlId;
106
88
  constructor(message, options) {
107
89
  super(message, { cause: options.cause });
108
90
  this.errorCode = options.errorCode;
109
91
  this.severity = options.severity;
110
- this.raw = options.raw;
111
- }
112
- /**
113
- * Build an ERR segment AST node from this exception's error code and
114
- * severity.
115
- */
116
- toErrSegment() {
117
- return s("ERR", f(""), f(""), f(this.errorCode), f(this.severity ?? Severity.Error));
92
+ this.text = options.text;
93
+ this.controlId = options.controlId;
118
94
  }
119
95
  };
120
96
  /**
@@ -175,8 +151,7 @@ var AckCommitReject = class extends AckException {
175
151
  * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).
176
152
  *
177
153
  * Used to wrap unexpected/unknown errors that don't map to a specific
178
- * HL7v2 error condition. This is the default error produced by
179
- * `ackMiddleware` when a handler throws an unrecognized exception.
154
+ * HL7v2 error condition.
180
155
  */
181
156
  var ApplicationInternalError = class extends AckApplicationError {
182
157
  constructor(message, cause) {
@@ -224,6 +199,6 @@ var UnsupportedMessageTypeReject = class extends AckApplicationReject {
224
199
  }
225
200
  };
226
201
  //#endregion
227
- export { AckApplicationError, AckApplicationReject, AckCode, AckCommitError, AckCommitReject, AckException, ApplicationInternalError, CommitInternalError, Hl7ErrorCode, Severity, UnsupportedMessageTypeReject, acknowledge, uid };
202
+ export { AckApplicationError, AckApplicationReject, AckCode, AckCommitError, AckCommitReject, AckException, ApplicationInternalError, CommitInternalError, Hl7ErrorCode, Severity, UnsupportedMessageTypeReject, isAckCode, isAckNakCode, isAckSuccessCode };
228
203
 
229
204
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../src/uid.ts","../src/acknowledge.ts","../src/exception.ts","../src/errors/application-internal-error.ts","../src/errors/commit-internal-error.ts","../src/errors/unsupported-message-type-reject.ts"],"sourcesContent":["/** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */\nexport const AckCode = {\n ApplicationAccept: \"AA\",\n ApplicationError: \"AE\",\n ApplicationReject: \"AR\",\n CommitAccept: \"CA\",\n CommitError: \"CE\",\n CommitReject: \"CR\",\n} as const;\n\nexport type AckCodeValue = (typeof AckCode)[keyof typeof AckCode];\n\n/** Accept codes used as `successCode` in `acknowledge()`. */\nexport type AckSuccessCode =\n | typeof AckCode.ApplicationAccept\n | typeof AckCode.CommitAccept;\n\n/**\n * HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across\n * all versions (v2.1–v2.9).\n */\nexport const Hl7ErrorCode = {\n ApplicationInternalError: \"207\",\n ApplicationRecordLocked: \"206\",\n DataTypeError: \"102\",\n DuplicateKeyIdentifier: \"205\",\n MessageAccepted: \"0\",\n RequiredFieldMissing: \"101\",\n SegmentSequenceError: \"100\",\n TableValueNotFound: \"103\",\n UnknownKeyIdentifier: \"204\",\n UnsupportedEventCode: \"201\",\n UnsupportedMessageType: \"200\",\n UnsupportedProcessingId: \"202\",\n UnsupportedVersionId: \"203\",\n} as const;\n\nexport type Hl7ErrorCodeValue =\n (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];\n\n/** HL7v2 Table 0516 — Error severity codes used in ERR-4. */\nexport const Severity = {\n Error: \"E\",\n Info: \"I\",\n Warning: \"W\",\n} as const;\n\nexport type SeverityValue = (typeof Severity)[keyof typeof Severity];\n","import { nanoid } from \"nanoid\";\n\nconst MAX_LENGTH = 20;\n\nexport interface Options {\n prefix?: string;\n size?: number;\n}\n\nexport function uid(options: Options = {}): string {\n const { prefix, size = MAX_LENGTH } = options;\n\n if (!prefix) {\n return nanoid(size);\n }\n\n const remaining = size - prefix.length;\n\n if (remaining <= 0) {\n return prefix.slice(0, size);\n }\n\n return `${prefix}${nanoid(remaining)}`;\n}\n","import type { Root, Segment } from \"@glion/ast\";\nimport { c, f, m, s } from \"@glion/builder\";\nimport { value } from \"@glion/util-query\";\nimport { Timestamp } from \"@glion/util-timestamp\";\n\nimport { AckCode } from \"./constants\";\nimport type { AckSuccessCode } from \"./constants\";\nimport type { AckException } from \"./exception\";\nimport { uid } from \"./uid\";\n\nexport interface SendingInfo {\n application: string;\n facility: string;\n}\n\nexport type AcknowledgeOptions = {\n /** Custom MSH-10 control ID. Auto-generated via `uid()` when omitted. */\n id?: string;\n /** MSH-3/MSH-4 of the ACK. Defaults to the original message's MSH-5/MSH-6. */\n sending?: SendingInfo;\n /** MSH-11 processing ID. Defaults to the original message's MSH-11. */\n processingId?: string;\n} & (\n | {\n /**\n * Sets the ACK code (AE/AR/CE/CR) and populates MSA-3 with the error\n * message.\n */\n error: AckException;\n /** Include ERR segment when an error is provided. Defaults to `true`. */\n includeErrSegment?: boolean;\n successCode?: never;\n }\n | {\n error?: never;\n includeErrSegment?: never;\n /**\n * MSA-1 code when no error is present. Defaults to\n * `AckCode.ApplicationAccept`.\n */\n successCode?: AckSuccessCode;\n }\n);\n\n// -- Field extraction ----\n\ninterface OriginFields {\n controlId: string;\n version: string;\n triggerEvent: string;\n processingId: string;\n sendingApp: string;\n sendingFac: string;\n receivingApp: string;\n receivingFac: string;\n}\n\nfunction extractOriginFields(tree: Root): OriginFields {\n return {\n controlId: value(tree, \"MSH-10\")?.value ?? \"\",\n processingId: value(tree, \"MSH-11\")?.value ?? \"P\",\n receivingApp: value(tree, \"MSH-5\")?.value ?? \"\",\n receivingFac: value(tree, \"MSH-6\")?.value ?? \"\",\n sendingApp: value(tree, \"MSH-3\")?.value ?? \"\",\n sendingFac: value(tree, \"MSH-4\")?.value ?? \"\",\n triggerEvent: value(tree, \"MSH-9.2\")?.value ?? \"\",\n version: value(tree, \"MSH-12.1\")?.value ?? \"\",\n };\n}\n\n// -- Segment builders ----\n\nfunction buildMsh(\n origin: OriginFields,\n options: Pick<AcknowledgeOptions, \"id\" | \"sending\" | \"processingId\">\n): Segment {\n const sendApp = options.sending?.application ?? origin.receivingApp;\n const sendFac = options.sending?.facility ?? origin.receivingFac;\n const pid = options.processingId ?? origin.processingId;\n const controlId = options.id ?? uid();\n const msgType = origin.triggerEvent\n ? f(c(\"ACK\"), c(origin.triggerEvent))\n : f(\"ACK\");\n\n return s(\n \"MSH\",\n f(\"|\"),\n f(\"^~\\\\&\"),\n f(sendApp),\n f(sendFac),\n f(origin.sendingApp),\n f(origin.sendingFac),\n f(Timestamp.now().toString()),\n f(\"\"),\n msgType,\n f(controlId),\n f(pid),\n f(origin.version)\n );\n}\n\nfunction buildMsa(code: string, controlId: string, message?: string): Segment {\n return message\n ? s(\"MSA\", f(code), f(controlId), f(message))\n : s(\"MSA\", f(code), f(controlId));\n}\n\n// -- Public API ----\n\nexport function acknowledge(\n origin: Root,\n {\n id,\n processingId,\n sending,\n error,\n includeErrSegment = true,\n successCode = AckCode.ApplicationAccept,\n }: AcknowledgeOptions = {}\n): Root {\n const fields = extractOriginFields(origin);\n const code = error?.code ?? successCode;\n\n const segments: Segment[] = [\n buildMsh(fields, {\n id,\n processingId,\n sending,\n }),\n buildMsa(code, fields.controlId, error?.message),\n ];\n\n if (error && includeErrSegment) {\n segments.push(error.toErrSegment());\n }\n\n return m(...segments);\n}\n","import type { Segment } from \"@glion/ast\";\nimport { f, s } from \"@glion/builder\";\n\nimport { AckCode, Severity } from \"./constants\";\nimport type {\n AckCodeValue,\n Hl7ErrorCodeValue,\n SeverityValue,\n} from \"./constants\";\n\nexport interface AckExceptionOptions extends ErrorOptions {\n errorCode: Hl7ErrorCodeValue;\n severity?: SeverityValue;\n /**\n * The raw HL7v2 ACK message associated with this exception, when one\n * exists. Set when the exception is derived from an existing ACK;\n * left undefined when no ACK has been produced yet.\n */\n raw?: string;\n}\n\n/**\n * Abstract base class for all HL7v2 acknowledgment exceptions.\n *\n * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).\n * Each exception carries an error code (Table 0357), optional severity\n * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.\n *\n * Use `instanceof AckException` to detect any ACK-level error in middleware.\n */\nexport abstract class AckException extends Error {\n abstract readonly code: AckCodeValue;\n readonly errorCode: Hl7ErrorCodeValue;\n readonly severity: SeverityValue | undefined;\n /**\n * The raw HL7v2 ACK message associated with this exception, when one\n * exists. Set when the exception is derived from an existing ACK;\n * left undefined when no ACK has been produced yet.\n */\n readonly raw: string | undefined;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, { cause: options.cause });\n this.errorCode = options.errorCode;\n this.severity = options.severity;\n this.raw = options.raw;\n }\n\n /**\n * Build an ERR segment AST node from this exception's error code and\n * severity.\n */\n toErrSegment(): Segment {\n return s(\n \"ERR\",\n f(\"\"),\n f(\"\"),\n f(this.errorCode),\n f(this.severity ?? Severity.Error)\n );\n }\n}\n\n/**\n * Application-level error (MSA-1 = `AE`).\n *\n * Throw when the message was understood but could not be processed\n * due to an application-level problem (e.g. validation failure, unknown key).\n */\nexport class AckApplicationError extends AckException {\n readonly code = AckCode.ApplicationError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationError\";\n }\n}\n\n/**\n * Application-level reject (MSA-1 = `AR`).\n *\n * Throw when the message is rejected outright at the application level\n * (e.g. unsupported message type, unsupported version).\n */\nexport class AckApplicationReject extends AckException {\n readonly code = AckCode.ApplicationReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationReject\";\n }\n}\n\n/**\n * Commit-level error (MSA-1 = `CE`).\n *\n * Throw when the message could not be safely persisted/committed\n * (e.g. storage failure). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitError extends AckException {\n readonly code = AckCode.CommitError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitError\";\n }\n}\n\n/**\n * Commit-level reject (MSA-1 = `CR`).\n *\n * Throw when the message is rejected at the commit level\n * (e.g. message cannot be stored). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitReject extends AckException {\n readonly code = AckCode.CommitReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitReject\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationError } from \"../exception\";\n\n/**\n * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used to wrap unexpected/unknown errors that don't map to a specific\n * HL7v2 error condition. This is the default error produced by\n * `ackMiddleware` when a handler throws an unrecognized exception.\n */\nexport class ApplicationInternalError extends AckApplicationError {\n constructor(message: string, cause?: Error) {\n super(message, {\n cause,\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n });\n this.name = \"ApplicationInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckCommitError } from \"../exception\";\n\n/**\n * Commit-level internal error (MSA-1 = `CE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used when the message could not be persisted due to an internal\n * infrastructure failure (e.g. database unavailable).\n */\nexport class CommitInternalError extends AckCommitError {\n constructor(message: string, cause?: Error) {\n super(message, {\n cause,\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n });\n this.name = \"CommitInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationReject } from \"../exception\";\n\n/**\n * Unsupported message type reject (MSA-1 = `AR`, ERR-3 = `200`, ERR-4 = `E`).\n *\n * Throw when the receiving application does not handle the inbound\n * message type (e.g. ADT^A01 sent to a system that only accepts ORU).\n */\nexport class UnsupportedMessageTypeReject extends AckApplicationReject {\n constructor(message: string) {\n super(message, {\n errorCode: Hl7ErrorCode.UnsupportedMessageType,\n severity: Severity.Error,\n });\n this.name = \"UnsupportedMessageTypeReject\";\n }\n}\n"],"mappings":";;;;;;AACA,MAAa,UAAU;CACrB,mBAAmB;CACnB,kBAAkB;CAClB,mBAAmB;CACnB,cAAc;CACd,aAAa;CACb,cAAc;CACf;;;;;AAaD,MAAa,eAAe;CAC1B,0BAA0B;CAC1B,yBAAyB;CACzB,eAAe;CACf,wBAAwB;CACxB,iBAAiB;CACjB,sBAAsB;CACtB,sBAAsB;CACtB,oBAAoB;CACpB,sBAAsB;CACtB,sBAAsB;CACtB,wBAAwB;CACxB,yBAAyB;CACzB,sBAAsB;CACvB;;AAMD,MAAa,WAAW;CACtB,OAAO;CACP,MAAM;CACN,SAAS;CACV;;;AC3CD,MAAM,aAAa;AAOnB,SAAgB,IAAI,UAAmB,EAAE,EAAU;CACjD,MAAM,EAAE,QAAQ,OAAO,eAAe;AAEtC,KAAI,CAAC,OACH,QAAO,OAAO,KAAK;CAGrB,MAAM,YAAY,OAAO,OAAO;AAEhC,KAAI,aAAa,EACf,QAAO,OAAO,MAAM,GAAG,KAAK;AAG9B,QAAO,GAAG,SAAS,OAAO,UAAU;;;;ACmCtC,SAAS,oBAAoB,MAA0B;AACrD,QAAO;EACL,WAAW,MAAM,MAAM,SAAS,EAAE,SAAS;EAC3C,cAAc,MAAM,MAAM,SAAS,EAAE,SAAS;EAC9C,cAAc,MAAM,MAAM,QAAQ,EAAE,SAAS;EAC7C,cAAc,MAAM,MAAM,QAAQ,EAAE,SAAS;EAC7C,YAAY,MAAM,MAAM,QAAQ,EAAE,SAAS;EAC3C,YAAY,MAAM,MAAM,QAAQ,EAAE,SAAS;EAC3C,cAAc,MAAM,MAAM,UAAU,EAAE,SAA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Aa;GACxB,UAAU,SAAS;GACpB,CAAC;AACF,OAAK,OAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../src/helper.ts","../src/exception.ts","../src/errors/application-internal-error.ts","../src/errors/commit-internal-error.ts","../src/errors/unsupported-message-type-reject.ts"],"sourcesContent":["/** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */\nexport const AckCode = {\n ApplicationAccept: \"AA\",\n ApplicationError: \"AE\",\n ApplicationReject: \"AR\",\n CommitAccept: \"CA\",\n CommitError: \"CE\",\n CommitReject: \"CR\",\n} as const;\n\nexport type AckCode = (typeof AckCode)[keyof typeof AckCode];\n\n/** Accept codes used as `successCode` in `acknowledge()`. */\nexport type AckSuccessCode =\n | typeof AckCode.ApplicationAccept\n | typeof AckCode.CommitAccept;\n\n/** Reject/error codes — the NAK half of Table 0008. */\nexport type AckNakCode =\n | typeof AckCode.ApplicationError\n | typeof AckCode.ApplicationReject\n | typeof AckCode.CommitError\n | typeof AckCode.CommitReject;\n\n/**\n * HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across\n * all versions (v2.1–v2.9).\n */\nexport const Hl7ErrorCode = {\n ApplicationInternalError: \"207\",\n ApplicationRecordLocked: \"206\",\n DataTypeError: \"102\",\n DuplicateKeyIdentifier: \"205\",\n MessageAccepted: \"0\",\n RequiredFieldMissing: \"101\",\n SegmentSequenceError: \"100\",\n TableValueNotFound: \"103\",\n UnknownKeyIdentifier: \"204\",\n UnsupportedEventCode: \"201\",\n UnsupportedMessageType: \"200\",\n UnsupportedProcessingId: \"202\",\n UnsupportedVersionId: \"203\",\n} as const;\n\nexport type Hl7ErrorCode = (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];\n\n/** HL7v2 Table 0516 — Error severity codes used in ERR-4. */\nexport const Severity = {\n Error: \"E\",\n Info: \"I\",\n Warning: \"W\",\n} as const;\n\nexport type Severity = (typeof Severity)[keyof typeof Severity];\n","/**\n * Type guards over the HL7v2 Table 0008 acknowledgment codes — the runtime\n * half of `./constants`.\n *\n * @module\n */\n\nimport { AckCode } from \"./constants\";\nimport type { AckNakCode, AckSuccessCode } from \"./constants\";\n\n// Derived from AckCode, so the guard can never drift from the table.\nconst ACK_CODES: ReadonlySet<string> = new Set(Object.values(AckCode));\n\n/** Narrow an arbitrary string to a Table 0008 acknowledgment code. */\nexport function isAckCode(value: string): value is AckCode {\n return ACK_CODES.has(value);\n}\n\n/**\n * Narrow an arbitrary string to a NAK code — the reject half of Table 0008,\n * defined the way the spec defines it: any acknowledgment code that is not\n * an accept.\n */\nexport function isAckNakCode(value: string): value is AckNakCode {\n return (\n isAckCode(value) &&\n value !== AckCode.ApplicationAccept &&\n value !== AckCode.CommitAccept\n );\n}\n\n/**\n * Narrow an arbitrary string to an accept code — the accept half of Table\n * 0008, and the complement of {@link isAckNakCode}.\n */\nexport function isAckSuccessCode(value: string): value is AckSuccessCode {\n return value === AckCode.ApplicationAccept || value === AckCode.CommitAccept;\n}\n","import { AckCode } from \"./constants\";\nimport type { AckNakCode } from \"./constants\";\n\nexport interface AckExceptionOptions extends ErrorOptions {\n /**\n * ERR-3 condition code (Table 0357 — see {@link Hl7ErrorCode}). A known\n * code when building an outbound rejection; an arbitrary peer-supplied\n * string — or absent — when derived from an inbound ACK that may carry a\n * non-standard code or no ERR segment at all.\n */\n errorCode?: string;\n /**\n * ERR-4 severity (Table 0516 — see `Severity`); optional for inbound\n * ACKs.\n */\n severity?: string;\n /**\n * MSA-3 text message — the remote system's own diagnostic sentence, when\n * the NAK carried one. Exceptions deliberately do not carry the full ACK\n * payload (raw text or AST): message content on an exception ends up in\n * logs and error trackers, and full HL7v2 payloads carry PHI.\n */\n text?: string;\n /**\n * MSA-2 message control ID echoed from the original MSH-10 of the\n * message the receiver is rejecting. Present when the exception is\n * derived from an inbound ACK; absent when synthesised before any\n * acknowledgment exists.\n */\n controlId?: string;\n}\n\n/**\n * Abstract base class for all HL7v2 acknowledgment exceptions.\n *\n * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).\n * Each exception carries an error code (Table 0357), optional severity\n * (Table 0516). Building an ERR segment is deliberately left to the\n * implementation: its layout changed across HL7v2 versions (ELD in ERR-1\n * before v2.5, ERR-3/ERR-4 after), so a version-agnostic package carries\n * the data instead of rendering the segment.\n *\n * Use `instanceof AckException` to detect any ACK-level error in middleware.\n */\nexport abstract class AckException extends Error {\n abstract readonly code: AckNakCode;\n readonly errorCode: string | undefined;\n readonly severity: string | undefined;\n /** MSA-3 text message from the remote NAK, when present. */\n readonly text: string | undefined;\n /**\n * MSA-2 control ID echoed from the original MSH-10. Present when the\n * exception is derived from an inbound ACK; absent otherwise.\n */\n readonly controlId: string | undefined;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, { cause: options.cause });\n this.errorCode = options.errorCode;\n this.severity = options.severity;\n this.text = options.text;\n this.controlId = options.controlId;\n }\n}\n\n/**\n * Application-level error (MSA-1 = `AE`).\n *\n * Throw when the message was understood but could not be processed\n * due to an application-level problem (e.g. validation failure, unknown key).\n */\nexport class AckApplicationError extends AckException {\n readonly code = AckCode.ApplicationError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationError\";\n }\n}\n\n/**\n * Application-level reject (MSA-1 = `AR`).\n *\n * Throw when the message is rejected outright at the application level\n * (e.g. unsupported message type, unsupported version).\n */\nexport class AckApplicationReject extends AckException {\n readonly code = AckCode.ApplicationReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationReject\";\n }\n}\n\n/**\n * Commit-level error (MSA-1 = `CE`).\n *\n * Throw when the message could not be safely persisted/committed\n * (e.g. storage failure). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitError extends AckException {\n readonly code = AckCode.CommitError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitError\";\n }\n}\n\n/**\n * Commit-level reject (MSA-1 = `CR`).\n *\n * Throw when the message is rejected at the commit level\n * (e.g. message cannot be stored). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitReject extends AckException {\n readonly code = AckCode.CommitReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitReject\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationError } from \"../exception\";\n\n/**\n * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used to wrap unexpected/unknown errors that don't map to a specific\n * HL7v2 error condition.\n */\nexport class ApplicationInternalError extends AckApplicationError {\n constructor(message: string, cause?: Error) {\n super(message, {\n cause,\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n });\n this.name = \"ApplicationInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckCommitError } from \"../exception\";\n\n/**\n * Commit-level internal error (MSA-1 = `CE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used when the message could not be persisted due to an internal\n * infrastructure failure (e.g. database unavailable).\n */\nexport class CommitInternalError extends AckCommitError {\n constructor(message: string, cause?: Error) {\n super(message, {\n cause,\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n });\n this.name = \"CommitInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationReject } from \"../exception\";\n\n/**\n * Unsupported message type reject (MSA-1 = `AR`, ERR-3 = `200`, ERR-4 = `E`).\n *\n * Throw when the receiving application does not handle the inbound\n * message type (e.g. ADT^A01 sent to a system that only accepts ORU).\n */\nexport class UnsupportedMessageTypeReject extends AckApplicationReject {\n constructor(message: string) {\n super(message, {\n errorCode: Hl7ErrorCode.UnsupportedMessageType,\n severity: Severity.Error,\n });\n this.name = \"UnsupportedMessageTypeReject\";\n }\n}\n"],"mappings":";;AACA,MAAa,UAAU;CACrB,mBAAmB;CACnB,kBAAkB;CAClB,mBAAmB;CACnB,cAAc;CACd,aAAa;CACb,cAAc;CACf;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,OAAK,OAAO;;;;;;;;;AAUhB,IAAa,kBAAb,cAAqC,aAAa;CAChD,OAAgB,QAAQ;CAExB,YAAY,SAAiB,SAA8B;AACzD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;;;;;;;;;AChHhB,IAAa,2BAAb,cAA8C,oBAAoB;CAChE,YAAY,SAAiB,OAAe;AAC1C,QAAM,SAAS;GACb;GACA,WAAW,aAAa;GACxB,UAAU,SAAS;GACpB,CAAC;AACF,OAAK,OAAO;;;;;;;;;;;ACPhB,IAAa,sBAAb,cAAyC,eAAe;CACtD,YAAY,SAAiB,OAAe;AAC1C,QAAM,SAAS;GACb;GACA,WAAW,aAAa;GACxB,UAAU,SAAS;GACpB,CAAC;AACF,OAAK,OAAO;;;;;;;;;;;ACPhB,IAAa,+BAAb,cAAkD,qBAAqB;CACrE,YAAY,SAAiB;AAC3B,QAAM,SAAS;GACb,WAAW,aAAa;GACxB,UAAU,SAAS;GACpB,CAAC;AACF,OAAK,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/ack",
3
- "version": "0.16.0",
3
+ "version": "0.20.0",
4
4
  "description": "HL7v2 acknowledgment message builder and typed error classes",
5
5
  "keywords": [
6
6
  "ack",
@@ -34,30 +34,26 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "nanoid": "5.1.7",
38
- "@glion/ast": "0.16.0",
39
- "@glion/builder": "0.16.0",
40
- "@glion/util-query": "0.16.0",
41
- "@glion/util-timestamp": "0.16.0"
37
+ "@glion/ast": "0.20.0"
42
38
  },
43
39
  "devDependencies": {
44
40
  "@types/node": "25.6.0",
45
- "@vitest/coverage-v8": "4.1.5",
41
+ "@vitest/coverage-v8": "4.1.11",
46
42
  "publint": "0.3.18",
47
43
  "tsdown": "0.21.10",
48
44
  "typescript": "6.0.3",
49
- "vitest": "4.1.5",
50
- "@glion/to-hl7v2": "0.16.0",
51
- "@glion/tsconfig": "0.16.0",
52
- "@glion/check-readme": "0.16.0",
53
- "@glion/testing": "0.16.0"
45
+ "vitest": "4.1.11",
46
+ "@glion/check-readme": "0.18.0",
47
+ "@glion/testing": "0.18.0",
48
+ "@glion/to-hl7v2": "0.20.0",
49
+ "@glion/tsconfig": "0.18.0"
54
50
  },
55
51
  "engines": {
56
- "node": ">=20"
52
+ "node": ">=22"
57
53
  },
58
54
  "scripts": {
59
55
  "build": "tsdown && tsc --emitDeclarationOnly",
60
- "check-types": "tsc --noEmit",
56
+ "check-types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
61
57
  "check:readme": "glion-check-readme",
62
58
  "test": "vitest run",
63
59
  "test:coverage": "vitest run --coverage",
@@ -1,34 +0,0 @@
1
- import type { Root } from "@glion/ast";
2
- import type { AckSuccessCode } from "./constants";
3
- import type { AckException } from "./exception";
4
- export interface SendingInfo {
5
- application: string;
6
- facility: string;
7
- }
8
- export type AcknowledgeOptions = {
9
- /** Custom MSH-10 control ID. Auto-generated via `uid()` when omitted. */
10
- id?: string;
11
- /** MSH-3/MSH-4 of the ACK. Defaults to the original message's MSH-5/MSH-6. */
12
- sending?: SendingInfo;
13
- /** MSH-11 processing ID. Defaults to the original message's MSH-11. */
14
- processingId?: string;
15
- } & ({
16
- /**
17
- * Sets the ACK code (AE/AR/CE/CR) and populates MSA-3 with the error
18
- * message.
19
- */
20
- error: AckException;
21
- /** Include ERR segment when an error is provided. Defaults to `true`. */
22
- includeErrSegment?: boolean;
23
- successCode?: never;
24
- } | {
25
- error?: never;
26
- includeErrSegment?: never;
27
- /**
28
- * MSA-1 code when no error is present. Defaults to
29
- * `AckCode.ApplicationAccept`.
30
- */
31
- successCode?: AckSuccessCode;
32
- });
33
- export declare function acknowledge(origin: Root, { id, processingId, sending, error, includeErrSegment, successCode, }?: AcknowledgeOptions): Root;
34
- //# sourceMappingURL=acknowledge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acknowledge.d.ts","sourceRoot":"","sources":["../src/acknowledge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,YAAY,CAAC;AAMhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yEAAyE;IACzE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,CACA;IACE;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,iBAAiB,CAAC,EAAE,KAAK,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B,CACJ,CAAC;AAmEF,wBAAgB,WAAW,CACzB,MAAM,EAAE,IAAI,EACZ,EACE,EAAE,EACF,YAAY,EACZ,OAAO,EACP,KAAK,EACL,iBAAwB,EACxB,WAAuC,GACxC,GAAE,kBAAuB,GACzB,IAAI,CAkBN"}
package/dist/uid.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export interface Options {
2
- prefix?: string;
3
- size?: number;
4
- }
5
- export declare function uid(options?: Options): string;
6
- //# sourceMappingURL=uid.d.ts.map
package/dist/uid.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../src/uid.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,GAAG,CAAC,OAAO,GAAE,OAAY,GAAG,MAAM,CAcjD"}