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