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