@cosyte/synth 0.1.7 → 0.1.9

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 37e934b: A generator now loads its parser where `import.meta.resolve` throws or answers with a URL that is not a `file:` URL, as inside Deno's test runner.
8
+
9
+ Before, the first generator call that needed a parser threw there (`TypeError: Invalid arguments` under Deno's test runner). Now the ES module build loads the parser by name through `require` instead, the same fallback it already takes where Node.js cannot `require` an ES module, so a returned value is an instance of the CommonJS copy of the parser's classes. Nothing changes on Node.js 22.12 or later, and no output changes. A caller changes nothing.
10
+
11
+ ## 0.1.8
12
+
13
+ ### Patch Changes
14
+
15
+ - 2f6dff4: `engines.node` is now `>=22.12.0`, where it was `>=22.0.0`. Since 0.1.6 a generator loads its parser on first use through `require`, and Node.js loads an ES module that way by default only from 22.12. On 22.0 to 22.11 the ES module build fell back to the parser's CommonJS entry, so a value it returned was an instance of a second copy of the parser's classes and `instanceof` against a class imported with `import` was false. The 0.1.6 entry said a returned value was an instance of the classes your code imports; that holds on 22.12 and later, and CI now runs the built package's smoke, which checks `instanceof` under `import` and `require`, on Node.js 22.12.0 itself. If you run Node.js 22.0 to 22.11, upgrade to 22.12 or later. npm warns about the engines range by default and refuses the install only with `engine-strict`.
16
+
17
+ If you bundle code that uses `@cosyte/synth`, mark `@cosyte/synth` and each `@cosyte/*` parser you use as external (esbuild `--external:@cosyte/*`, Rollup `external`, webpack `externals`) and install them beside the bundle. A bundler cannot follow the first-use load, so a bundle that inlines a parser holds a second copy of it, and one that omits a parser fails with "Cannot find module" on the first call that needs it.
18
+
19
+ No generated value, export, warning code or seed mapping changes.
20
+
21
+ - dd2b762: Every artifact now says it is test data, in the field its standard gives for that, so a generated fixture that ends up somewhere real can be told apart from production data. HL7 v2 messages declared processing ID `P` (production) in MSH-11; X12 already set ISA-15 to `T`.
22
+
23
+ Output change: HL7 v2 messages set MSH-11 to `T` where it was `P`. Every FHIR resource, every resource inside a Bundle and the Bundle itself carry `meta.security` with the `HTEST` ("test health data") code from `http://terminology.hl7.org/CodeSystem/v3-ActReason`, so a resource built with `usCore: false` and a base Patient now carry a `meta` too, and the document Bundle's Organization and Composition carry one. ASTM messages set the header's processing ID (H.12) to `T`, so the `H` record gains the empty fields H.6 to H.11 before it. C-CDA, X12 and NCPDP output is unchanged. A golden file committed from an earlier release for HL7 v2, FHIR or ASTM has to be regenerated.
24
+
25
+ The marker is always on: there is no option to turn it off. The exported `meta(profiles)` helper in `@cosyte/synth/fhir` now adds the `HTEST` label as well, and accepts an empty list, which leaves `meta.profile` out. If your code reads `meta` from a generated resource and expected only `profile`, read `meta.profile` by name.
26
+
3
27
  ## 0.1.7
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  [![npm version](https://img.shields.io/npm/v/@cosyte/synth.svg)](https://www.npmjs.com/package/@cosyte/synth)
13
13
  [![CI](https://img.shields.io/github/actions/workflow/status/cosyte/synth/ci.yml?branch=main&label=CI)](https://github.com/cosyte/synth/actions/workflows/ci.yml)
14
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/cosyte/synth/blob/main/LICENSE)
15
- [![Node](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org)
15
+ [![Node](https://img.shields.io/badge/node-%3E%3D22.12.0-brightgreen.svg)](https://nodejs.org)
16
16
 
17
17
  Deterministic, seedable synthetic healthcare test fixtures for Node.js and TypeScript: HL7 v2, FHIR R4 and US Core, C-CDA, X12, NCPDP, and ASTM, spec-clean by construction and never real PHI.
18
18
 
@@ -57,7 +57,13 @@ pairing (no `@cosyte/deid` adapter, or not generated); and optional **Synthea**
57
57
  npm install @cosyte/synth @cosyte/hl7 @cosyte/fhir @cosyte/ccda @cosyte/x12 @cosyte/ncpdp @cosyte/astm
58
58
  ```
59
59
 
60
- Node.js 22 or later, tested on 22, 24, and 26.
60
+ Node.js 22.12 or later, tested on 22.12, 22, 24, and 26. A generator loads its parser on first use
61
+ through `require`, and Node.js loads an ES module that way only from 22.12, so a value you get back
62
+ is an instance of the parser classes you import.
63
+
64
+ **Bundling.** A bundler cannot see that load. If you bundle code that uses `@cosyte/synth`, mark
65
+ `@cosyte/synth` and every `@cosyte/*` parser you use as external (esbuild `--external:@cosyte/*`,
66
+ Rollup and Vite `external`, webpack `externals`) and install them beside the bundle.
61
67
 
62
68
  `@cosyte/hl7`, `@cosyte/fhir`, `@cosyte/ccda`, `@cosyte/x12`, `@cosyte/ncpdp`, `@cosyte/astm`, and
63
69
  `@cosyte/deid` are **optional peer dependencies**, each needed only for its subpath (`@cosyte/synth/hl7`,
@@ -605,7 +605,12 @@ function isRequireEsmRefusal(error) {
605
605
  }
606
606
  function loadPeer(specifier, host) {
607
607
  if (host.resolve === void 0) return host.require(specifier);
608
- const entry = url.fileURLToPath(host.resolve(specifier));
608
+ let entry;
609
+ try {
610
+ entry = url.fileURLToPath(host.resolve(specifier));
611
+ } catch {
612
+ return host.require(specifier);
613
+ }
609
614
  try {
610
615
  return host.require(entry);
611
616
  } catch (error) {
@@ -666,8 +671,10 @@ function buildResultInput(options) {
666
671
  records.push({ type: "C", source: "L", text: rng.pick(ASTM_COMMENT_TEXT), commentType: "G" });
667
672
  }
668
673
  return {
669
- // H.3 (message control id) and H.4 (access password) stay empty; H.5 is the sender name.
670
- header: { fields: ["", "", head.sender] },
674
+ // H.3 (message control id) and H.4 (access password) stay empty; H.5 is the sender name. H.6 to
675
+ // H.11 stay empty, and H.12, the processing ID, is `T` (training), never `P` (production): every
676
+ // message says it is test data in the field the standard gives for it.
677
+ header: { fields: ["", "", head.sender, "", "", "", "", "", "", "T"] },
671
678
  records,
672
679
  terminationCode: "N"
673
680
  };