@the-cascade-protocol/cli 0.2.0
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/.dockerignore +7 -0
- package/.eslintrc.json +23 -0
- package/.prettierrc +7 -0
- package/DOCKER.md +36 -0
- package/Dockerfile +18 -0
- package/README.md +69 -0
- package/dist/commands/capabilities.d.ts +9 -0
- package/dist/commands/capabilities.d.ts.map +1 -0
- package/dist/commands/capabilities.js +194 -0
- package/dist/commands/capabilities.js.map +1 -0
- package/dist/commands/conformance.d.ts +15 -0
- package/dist/commands/conformance.d.ts.map +1 -0
- package/dist/commands/conformance.js +348 -0
- package/dist/commands/conformance.js.map +1 -0
- package/dist/commands/convert.d.ts +21 -0
- package/dist/commands/convert.d.ts.map +1 -0
- package/dist/commands/convert.js +134 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/pod/export.d.ts +8 -0
- package/dist/commands/pod/export.d.ts.map +1 -0
- package/dist/commands/pod/export.js +72 -0
- package/dist/commands/pod/export.js.map +1 -0
- package/dist/commands/pod/helpers.d.ts +79 -0
- package/dist/commands/pod/helpers.d.ts.map +1 -0
- package/dist/commands/pod/helpers.js +369 -0
- package/dist/commands/pod/helpers.js.map +1 -0
- package/dist/commands/pod/index.d.ts +20 -0
- package/dist/commands/pod/index.d.ts.map +1 -0
- package/dist/commands/pod/index.js +29 -0
- package/dist/commands/pod/index.js.map +1 -0
- package/dist/commands/pod/info.d.ts +9 -0
- package/dist/commands/pod/info.d.ts.map +1 -0
- package/dist/commands/pod/info.js +196 -0
- package/dist/commands/pod/info.js.map +1 -0
- package/dist/commands/pod/init.d.ts +9 -0
- package/dist/commands/pod/init.d.ts.map +1 -0
- package/dist/commands/pod/init.js +251 -0
- package/dist/commands/pod/init.js.map +1 -0
- package/dist/commands/pod/query.d.ts +9 -0
- package/dist/commands/pod/query.d.ts.map +1 -0
- package/dist/commands/pod/query.js +169 -0
- package/dist/commands/pod/query.js.map +1 -0
- package/dist/commands/pod 2.js +1017 -0
- package/dist/commands/pod.d.ts +28 -0
- package/dist/commands/pod.d.ts 2.map +1 -0
- package/dist/commands/pod.d.ts.map +1 -0
- package/dist/commands/pod.js +1031 -0
- package/dist/commands/pod.js 2.map +1 -0
- package/dist/commands/pod.js.map +1 -0
- package/dist/commands/serve.d.ts +33 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +74 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/validate.d.ts +18 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +275 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/fhir-converter/cascade-to-fhir.d.ts +17 -0
- package/dist/lib/fhir-converter/cascade-to-fhir.d.ts.map +1 -0
- package/dist/lib/fhir-converter/cascade-to-fhir.js +358 -0
- package/dist/lib/fhir-converter/cascade-to-fhir.js.map +1 -0
- package/dist/lib/fhir-converter/converters-clinical.d.ts +29 -0
- package/dist/lib/fhir-converter/converters-clinical.d.ts.map +1 -0
- package/dist/lib/fhir-converter/converters-clinical.js +391 -0
- package/dist/lib/fhir-converter/converters-clinical.js.map +1 -0
- package/dist/lib/fhir-converter/converters-demographics.d.ts +20 -0
- package/dist/lib/fhir-converter/converters-demographics.d.ts.map +1 -0
- package/dist/lib/fhir-converter/converters-demographics.js +242 -0
- package/dist/lib/fhir-converter/converters-demographics.js.map +1 -0
- package/dist/lib/fhir-converter/fhir-to-cascade.d.ts +17 -0
- package/dist/lib/fhir-converter/fhir-to-cascade.d.ts.map +1 -0
- package/dist/lib/fhir-converter/fhir-to-cascade.js +63 -0
- package/dist/lib/fhir-converter/fhir-to-cascade.js.map +1 -0
- package/dist/lib/fhir-converter/index.d.ts +36 -0
- package/dist/lib/fhir-converter/index.d.ts.map +1 -0
- package/dist/lib/fhir-converter/index.js +187 -0
- package/dist/lib/fhir-converter/index.js.map +1 -0
- package/dist/lib/fhir-converter/types.d.ts +77 -0
- package/dist/lib/fhir-converter/types.d.ts.map +1 -0
- package/dist/lib/fhir-converter/types.js +236 -0
- package/dist/lib/fhir-converter/types.js.map +1 -0
- package/dist/lib/fhir-converter.d.ts +62 -0
- package/dist/lib/fhir-converter.d.ts.map +1 -0
- package/dist/lib/fhir-converter.js +1474 -0
- package/dist/lib/fhir-converter.js.map +1 -0
- package/dist/lib/mcp/audit.d.ts +24 -0
- package/dist/lib/mcp/audit.d.ts.map +1 -0
- package/dist/lib/mcp/audit.js +85 -0
- package/dist/lib/mcp/audit.js.map +1 -0
- package/dist/lib/mcp/server.d.ts +38 -0
- package/dist/lib/mcp/server.d.ts.map +1 -0
- package/dist/lib/mcp/server.js +172 -0
- package/dist/lib/mcp/server.js.map +1 -0
- package/dist/lib/mcp/tools.d.ts +47 -0
- package/dist/lib/mcp/tools.d.ts.map +1 -0
- package/dist/lib/mcp/tools.js +547 -0
- package/dist/lib/mcp/tools.js.map +1 -0
- package/dist/lib/output.d.ts +26 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +64 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/shacl-validator.d.ts +53 -0
- package/dist/lib/shacl-validator.d.ts.map +1 -0
- package/dist/lib/shacl-validator.js +245 -0
- package/dist/lib/shacl-validator.js.map +1 -0
- package/dist/lib/turtle-parser.d.ts +64 -0
- package/dist/lib/turtle-parser.d.ts.map +1 -0
- package/dist/lib/turtle-parser.js +236 -0
- package/dist/lib/turtle-parser.js.map +1 -0
- package/dist/shapes/checkup.shapes.ttl +1459 -0
- package/dist/shapes/clinical.shapes.ttl +1350 -0
- package/dist/shapes/clinical.ttl +1369 -0
- package/dist/shapes/core.shapes.ttl +450 -0
- package/dist/shapes/core.ttl +603 -0
- package/dist/shapes/coverage.shapes.ttl +214 -0
- package/dist/shapes/coverage.ttl +182 -0
- package/dist/shapes/health.shapes.ttl +697 -0
- package/dist/shapes/health.ttl +859 -0
- package/dist/shapes/pots.shapes.ttl +481 -0
- package/package.json +54 -0
- package/src/commands/capabilities.ts +235 -0
- package/src/commands/conformance.ts +447 -0
- package/src/commands/convert.ts +164 -0
- package/src/commands/pod/export.ts +85 -0
- package/src/commands/pod/helpers.ts +449 -0
- package/src/commands/pod/index.ts +32 -0
- package/src/commands/pod/info.ts +239 -0
- package/src/commands/pod/init.ts +273 -0
- package/src/commands/pod/query.ts +224 -0
- package/src/commands/serve.ts +92 -0
- package/src/commands/validate.ts +303 -0
- package/src/index.ts +58 -0
- package/src/lib/fhir-converter/cascade-to-fhir.ts +369 -0
- package/src/lib/fhir-converter/converters-clinical.ts +446 -0
- package/src/lib/fhir-converter/converters-demographics.ts +270 -0
- package/src/lib/fhir-converter/fhir-to-cascade.ts +82 -0
- package/src/lib/fhir-converter/index.ts +215 -0
- package/src/lib/fhir-converter/types.ts +318 -0
- package/src/lib/mcp/audit.ts +107 -0
- package/src/lib/mcp/server.ts +192 -0
- package/src/lib/mcp/tools.ts +668 -0
- package/src/lib/output.ts +76 -0
- package/src/lib/shacl-validator.ts +314 -0
- package/src/lib/turtle-parser.ts +277 -0
- package/src/shapes/checkup.shapes.ttl +1459 -0
- package/src/shapes/clinical.shapes.ttl +1350 -0
- package/src/shapes/clinical.ttl +1369 -0
- package/src/shapes/core.shapes.ttl +450 -0
- package/src/shapes/core.ttl +603 -0
- package/src/shapes/coverage.shapes.ttl +214 -0
- package/src/shapes/coverage.ttl +182 -0
- package/src/shapes/health.shapes.ttl +697 -0
- package/src/shapes/health.ttl +859 -0
- package/src/shapes/pots.shapes.ttl +481 -0
- package/test-fixtures/fhir-bundle-example.json +216 -0
- package/test-fixtures/fhir-medication-example.json +18 -0
- package/tests/cli.test.ts +126 -0
- package/tests/fhir-converter.test.ts +874 -0
- package/tests/mcp-server.test.ts +396 -0
- package/tests/pod.test.ts +400 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"resourceType": "MedicationStatement",
|
|
3
|
+
"id": "example-med",
|
|
4
|
+
"status": "active",
|
|
5
|
+
"medicationCodeableConcept": {
|
|
6
|
+
"coding": [
|
|
7
|
+
{
|
|
8
|
+
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
|
|
9
|
+
"code": "860975",
|
|
10
|
+
"display": "Metformin 500mg"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"text": "Metformin HCl 500mg"
|
|
14
|
+
},
|
|
15
|
+
"subject": { "reference": "Patient/example" },
|
|
16
|
+
"effectivePeriod": { "start": "2024-01-15" },
|
|
17
|
+
"dosage": [{ "text": "500mg twice daily" }]
|
|
18
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
const CLI_PATH = resolve(__dirname, '../dist/index.js');
|
|
6
|
+
|
|
7
|
+
function runCli(args: string): string {
|
|
8
|
+
try {
|
|
9
|
+
return execSync(`node ${CLI_PATH} ${args}`, {
|
|
10
|
+
encoding: 'utf-8',
|
|
11
|
+
timeout: 10000,
|
|
12
|
+
}).trim();
|
|
13
|
+
} catch (error: unknown) {
|
|
14
|
+
const execError = error as { stdout?: string; stderr?: string; status?: number };
|
|
15
|
+
// Commands that exit with non-zero still produce output
|
|
16
|
+
return (execError.stdout ?? '').trim() + (execError.stderr ?? '').trim();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('cascade CLI', () => {
|
|
21
|
+
describe('--version', () => {
|
|
22
|
+
it('should print the version number', () => {
|
|
23
|
+
const output = runCli('--version');
|
|
24
|
+
expect(output).toBe('0.2.0');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('--help', () => {
|
|
29
|
+
it('should print help text', () => {
|
|
30
|
+
const output = runCli('--help');
|
|
31
|
+
expect(output).toContain('Cascade Protocol CLI');
|
|
32
|
+
expect(output).toContain('validate');
|
|
33
|
+
expect(output).toContain('convert');
|
|
34
|
+
expect(output).toContain('pod');
|
|
35
|
+
expect(output).toContain('conformance');
|
|
36
|
+
expect(output).toContain('serve');
|
|
37
|
+
expect(output).toContain('capabilities');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should include examples in help output', () => {
|
|
41
|
+
const output = runCli('--help');
|
|
42
|
+
expect(output).toContain('Examples:');
|
|
43
|
+
expect(output).toContain('cascade validate record.ttl');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('capabilities', () => {
|
|
48
|
+
it('should output valid JSON', () => {
|
|
49
|
+
const output = runCli('capabilities');
|
|
50
|
+
const parsed = JSON.parse(output);
|
|
51
|
+
expect(parsed).toBeDefined();
|
|
52
|
+
expect(parsed.name).toBe('@the-cascade-protocol/cli');
|
|
53
|
+
expect(parsed.version).toBe('0.2.0');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should list all tools', () => {
|
|
57
|
+
const output = runCli('capabilities');
|
|
58
|
+
const parsed = JSON.parse(output);
|
|
59
|
+
expect(parsed.tools).toBeInstanceOf(Array);
|
|
60
|
+
expect(parsed.tools.length).toBeGreaterThan(0);
|
|
61
|
+
|
|
62
|
+
const toolNames = parsed.tools.map((t: { name: string }) => t.name);
|
|
63
|
+
expect(toolNames).toContain('validate');
|
|
64
|
+
expect(toolNames).toContain('convert');
|
|
65
|
+
expect(toolNames).toContain('pod init');
|
|
66
|
+
expect(toolNames).toContain('serve');
|
|
67
|
+
expect(toolNames).toContain('capabilities');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should mark capabilities as implemented', () => {
|
|
71
|
+
const output = runCli('capabilities');
|
|
72
|
+
const parsed = JSON.parse(output);
|
|
73
|
+
const capTool = parsed.tools.find((t: { name: string }) => t.name === 'capabilities');
|
|
74
|
+
expect(capTool.status).toBe('implemented');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should include protocol URL', () => {
|
|
78
|
+
const output = runCli('capabilities');
|
|
79
|
+
const parsed = JSON.parse(output);
|
|
80
|
+
expect(parsed.protocol).toBe('https://cascadeprotocol.org');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('validate', () => {
|
|
85
|
+
it('should report error for non-existent file', () => {
|
|
86
|
+
const output = runCli('validate nonexistent.ttl');
|
|
87
|
+
expect(output).toContain('Path not found');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should validate a valid Turtle file', () => {
|
|
91
|
+
const podPath = resolve(__dirname, '../../reference-patient-pod/clinical/medications.ttl');
|
|
92
|
+
const output = runCli(`validate ${podPath}`);
|
|
93
|
+
expect(output).toContain('PASS');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should output JSON when --json flag is used', () => {
|
|
97
|
+
const podPath = resolve(__dirname, '../../reference-patient-pod/clinical/medications.ttl');
|
|
98
|
+
const output = runCli(`--json validate ${podPath}`);
|
|
99
|
+
const parsed = JSON.parse(output);
|
|
100
|
+
expect(parsed).toBeInstanceOf(Array);
|
|
101
|
+
expect(parsed[0].valid).toBe(true);
|
|
102
|
+
expect(parsed[0].quadCount).toBeGreaterThan(0);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should validate a directory of Turtle files', () => {
|
|
106
|
+
const podPath = resolve(__dirname, '../../reference-patient-pod/clinical');
|
|
107
|
+
const output = runCli(`validate ${podPath}`);
|
|
108
|
+
expect(output).toContain('PASS');
|
|
109
|
+
expect(output).toContain('Validation Summary');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('global options', () => {
|
|
114
|
+
it('should accept --json flag', () => {
|
|
115
|
+
const output = runCli('--json capabilities');
|
|
116
|
+
const parsed = JSON.parse(output);
|
|
117
|
+
expect(parsed.name).toBe('@the-cascade-protocol/cli');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should accept --verbose flag', () => {
|
|
121
|
+
// --verbose should not cause an error
|
|
122
|
+
const output = runCli('--verbose capabilities');
|
|
123
|
+
expect(output).toBeTruthy();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|