@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/dist/bin/cosyte.mjs
CHANGED
|
@@ -253,19 +253,24 @@ function anyError(findings) {
|
|
|
253
253
|
return findings.some((f) => ERROR_SEVERITIES.has(f.severity));
|
|
254
254
|
}
|
|
255
255
|
async function loadOptional(format, load) {
|
|
256
|
+
return loadOptionalPackage(
|
|
257
|
+
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`,
|
|
258
|
+
load
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
async function loadOptionalPackage(detail, load) {
|
|
256
262
|
try {
|
|
257
263
|
return await load();
|
|
258
264
|
} catch (e) {
|
|
259
265
|
if (isModuleNotFound(e)) {
|
|
260
|
-
throw new CliError(
|
|
261
|
-
CLI_CODES.CLI_PARSER_UNAVAILABLE,
|
|
262
|
-
EXIT.UNAVAILABLE,
|
|
263
|
-
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`
|
|
264
|
-
);
|
|
266
|
+
throw new CliError(CLI_CODES.CLI_PARSER_UNAVAILABLE, EXIT.UNAVAILABLE, detail);
|
|
265
267
|
}
|
|
266
268
|
throw e;
|
|
267
269
|
}
|
|
268
270
|
}
|
|
271
|
+
async function loadFhir() {
|
|
272
|
+
return loadOptionalPackage(FHIR_UNAVAILABLE, () => import('@cosyte/fhir'));
|
|
273
|
+
}
|
|
269
274
|
function isModuleNotFound(e) {
|
|
270
275
|
if (typeof e !== "object" || e === null) return false;
|
|
271
276
|
const code = "code" in e ? e.code : void 0;
|
|
@@ -284,7 +289,7 @@ async function parseFormat(format, bytes) {
|
|
|
284
289
|
};
|
|
285
290
|
}
|
|
286
291
|
case "fhir": {
|
|
287
|
-
const { parseResource, serializeResource } = await
|
|
292
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
288
293
|
const text = decode(bytes);
|
|
289
294
|
const { resource, issues } = parseResource(text);
|
|
290
295
|
const model = JSON.parse(serializeResource(resource));
|
|
@@ -345,7 +350,7 @@ async function inspectFormat(format, bytes) {
|
|
|
345
350
|
};
|
|
346
351
|
}
|
|
347
352
|
case "fhir": {
|
|
348
|
-
const { parseResource, resourceType, readBundle } = await
|
|
353
|
+
const { parseResource, resourceType, readBundle } = await loadFhir();
|
|
349
354
|
const { resource, issues } = parseResource(decode(bytes));
|
|
350
355
|
const rt = resourceType(resource) ?? null;
|
|
351
356
|
if (rt === "Bundle") {
|
|
@@ -455,7 +460,7 @@ async function fmtFormat(format, bytes) {
|
|
|
455
460
|
return { output: msg.toString(), warningCount: msg.warnings.length };
|
|
456
461
|
}
|
|
457
462
|
case "fhir": {
|
|
458
|
-
const { parseResource, serializeResource } = await
|
|
463
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
459
464
|
const { resource, issues } = parseResource(decode(bytes));
|
|
460
465
|
return { output: serializeResource(resource), warningCount: issues.length };
|
|
461
466
|
}
|
|
@@ -493,7 +498,7 @@ async function fmtFormat(format, bytes) {
|
|
|
493
498
|
async function validateFormat(format, bytes) {
|
|
494
499
|
switch (format) {
|
|
495
500
|
case "fhir": {
|
|
496
|
-
const { parseResource, validateResource } = await
|
|
501
|
+
const { parseResource, validateResource } = await loadFhir();
|
|
497
502
|
const { resource, issues } = parseResource(decode(bytes));
|
|
498
503
|
const validation = validateResource(resource);
|
|
499
504
|
const findings = [
|
|
@@ -586,7 +591,7 @@ function unsupportedInternal(format, op) {
|
|
|
586
591
|
`format '${format}' does not support \`${op}\``
|
|
587
592
|
);
|
|
588
593
|
}
|
|
589
|
-
var OP_SUPPORT, ERROR_SEVERITIES;
|
|
594
|
+
var OP_SUPPORT, ERROR_SEVERITIES, FHIR_UNAVAILABLE;
|
|
590
595
|
var init_parsers = __esm({
|
|
591
596
|
"src/core/parsers.ts"() {
|
|
592
597
|
init_diagnostics();
|
|
@@ -603,6 +608,7 @@ var init_parsers = __esm({
|
|
|
603
608
|
mllp: /* @__PURE__ */ new Set(["parse", "inspect"])
|
|
604
609
|
};
|
|
605
610
|
ERROR_SEVERITIES = /* @__PURE__ */ new Set(["error", "fatal"]);
|
|
611
|
+
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";
|
|
606
612
|
}
|
|
607
613
|
});
|
|
608
614
|
|
|
@@ -779,8 +785,8 @@ async function convertCommand(args, deps2, posture = VALUE_FREE) {
|
|
|
779
785
|
async function runConvert(bytes, posture) {
|
|
780
786
|
const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
|
|
781
787
|
import('@cosyte/hl7'),
|
|
782
|
-
import('@cosyte/transform'),
|
|
783
|
-
|
|
788
|
+
loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
|
|
789
|
+
loadFhir()
|
|
784
790
|
]);
|
|
785
791
|
let msg;
|
|
786
792
|
try {
|
|
@@ -811,12 +817,13 @@ function convertOutcome(findings) {
|
|
|
811
817
|
`;
|
|
812
818
|
return { hasError: errors > 0, report: lines.join("") + summary };
|
|
813
819
|
}
|
|
814
|
-
var CONVERT_OPTIONS, SUPPORTED_TARGET, ERROR_SEVERITIES2;
|
|
820
|
+
var CONVERT_OPTIONS, SUPPORTED_TARGET, ERROR_SEVERITIES2, TRANSFORM_UNAVAILABLE;
|
|
815
821
|
var init_convert = __esm({
|
|
816
822
|
"src/commands/convert.ts"() {
|
|
817
823
|
init_diagnostics();
|
|
818
824
|
init_exit_codes();
|
|
819
825
|
init_input();
|
|
826
|
+
init_parsers();
|
|
820
827
|
init_phi();
|
|
821
828
|
init_wrap();
|
|
822
829
|
CONVERT_OPTIONS = {
|
|
@@ -828,6 +835,7 @@ var init_convert = __esm({
|
|
|
828
835
|
};
|
|
829
836
|
SUPPORTED_TARGET = "fhir";
|
|
830
837
|
ERROR_SEVERITIES2 = /* @__PURE__ */ new Set(["error", "fatal"]);
|
|
838
|
+
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";
|
|
831
839
|
}
|
|
832
840
|
});
|
|
833
841
|
async function inspectCommand(args, deps2, posture = VALUE_FREE) {
|
|
@@ -1141,7 +1149,7 @@ var init_validate = __esm({
|
|
|
1141
1149
|
var VERSION;
|
|
1142
1150
|
var init_version = __esm({
|
|
1143
1151
|
"src/core/version.ts"() {
|
|
1144
|
-
VERSION = "0.0.
|
|
1152
|
+
VERSION = "0.0.3";
|
|
1145
1153
|
}
|
|
1146
1154
|
});
|
|
1147
1155
|
|