@atomic-ehr/fhir-canonical-manager 0.0.13 → 0.0.15
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/dist/cache.d.ts +17 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +50 -0
- package/dist/cache.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +15 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +7 -10
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/list.d.ts.map +1 -1
- package/dist/cli/list.js +14 -10
- package/dist/cli/list.js.map +1 -1
- package/dist/cli/resolve.js +7 -7
- package/dist/cli/resolve.js.map +1 -1
- package/dist/cli/search.js +9 -9
- package/dist/cli/search.js.map +1 -1
- package/dist/cli/searchparam.d.ts.map +1 -1
- package/dist/cli/searchparam.js +27 -24
- package/dist/cli/searchparam.js.map +1 -1
- package/dist/fs/index.d.ts +1 -1
- package/dist/fs/index.d.ts.map +1 -1
- package/dist/fs/index.js +1 -1
- package/dist/fs/index.js.map +1 -1
- package/dist/fs/utils.js +2 -2
- package/dist/fs/utils.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/manager/canonical.d.ts +1 -1
- package/dist/manager/canonical.d.ts.map +1 -1
- package/dist/manager/canonical.js +77 -45
- package/dist/manager/canonical.js.map +1 -1
- package/dist/manager/index.d.ts +1 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +1 -2
- package/dist/manager/index.js.map +1 -1
- package/dist/package.d.ts +4 -0
- package/dist/package.d.ts.map +1 -0
- package/dist/package.js +69 -0
- package/dist/package.js.map +1 -0
- package/dist/{reference/manager.d.ts → reference.d.ts} +8 -3
- package/dist/reference.d.ts.map +1 -0
- package/dist/{reference/manager.js → reference.js} +13 -4
- package/dist/reference.js.map +1 -0
- package/dist/resolver.d.ts +4 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/{resolver/context.js → resolver.js} +2 -2
- package/dist/resolver.js.map +1 -0
- package/dist/scanner/directory.d.ts +2 -2
- package/dist/scanner/directory.d.ts.map +1 -1
- package/dist/scanner/directory.js +24 -27
- package/dist/scanner/directory.js.map +1 -1
- package/dist/scanner/index.d.ts +4 -4
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +4 -4
- package/dist/scanner/index.js.map +1 -1
- package/dist/scanner/package.d.ts +1 -1
- package/dist/scanner/package.d.ts.map +1 -1
- package/dist/scanner/package.js +4 -4
- package/dist/scanner/package.js.map +1 -1
- package/dist/scanner/parser.d.ts +2 -2
- package/dist/scanner/parser.d.ts.map +1 -1
- package/dist/scanner/parser.js +1 -1
- package/dist/scanner/parser.js.map +1 -1
- package/dist/scanner/processor.d.ts +2 -2
- package/dist/scanner/processor.d.ts.map +1 -1
- package/dist/scanner/processor.js +3 -3
- package/dist/scanner/processor.js.map +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -2
- package/dist/search/index.js.map +1 -1
- package/dist/search/smart.d.ts +1 -1
- package/dist/search/smart.d.ts.map +1 -1
- package/dist/search/smart.js +3 -7
- package/dist/search/smart.js.map +1 -1
- package/dist/search/terms.js.map +1 -1
- package/dist/types/core.d.ts +5 -4
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/dist/types/internal.d.ts +7 -4
- package/dist/types/internal.d.ts.map +1 -1
- package/package.json +12 -2
- package/src/cache.ts +59 -0
- package/src/cli/index.ts +112 -114
- package/src/cli/init.ts +104 -108
- package/src/cli/list.ts +84 -77
- package/src/cli/resolve.ts +57 -57
- package/src/cli/search.ts +72 -72
- package/src/cli/searchparam.ts +118 -117
- package/src/constants.ts +1 -1
- package/src/fs/index.ts +1 -1
- package/src/fs/utils.ts +16 -16
- package/src/index.ts +9 -12
- package/src/manager/canonical.ts +349 -360
- package/src/manager/index.ts +1 -3
- package/src/package.ts +79 -0
- package/src/reference.ts +77 -0
- package/src/resolver.ts +38 -0
- package/src/scanner/directory.ts +25 -31
- package/src/scanner/index.ts +4 -4
- package/src/scanner/package.ts +26 -29
- package/src/scanner/parser.ts +25 -27
- package/src/scanner/processor.ts +51 -55
- package/src/search/index.ts +2 -2
- package/src/search/smart.ts +41 -48
- package/src/search/terms.ts +17 -17
- package/src/types/core.ts +102 -89
- package/src/types/index.ts +2 -2
- package/src/types/internal.ts +36 -34
- package/dist/cache/core.d.ts +0 -7
- package/dist/cache/core.d.ts.map +0 -1
- package/dist/cache/core.js +0 -11
- package/dist/cache/core.js.map +0 -1
- package/dist/cache/index.d.ts +0 -4
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/index.js +0 -4
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/persistence.d.ts +0 -5
- package/dist/cache/persistence.d.ts.map +0 -1
- package/dist/cache/persistence.js +0 -25
- package/dist/cache/persistence.js.map +0 -1
- package/dist/cache/validation.d.ts +0 -2
- package/dist/cache/validation.d.ts.map +0 -1
- package/dist/cache/validation.js +0 -21
- package/dist/cache/validation.js.map +0 -1
- package/dist/package/detector.d.ts +0 -2
- package/dist/package/detector.d.ts.map +0 -1
- package/dist/package/detector.js +0 -19
- package/dist/package/detector.js.map +0 -1
- package/dist/package/index.d.ts +0 -3
- package/dist/package/index.d.ts.map +0 -1
- package/dist/package/index.js +0 -3
- package/dist/package/index.js.map +0 -1
- package/dist/package/installer.d.ts +0 -2
- package/dist/package/installer.d.ts.map +0 -1
- package/dist/package/installer.js +0 -55
- package/dist/package/installer.js.map +0 -1
- package/dist/reference/index.d.ts +0 -5
- package/dist/reference/index.d.ts.map +0 -1
- package/dist/reference/index.js +0 -4
- package/dist/reference/index.js.map +0 -1
- package/dist/reference/manager.d.ts.map +0 -1
- package/dist/reference/manager.js.map +0 -1
- package/dist/reference/store.d.ts +0 -6
- package/dist/reference/store.d.ts.map +0 -1
- package/dist/reference/store.js +0 -6
- package/dist/reference/store.js.map +0 -1
- package/dist/resolver/context.d.ts +0 -4
- package/dist/resolver/context.d.ts.map +0 -1
- package/dist/resolver/context.js.map +0 -1
- package/dist/resolver/index.d.ts +0 -2
- package/dist/resolver/index.d.ts.map +0 -1
- package/dist/resolver/index.js +0 -2
- package/dist/resolver/index.js.map +0 -1
- package/src/cache/core.ts +0 -20
- package/src/cache/index.ts +0 -7
- package/src/cache/persistence.ts +0 -39
- package/src/cache/validation.ts +0 -27
- package/src/package/detector.ts +0 -24
- package/src/package/index.ts +0 -6
- package/src/package/installer.ts +0 -77
- package/src/reference/index.ts +0 -10
- package/src/reference/manager.ts +0 -51
- package/src/reference/store.ts +0 -15
- package/src/resolver/context.ts +0 -25
- package/src/resolver/index.ts +0 -5
package/src/cli/searchparam.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { CanonicalManager } from "../index.js";
|
|
6
|
-
import { parseArgs, loadPackageJson, getConfigFromPackageJson } from "./index.js";
|
|
7
6
|
import type { SearchParameter } from "../types/index.js";
|
|
7
|
+
import { getConfigFromPackageJson, loadPackageJson, parseArgs } from "./index.js";
|
|
8
8
|
|
|
9
9
|
export async function searchParamCommand(args: string[]): Promise<void> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const { positional, options } = parseArgs(args);
|
|
11
|
+
|
|
12
|
+
if (options.help || positional.length === 0) {
|
|
13
|
+
console.log(`
|
|
14
14
|
Usage: fcm searchparam <resourceType> [options]
|
|
15
15
|
|
|
16
16
|
Display search parameters for a specific FHIR resource type
|
|
@@ -27,136 +27,137 @@ Examples:
|
|
|
27
27
|
fcm searchparam Observation --format json
|
|
28
28
|
fcm searchparam Encounter --format csv
|
|
29
29
|
`);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const packageJson = await loadPackageJson();
|
|
38
|
-
if (!packageJson) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
"No package.json found. Run 'fcm init' to initialize a project.",
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const config = getConfigFromPackageJson(packageJson);
|
|
45
|
-
const manager = CanonicalManager({
|
|
46
|
-
packages: config.packages || [],
|
|
47
|
-
registry: config.registry,
|
|
48
|
-
workingDir: config.workingDir || process.cwd(),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await manager.init();
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const searchParams = await manager.getSearchParametersForResource(resourceType!);
|
|
55
|
-
|
|
56
|
-
if (searchParams.length === 0) {
|
|
57
|
-
console.log(`No search parameters found for resource type '${resourceType}'`);
|
|
58
|
-
return;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const resourceType = positional[0];
|
|
34
|
+
if (!resourceType) {
|
|
35
|
+
console.error("Error: Resource type is required");
|
|
36
|
+
process.exit(1);
|
|
59
37
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
const format = (options.format as string) || "table";
|
|
39
|
+
|
|
40
|
+
// Load config from package.json
|
|
41
|
+
const packageJson = await loadPackageJson();
|
|
42
|
+
if (!packageJson) {
|
|
43
|
+
throw new Error("No package.json found. Run 'fcm init' to initialize a project.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const config = getConfigFromPackageJson(packageJson);
|
|
47
|
+
const manager = CanonicalManager({
|
|
48
|
+
packages: config.packages || [],
|
|
49
|
+
registry: config.registry,
|
|
50
|
+
workingDir: config.workingDir || process.cwd(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await manager.init();
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const searchParams = await manager.getSearchParametersForResource(resourceType);
|
|
57
|
+
|
|
58
|
+
if (searchParams.length === 0) {
|
|
59
|
+
console.log(`No search parameters found for resource type '${resourceType}'`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Format output based on requested format
|
|
64
|
+
switch (format) {
|
|
65
|
+
case "json":
|
|
66
|
+
outputJson(searchParams);
|
|
67
|
+
break;
|
|
68
|
+
case "csv":
|
|
69
|
+
outputCsv(searchParams);
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
outputTable(searchParams);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
await manager.destroy();
|
|
73
77
|
}
|
|
74
|
-
} finally {
|
|
75
|
-
await manager.destroy();
|
|
76
|
-
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
function outputTable(searchParams: SearchParameter[]): void {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
console.log("");
|
|
82
|
+
|
|
83
|
+
// Display each parameter as a multiline block
|
|
84
|
+
for (const param of searchParams) {
|
|
85
|
+
const code = param.code || "";
|
|
86
|
+
const type = param.type || "";
|
|
87
|
+
const expression = param.expression || "";
|
|
88
|
+
const url = param.url || "";
|
|
89
|
+
|
|
90
|
+
console.log(`Code: ${code}`);
|
|
91
|
+
console.log(`Type: ${type}`);
|
|
92
|
+
if (expression) {
|
|
93
|
+
// Wrap long expressions
|
|
94
|
+
if (expression.length > 60) {
|
|
95
|
+
console.log(`Expression: ${wrapText(expression, 60, " ")}`);
|
|
96
|
+
} else {
|
|
97
|
+
console.log(`Expression: ${expression}`);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
console.log(`Expression: (none)`);
|
|
101
|
+
}
|
|
102
|
+
console.log(`URL: ${url}`);
|
|
103
|
+
console.log("---");
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
console.log(
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
console.log(`Total: ${searchParams.length} search parameters`);
|
|
105
|
+
|
|
106
|
+
console.log(`Total: ${searchParams.length} search parameters`);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
// Helper function to wrap text at specified width
|
|
109
110
|
function wrapText(text: string, width: number, indent: string): string {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
const words = text.split(" ");
|
|
112
|
+
const lines: string[] = [];
|
|
113
|
+
let currentLine = "";
|
|
114
|
+
|
|
115
|
+
for (const word of words) {
|
|
116
|
+
if (currentLine.length + word.length + 1 <= width) {
|
|
117
|
+
currentLine += (currentLine ? " " : "") + word;
|
|
118
|
+
} else {
|
|
119
|
+
if (currentLine) {
|
|
120
|
+
lines.push(currentLine);
|
|
121
|
+
}
|
|
122
|
+
currentLine = word;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (currentLine) {
|
|
119
127
|
lines.push(currentLine);
|
|
120
|
-
}
|
|
121
|
-
currentLine = word;
|
|
122
128
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (currentLine) {
|
|
126
|
-
lines.push(currentLine);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return lines.join('\n' + indent);
|
|
129
|
+
|
|
130
|
+
return lines.join(`\n${indent}`);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
function outputJson(searchParams: SearchParameter[]): void {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
const output = searchParams.map((param) => ({
|
|
135
|
+
code: param.code,
|
|
136
|
+
type: param.type,
|
|
137
|
+
expression: param.expression || null,
|
|
138
|
+
url: param.url,
|
|
139
|
+
}));
|
|
140
|
+
console.log(JSON.stringify(output, null, 2));
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
function outputCsv(searchParams: SearchParameter[]): void {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
// CSV header
|
|
145
|
+
console.log("Code,Type,Expression,URL");
|
|
146
|
+
|
|
147
|
+
// CSV rows - no truncation for CSV output
|
|
148
|
+
for (const param of searchParams) {
|
|
149
|
+
const code = escapeCsv(param.code || "");
|
|
150
|
+
const type = escapeCsv(param.type || "");
|
|
151
|
+
const expression = escapeCsv(param.expression || "");
|
|
152
|
+
const url = escapeCsv(param.url || "");
|
|
153
|
+
console.log(`${code},${type},${expression},${url}`);
|
|
154
|
+
}
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
function escapeCsv(value: string): string {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
158
|
+
// Escape CSV values that contain commas, quotes, or newlines
|
|
159
|
+
if (value.includes(",") || value.includes('"') || value.includes("\n")) {
|
|
160
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
}
|
package/src/constants.ts
CHANGED
package/src/fs/index.ts
CHANGED
package/src/fs/utils.ts
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
* File system utility functions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import * as fs from
|
|
6
|
-
import * as path from
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
7
|
|
|
8
8
|
export const fileExists = async (filePath: string): Promise<boolean> => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(filePath);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const ensureDir = async (dirPath: string): Promise<void> => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
try {
|
|
19
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
20
|
+
} catch {
|
|
21
|
+
// Ignore errors
|
|
22
|
+
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const isFhirPackage = async (dirPath: string): Promise<boolean> => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
26
|
+
const indexPath = path.join(dirPath, ".index.json");
|
|
27
|
+
return fileExists(indexPath);
|
|
28
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
* A package manager for FHIR resources with canonical URL resolution
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Re-export all public types
|
|
7
|
-
export * from './types/index.js';
|
|
8
|
-
|
|
9
|
-
// Re-export reference management
|
|
10
|
-
export { createReferenceManager, ReferenceManagerFactory as ReferenceManager } from './reference/index.js';
|
|
11
|
-
export type { ReferenceManager as ReferenceManagerType } from './reference/index.js';
|
|
12
|
-
|
|
13
6
|
// Re-export main CanonicalManager factory and class
|
|
14
|
-
export { CanonicalManager, createCanonicalManager } from
|
|
15
|
-
|
|
7
|
+
export { CanonicalManager, createCanonicalManager } from "./manager/index.js";
|
|
8
|
+
export type { ReferenceManager as ReferenceManagerType } from "./reference.js";
|
|
9
|
+
// Re-export reference management
|
|
10
|
+
export { createReferenceManager, ReferenceManagerFactory as ReferenceManager } from "./reference.js";
|
|
16
11
|
// Re-export CanonicalManager type interface with T prefix
|
|
17
|
-
export type { CanonicalManager as TCanonicalManager } from
|
|
12
|
+
export type { CanonicalManager as TCanonicalManager } from "./types/core.js";
|
|
13
|
+
// Re-export all public types
|
|
14
|
+
export * from "./types/index.js";
|
|
18
15
|
|
|
19
16
|
// Default export for backward compatibility
|
|
20
|
-
import { createCanonicalManager } from
|
|
21
|
-
export default createCanonicalManager;
|
|
17
|
+
import { createCanonicalManager } from "./manager/index.js";
|
|
18
|
+
export default createCanonicalManager;
|