@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.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprot
|
|
|
5
5
|
import { parseArgs } from 'util';
|
|
6
6
|
|
|
7
7
|
// src/core/version.ts
|
|
8
|
-
var VERSION = "0.0.
|
|
8
|
+
var VERSION = "0.0.4";
|
|
9
9
|
|
|
10
10
|
// src/core/exit-codes.ts
|
|
11
11
|
var EXIT = {
|
|
@@ -226,19 +226,25 @@ function anyError(findings) {
|
|
|
226
226
|
return findings.some((f) => ERROR_SEVERITIES.has(f.severity));
|
|
227
227
|
}
|
|
228
228
|
async function loadOptional(format, load) {
|
|
229
|
+
return loadOptionalPackage(
|
|
230
|
+
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`,
|
|
231
|
+
load
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
async function loadOptionalPackage(detail, load) {
|
|
229
235
|
try {
|
|
230
236
|
return await load();
|
|
231
237
|
} catch (e) {
|
|
232
238
|
if (isModuleNotFound(e)) {
|
|
233
|
-
throw new CliError(
|
|
234
|
-
CLI_CODES.CLI_PARSER_UNAVAILABLE,
|
|
235
|
-
EXIT.UNAVAILABLE,
|
|
236
|
-
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`
|
|
237
|
-
);
|
|
239
|
+
throw new CliError(CLI_CODES.CLI_PARSER_UNAVAILABLE, EXIT.UNAVAILABLE, detail);
|
|
238
240
|
}
|
|
239
241
|
throw e;
|
|
240
242
|
}
|
|
241
243
|
}
|
|
244
|
+
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";
|
|
245
|
+
async function loadFhir() {
|
|
246
|
+
return loadOptionalPackage(FHIR_UNAVAILABLE, () => import('@cosyte/fhir'));
|
|
247
|
+
}
|
|
242
248
|
function isModuleNotFound(e) {
|
|
243
249
|
if (typeof e !== "object" || e === null) return false;
|
|
244
250
|
const code = "code" in e ? e.code : void 0;
|
|
@@ -257,7 +263,7 @@ async function parseFormat(format, bytes) {
|
|
|
257
263
|
};
|
|
258
264
|
}
|
|
259
265
|
case "fhir": {
|
|
260
|
-
const { parseResource, serializeResource } = await
|
|
266
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
261
267
|
const text = decode(bytes);
|
|
262
268
|
const { resource, issues } = parseResource(text);
|
|
263
269
|
const model = JSON.parse(serializeResource(resource));
|
|
@@ -318,7 +324,7 @@ async function inspectFormat(format, bytes) {
|
|
|
318
324
|
};
|
|
319
325
|
}
|
|
320
326
|
case "fhir": {
|
|
321
|
-
const { parseResource, resourceType, readBundle } = await
|
|
327
|
+
const { parseResource, resourceType, readBundle } = await loadFhir();
|
|
322
328
|
const { resource, issues } = parseResource(decode(bytes));
|
|
323
329
|
const rt = resourceType(resource) ?? null;
|
|
324
330
|
if (rt === "Bundle") {
|
|
@@ -423,7 +429,7 @@ async function inspectFormat(format, bytes) {
|
|
|
423
429
|
async function validateFormat(format, bytes) {
|
|
424
430
|
switch (format) {
|
|
425
431
|
case "fhir": {
|
|
426
|
-
const { parseResource, validateResource } = await
|
|
432
|
+
const { parseResource, validateResource } = await loadFhir();
|
|
427
433
|
const { resource, issues } = parseResource(decode(bytes));
|
|
428
434
|
const validation = validateResource(resource);
|
|
429
435
|
const findings = [
|
|
@@ -671,11 +677,12 @@ async function convertCommand(args, deps, posture = VALUE_FREE) {
|
|
|
671
677
|
return { stdout: `${conversion.bundleText}
|
|
672
678
|
`, stderr, exit };
|
|
673
679
|
}
|
|
680
|
+
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";
|
|
674
681
|
async function runConvert(bytes, posture) {
|
|
675
682
|
const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
|
|
676
683
|
import('@cosyte/hl7'),
|
|
677
|
-
import('@cosyte/transform'),
|
|
678
|
-
|
|
684
|
+
loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
|
|
685
|
+
loadFhir()
|
|
679
686
|
]);
|
|
680
687
|
let msg;
|
|
681
688
|
try {
|