@atomic-ehr/fhir-canonical-manager 0.0.14 → 0.0.16

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.
Files changed (81) hide show
  1. package/dist/cache.d.ts +4 -1
  2. package/dist/cache.d.ts.map +1 -1
  3. package/dist/cache.js +30 -4
  4. package/dist/cache.js.map +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/local.d.ts +5 -0
  10. package/dist/local.d.ts.map +1 -0
  11. package/dist/local.js +148 -0
  12. package/dist/local.js.map +1 -0
  13. package/dist/manager/canonical.d.ts.map +1 -1
  14. package/dist/manager/canonical.js +231 -22
  15. package/dist/manager/canonical.js.map +1 -1
  16. package/dist/manager/package-spec.d.ts +5 -0
  17. package/dist/manager/package-spec.d.ts.map +1 -0
  18. package/dist/manager/package-spec.js +28 -0
  19. package/dist/manager/package-spec.js.map +1 -0
  20. package/dist/package.d.ts.map +1 -1
  21. package/dist/package.js +25 -5
  22. package/dist/package.js.map +1 -1
  23. package/dist/{reference/manager.d.ts → reference.d.ts} +8 -3
  24. package/dist/reference.d.ts.map +1 -0
  25. package/dist/{reference/manager.js → reference.js} +7 -2
  26. package/dist/reference.js.map +1 -0
  27. package/dist/{resolver/context.d.ts → resolver.d.ts} +3 -3
  28. package/dist/resolver.d.ts.map +1 -0
  29. package/dist/{resolver/context.js → resolver.js} +1 -1
  30. package/dist/resolver.js.map +1 -0
  31. package/dist/types/core.d.ts +14 -2
  32. package/dist/types/core.d.ts.map +1 -1
  33. package/dist/types/internal.d.ts +4 -2
  34. package/dist/types/internal.d.ts.map +1 -1
  35. package/package.json +2 -3
  36. package/dist/reference/index.d.ts +0 -4
  37. package/dist/reference/index.d.ts.map +0 -1
  38. package/dist/reference/index.js +0 -3
  39. package/dist/reference/index.js.map +0 -1
  40. package/dist/reference/manager.d.ts.map +0 -1
  41. package/dist/reference/manager.js.map +0 -1
  42. package/dist/reference/store.d.ts +0 -6
  43. package/dist/reference/store.d.ts.map +0 -1
  44. package/dist/reference/store.js +0 -6
  45. package/dist/reference/store.js.map +0 -1
  46. package/dist/resolver/context.d.ts.map +0 -1
  47. package/dist/resolver/context.js.map +0 -1
  48. package/dist/resolver/index.d.ts +0 -2
  49. package/dist/resolver/index.d.ts.map +0 -1
  50. package/dist/resolver/index.js +0 -2
  51. package/dist/resolver/index.js.map +0 -1
  52. package/src/cache.ts +0 -58
  53. package/src/cli/index.ts +0 -181
  54. package/src/cli/init.ts +0 -112
  55. package/src/cli/list.ts +0 -95
  56. package/src/cli/resolve.ts +0 -63
  57. package/src/cli/search.ts +0 -83
  58. package/src/cli/searchparam.ts +0 -163
  59. package/src/constants.ts +0 -6
  60. package/src/fs/index.ts +0 -5
  61. package/src/fs/utils.ts +0 -28
  62. package/src/index.ts +0 -18
  63. package/src/manager/canonical.ts +0 -327
  64. package/src/manager/index.ts +0 -6
  65. package/src/package.ts +0 -79
  66. package/src/reference/index.ts +0 -8
  67. package/src/reference/manager.ts +0 -55
  68. package/src/reference/store.ts +0 -14
  69. package/src/resolver/context.ts +0 -25
  70. package/src/resolver/index.ts +0 -5
  71. package/src/scanner/directory.ts +0 -36
  72. package/src/scanner/index.ts +0 -8
  73. package/src/scanner/package.ts +0 -35
  74. package/src/scanner/parser.ts +0 -40
  75. package/src/scanner/processor.ts +0 -65
  76. package/src/search/index.ts +0 -6
  77. package/src/search/smart.ts +0 -50
  78. package/src/search/terms.ts +0 -22
  79. package/src/types/core.ts +0 -131
  80. package/src/types/index.ts +0 -6
  81. package/src/types/internal.ts +0 -59
