@cosyte/x12 0.0.14 → 0.0.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/CHANGELOG.md +800 -5
- package/KNOWN-LIMITATIONS.md +553 -19
- package/README.md +1 -1
- package/dist/index.cjs +397 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -52
- package/dist/index.d.ts +233 -52
- package/dist/index.mjs +397 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -285,9 +285,7 @@ interface X12ParseWarning {
|
|
|
285
285
|
* Neither side is echoed, not truncated and not hashed. A control number is
|
|
286
286
|
* free-form trading-partner text on five of the six slots (only ISA-13 is
|
|
287
287
|
* fixed-width), routinely carries a batch or patient-account identifier in
|
|
288
|
-
* the field, and is entirely sender-controlled.
|
|
289
|
-
* `iea.elements[2]`, `gs.elements[6]`, `ge.elements[2]`, `st.elements[2]`
|
|
290
|
-
* and `se.elements[2]` off the model when you need the values.
|
|
288
|
+
* the field, and is entirely sender-controlled.
|
|
291
289
|
*
|
|
292
290
|
* @example
|
|
293
291
|
* ```ts
|
|
@@ -319,8 +317,7 @@ declare function pre005010(position: X12Position): X12ParseWarning;
|
|
|
319
317
|
* Build an `X12_GROUP_COUNT_MISMATCH` warning. Emitted when IEA-01 does not
|
|
320
318
|
* equal the actual number of GS..GE groups present in the interchange.
|
|
321
319
|
* Trading partners use this to detect transmission truncation. Both numbers
|
|
322
|
-
* stay on the model
|
|
323
|
-
* is silently corrected.
|
|
320
|
+
* stay on the model and neither is silently corrected.
|
|
324
321
|
*
|
|
325
322
|
* @example
|
|
326
323
|
* ```ts
|
|
@@ -332,8 +329,7 @@ declare function groupCountMismatch(position: X12Position): X12ParseWarning;
|
|
|
332
329
|
/**
|
|
333
330
|
* Build an `X12_TRANSACTION_COUNT_MISMATCH` warning. Emitted when GE-01
|
|
334
331
|
* does not equal the actual number of ST..SE transaction sets present in
|
|
335
|
-
* the group. Both numbers stay on the model
|
|
336
|
-
* `group.transactions.length`).
|
|
332
|
+
* the group. Both numbers stay on the model.
|
|
337
333
|
*
|
|
338
334
|
* @example
|
|
339
335
|
* ```ts
|
|
@@ -588,10 +584,15 @@ declare function missingRequiredLoop(position: X12Position, loop: X12RequiredLoo
|
|
|
588
584
|
* Build an `X12_837_UNKNOWN_VARIANT` warning. Emitted when the 837 helper
|
|
589
585
|
* cannot resolve the variant from ST-03's implementation-convention
|
|
590
586
|
* reference AND no SVx service-line segment is present to fall back on.
|
|
591
|
-
* The parsed submission still ships with `variant: "unknown"
|
|
592
|
-
* verbatim reference on `submission.implementationConventionReference`; the
|
|
587
|
+
* The parsed submission still ships with `variant: "unknown"`, and the
|
|
593
588
|
* walker does its best on shared structure (envelope, HL, claim header) and
|
|
594
|
-
* skips variant-specific service-line decoding.
|
|
589
|
+
* skips variant-specific service-line decoding. **This message deliberately
|
|
590
|
+
* points at no model field.** Recognition reads `ST-03` as FRAMED while
|
|
591
|
+
* `submission.implementationConventionReference` is decoded of any `?` release
|
|
592
|
+
* escape, so on a document that escapes a delimiter inside `ST-03` the two
|
|
593
|
+
* differ and the model field can hold an identifier this code just said was
|
|
594
|
+
* not recognised (`X12-ST03-READ-NOT-RELEASE-AWARE`). A pointer stood here and
|
|
595
|
+
* in the message text and is DELETED, not reworded.
|
|
595
596
|
*
|
|
596
597
|
* `get837Claims` anchors this at the **ST**, which is `tx.segments[0]` and
|
|
597
598
|
* carries the ST-03 the resolution reads. Through `0.0.10` it passed
|
|
@@ -1454,6 +1455,12 @@ declare const NON_SPEC_SEGMENT_ID = "(non-spec)";
|
|
|
1454
1455
|
* decodes to an empty segment (`id: ""`, `elements: [""]`); callers that
|
|
1455
1456
|
* care can guard.
|
|
1456
1457
|
*
|
|
1458
|
+
* **A degenerate delimiter set whose ELEMENT SEPARATOR is itself `?` splits
|
|
1459
|
+
* literally**, because one byte cannot both separate and escape. Only that
|
|
1460
|
+
* role is guarded here: a `?` repetition or component separator is a
|
|
1461
|
+
* different call and is deliberately unchanged (see
|
|
1462
|
+
* {@link "./release.js".splitWithRelease}).
|
|
1463
|
+
*
|
|
1457
1464
|
* @example
|
|
1458
1465
|
* ```ts
|
|
1459
1466
|
* import { decodeSegment } from "@cosyte/x12";
|
|
@@ -1916,7 +1923,9 @@ interface Ta1Segment {
|
|
|
1916
1923
|
*
|
|
1917
1924
|
* `elements` on the ST and SE segments themselves IS decoded at envelope
|
|
1918
1925
|
* time so envelope invariants can be checked (ST-02 ↔ SE-02 control-number
|
|
1919
|
-
* reconciliation, SE-01 segment count).
|
|
1926
|
+
* reconciliation, SE-01 segment count). **Read "decoded" as element-SPLIT and
|
|
1927
|
+
* nothing more: the strings are PRE-`?`-unescape**, and a reader that publishes
|
|
1928
|
+
* one to a consumer unescapes it first (`X12-ST03-READ-NOT-RELEASE-AWARE`).
|
|
1920
1929
|
*
|
|
1921
1930
|
* @example
|
|
1922
1931
|
* ```ts
|
|
@@ -2483,9 +2492,10 @@ declare function unescapeRelease(input: string, delimiters: Delimiters, emit: (w
|
|
|
2483
2492
|
* the untyped-refusal defect this package has fixed elsewhere. This is a pure
|
|
2484
2493
|
* text utility with no spec, no element and no caller context to name, so
|
|
2485
2494
|
* `TypeError` is the accurate answer for a wrong-typed argument. **Nothing
|
|
2486
|
-
* inside this library can reach it**:
|
|
2495
|
+
* inside this library can reach it**: every builder routes its elements
|
|
2487
2496
|
* through `src/builder/caller-string.ts`, which refuses first with the calling
|
|
2488
|
-
* builder's own typed, code-tagged error.
|
|
2497
|
+
* builder's own typed, code-tagged error. (No count: it is asserted by
|
|
2498
|
+
* `test/builder-string-type.test.ts` and was stale here.) This throw is the backstop for a
|
|
2489
2499
|
* consumer calling the export directly, where the alternative was silent data
|
|
2490
2500
|
* loss.
|
|
2491
2501
|
*
|
|
@@ -5720,22 +5730,23 @@ declare function get837Claims(delimiters: Delimiters, tx: X12TransactionSet, opt
|
|
|
5720
5730
|
|
|
5721
5731
|
/**
|
|
5722
5732
|
* Interchange + group + transaction identity for the built 837. The builder
|
|
5723
|
-
* fixes GS-01 to `"HC"
|
|
5724
|
-
* (`005010X222A2` / `X223A3` / `X224A2`) so the caller never
|
|
5725
|
-
*
|
|
5726
|
-
*
|
|
5727
|
-
*
|
|
5728
|
-
*
|
|
5729
|
-
*
|
|
5730
|
-
*
|
|
5731
|
-
*
|
|
5732
|
-
*
|
|
5733
|
-
*
|
|
5734
|
-
*
|
|
5735
|
-
*
|
|
5736
|
-
*
|
|
5737
|
-
*
|
|
5738
|
-
*
|
|
5733
|
+
* fixes GS-01 to `"HC"`, and defaults the ST-03 / GS-08 reference to the
|
|
5734
|
+
* variant's TR3 (`005010X222A2` / `X223A3` / `X224A2`) so the caller never
|
|
5735
|
+
* has to hand-code it.
|
|
5736
|
+
*
|
|
5737
|
+
* **🩺 That default is not what every trading partner accepts, so
|
|
5738
|
+
* {@link Build837EnvelopeSpec.implementationConventionReference} overrides
|
|
5739
|
+
* it.** The three defaults are published errata guides, but they are
|
|
5740
|
+
* neither the identifiers HIPAA adopts at 45 CFR 162.1102 nor the ones
|
|
5741
|
+
* payer companion guides commonly require in ST-03 / GS-08 (CMS and several
|
|
5742
|
+
* state Medicaid guides state `005010X222A1` for Professional and
|
|
5743
|
+
* `005010X223A2` for Institutional). **A partner that requires one of those
|
|
5744
|
+
* will reject a Professional or Institutional 837 built on the default**,
|
|
5745
|
+
* and the override is how you send what your partner asked for. The default
|
|
5746
|
+
* itself was deliberately NOT re-stamped: which published guide identifier
|
|
5747
|
+
* a partner accepts is a partner fact rather than a spec fact, and changing
|
|
5748
|
+
* bytes this library already emitted would break the partners it works with
|
|
5749
|
+
* today. The READ side is unaffected - `get837Claims` recognises all of
|
|
5739
5750
|
* these references.
|
|
5740
5751
|
*
|
|
5741
5752
|
* @example
|
|
@@ -5764,6 +5775,44 @@ interface Build837EnvelopeSpec {
|
|
|
5764
5775
|
readonly groupControlNumber: string;
|
|
5765
5776
|
/** ST-02 / SE-02 - transaction set control number. */
|
|
5766
5777
|
readonly transactionSetControlNumber: string;
|
|
5778
|
+
/**
|
|
5779
|
+
* 🩺 ST-03 **and** GS-08 - the implementation convention reference this
|
|
5780
|
+
* 837 declares. Default: the variant's TR3 (`005010X222A2` Professional,
|
|
5781
|
+
* `005010X223A3` Institutional, `005010X224A2` Dental).
|
|
5782
|
+
*
|
|
5783
|
+
* **Set it to whatever your trading partner's companion guide requires**,
|
|
5784
|
+
* for example `005010X222A1` on a professional claim to a payer that asks
|
|
5785
|
+
* for it. Which published identifier a partner accepts is a partner fact,
|
|
5786
|
+
* so this library will not choose for you: it defaults to a real published
|
|
5787
|
+
* guide and gets out of the way. **One value is written to both elements**,
|
|
5788
|
+
* because this builder has always written the same reference to ST-03 and
|
|
5789
|
+
* GS-08 and nothing grounds a caller making them differ. That is a statement
|
|
5790
|
+
* about the bytes this field emits, not about what each element may legally
|
|
5791
|
+
* hold: GS-08 is data element 480 (`AN 1/12`) and ST-03 is element 1705
|
|
5792
|
+
* (`AN 1/35`), and nothing here bounds the length.
|
|
5793
|
+
*
|
|
5794
|
+
* Refused, all `X12_837_BUILD_INVALID_SPEC`. An **empty** string, because a
|
|
5795
|
+
* trailing empty element is dropped on emit, so it would delete ST-03 and
|
|
5796
|
+
* GS-08 rather than send them empty. One carrying an **active delimiter or
|
|
5797
|
+
* the release character**, because these two elements cannot carry it even
|
|
5798
|
+
* escaped: the ST and GS segments are read by a splitter that is not
|
|
5799
|
+
* release-aware, so the declaration would silently become two elements. And
|
|
5800
|
+
* one **this library's own reader resolves to a different variant**
|
|
5801
|
+
* (`005010X223A2` handed to `build837P`): the file would declare one variant
|
|
5802
|
+
* and carry another's service segments, and `get837Claims` would then decode
|
|
5803
|
+
* none of its service lines. Those are what this field adds, on top of the
|
|
5804
|
+
* element-type guard every string slot already has, which refuses a
|
|
5805
|
+
* non-string with the same code - no total is published. **Anything else is
|
|
5806
|
+
* emitted as given** - the set of published errata is not provably
|
|
5807
|
+
* exhaustive, so an identifier this library does not carry is the caller's
|
|
5808
|
+
* call, not an error.
|
|
5809
|
+
*
|
|
5810
|
+
* 🩺 A guard on this element cannot make the element trustworthy. An active
|
|
5811
|
+
* delimiter in a DIFFERENT envelope field splits its own segment and shifts
|
|
5812
|
+
* every element after it, so ST-03 / GS-08 are then read out of a
|
|
5813
|
+
* neighbour's slot. `KNOWN-LIMITATIONS.md` carries the measurement.
|
|
5814
|
+
*/
|
|
5815
|
+
readonly implementationConventionReference?: string;
|
|
5767
5816
|
/** ISA-05 - interchange sender qualifier. Default `"ZZ"`. */
|
|
5768
5817
|
readonly senderQualifier?: string;
|
|
5769
5818
|
/** ISA-07 - interchange receiver qualifier. Default `"ZZ"`. */
|
|
@@ -6475,8 +6524,9 @@ interface Build837Spec {
|
|
|
6475
6524
|
|
|
6476
6525
|
/**
|
|
6477
6526
|
* `build837P` / `build837I` / `build837D` - pure-function builders for a
|
|
6478
|
-
* 005010 837 Healthcare Claim (Professional
|
|
6479
|
-
*
|
|
6527
|
+
* 005010 837 Healthcare Claim (Professional, Institutional, Dental; the
|
|
6528
|
+
* ST-03 / GS-08 guide reference defaults to `X222A2` / `X223A3` / `X224A2`
|
|
6529
|
+
* and the caller may state another). NEVER auto-sends, NEVER opens a socket, NEVER
|
|
6480
6530
|
* touches the filesystem. The library mechanically emits the claim it is
|
|
6481
6531
|
* told; a spec whose billing-provider → subscriber → (claims | patient)
|
|
6482
6532
|
* tree cannot form a valid HL hierarchy is REFUSED via {@link
|
|
@@ -6505,7 +6555,9 @@ interface Build837Spec {
|
|
|
6505
6555
|
*/
|
|
6506
6556
|
|
|
6507
6557
|
/**
|
|
6508
|
-
* `build837P` - assemble a
|
|
6558
|
+
* `build837P` - assemble a Professional 837 around the spec, declaring
|
|
6559
|
+
* `005010X222A2` unless `envelope.implementationConventionReference` states
|
|
6560
|
+
* the guide your trading partner requires.
|
|
6509
6561
|
*
|
|
6510
6562
|
* @example
|
|
6511
6563
|
* ```ts
|
|
@@ -6537,8 +6589,10 @@ interface Build837Spec {
|
|
|
6537
6589
|
*/
|
|
6538
6590
|
declare function build837P(spec: Build837Spec): X12Interchange;
|
|
6539
6591
|
/**
|
|
6540
|
-
* `build837I` - assemble
|
|
6541
|
-
*
|
|
6592
|
+
* `build837I` - assemble an Institutional 837 around the spec, declaring
|
|
6593
|
+
* `005010X223A3` unless `envelope.implementationConventionReference` states
|
|
6594
|
+
* the guide your trading partner requires. Service lines must be
|
|
6595
|
+
* `variant: "I"` (SV2).
|
|
6542
6596
|
*
|
|
6543
6597
|
* @example
|
|
6544
6598
|
* ```ts
|
|
@@ -6549,8 +6603,10 @@ declare function build837P(spec: Build837Spec): X12Interchange;
|
|
|
6549
6603
|
*/
|
|
6550
6604
|
declare function build837I(spec: Build837Spec): X12Interchange;
|
|
6551
6605
|
/**
|
|
6552
|
-
* `build837D` - assemble a
|
|
6553
|
-
*
|
|
6606
|
+
* `build837D` - assemble a Dental 837 around the spec, declaring
|
|
6607
|
+
* `005010X224A2` unless `envelope.implementationConventionReference` states
|
|
6608
|
+
* the guide your trading partner requires. Service lines must be
|
|
6609
|
+
* `variant: "D"` (SV3); per-line tooth detail rides on TOO.
|
|
6554
6610
|
*
|
|
6555
6611
|
* @example
|
|
6556
6612
|
* ```ts
|
|
@@ -12288,7 +12344,9 @@ type Ta1AckCode = (typeof TA1_ACK_CODES)[keyof typeof TA1_ACK_CODES];
|
|
|
12288
12344
|
* TA1-05 interchange note code (ASC X12 code list I18). Codes `000`–`028`
|
|
12289
12345
|
* are defined by the standard; values past `028` exist in some standard
|
|
12290
12346
|
* revisions and are accepted on parse (Postel's Law) but not enumerated
|
|
12291
|
-
* here - the parsed model carries the
|
|
12347
|
+
* here - the parsed model carries the un-narrowed string on `noteCodeRaw`,
|
|
12348
|
+
* post-`?`-unescape as of `X12-TA1-RESIDUALS`. **A clause here said "verbatim"
|
|
12349
|
+
* and is deleted rather than reworded**; `raw.elements[5]` is the byte surface.
|
|
12292
12350
|
*
|
|
12293
12351
|
* `000` is the canonical "no error" note paired with a `TA1-04 == 'A'`
|
|
12294
12352
|
* acceptance. The build-time safety guard refuses a fabricated `A` paired
|
|
@@ -12365,9 +12423,11 @@ declare const TA1_NOTE_CODES: {
|
|
|
12365
12423
|
/**
|
|
12366
12424
|
* String-literal union over {@link TA1_NOTE_CODES} - the standard-issued
|
|
12367
12425
|
* note codes `000`–`028`. Real-world inbound TA1 may carry a value past
|
|
12368
|
-
* `028` (some revisions extend the list); `parseTA1` exposes the
|
|
12369
|
-
* string in that case so the
|
|
12370
|
-
* cannot statically type it.
|
|
12426
|
+
* `028` (some revisions extend the list); `parseTA1` exposes the
|
|
12427
|
+
* un-narrowed string on `noteCodeRaw` in that case, so the value survives
|
|
12428
|
+
* even when the union cannot statically type it. **It is post-`?`-unescape
|
|
12429
|
+
* as of `X12-TA1-RESIDUALS`, and a clause here calling it VERBATIM is
|
|
12430
|
+
* deleted rather than reworded** - `raw.elements[5]` is the byte surface.
|
|
12371
12431
|
*/
|
|
12372
12432
|
type Ta1NoteCode = (typeof TA1_NOTE_CODES)[keyof typeof TA1_NOTE_CODES];
|
|
12373
12433
|
|
|
@@ -12589,13 +12649,23 @@ interface X12Ack999 {
|
|
|
12589
12649
|
* - `interchangeTime` - TA1-03: HHMM (echoes inbound ISA-10).
|
|
12590
12650
|
* - `ackCode` - TA1-04: {@link Ta1AckCode}.
|
|
12591
12651
|
* - `noteCode` - TA1-05: typed when the value is a known I18 code
|
|
12592
|
-
* ({@link Ta1NoteCode}); the
|
|
12593
|
-
* so unknown extensions
|
|
12594
|
-
*
|
|
12595
|
-
*
|
|
12652
|
+
* ({@link Ta1NoteCode}); `noteCodeRaw` carries the un-narrowed string
|
|
12653
|
+
* alongside so unknown extensions survive. **A clause here said that
|
|
12654
|
+
* string is preserved VERBATIM and is deleted, not reworded:**
|
|
12655
|
+
* `X12-TA1-RESIDUALS` made it post-unescape, and `raw.elements[5]` is
|
|
12656
|
+
* the verbatim surface.
|
|
12657
|
+
* - `noteCodeRaw` - the un-narrowed TA1-05 string. Equal to `noteCode` when
|
|
12658
|
+
* the value is a known I18 code; equal to the decoded inbound text when
|
|
12659
|
+
* not.
|
|
12596
12660
|
* - `raw` - the underlying envelope-level {@link Ta1Segment}, for
|
|
12597
12661
|
* byte-exact round-trip.
|
|
12598
12662
|
*
|
|
12663
|
+
* **The five decoded fields are POST-`?`-unescape; `raw` is the verbatim
|
|
12664
|
+
* byte surface and is not.** `X12-TA1-RESIDUALS` moved the decoded half:
|
|
12665
|
+
* before it, a released TA1-01 read back carrying its `?` and matched no
|
|
12666
|
+
* ISA-13, while every dot-path read of the same element already unescaped.
|
|
12667
|
+
* Read `raw.elements` when you want the bytes.
|
|
12668
|
+
*
|
|
12599
12669
|
* @example
|
|
12600
12670
|
* ```ts
|
|
12601
12671
|
* import type { X12AckTA1 } from "@cosyte/x12";
|
|
@@ -12862,6 +12932,93 @@ declare function build999(spec: Build999Spec): X12Interchange;
|
|
|
12862
12932
|
* library does NOT silently invent envelope bytes around it - the caller's
|
|
12863
12933
|
* application boundary owns whether the TA1 is embedded in an outbound
|
|
12864
12934
|
* interchange or sent as a standalone TA1-only interchange.
|
|
12935
|
+
*
|
|
12936
|
+
* ## 🩺 Why every element is released, and what that changed
|
|
12937
|
+
*
|
|
12938
|
+
* `raw` used to be `[...five caller values].join(elementSeparator)` with
|
|
12939
|
+
* nothing in between, so a caller value carrying an active delimiter took
|
|
12940
|
+
* a slot of its own and shifted every element after it down one. TA1-04 is
|
|
12941
|
+
* the disposition and TA1-05 the note, so the shift landed the read on the
|
|
12942
|
+
* wrong pair, and `parseTA1` narrows an out-of-enum TA1-04 to `R`:
|
|
12943
|
+
* **an Accept this library emitted read back as a Reject**, with the TA1-01
|
|
12944
|
+
* reassociation key merged into TA1-02 and `warnings: []` on every channel.
|
|
12945
|
+
* The inverse is the less safe one and also existed: a `noteCode` of
|
|
12946
|
+
* literally `"A"` (a value the type forbids and nothing checks at run time)
|
|
12947
|
+
* shifted onto TA1-04 and made a **Reject read back as an Accept**, which a
|
|
12948
|
+
* sender never resubmits against.
|
|
12949
|
+
*
|
|
12950
|
+
* The grounding is inside the package, not in a spec clause, which is the
|
|
12951
|
+
* same tiebreak `X12-ENVELOPE-SPLITTER-NOT-RELEASE-AWARE` recorded: one
|
|
12952
|
+
* function disagreed with itself. This module emitted bytes that this
|
|
12953
|
+
* package's own reader decoded into a different disposition than the one
|
|
12954
|
+
* the caller asked for, and every other builder already released the same
|
|
12955
|
+
* class of element through the same helper.
|
|
12956
|
+
*
|
|
12957
|
+
* **It changes bytes, and that is the cost that kept it open for a slice.**
|
|
12958
|
+
* A value containing none of the four delimiters or the release character
|
|
12959
|
+
* is emitted byte-for-byte as before, which is every conformant TA1. A
|
|
12960
|
+
* value containing one is now released, so its bytes differ from the ones
|
|
12961
|
+
* `0.0.14` and earlier put on the wire. What that costs is stated outright
|
|
12962
|
+
* below rather than argued away, and **without a total**: two drafts of this
|
|
12963
|
+
* account published a closed one and both were refuted.
|
|
12964
|
+
*
|
|
12965
|
+
* - **The consumer predicate moves in BOTH directions.** Read the property
|
|
12966
|
+
* rather than a direction list: `parseTA1` of a `buildTA1` output now
|
|
12967
|
+
* reports the disposition and note the CALLER passed, where before it
|
|
12968
|
+
* reported whatever element the shift left in TA1-04. So
|
|
12969
|
+
* `ackCode === "R"` stops firing where an Accept had been shifted onto
|
|
12970
|
+
* it, and starts firing where a Reject had been shifted off it -
|
|
12971
|
+
* `interchangeTime: "12*A"` with `ackCode: "R"` read `"A"` before and
|
|
12972
|
+
* reads `"R"` here, every field a valid member of its union. What is
|
|
12973
|
+
* one-directional is the safety, which is a different statement.
|
|
12974
|
+
* - **Only three values in the escaped set ever shifted the segment's own
|
|
12975
|
+
* element framing**: the element separator, the segment terminator, and
|
|
12976
|
+
* a `?` immediately before the separator. **`^` and `:` moved the
|
|
12977
|
+
* dot-path reader instead, and releasing them is a GAIN there.**
|
|
12978
|
+
* `getSegmentValue(ta1, "01")` answered `"0000"` before for a control
|
|
12979
|
+
* number of `"0000^0001"`, truncating the reassociation key to the first
|
|
12980
|
+
* repetition, and answers `"0000^0001"` here; the composite read `"01-1"`
|
|
12981
|
+
* answered `"0000"` for `"0000:0001"`. **The measured pure cost is a
|
|
12982
|
+
* MID-STRING `?`, and only on the surfaces documented as raw**: `raw` and
|
|
12983
|
+
* `elements` read `"0000??0001"` where they read `"0000?0001"`, while the
|
|
12984
|
+
* dot-path read of THAT value unescapes and answered `"0000?0001"` on
|
|
12985
|
+
* both. Read the clause as scoped to the mid-string `?`, because it is
|
|
12986
|
+
* not true of `^` or `:` three sentences up. **`getSegmentValue` takes an
|
|
12987
|
+
* `X12Segment` and `Ta1Segment` carries no `id`, so add one to read a TA1
|
|
12988
|
+
* through it.** No total is published: that is what was measured, not a
|
|
12989
|
+
* closed account.
|
|
12990
|
+
* **🩺 A CLAUSE NAMING `parseTA1`'s FIELDS AS A THIRD SUCH SURFACE STOOD
|
|
12991
|
+
* HERE AND IS DELETED, NOT REWORDED.** `X12-TA1-RESIDUALS` made those
|
|
12992
|
+
* fields post-unescape, so it is measured false; do not restate it.
|
|
12993
|
+
* - **A caller who was pre-releasing the value themselves** (the remedy
|
|
12994
|
+
* `KNOWN-LIMITATIONS.md` named while this was open) is now escaping
|
|
12995
|
+
* twice: `"00000001??"` in, `"00000001????"` out. The framing and the
|
|
12996
|
+
* disposition stay correct, and this one regresses on BOTH kinds of
|
|
12997
|
+
* surface - the dot-path read answers `"00000001??"` where it answered
|
|
12998
|
+
* `"00000001?"`. Drop the hand-rolled escape.
|
|
12999
|
+
*
|
|
13000
|
+
* **And an EMPTY control number USED to go out unrefused.** `escapeRelease`
|
|
13001
|
+
* early-returns on `""` and this module had no required-field guard, so
|
|
13002
|
+
* `interchangeControlNumber: ""` emitted `TA1**260601*1200*A*000` with no
|
|
13003
|
+
* error, through `0.0.15`. `X12-EMPTY-CONTROL-NUMBER-FABRICATED` closed it:
|
|
13004
|
+
* see {@link "../../builder/caller-control-number.js".requireControlNumber}.
|
|
13005
|
+
* `X12-CONTROL-NUMBER-GUARD-NOT-TYPE-CHECKED` then made the same guard
|
|
13006
|
+
* type-check, so TA1-01 draws a refusal naming TA1-01 rather than the escaper's
|
|
13007
|
+
* one naming only the builder - same class, same code, different words. The
|
|
13008
|
+
* guard is still byte-strict, so a whitespace-only TA1-01 still builds.
|
|
13009
|
+
*
|
|
13010
|
+
* **The other four slots were left open by that slice and `X12-TA1-RESIDUALS`
|
|
13011
|
+
* closes them.** TA1-01's guard was the only required-field guard this module
|
|
13012
|
+
* had, so `interchangeDate`, `interchangeTime`, `ackCode` and `noteCode` each
|
|
13013
|
+
* emitted an absent element on `""` with `warnings: []`. **TA1-05's cell has to
|
|
13014
|
+
* be read against a NON-Accept disposition, or `enforceAcceptIsClean` reaches
|
|
13015
|
+
* it first and the reading measures that guard instead** - see
|
|
13016
|
+
* {@link requireTa1Element}, which carries the grounding and the residual it
|
|
13017
|
+
* deliberately leaves.
|
|
13018
|
+
*
|
|
13019
|
+
* And the release is scoped to the delimiter set the caller states through
|
|
13020
|
+
* {@link BuildTA1Options} - see that interface for why guessing one is a
|
|
13021
|
+
* value corruption rather than a safe default.
|
|
12865
13022
|
*/
|
|
12866
13023
|
|
|
12867
13024
|
/**
|
|
@@ -12876,7 +13033,18 @@ declare function build999(spec: Build999Spec): X12Interchange;
|
|
|
12876
13033
|
* - `ackCode === "A"` paired with `noteCode !== "000"` →
|
|
12877
13034
|
* {@link "./errors.js".ACK_BUILD_ERROR_CODES.X12_TA1_ACCEPT_WITH_NOTE}.
|
|
12878
13035
|
* Accept must mean accept. Use `E` (accept with errors) when the
|
|
12879
|
-
* inbound had structural defects you elected to ignore.
|
|
13036
|
+
* inbound had structural defects you elected to ignore. This one runs
|
|
13037
|
+
* FIRST and its precedence is unchanged.
|
|
13038
|
+
* - Any of the five element values that is not a `string` →
|
|
13039
|
+
* {@link "./errors.js".ACK_BUILD_ERROR_CODES.X12_ACK_INVALID_SPEC}. This
|
|
13040
|
+
* is not a bonus guard: releasing a value means routing it through
|
|
13041
|
+
* {@link "../../builder/caller-string.js".makeCallerEscaper}, and the
|
|
13042
|
+
* bare `escapeRelease` underneath it returns its empty accumulator for a
|
|
13043
|
+
* `number`, so escaping without the type check would have replaced the
|
|
13044
|
+
* shifted-element defect with a silently VANISHED TA1-01. **A number or
|
|
13045
|
+
* an `undefined` control number used to emit as `TA1*12345*…` (the
|
|
13046
|
+
* number surviving onto `elements`, in a `readonly string[]`) or
|
|
13047
|
+
* `TA1**250101*…`; both now refuse.**
|
|
12880
13048
|
*
|
|
12881
13049
|
* @param spec - The TA1 fields. `interchangeControlNumber` echoes the
|
|
12882
13050
|
* inbound ISA-13; `interchangeDate` / `interchangeTime` echo
|
|
@@ -12914,13 +13082,28 @@ declare function build999(spec: Build999Spec): X12Interchange;
|
|
|
12914
13082
|
*/
|
|
12915
13083
|
declare function buildTA1(spec: BuildTA1Spec, options?: BuildTA1Options): Ta1Segment;
|
|
12916
13084
|
/**
|
|
12917
|
-
* Options accepted by {@link buildTA1}
|
|
12918
|
-
*
|
|
12919
|
-
*
|
|
12920
|
-
*
|
|
13085
|
+
* Options accepted by {@link buildTA1}: the delimiter set the returned
|
|
13086
|
+
* segment will be read against. Every field is optional and defaults to the
|
|
13087
|
+
* cosyte parser archetype (`*` element, `^` repetition, `:` component, `~`
|
|
13088
|
+
* segment), which is the same four `build999` takes on
|
|
13089
|
+
* {@link "./types.js".Build999EnvelopeSpec}.
|
|
13090
|
+
*
|
|
13091
|
+
* **The three non-element fields exist for ESCAPING and nothing else.**
|
|
13092
|
+
* `buildTA1` still emits no segment terminator, no repetition and no
|
|
13093
|
+
* composite. It has to know them because a caller value carrying one of
|
|
13094
|
+
* them has to be released, and because escaping a byte that is NOT a
|
|
13095
|
+
* delimiter where the segment lands corrupts the value: `unescapeRelease`
|
|
13096
|
+
* preserves `?X` verbatim for any `X` outside the declared set, so a value
|
|
13097
|
+
* released against a guessed delimiter comes back carrying a stray `?`.
|
|
13098
|
+
* **If you embed a TA1 in an envelope whose delimiters are not the
|
|
13099
|
+
* archetype, state them here** - the defaults are an assumption this
|
|
13100
|
+
* function cannot verify, exactly as they were before it escaped anything.
|
|
12921
13101
|
*/
|
|
12922
13102
|
interface BuildTA1Options {
|
|
12923
13103
|
readonly elementSeparator?: string;
|
|
13104
|
+
readonly repetitionSeparator?: string;
|
|
13105
|
+
readonly componentSeparator?: string;
|
|
13106
|
+
readonly segmentTerminator?: string;
|
|
12924
13107
|
}
|
|
12925
13108
|
|
|
12926
13109
|
/**
|
|
@@ -13008,9 +13191,7 @@ interface BuildTA1Options {
|
|
|
13008
13191
|
* Every warning it emits is built by the same value-free factories the parser
|
|
13009
13192
|
* uses: `message` is a frozen-registry lookup and `position` locates the
|
|
13010
13193
|
* control segment, so a declared count or control number can never reach a
|
|
13011
|
-
* diagnostic.
|
|
13012
|
-
* (`se.elements[1]` against `tx.rawSegments.length`, `ge.elements[1]` against
|
|
13013
|
-
* `group.transactions.length`, `iea.elements[1]` against `ix.groups.length`).
|
|
13194
|
+
* diagnostic.
|
|
13014
13195
|
*/
|
|
13015
13196
|
|
|
13016
13197
|
/**
|