@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/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var promises = require('fs/promises');
|
|
|
4
4
|
var util = require('util');
|
|
5
5
|
|
|
6
6
|
// src/core/version.ts
|
|
7
|
-
var VERSION = "0.0.
|
|
7
|
+
var VERSION = "0.0.4";
|
|
8
8
|
|
|
9
9
|
// src/core/exit-codes.ts
|
|
10
10
|
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") {
|
|
@@ -430,7 +436,7 @@ async function fmtFormat(format, bytes) {
|
|
|
430
436
|
return { output: msg.toString(), warningCount: msg.warnings.length };
|
|
431
437
|
}
|
|
432
438
|
case "fhir": {
|
|
433
|
-
const { parseResource, serializeResource } = await
|
|
439
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
434
440
|
const { resource, issues } = parseResource(decode(bytes));
|
|
435
441
|
return { output: serializeResource(resource), warningCount: issues.length };
|
|
436
442
|
}
|
|
@@ -468,7 +474,7 @@ async function fmtFormat(format, bytes) {
|
|
|
468
474
|
async function validateFormat(format, bytes) {
|
|
469
475
|
switch (format) {
|
|
470
476
|
case "fhir": {
|
|
471
|
-
const { parseResource, validateResource } = await
|
|
477
|
+
const { parseResource, validateResource } = await loadFhir();
|
|
472
478
|
const { resource, issues } = parseResource(decode(bytes));
|
|
473
479
|
const validation = validateResource(resource);
|
|
474
480
|
const findings = [
|
|
@@ -838,11 +844,12 @@ async function convertCommand(args, deps, posture = VALUE_FREE) {
|
|
|
838
844
|
return { stdout: `${conversion.bundleText}
|
|
839
845
|
`, stderr, exit };
|
|
840
846
|
}
|
|
847
|
+
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";
|
|
841
848
|
async function runConvert(bytes, posture) {
|
|
842
849
|
const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
|
|
843
850
|
import('@cosyte/hl7'),
|
|
844
|
-
import('@cosyte/transform'),
|
|
845
|
-
|
|
851
|
+
loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
|
|
852
|
+
loadFhir()
|
|
846
853
|
]);
|
|
847
854
|
let msg;
|
|
848
855
|
try {
|
|
@@ -1443,6 +1450,7 @@ exports.formatsSupporting = formatsSupporting;
|
|
|
1443
1450
|
exports.inspectCommand = inspectCommand;
|
|
1444
1451
|
exports.inspectFormat = inspectFormat;
|
|
1445
1452
|
exports.loadOptional = loadOptional;
|
|
1453
|
+
exports.loadOptionalPackage = loadOptionalPackage;
|
|
1446
1454
|
exports.mapCodesCommand = mapCodesCommand;
|
|
1447
1455
|
exports.parseCommand = parseCommand;
|
|
1448
1456
|
exports.parseFailureResult = parseFailureResult;
|