@cosyte/cli 0.0.2 → 0.0.3
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 +117 -0
- package/README.md +60 -38
- package/dist/bin/cosyte-mcp.cjs +18 -11
- package/dist/bin/cosyte-mcp.cjs.map +1 -1
- package/dist/bin/cosyte-mcp.mjs +18 -11
- package/dist/bin/cosyte-mcp.mjs.map +1 -1
- package/dist/bin/cosyte.cjs +22 -14
- package/dist/bin/cosyte.cjs.map +1 -1
- package/dist/bin/cosyte.mjs +22 -14
- package/dist/bin/cosyte.mjs.map +1 -1
- package/dist/index.cjs +20 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -6
- package/dist/index.d.ts +40 -6
- package/dist/index.mjs +20 -13
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.cjs +18 -11
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.mjs +18 -11
- package/dist/mcp.mjs.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,76 @@ this file is maintained by hand (Changesets handles the version bump and publish
|
|
|
11
11
|
|
|
12
12
|
### Fixed
|
|
13
13
|
|
|
14
|
+
- **`@cosyte/cli` can be installed from npm again (CLI-UNINSTALLABLE-MANIFEST).** `0.0.1` and `0.0.2`
|
|
15
|
+
both published with all ten `@cosyte/*` sibling packages declared as `file:vendor/*.tgz` local
|
|
16
|
+
paths. `vendor/` is not in `files` and there is no `bundledDependencies`, so the tarball shipped
|
|
17
|
+
none of them and every install route died on the first: `ENOENT ...
|
|
18
|
+
node_modules/@cosyte/cli/vendor/cosyte-fhir-0.0.0.tgz`. The siblings are now real registry ranges:
|
|
19
|
+
`@cosyte/hl7` (`^0.0.7`) and `@cosyte/terminology` (`^0.0.9`) as hard `dependencies`, and the six
|
|
20
|
+
breadth parsers plus `@cosyte/transform` (`^0.0.4`) as `optionalDependencies`. Verified the way a
|
|
21
|
+
dry-run cannot: the packed tarball was installed in a clean directory outside the repo (exit `0`),
|
|
22
|
+
then both bins were run and the `.` subpath imported under ESM and CJS.
|
|
23
|
+
|
|
24
|
+
- **`VERSION` and `cosyte --version` now report the release you are running (CLI-VERSION-DRIFT).**
|
|
25
|
+
`src/core/version.ts` exported `"0.0.0"` while `package.json` said `0.0.2`, and the constant's own
|
|
26
|
+
doc comment claimed it was "synced with `package.json#version` on release by the Changesets
|
|
27
|
+
`version` script" when no such step existed. Confirmed in the published tarball: `@cosyte/cli@0.0.2`
|
|
28
|
+
ships `VERSION = "0.0.0"` in `dist/index.mjs` and `dist/index.cjs`. It reached two user-visible
|
|
29
|
+
surfaces, `cosyte --version` and the MCP server's advertised `serverInfo.version`. `scripts/sync-version.mjs`
|
|
30
|
+
(ported from `@cosyte/transform`) now runs inside the `version` script, and `test/sanity.test.ts`
|
|
31
|
+
compares the export against `package.json` so a skipped sync goes red rather than shipping.
|
|
32
|
+
**The two assertions that let five bad releases through the sibling packages are fixed here, not
|
|
33
|
+
just the value:** `docs-content/installation.md` asserted `typeof VERSION` (true of every wrong
|
|
34
|
+
value) and now asserts the exact version, which the sync script keeps in step; and the declaration's
|
|
35
|
+
`: string` annotation, which the sync script's pattern keys on, is pinned by its own test, so
|
|
36
|
+
dropping it fails at `pnpm test` instead of silently at release time.
|
|
37
|
+
|
|
38
|
+
- **The `attw` publish gate no longer exits 0 on an untyped pack (ATTW-FALSE-GREEN-PORT).** The
|
|
39
|
+
`attw` script was the bare CLI (`attw --pack . --profile node16`), and
|
|
40
|
+
`@arethetypeswrong/cli@0.18.4`'s `getExitCode.js` opens with `if (!analysis.types) return 0`,
|
|
41
|
+
returning before the problem list is read. So a tarball carrying no declarations at all printed
|
|
42
|
+
"This package does not contain types." and **exited 0**, and `verify.sh` propagated that 0 as a
|
|
43
|
+
pass. Reproduced on this package with zero concurrency and the real `--profile node16`
|
|
44
|
+
invocation, twice: with `dist/` removed, and with all ten of the build's declaration files
|
|
45
|
+
deleted and its JS left in place. The second is the realistic window, because `tsup` writes JS in
|
|
46
|
+
one pass and declarations in a later one; instrumented on one build here at a 10ms poll, all
|
|
47
|
+
eight `.mjs`/`.cjs` files appeared on a single poll at 4.92s and all ten declarations on a single
|
|
48
|
+
later poll at 11.82s, a 6.90s interval. That interval moves with load (7.85s on a busier box);
|
|
49
|
+
the ordering, and the ten declarations landing together, do not. Not answered with a lock or a
|
|
50
|
+
build queue: the gate is now able to report that its own inputs were missing, whatever removed
|
|
51
|
+
them.
|
|
52
|
+
- `scripts/attw.mjs` (ported from the fix shipped in `@cosyte/terminology`) runs two nets around
|
|
53
|
+
the real binary. A **preflight** that every relative path `package.json` promises exists and is
|
|
54
|
+
non-empty, naming the missing file; and a **post-check** that promotes the untyped sentence to a
|
|
55
|
+
failure, which catches declarations that are on disk but excluded from the tarball. Every
|
|
56
|
+
argument this repo passes is forwarded, so `--profile node16` keeps its exact meaning: measured
|
|
57
|
+
here, without it `@cosyte/cli/mcp` fails `node10` resolution and `attw` exits 1.
|
|
58
|
+
- **The preflight also walks `bin`, which the ported original did not**, because this is a `bin`
|
|
59
|
+
package and the sibling it came from ships no executable. Measured: with `dist/bin/cosyte.mjs`
|
|
60
|
+
deleted and everything else built, `attw --pack . --profile node16` printed every subpath green
|
|
61
|
+
and exited 0 over a tarball with no `cosyte` command in it.
|
|
62
|
+
- **`--quiet`, `-q`, `--format`, `-f` and `--config-path` are refused by option name and not by
|
|
63
|
+
value**, as is a `.attw.json` setting `quiet` or `format` (`readConfig()` applies it after
|
|
64
|
+
argv). Each was measured here to remove the untyped sentence from the output while still
|
|
65
|
+
exiting 0. `--config-path` is refused on a measurement rather than the inference the original
|
|
66
|
+
recorded. **Two limits are disclosed rather than closed**, both measured: the match is on an
|
|
67
|
+
exact argv token, so commander's attached and clustered short forms `-fjson` and `-Pf json` get
|
|
68
|
+
through (`-qP` does not; the wrapper treats an empty transcript as a failure), and a declared
|
|
69
|
+
path not starting with `.` is skipped by the preflight. The invocation this replaced exited 0
|
|
70
|
+
on the same pack with no arguments at all.
|
|
71
|
+
- **A correction to the ported message.** `files: ["dist"]` packs all ten declarations `tsup`
|
|
72
|
+
emits while `package.json` names only four; the shared `dist/io-<hash>.d.*` **and the four
|
|
73
|
+
`dist/bin/*.d.*`** ride along unnamed, and `analysis.types` is true if the tarball carries any
|
|
74
|
+
declaration. Measured on this tree: losing the four declared declarations gives "No types"
|
|
75
|
+
problems and **exit 1** while any of the other six survives, and only losing all ten gives the
|
|
76
|
+
untyped sentence and **exit 0**. So a partial declaration loss is caught by `attw` itself and
|
|
77
|
+
only a total one is the false green. The preflight reports both outcomes instead of asserting
|
|
78
|
+
the exit 0, which the inherited wording would have done falsely.
|
|
79
|
+
- `test/scripts/attw-gate.test.ts` pins all of it against the real binary, including attw's own
|
|
80
|
+
exit 0, a negative control on a well-formed package, that a genuine attw failure still fails
|
|
81
|
+
with attw's own status, and that the profile flag survives the wrapper in both directions.
|
|
82
|
+
- `scripts/verify.sh` in the meta-repo is unchanged; its propagation was never at fault.
|
|
83
|
+
|
|
14
84
|
- **The public surface now states that `0.0.1` is published and uninstallable (ASSETS-P8).** `0.0.1`
|
|
15
85
|
published on 2026-07-29 with all ten `file:vendor/*.tgz` dependency specifiers intact. `vendor/` is
|
|
16
86
|
not in `files` and there is no `bundledDependencies`, so every install route (`npm i`, `npm i -g`,
|
|
@@ -44,6 +114,53 @@ this file is maintained by hand (Changesets handles the version bump and publish
|
|
|
44
114
|
routed through a guarded loader to degrade to `CLI_PARSER_UNAVAILABLE` (exit `69`) rather than
|
|
45
115
|
crash. `loadOptional()` cannot be reused unchanged: it takes a `CosyteFormat`, and `"transform"` is
|
|
46
116
|
not one, and its diagnostic hardcodes the word "parser". Not undertaken here.
|
|
117
|
+
- **Superseded within this same unreleased set**, by the two entries at the top of this section:
|
|
118
|
+
the swap and the loader change were both carried out. Two claims that entry made did not survive
|
|
119
|
+
contact: the "name similarity" reading of the `@cosyte/fhir` `E403` was **retracted across the
|
|
120
|
+
ecosystem on 2026-08-03** (the cause is unexplained; do not assert one), and "npm tolerates an
|
|
121
|
+
`optionalDependency` that fails to resolve" is true only in isolation. Declaring **both**
|
|
122
|
+
`@cosyte/fhir` and `@cosyte/transform` optional fails the install outright with `ERESOLVE`, which
|
|
123
|
+
is why `@cosyte/fhir` ended up not declared at all rather than declared optional.
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
|
|
127
|
+
- **FHIR support is unavailable in an npm-installed copy, and now says so instead of crashing.**
|
|
128
|
+
`@cosyte/fhir` is not on the npm registry, so it cannot be declared as a dependency at all;
|
|
129
|
+
measured, declaring it alongside `@cosyte/transform` (which requires it) fails the whole install
|
|
130
|
+
with `ERESOLVE`. `@cosyte/transform` is therefore skipped by npm as an unresolvable optional
|
|
131
|
+
dependency. Both were previously loaded with a bare `await import()`, which in an installed copy
|
|
132
|
+
would have surfaced a raw resolver error and a stack frame, so FHIR `parse`/`inspect`/`fmt`/`validate`
|
|
133
|
+
and `convert` now degrade to a value-free `CLI_PARSER_UNAVAILABLE` (exit `69`) with a diagnostic that
|
|
134
|
+
says the package is not on the registry rather than "install it". **Neither diagnostic says "install
|
|
135
|
+
it", and that is deliberate**: `npm install @cosyte/transform` fails `E404` on its own
|
|
136
|
+
`@cosyte/fhir` peer, so `loadOptional()`'s stock wording ("install it to use this format, it is an
|
|
137
|
+
optional dependency") would point a user at a command that cannot succeed. New
|
|
138
|
+
`loadOptionalPackage(detail, load)` under `loadOptional`, exported on the `.` subpath.
|
|
139
|
+
`@cosyte/fhir` is retained as a `devDependency` on the vendored tarball so this repo's own FHIR and
|
|
140
|
+
`convert` tests still run; note that `devDependencies` **are** published, so that one
|
|
141
|
+
`file:vendor/*.tgz` specifier does remain in the manifest, harmlessly, because a consumer never
|
|
142
|
+
installs a dependency's `devDependencies` (verified: the install exits `0`). HL7 v2, `map-codes` and
|
|
143
|
+
the six breadth formats are unaffected and work from a plain install.
|
|
144
|
+
|
|
145
|
+
- **Documented a pre-existing defect that this release makes reachable for the first time:
|
|
146
|
+
`--omit=optional` produces an install in which the `cosyte` command does not run at all.** The
|
|
147
|
+
install exits `0`, then every invocation, `--version` included, fails with `ERR_MODULE_NOT_FOUND` on
|
|
148
|
+
`@modelcontextprotocol/sdk` and a raw stack trace, because the built `dist/bin/cosyte.mjs` imports
|
|
149
|
+
the SDK statically at the top level rather than only on the `mcp` path. Verified identical on the
|
|
150
|
+
base commit, so it is not introduced here; it simply could not be hit before, because the package
|
|
151
|
+
could not be installed at all. `docs-content/` now says not to use that flag instead of implying it
|
|
152
|
+
is a supported way to slim the install. **The code defect is not fixed here** and needs its own
|
|
153
|
+
change: it also falsifies the "a plain `cosyte parse` never pulls it" claim in `src/bin/cosyte.ts`.
|
|
154
|
+
|
|
155
|
+
- **The docs no longer tell you to run `npx @cosyte/cli …`, which never worked.** Separate from the
|
|
156
|
+
packaging defect and not fixed by it: `npx` runs the executable whose name matches the package
|
|
157
|
+
name's last segment, which would be `cli`, and this package ships `cosyte` and `cosyte-mcp`, so the
|
|
158
|
+
short form fails with `could not determine executable to run`. Reproduced on the published `0.0.2`
|
|
159
|
+
and on the fixed tarball, whose `bin` block is byte-identical. `README.md`, `docs-content/installation.md`
|
|
160
|
+
and both MCP registration snippets now use `npx --package @cosyte/cli cosyte …` /
|
|
161
|
+
`npx -y --package @cosyte/cli cosyte-mcp`, each measured working. A `cli` bin alias would fix the
|
|
162
|
+
short form and is deliberately not added, because `npm install -g` would then claim a command named
|
|
163
|
+
`cli` on the user's `PATH`.
|
|
47
164
|
|
|
48
165
|
### Added
|
|
49
166
|
|
package/README.md
CHANGED
|
@@ -22,10 +22,9 @@ It is a thin, honest skin over libraries that already own correctness ([`@cosyte
|
|
|
22
22
|
and owns two disciplines of its own: a documented **exit-code contract** and a **value-free
|
|
23
23
|
diagnostic** posture.
|
|
24
24
|
|
|
25
|
-
## Known issue: `0.0.1`
|
|
25
|
+
## Known issue: `0.0.1` and `0.0.2` are published but cannot be installed
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
this:
|
|
27
|
+
**`npm install @cosyte/cli@0.0.1` and `@0.0.2` both fail.** They end in an `ENOENT`, like this:
|
|
29
28
|
|
|
30
29
|
```
|
|
31
30
|
npm error code ENOENT
|
|
@@ -33,26 +32,33 @@ npm error path node_modules/@cosyte/cli/vendor/cosyte-fhir-0.0.0.tgz
|
|
|
33
32
|
npm error enoent ENOENT: no such file or directory
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
`npx
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
`npx` and `npm install -g` fail the same way on those two versions, and so does the `npx`-based MCP
|
|
36
|
+
server registration below. There is no workaround from the consumer side. **Nothing is wrong with your
|
|
37
|
+
setup, and re-running it will not help.**
|
|
39
38
|
|
|
40
|
-
**Why.**
|
|
39
|
+
**Why.** Those manifests declared the ten `@cosyte/*` sibling packages as local file paths
|
|
41
40
|
(`file:vendor/*.tgz`) rather than as npm version ranges. Those tarballs live in the git repository and
|
|
42
|
-
are deliberately not part of the published package, so npm
|
|
43
|
-
does not exist in your `node_modules` and
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
**A published version is immutable, so `0.0.1`
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
are deliberately not part of the published package, so npm resolved the paths against a directory that
|
|
42
|
+
does not exist in your `node_modules` and stopped at the first one. It was a packaging defect in those
|
|
43
|
+
releases, not a fault in any command.
|
|
44
|
+
|
|
45
|
+
**A published version is immutable, so `0.0.1` and `0.0.2` stay broken: install a later version.** The
|
|
46
|
+
sibling packages are now declared as real npm ranges, and the resulting tarball has been installed from
|
|
47
|
+
outside this repository and exercised, which is the check a `npm publish --dry-run` cannot perform.
|
|
48
|
+
|
|
49
|
+
**One dependency could not be made real, and it costs you FHIR support.** `@cosyte/fhir` is not on the
|
|
50
|
+
npm registry, so it cannot be a dependency of this package at all; `@cosyte/transform` is on npm but
|
|
51
|
+
requires it, so npm skips that too. In an installed copy:
|
|
52
|
+
|
|
53
|
+
- FHIR `parse` / `inspect` / `fmt` / `validate` and the `convert` command report a value-free
|
|
54
|
+
`CLI_PARSER_UNAVAILABLE` and exit `69`. They never guess, and they never blame your input.
|
|
55
|
+
- HL7 v2, `map-codes`, and the six breadth formats (X12, C-CDA, DICOM, NCPDP, ASTM, MLLP) all work.
|
|
56
|
+
|
|
57
|
+
To use the FHIR commands today, run the CLI from a source checkout (`pnpm install && pnpm build`, then
|
|
58
|
+
invoke `dist/bin/cosyte.mjs`), where the FHIR library is supplied locally.
|
|
59
|
+
|
|
60
|
+
> **Status:** pre-alpha (`0.0.x`). `0.0.1` and `0.0.2` are on npm and **cannot be installed** (see
|
|
61
|
+
> above); a later version fixes that. The `cosyte` command wraps **all eight
|
|
56
62
|
> cosyte formats** (**HL7 v2**, **FHIR R4**, **X12**, **ASTM**, **NCPDP SCRIPT**, **C-CDA**, **DICOM**,
|
|
57
63
|
> and **MLLP**) plus the `@cosyte/transform` and `@cosyte/terminology` higher-layer libraries, with
|
|
58
64
|
> conservative content-format autodetection and a documented exit-code contract:
|
|
@@ -82,25 +88,40 @@ checkout (`pnpm install && pnpm build`, then invoke `dist/bin/cosyte.mjs`).
|
|
|
82
88
|
>
|
|
83
89
|
> The CLI is **feature-complete**: an argv+stdin+MCP fuzz gate, an exit-code golden matrix, a
|
|
84
90
|
> built-package smoke of both bins, and a clean `npm publish` dry-run. Those gates cover the code, and
|
|
85
|
-
> the code
|
|
86
|
-
> described above, which is why `0.0.1` published green and still cannot be installed: a
|
|
87
|
-
> builds the tarball but never resolves it from a registry. **
|
|
88
|
-
> and
|
|
89
|
-
>
|
|
91
|
+
> the code was never what was broken. The one release step they do not cover is the dependency swap
|
|
92
|
+
> described above, which is why `0.0.1` and `0.0.2` published green and still cannot be installed: a
|
|
93
|
+
> dry-run builds the tarball but never resolves it from a registry. **That swap has now been made**,
|
|
94
|
+
> and installing the packed tarball from outside the repository is a release step in its own right.
|
|
95
|
+
> `@cosyte/fhir` is the one dependency it could not cover, which is why FHIR support is absent from an
|
|
96
|
+
> installed copy rather than merely deferred. See [RELEASING.md](./RELEASING.md).
|
|
90
97
|
|
|
91
98
|
## Run it
|
|
92
99
|
|
|
93
|
-
> **
|
|
94
|
-
>
|
|
95
|
-
>
|
|
96
|
-
>
|
|
100
|
+
> **These commands do not work yet, and the reason is now only that no fixed version has shipped.**
|
|
101
|
+
> The newest version on npm is `0.0.2`, and it is one of the two that cannot be installed. The
|
|
102
|
+
> packaging defect is fixed in this repository and proven by installing the packed tarball outside it,
|
|
103
|
+
> but a published version is immutable, so the fix reaches you only in the next release. Until then,
|
|
104
|
+
> run it from a source checkout: `pnpm install && pnpm build`, then invoke `dist/bin/cosyte.mjs`.
|
|
97
105
|
|
|
98
106
|
```bash
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
cosyte --help
|
|
107
|
+
npm install -g @cosyte/cli # put `cosyte` on your PATH
|
|
108
|
+
cosyte parse message.hl7 # format autodetected → HL7 v2
|
|
102
109
|
```
|
|
103
110
|
|
|
111
|
+
Or without installing, using `npx`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx --package @cosyte/cli cosyte parse message.hl7
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
> **`npx @cosyte/cli …` (the short form) does not work, and this is not the packaging defect above.**
|
|
118
|
+
> It fails with `could not determine executable to run`. When a package ships more than one
|
|
119
|
+
> executable, `npx` runs the one whose name matches the package name's last segment; that would be
|
|
120
|
+
> `cli`, and this package ships `cosyte` and `cosyte-mcp`. Naming the executable explicitly with
|
|
121
|
+
> `--package` is the supported form, and it works. A `cli` executable is deliberately **not** added as
|
|
122
|
+
> an alias: `npm install -g` would then put a command called `cli` on every user's `PATH`, which is far
|
|
123
|
+
> too generic a name to claim.
|
|
124
|
+
|
|
104
125
|
## `cosyte parse`
|
|
105
126
|
|
|
106
127
|
Read a file (or stdin via `-`), autodetect the format by content, and print the parsed model as typed
|
|
@@ -274,15 +295,16 @@ subprocess**, not a hosted endpoint. Register it in an MCP client's config:
|
|
|
274
295
|
```json
|
|
275
296
|
{
|
|
276
297
|
"mcpServers": {
|
|
277
|
-
"cosyte": { "command": "npx", "args": ["-y", "@cosyte/cli", "mcp"] }
|
|
298
|
+
"cosyte": { "command": "npx", "args": ["-y", "--package", "@cosyte/cli", "cosyte-mcp"] }
|
|
278
299
|
}
|
|
279
300
|
}
|
|
280
301
|
```
|
|
281
302
|
|
|
282
|
-
>
|
|
283
|
-
>
|
|
284
|
-
> [
|
|
285
|
-
>
|
|
303
|
+
> **`--package` is required, and the shorter `["-y", "@cosyte/cli", "mcp"]` does not work**: it fails
|
|
304
|
+
> with `could not determine executable to run`, for the `npx` executable-selection reason described
|
|
305
|
+
> under [Run it](#run-it) above. This also needs a version that can be installed at all, so not
|
|
306
|
+
> `0.0.1` or `0.0.2`. The `convert` tool reports `CLI_PARSER_UNAVAILABLE` from an npm install, because
|
|
307
|
+
> the FHIR library is not on the registry.
|
|
286
308
|
|
|
287
309
|
`cosyte mcp` and the standalone `cosyte-mcp` bin both start the stdio server. It exposes four tools
|
|
288
310
|
(`parse`, `validate`, `inspect`, `convert`), each calling the same command the terminal runs, so the CLI
|
package/dist/bin/cosyte-mcp.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
|
7
7
|
var util = require('util');
|
|
8
8
|
|
|
9
9
|
// src/core/version.ts
|
|
10
|
-
var VERSION = "0.0.
|
|
10
|
+
var VERSION = "0.0.3";
|
|
11
11
|
|
|
12
12
|
// src/core/exit-codes.ts
|
|
13
13
|
var EXIT = {
|
|
@@ -228,19 +228,25 @@ function anyError(findings) {
|
|
|
228
228
|
return findings.some((f) => ERROR_SEVERITIES.has(f.severity));
|
|
229
229
|
}
|
|
230
230
|
async function loadOptional(format, load) {
|
|
231
|
+
return loadOptionalPackage(
|
|
232
|
+
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`,
|
|
233
|
+
load
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
async function loadOptionalPackage(detail, load) {
|
|
231
237
|
try {
|
|
232
238
|
return await load();
|
|
233
239
|
} catch (e) {
|
|
234
240
|
if (isModuleNotFound(e)) {
|
|
235
|
-
throw new CliError(
|
|
236
|
-
CLI_CODES.CLI_PARSER_UNAVAILABLE,
|
|
237
|
-
EXIT.UNAVAILABLE,
|
|
238
|
-
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`
|
|
239
|
-
);
|
|
241
|
+
throw new CliError(CLI_CODES.CLI_PARSER_UNAVAILABLE, EXIT.UNAVAILABLE, detail);
|
|
240
242
|
}
|
|
241
243
|
throw e;
|
|
242
244
|
}
|
|
243
245
|
}
|
|
246
|
+
var FHIR_UNAVAILABLE = "the @cosyte/fhir parser is not installed, and it is not currently on the npm registry, so it cannot be installed from there; FHIR support is unavailable in this install";
|
|
247
|
+
async function loadFhir() {
|
|
248
|
+
return loadOptionalPackage(FHIR_UNAVAILABLE, () => import('@cosyte/fhir'));
|
|
249
|
+
}
|
|
244
250
|
function isModuleNotFound(e) {
|
|
245
251
|
if (typeof e !== "object" || e === null) return false;
|
|
246
252
|
const code = "code" in e ? e.code : void 0;
|
|
@@ -259,7 +265,7 @@ async function parseFormat(format, bytes) {
|
|
|
259
265
|
};
|
|
260
266
|
}
|
|
261
267
|
case "fhir": {
|
|
262
|
-
const { parseResource, serializeResource } = await
|
|
268
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
263
269
|
const text = decode(bytes);
|
|
264
270
|
const { resource, issues } = parseResource(text);
|
|
265
271
|
const model = JSON.parse(serializeResource(resource));
|
|
@@ -320,7 +326,7 @@ async function inspectFormat(format, bytes) {
|
|
|
320
326
|
};
|
|
321
327
|
}
|
|
322
328
|
case "fhir": {
|
|
323
|
-
const { parseResource, resourceType, readBundle } = await
|
|
329
|
+
const { parseResource, resourceType, readBundle } = await loadFhir();
|
|
324
330
|
const { resource, issues } = parseResource(decode(bytes));
|
|
325
331
|
const rt = resourceType(resource) ?? null;
|
|
326
332
|
if (rt === "Bundle") {
|
|
@@ -425,7 +431,7 @@ async function inspectFormat(format, bytes) {
|
|
|
425
431
|
async function validateFormat(format, bytes) {
|
|
426
432
|
switch (format) {
|
|
427
433
|
case "fhir": {
|
|
428
|
-
const { parseResource, validateResource } = await
|
|
434
|
+
const { parseResource, validateResource } = await loadFhir();
|
|
429
435
|
const { resource, issues } = parseResource(decode(bytes));
|
|
430
436
|
const validation = validateResource(resource);
|
|
431
437
|
const findings = [
|
|
@@ -673,11 +679,12 @@ async function convertCommand(args, deps, posture = VALUE_FREE) {
|
|
|
673
679
|
return { stdout: `${conversion.bundleText}
|
|
674
680
|
`, stderr, exit };
|
|
675
681
|
}
|
|
682
|
+
var TRANSFORM_UNAVAILABLE = "the @cosyte/transform conversion library is not installed, so convert is unavailable; it requires @cosyte/fhir, which is not currently on the npm registry, so npm skips transform as an unresolvable optional dependency and installing it directly fails for the same reason";
|
|
676
683
|
async function runConvert(bytes, posture) {
|
|
677
684
|
const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
|
|
678
685
|
import('@cosyte/hl7'),
|
|
679
|
-
import('@cosyte/transform'),
|
|
680
|
-
|
|
686
|
+
loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
|
|
687
|
+
loadFhir()
|
|
681
688
|
]);
|
|
682
689
|
let msg;
|
|
683
690
|
try {
|