@cosyte/cli 0.0.2 → 0.0.4
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 +289 -30
- 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/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.4";
|
|
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 {
|