@@ -1,40 +0,0 @@
1
- /**
2
- * Index file parsing and validation
3
- */
4
-
5
- import type { IndexFile } from "../types/index.js";
6
-
7
- export const isValidFileEntry = (entry: any): boolean => {
8
- if (!entry || typeof entry !== "object") return false;
9
- if (!entry.filename || typeof entry.filename !== "string") return false;
10
- if (!entry.resourceType || typeof entry.resourceType !== "string") return false;
11
- if (!entry.id || typeof entry.id !== "string") return false;
12
-
13
- const optionalStringFields = ["url", "version", "kind", "type"];
14
- for (const field of optionalStringFields) {
15
- if (entry[field] !== undefined && typeof entry[field] !== "string") {
16
- return false;
17
- }
18
- }
19
-
20
- return true;
21
- };
22
-
23
- export const isValidIndexFile = (data: any): boolean => {
24
- if (!data || typeof data !== "object") return false;
25
- if (!data["index-version"] || typeof data["index-version"] !== "number") return false;
26
- if (!Array.isArray(data.files)) return false;
27
- return data.files.every((file: any) => isValidFileEntry(file));
28
- };
29
-
30
- export const parseIndex = (content: string, _filePath: string): IndexFile | null => {
31
- try {
32
- const data = JSON.parse(content);
33
- if (!isValidIndexFile(data)) {
34
- return null;
35
- }
36
- return data as IndexFile;
37
- } catch {
38
- return null;
39
- }
40
- };
@@ -1,65 +0,0 @@
1
- /**
2
- * Index processing functionality
3
- */
4
-
5
- import * as fs from "node:fs/promises";
6
- import * as path from "node:path";
7
- import type { ExtendedCache } from "../cache.js";
8
- import type { IndexEntry, PackageJson } from "../types/index.js";
9
- import { parseIndex } from "./parser.js";
10
-
11
- export const processIndex = async (basePath: string, packageJson: PackageJson, cache: ExtendedCache): Promise<void> => {
12
- const indexPath = path.join(basePath, ".index.json");
13
-
14
- try {
15
- const indexContent = await fs.readFile(indexPath, "utf-8");
16
- const index = parseIndex(indexContent, indexPath);
17
-
18
- if (!index) return;
19
-
20
- for (const file of index.files) {
21
- if (!file.url) continue;
22
-
23
- const filePath = path.join(basePath, file.filename);
24
-
25
- const id = cache.referenceManager.generateId({
26
- packageName: packageJson.name,
27
- packageVersion: packageJson.version,
28
- filePath,
29
- });
30
-
31
- cache.referenceManager.set(id, {
32
- packageName: packageJson.name,
33
- packageVersion: packageJson.version,
34
- filePath,
35
- resourceType: file.resourceType,
36
- url: file.url,
37
- version: file.version,
38
- });
39
-
40
- const entry: IndexEntry = {
41
- id,
42
- resourceType: file.resourceType,
43
- indexVersion: index["index-version"],
44
- url: file.url,
45
- version: file.version,
46
- kind: file.kind,
47
- type: file.type,
48
- package: {
49
- name: packageJson.name,
50
- version: packageJson.version,
51
- },
52
- };
53
-
54
- if (!cache.entries[file.url]) {
55
- cache.entries[file.url] = [];
56
- }
57
- const entries = cache.entries[file.url];
58
- if (entries) {
59
- entries.push(entry);
60
- }
61
- }
62
- } catch {
63
- // Silently ignore index processing errors
64
- }
65
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * Search module exports
3
- */
4
-
5
- export { filterBySmartSearch, type SmartSearchFilters } from "./smart.js";
6
- export { expandedTerms } from "./terms.js";
@@ -1,50 +0,0 @@
1
- /**
2
- * Smart search functionality with abbreviation support
3
- */
4
-
5
- import type { IndexEntry, PackageId } from "../types/index.js";
6
- import { expandedTerms } from "./terms.js";
7
-
8
- export interface SmartSearchFilters {
9
- resourceType?: string;
10
- type?: string;
11
- kind?: string;
12
- package?: PackageId;
13
- }
14
-
15
- export const filterBySmartSearch = (results: IndexEntry[], searchTerms: string[]): IndexEntry[] => {
16
- if (searchTerms.length === 0) {
17
- return results;
18
- }
19
-
20
- const terms = searchTerms.map((t) => t.toLowerCase());
21
-
22
- return results.filter((entry) => {
23
- if (!entry.url) return false;
24
- const urlLower = entry.url.toLowerCase();
25
-
26
- // Also check type and resourceType for matching
27
- const fullText = [urlLower, entry.type?.toLowerCase() || "", entry.resourceType?.toLowerCase() || ""].join(" ");
28
-
29
- // Check if all search terms match
30
- return terms.every((term) => {
31
- // Split the text into parts (by /, -, _, ., spaces)
32
- const allParts = fullText.split(/[/\-_.\s]+/);
33
-
34
- // Check if any part starts with the search term
35
- const directMatch = allParts.some((part) => part.startsWith(term));
36
- if (directMatch) return true;
37
-
38
- // Check if the term is an abbreviation
39
- const expansions = expandedTerms[term] || [];
40
- for (const expansion of expansions) {
41
- if (allParts.some((part) => part.startsWith(expansion))) {
42
- return true;
43
- }
44
- }
45
-
46
- // If still no match, check if the term appears anywhere (substring match)
47
- return fullText.includes(term);
48
- });
49
- });
50
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * Search term expansion and abbreviations
3
- */
4
-
5
- export const expandedTerms: Record<string, string[]> = {
6
- str: ["structure"],
7
- struct: ["structure"],
8
- def: ["definition"],
9
- pati: ["patient"],
10
- obs: ["observation"],
11
- org: ["organization"],
12
- pract: ["practitioner"],
13
- med: ["medication", "medicinal"],
14
- req: ["request"],
15
- resp: ["response"],
16
- ref: ["reference"],
17
- val: ["value"],
18
- code: ["codesystem", "code"],
19
- cs: ["codesystem"],
20
- vs: ["valueset"],
21
- sd: ["structuredefinition"],
22
- };
package/src/types/core.ts DELETED
@@ -1,131 +0,0 @@
1
- /**
2
- * Core public API types for FHIR Canonical Manager
3
- */
4
-
5
- export interface Reference {
6
- id: string;
7
- resourceType: string;
8
- }
9
-
10
- export interface PackageId {
11
- name: string;
12
- version: string;
13
- }
14
-
15
- export interface IndexEntry extends Reference {
16
- indexVersion: number;
17
- kind?: string;
18
- url?: string;
19
- type?: string;
20
- version?: string;
21
- package?: PackageId;
22
- }
23
-
24
- export interface Resource extends Reference {
25
- url?: string;
26
- version?: string;
27
- [key: string]: any;
28
- }
29
-
30
- export interface SearchParameter {
31
- // Required fields
32
- url: string;
33
- name: string;
34
- code: string;
35
- base: string[];
36
- type: string;
37
- expression: string;
38
-
39
- // Optional commonly-used fields
40
- version?: string;
41
- target?: string[];
42
- multipleOr?: boolean;
43
- multipleAnd?: boolean;
44
- comparator?: Array<"eq" | "ne" | "gt" | "lt" | "ge" | "le" | "sa" | "eb" | "ap">;
45
- modifier?: Array<
46
- | "missing"
47
- | "exact"
48
- | "contains"
49
- | "not"
50
- | "text"
51
- | "in"
52
- | "not-in"
53
- | "below"
54
- | "above"
55
- | "type"
56
- | "identifier"
57
- | "ofType"
58
- >;
59
-
60
- // Open for all other FHIR SearchParameter fields
61
- [key: string]: any;
62
- }
63
-
64
- export interface SourceContext {
65
- id?: string;
66
- package?: PackageId;
67
- url?: string;
68
- path?: string;
69
- }
70
-
71
- export interface Config {
72
- packages: string[];
73
- workingDir: string;
74
- registry?: string;
75
- }
76
-
77
- export interface PackageInfo {
78
- id: PackageId;
79
- path: string;
80
- canonical?: string;
81
- fhirVersions?: string[];
82
- }
83
-
84
- export interface CanonicalManager {
85
- init(): Promise<void>;
86
- destroy(): Promise<void>;
87
- packages(): Promise<PackageId[]>;
88
- addPackages(...packageNames: string[]): Promise<void>;
89
- resolveEntry(
90
- canonicalUrl: string,
91
- options?: {
92
- package?: string;
93
- version?: string;
94
- sourceContext?: SourceContext;
95
- },
96
- ): Promise<IndexEntry>;
97
- resolve(
98
- canonicalUrl: string,
99
- options?: {
100
- package?: string;
101
- version?: string;
102
- sourceContext?: SourceContext;
103
- },
104
- ): Promise<Resource>;
105
- read(reference: Reference): Promise<Resource>;
106
- searchEntries(params: {
107
- kind?: string;
108
- url?: string;
109
- type?: string;
110
- version?: string;
111
- package?: PackageId;
112
- }): Promise<IndexEntry[]>;
113
- search(params: {
114
- kind?: string;
115
- url?: string;
116
- type?: string;
117
- version?: string;
118
- package?: PackageId;
119
- }): Promise<Resource[]>;
120
- smartSearch(
121
- searchTerms: string[],
122
- filters?: {
123
- resourceType?: string;
124
- type?: string;
125
- kind?: string;
126
- package?: PackageId;
127
- },
128
- ): Promise<IndexEntry[]>;
129
- getSearchParametersForResource(resourceType: string): Promise<SearchParameter[]>;
130
- packageJson(packageName: string): Promise<unknown>;
131
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Type exports for FHIR Canonical Manager
3
- */
4
-
5
- export * from "./core.js";
6
- export * from "./internal.js";
@@ -1,59 +0,0 @@
1
- /**
2
- * Internal implementation types for FHIR Canonical Manager
3
- */
4
-
5
- export interface IndexFile {
6
- "index-version": number;
7
- files: IndexFileEntry[];
8
- }
9
-
10
- export interface IndexFileEntry {
11
- filename: string;
12
- resourceType: string;
13
- id: string;
14
- url?: string;
15
- version?: string;
16
- kind?: string;
17
- type?: string;
18
- }
19
-
20
- export interface PackageJson {
21
- name: string;
22
- version: string;
23
- fhirVersions?: string[];
24
- type?: string;
25
- canonical?: string;
26
- dependencies?: Record<string, string>;
27
- }
28
-
29
- export interface ReferenceMetadata {
30
- packageName: string;
31
- packageVersion: string;
32
- filePath: string;
33
- resourceType: string;
34
- url?: string;
35
- version?: string;
36
- }
37
-
38
- export type CacheKey = string & { readonly __brand: unique symbol };
39
-
40
- export interface IndexCache {
41
- entries: Record<string, import("./core").IndexEntry[]>;
42
- packages: Record<string, import("./core").PackageInfo>;
43
- references: Record<string, ReferenceMetadata>;
44
- }
45
-
46
- export interface CacheData {
47
- entries: Record<string, import("./core").IndexEntry[]>;
48
- packages: Record<string, import("./core").PackageInfo>;
49
- references: Record<string, ReferenceMetadata>;
50
- packageLockHash?: string; // Hash of package-lock.json to detect changes
51
- }
52
-
53
- export interface ReferenceStore {
54
- get(id: string): ReferenceMetadata | undefined;
55
- set(id: string, metadata: ReferenceMetadata): void;
56
- has(id: string): boolean;
57
- clear(): void;
58
- size(): number;
59
- }