fhir-persistence 0.1.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/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/dist/cjs/index.cjs +8869 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/index.d.ts +3114 -0
- package/dist/cjs/package.json +5 -0
- package/dist/esm/index.d.ts +3114 -0
- package/dist/esm/index.mjs +8745 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/index.d.ts +3114 -0
- package/dist/lib/cache/resource-cache.d.ts +137 -0
- package/dist/lib/cache/resource-cache.d.ts.map +1 -0
- package/dist/lib/cli/reindex.d.ts +55 -0
- package/dist/lib/cli/reindex.d.ts.map +1 -0
- package/dist/lib/db/adapter.d.ts +79 -0
- package/dist/lib/db/adapter.d.ts.map +1 -0
- package/dist/lib/db/better-sqlite3-adapter.d.ts +65 -0
- package/dist/lib/db/better-sqlite3-adapter.d.ts.map +1 -0
- package/dist/lib/db/dialect.d.ts +87 -0
- package/dist/lib/db/dialect.d.ts.map +1 -0
- package/dist/lib/db/index.d.ts +18 -0
- package/dist/lib/db/index.d.ts.map +1 -0
- package/dist/lib/db/postgres-adapter.d.ts +84 -0
- package/dist/lib/db/postgres-adapter.d.ts.map +1 -0
- package/dist/lib/db/postgres-dialect.d.ts +36 -0
- package/dist/lib/db/postgres-dialect.d.ts.map +1 -0
- package/dist/lib/db/sqlite-adapter.d.ts +41 -0
- package/dist/lib/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/lib/db/sqlite-dialect.d.ts +34 -0
- package/dist/lib/db/sqlite-dialect.d.ts.map +1 -0
- package/dist/lib/index.d.ts +65 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/migration/ig-persistence-manager.d.ts +56 -0
- package/dist/lib/migration/ig-persistence-manager.d.ts.map +1 -0
- package/dist/lib/migration/migration-generator.d.ts +38 -0
- package/dist/lib/migration/migration-generator.d.ts.map +1 -0
- package/dist/lib/migration/reindex-scheduler.d.ts +82 -0
- package/dist/lib/migration/reindex-scheduler.d.ts.map +1 -0
- package/dist/lib/migration/schema-diff.d.ts +44 -0
- package/dist/lib/migration/schema-diff.d.ts.map +1 -0
- package/dist/lib/migrations/index.d.ts +8 -0
- package/dist/lib/migrations/index.d.ts.map +1 -0
- package/dist/lib/migrations/migration-runner.d.ts +102 -0
- package/dist/lib/migrations/migration-runner.d.ts.map +1 -0
- package/dist/lib/observability/search-logger.d.ts +74 -0
- package/dist/lib/observability/search-logger.d.ts.map +1 -0
- package/dist/lib/platform/platform-ig-definitions.d.ts +51 -0
- package/dist/lib/platform/platform-ig-definitions.d.ts.map +1 -0
- package/dist/lib/platform/platform-ig-loader.d.ts +30 -0
- package/dist/lib/platform/platform-ig-loader.d.ts.map +1 -0
- package/dist/lib/providers/definition-provider.d.ts +124 -0
- package/dist/lib/providers/definition-provider.d.ts.map +1 -0
- package/dist/lib/providers/fhir-definition-provider.d.ts +58 -0
- package/dist/lib/providers/fhir-definition-provider.d.ts.map +1 -0
- package/dist/lib/providers/fhir-runtime-provider.d.ts +75 -0
- package/dist/lib/providers/fhir-runtime-provider.d.ts.map +1 -0
- package/dist/lib/providers/in-memory-definition-provider.d.ts +72 -0
- package/dist/lib/providers/in-memory-definition-provider.d.ts.map +1 -0
- package/dist/lib/providers/index.d.ts +13 -0
- package/dist/lib/providers/index.d.ts.map +1 -0
- package/dist/lib/providers/property-path-runtime-provider.d.ts +34 -0
- package/dist/lib/providers/property-path-runtime-provider.d.ts.map +1 -0
- package/dist/lib/providers/runtime-provider.d.ts +84 -0
- package/dist/lib/providers/runtime-provider.d.ts.map +1 -0
- package/dist/lib/registry/element-cardinality.d.ts +15 -0
- package/dist/lib/registry/element-cardinality.d.ts.map +1 -0
- package/dist/lib/registry/index.d.ts +10 -0
- package/dist/lib/registry/index.d.ts.map +1 -0
- package/dist/lib/registry/package-registry-repo.d.ts +106 -0
- package/dist/lib/registry/package-registry-repo.d.ts.map +1 -0
- package/dist/lib/registry/search-parameter-registry.d.ts +175 -0
- package/dist/lib/registry/search-parameter-registry.d.ts.map +1 -0
- package/dist/lib/registry/structure-definition-registry.d.ts +93 -0
- package/dist/lib/registry/structure-definition-registry.d.ts.map +1 -0
- package/dist/lib/repo/errors.d.ts +61 -0
- package/dist/lib/repo/errors.d.ts.map +1 -0
- package/dist/lib/repo/history-bundle.d.ts +78 -0
- package/dist/lib/repo/history-bundle.d.ts.map +1 -0
- package/dist/lib/repo/index.d.ts +17 -0
- package/dist/lib/repo/index.d.ts.map +1 -0
- package/dist/lib/repo/indexing-pipeline.d.ts +108 -0
- package/dist/lib/repo/indexing-pipeline.d.ts.map +1 -0
- package/dist/lib/repo/lookup-table-writer.d.ts +46 -0
- package/dist/lib/repo/lookup-table-writer.d.ts.map +1 -0
- package/dist/lib/repo/reference-indexer.d.ts +56 -0
- package/dist/lib/repo/reference-indexer.d.ts.map +1 -0
- package/dist/lib/repo/row-builder.d.ts +78 -0
- package/dist/lib/repo/row-builder.d.ts.map +1 -0
- package/dist/lib/repo/row-indexer.d.ts +111 -0
- package/dist/lib/repo/row-indexer.d.ts.map +1 -0
- package/dist/lib/repo/sql-builder.d.ts +166 -0
- package/dist/lib/repo/sql-builder.d.ts.map +1 -0
- package/dist/lib/repo/types.d.ts +321 -0
- package/dist/lib/repo/types.d.ts.map +1 -0
- package/dist/lib/schema/ddl-generator.d.ts +81 -0
- package/dist/lib/schema/ddl-generator.d.ts.map +1 -0
- package/dist/lib/schema/index.d.ts +8 -0
- package/dist/lib/schema/index.d.ts.map +1 -0
- package/dist/lib/schema/table-schema-builder.d.ts +66 -0
- package/dist/lib/schema/table-schema-builder.d.ts.map +1 -0
- package/dist/lib/schema/table-schema.d.ts +236 -0
- package/dist/lib/schema/table-schema.d.ts.map +1 -0
- package/dist/lib/search/index.d.ts +22 -0
- package/dist/lib/search/index.d.ts.map +1 -0
- package/dist/lib/search/pagination.d.ts +53 -0
- package/dist/lib/search/pagination.d.ts.map +1 -0
- package/dist/lib/search/param-parser.d.ts +85 -0
- package/dist/lib/search/param-parser.d.ts.map +1 -0
- package/dist/lib/search/search-bundle.d.ts +61 -0
- package/dist/lib/search/search-bundle.d.ts.map +1 -0
- package/dist/lib/search/search-executor.d.ts +58 -0
- package/dist/lib/search/search-executor.d.ts.map +1 -0
- package/dist/lib/search/search-planner.d.ts +57 -0
- package/dist/lib/search/search-planner.d.ts.map +1 -0
- package/dist/lib/search/search-sql-builder.d.ts +86 -0
- package/dist/lib/search/search-sql-builder.d.ts.map +1 -0
- package/dist/lib/search/types.d.ts +219 -0
- package/dist/lib/search/types.d.ts.map +1 -0
- package/dist/lib/search/where-builder.d.ts +64 -0
- package/dist/lib/search/where-builder.d.ts.map +1 -0
- package/dist/lib/startup/fhir-system.d.ts +82 -0
- package/dist/lib/startup/fhir-system.d.ts.map +1 -0
- package/dist/lib/store/conditional-service.d.ts +76 -0
- package/dist/lib/store/conditional-service.d.ts.map +1 -0
- package/dist/lib/store/fhir-persistence.d.ts +81 -0
- package/dist/lib/store/fhir-persistence.d.ts.map +1 -0
- package/dist/lib/store/fhir-store.d.ts +44 -0
- package/dist/lib/store/fhir-store.d.ts.map +1 -0
- package/dist/lib/terminology/terminology-code-repo.d.ts +61 -0
- package/dist/lib/terminology/terminology-code-repo.d.ts.map +1 -0
- package/dist/lib/terminology/valueset-repo.d.ts +76 -0
- package/dist/lib/terminology/valueset-repo.d.ts.map +1 -0
- package/dist/lib/transaction/bundle-processor.d.ts +84 -0
- package/dist/lib/transaction/bundle-processor.d.ts.map +1 -0
- package/dist/lib/transaction/urn-resolver.d.ts +62 -0
- package/dist/lib/transaction/urn-resolver.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +87 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repository Types & Interfaces
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for FHIR resource persistence operations.
|
|
5
|
+
* All implementations must support transactional CRUD with versioning.
|
|
6
|
+
*
|
|
7
|
+
* Design decisions (from WF-E2E-001 Medplum analysis):
|
|
8
|
+
* - `id` and `versionId` are UUIDs, generated app-side
|
|
9
|
+
* - Every write produces a new history entry (new version snapshot)
|
|
10
|
+
* - Soft delete: `deleted=true`, `content=''`, `__version=-1`
|
|
11
|
+
* - Optimistic locking via `ifMatch` (versionId comparison)
|
|
12
|
+
*
|
|
13
|
+
* @module fhir-persistence/repo
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Operation context — flows through all CRUD/Search operations.
|
|
17
|
+
*
|
|
18
|
+
* S1 (Phase B): Only `project` is used — multi-tenant isolation.
|
|
19
|
+
* S5 (Phase C): Will extend to use `author`, `accessPolicy`, `superAdmin`.
|
|
20
|
+
*/
|
|
21
|
+
export interface OperationContext {
|
|
22
|
+
/** Current project ID for multi-tenant scoping. */
|
|
23
|
+
project?: string;
|
|
24
|
+
/** The actor performing the operation (User/Bot/ClientApplication reference). */
|
|
25
|
+
author?: string;
|
|
26
|
+
/** The AccessPolicy ID bound to this operation. */
|
|
27
|
+
accessPolicy?: string;
|
|
28
|
+
/** Whether this is a super-admin operation (bypasses project scoping). */
|
|
29
|
+
superAdmin?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Platform resource types that require special handling.
|
|
33
|
+
*
|
|
34
|
+
* These are MedXAI-defined resources (not part of FHIR R4 base spec).
|
|
35
|
+
* They participate in multi-tenant isolation via `projectId`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PLATFORM_RESOURCE_TYPES: ReadonlySet<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Protected resource types that can only be managed by super-admins or
|
|
40
|
+
* the system itself. Normal project-scoped operations cannot create/update/delete these.
|
|
41
|
+
*
|
|
42
|
+
* Phase B: informational only — enforcement deferred to Phase C (Auth).
|
|
43
|
+
*/
|
|
44
|
+
export declare const PROTECTED_RESOURCE_TYPES: ReadonlySet<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Resource types that can be managed by project admins (not just super-admins).
|
|
47
|
+
*
|
|
48
|
+
* Phase B: informational only — enforcement deferred to Phase C (Auth).
|
|
49
|
+
*/
|
|
50
|
+
export declare const PROJECT_ADMIN_RESOURCE_TYPES: ReadonlySet<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Minimal FHIR resource shape for persistence operations.
|
|
53
|
+
*
|
|
54
|
+
* This is intentionally loose — the repository does not validate
|
|
55
|
+
* resource structure (that's the validator's job). It only requires
|
|
56
|
+
* `resourceType` and optionally `id` / `meta`.
|
|
57
|
+
*/
|
|
58
|
+
export interface FhirResource {
|
|
59
|
+
resourceType: string;
|
|
60
|
+
id?: string;
|
|
61
|
+
meta?: FhirMeta;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* FHIR Meta element (subset used by the repository).
|
|
66
|
+
*/
|
|
67
|
+
export interface FhirMeta {
|
|
68
|
+
versionId?: string;
|
|
69
|
+
lastUpdated?: string;
|
|
70
|
+
source?: string;
|
|
71
|
+
profile?: string[];
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A FHIR resource that has been persisted (id and meta are guaranteed).
|
|
76
|
+
*/
|
|
77
|
+
export interface PersistedResource extends FhirResource {
|
|
78
|
+
id: string;
|
|
79
|
+
meta: FhirMeta & {
|
|
80
|
+
versionId: string;
|
|
81
|
+
lastUpdated: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Options for `createResource()`.
|
|
86
|
+
*/
|
|
87
|
+
export interface CreateResourceOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Pre-assigned UUID for the resource.
|
|
90
|
+
* Used in batch/transaction operations where the ID is determined
|
|
91
|
+
* before the create call.
|
|
92
|
+
*/
|
|
93
|
+
assignedId?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Options for `updateResource()`.
|
|
97
|
+
*/
|
|
98
|
+
export interface UpdateResourceOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Expected versionId for optimistic locking.
|
|
101
|
+
* If provided and does not match the current versionId,
|
|
102
|
+
* the update is rejected with `ResourceVersionConflictError`.
|
|
103
|
+
*
|
|
104
|
+
* Corresponds to the HTTP `If-Match` header.
|
|
105
|
+
*/
|
|
106
|
+
ifMatch?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Options for history queries.
|
|
110
|
+
*/
|
|
111
|
+
export interface HistoryOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Only include versions updated after this instant.
|
|
114
|
+
* Corresponds to the `_since` parameter.
|
|
115
|
+
*/
|
|
116
|
+
since?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Maximum number of entries to return.
|
|
119
|
+
* Corresponds to the `_count` parameter.
|
|
120
|
+
*/
|
|
121
|
+
count?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Cursor for pagination — the `lastUpdated` value of the last
|
|
124
|
+
* entry from the previous page. Only entries with `lastUpdated`
|
|
125
|
+
* strictly before this value are returned.
|
|
126
|
+
*/
|
|
127
|
+
cursor?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A single entry in a history result, including delete markers.
|
|
131
|
+
*/
|
|
132
|
+
export interface HistoryEntry {
|
|
133
|
+
/** The resource (null for delete entries). */
|
|
134
|
+
resource: PersistedResource | null;
|
|
135
|
+
/** The versionId for this entry. */
|
|
136
|
+
versionId: string;
|
|
137
|
+
/** The timestamp of this version. */
|
|
138
|
+
lastUpdated: string;
|
|
139
|
+
/** Whether this entry represents a deletion. */
|
|
140
|
+
deleted: boolean;
|
|
141
|
+
/** The resource type (needed for delete entries where resource is null). */
|
|
142
|
+
resourceType: string;
|
|
143
|
+
/** The resource id. */
|
|
144
|
+
id: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Options for search execution.
|
|
148
|
+
*/
|
|
149
|
+
export interface SearchOptions {
|
|
150
|
+
/** Whether to include total count. */
|
|
151
|
+
total?: 'none' | 'estimate' | 'accurate';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Result of a search execution.
|
|
155
|
+
*/
|
|
156
|
+
export interface SearchResult {
|
|
157
|
+
/** Matched resources. */
|
|
158
|
+
resources: PersistedResource[];
|
|
159
|
+
/** Included resources from _include/_revinclude (search.mode = 'include'). */
|
|
160
|
+
included?: PersistedResource[];
|
|
161
|
+
/** Total count (only when `total=accurate`). */
|
|
162
|
+
total?: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* FHIR Resource Repository — persistence contract.
|
|
166
|
+
*
|
|
167
|
+
* All write operations are transactional (ACID).
|
|
168
|
+
* All write operations produce a history entry.
|
|
169
|
+
*/
|
|
170
|
+
export interface ResourceRepository {
|
|
171
|
+
/**
|
|
172
|
+
* Create a new FHIR resource.
|
|
173
|
+
*
|
|
174
|
+
* - Generates `id` (UUID) if not provided via `options.assignedId`
|
|
175
|
+
* - Generates `meta.versionId` (UUID)
|
|
176
|
+
* - Sets `meta.lastUpdated` to current time
|
|
177
|
+
* - Writes to main table + history table in a transaction
|
|
178
|
+
* - If `context.project` is set, injects projectId into the row
|
|
179
|
+
*
|
|
180
|
+
* @returns The persisted resource with populated `id` and `meta`.
|
|
181
|
+
*/
|
|
182
|
+
createResource<T extends FhirResource>(resource: T, options?: CreateResourceOptions, context?: OperationContext): Promise<T & PersistedResource>;
|
|
183
|
+
/**
|
|
184
|
+
* Read a resource by type and ID.
|
|
185
|
+
*
|
|
186
|
+
* When `context.project` is set, verifies the resource belongs to that project.
|
|
187
|
+
*
|
|
188
|
+
* @throws ResourceNotFoundError if the resource does not exist.
|
|
189
|
+
* @throws ResourceGoneError if the resource has been deleted.
|
|
190
|
+
*/
|
|
191
|
+
readResource(resourceType: string, id: string, context?: OperationContext): Promise<PersistedResource>;
|
|
192
|
+
/**
|
|
193
|
+
* Update an existing resource.
|
|
194
|
+
*
|
|
195
|
+
* - The resource must have `id` set.
|
|
196
|
+
* - Generates new `meta.versionId` (UUID)
|
|
197
|
+
* - Sets `meta.lastUpdated` to current time
|
|
198
|
+
* - Writes to main table (UPSERT) + history table in a transaction
|
|
199
|
+
* - If `options.ifMatch` is set, performs optimistic locking check
|
|
200
|
+
* - If `context.project` is set, injects projectId into the row
|
|
201
|
+
*
|
|
202
|
+
* @throws ResourceNotFoundError if the resource does not exist.
|
|
203
|
+
* @throws ResourceGoneError if the resource has been deleted.
|
|
204
|
+
* @throws ResourceVersionConflictError if `ifMatch` does not match.
|
|
205
|
+
*/
|
|
206
|
+
updateResource<T extends FhirResource>(resource: T, options?: UpdateResourceOptions, context?: OperationContext): Promise<T & PersistedResource>;
|
|
207
|
+
/**
|
|
208
|
+
* Soft-delete a resource.
|
|
209
|
+
*
|
|
210
|
+
* - Sets `deleted=true`, `content=''`, `__version=-1`
|
|
211
|
+
* - Writes a delete history entry
|
|
212
|
+
*
|
|
213
|
+
* @throws ResourceNotFoundError if the resource does not exist.
|
|
214
|
+
* @throws ResourceGoneError if already deleted.
|
|
215
|
+
*/
|
|
216
|
+
deleteResource(resourceType: string, id: string, context?: OperationContext): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Read the version history of a resource (newest first).
|
|
219
|
+
*/
|
|
220
|
+
readHistory(resourceType: string, id: string, options?: HistoryOptions): Promise<HistoryEntry[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Read type-level history (all changes to a resource type, newest first).
|
|
223
|
+
*/
|
|
224
|
+
readTypeHistory(resourceType: string, options?: HistoryOptions): Promise<HistoryEntry[]>;
|
|
225
|
+
/**
|
|
226
|
+
* Read a specific version of a resource.
|
|
227
|
+
*
|
|
228
|
+
* @throws ResourceNotFoundError if the version does not exist.
|
|
229
|
+
*/
|
|
230
|
+
readVersion(resourceType: string, id: string, versionId: string): Promise<PersistedResource>;
|
|
231
|
+
/**
|
|
232
|
+
* Search for resources matching the given search request.
|
|
233
|
+
*
|
|
234
|
+
* - Executes parameterized SQL built from the search request
|
|
235
|
+
* - Optionally returns total count when `options.total === 'accurate'`
|
|
236
|
+
* - If `context.project` is set, adds projectId filter to the query
|
|
237
|
+
*
|
|
238
|
+
* @param request - Parsed FHIR search request.
|
|
239
|
+
* @param options - Search options (e.g., total mode).
|
|
240
|
+
* @param context - Operation context for project scoping.
|
|
241
|
+
* @returns Search result with matched resources and optional total.
|
|
242
|
+
*/
|
|
243
|
+
searchResources(request: import('../search/types.js').SearchRequest, options?: SearchOptions, context?: OperationContext): Promise<SearchResult>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* v1 ResourceRow — preserved for backward compatibility with FhirRepository (PG).
|
|
247
|
+
* @deprecated Use ResourceRowV2 for new code.
|
|
248
|
+
*/
|
|
249
|
+
export interface ResourceRow {
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
id: string;
|
|
252
|
+
content: string;
|
|
253
|
+
lastUpdated: string;
|
|
254
|
+
deleted: boolean;
|
|
255
|
+
projectId: string;
|
|
256
|
+
__version: number;
|
|
257
|
+
_source?: string;
|
|
258
|
+
_profile?: string[];
|
|
259
|
+
compartments?: string[];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* v2 ResourceRow — dialect-neutral, no projectId/__version.
|
|
263
|
+
*
|
|
264
|
+
* Changes from v1:
|
|
265
|
+
* - Removed `projectId` (no multi-tenancy)
|
|
266
|
+
* - Removed `__version` (schema version tracking)
|
|
267
|
+
* - Added `versionId` (UUID for ETag / optimistic locking)
|
|
268
|
+
* - `deleted` is number (0/1) for SQLite compat
|
|
269
|
+
* - `_profile` is JSON string, not string[]
|
|
270
|
+
* - `compartments` is JSON string, not string[]
|
|
271
|
+
*/
|
|
272
|
+
export interface ResourceRowV2 {
|
|
273
|
+
[key: string]: unknown;
|
|
274
|
+
id: string;
|
|
275
|
+
versionId: string;
|
|
276
|
+
content: string;
|
|
277
|
+
lastUpdated: string;
|
|
278
|
+
deleted: number;
|
|
279
|
+
_source?: string | null;
|
|
280
|
+
_profile?: string | null;
|
|
281
|
+
compartments?: string | null;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* v1 HistoryRow — preserved for backward compatibility.
|
|
285
|
+
* @deprecated Use HistoryRowV2 for new code.
|
|
286
|
+
*/
|
|
287
|
+
export interface HistoryRow {
|
|
288
|
+
[key: string]: unknown;
|
|
289
|
+
id: string;
|
|
290
|
+
versionId: string;
|
|
291
|
+
lastUpdated: string;
|
|
292
|
+
content: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* v2 HistoryRow — includes deleted flag.
|
|
296
|
+
*
|
|
297
|
+
* Changes from v1:
|
|
298
|
+
* - Added `deleted` (0/1) for soft-delete tracking
|
|
299
|
+
* - `content` preserved even on delete (ADR-08)
|
|
300
|
+
*/
|
|
301
|
+
export interface HistoryRowV2 {
|
|
302
|
+
[key: string]: unknown;
|
|
303
|
+
id: string;
|
|
304
|
+
versionId: string;
|
|
305
|
+
lastUpdated: string;
|
|
306
|
+
content: string;
|
|
307
|
+
deleted: number;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Schema version constant.
|
|
311
|
+
*
|
|
312
|
+
* Tracks the schema migration version (not the resource version).
|
|
313
|
+
* Incremented when the schema structure changes.
|
|
314
|
+
* Set to -1 for deleted resources.
|
|
315
|
+
*/
|
|
316
|
+
export declare const SCHEMA_VERSION = 1;
|
|
317
|
+
/**
|
|
318
|
+
* Schema version for deleted resources.
|
|
319
|
+
*/
|
|
320
|
+
export declare const DELETED_SCHEMA_VERSION = -1;
|
|
321
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/repo/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;;;;GAKG;AACH,MAAM,WAA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DL strings.
|
|
5
|
+
* All functions are pure — no database dependency.
|
|
6
|
+
*
|
|
7
|
+
* v2 upgrade: Now supports both SQLite and PostgreSQL dialects.
|
|
8
|
+
* The `dialect` parameter controls type mapping and syntax differences.
|
|
9
|
+
*
|
|
10
|
+
* ## Output Format
|
|
11
|
+
*
|
|
12
|
+
* - All identifiers are double-quoted for safety
|
|
13
|
+
* - Uses `CREATE TABLE IF NOT EXISTS` / `CREATE INDEX IF NOT EXISTS`
|
|
14
|
+
* - Generates all CREATE TABLEs first, then all CREATE INDEXes
|
|
15
|
+
* - Idempotent — safe to run multiple times
|
|
16
|
+
*
|
|
17
|
+
* @module fhir-persistence/schema
|
|
18
|
+
*/
|
|
19
|
+
import type { IndexSchema, MainTableSchema, HistoryTableSchema, ReferencesTableSchema, LookupTableSchema, GlobalLookupTableSchema, ResourceTableSet, SchemaDefinition } from './table-schema.js';
|
|
20
|
+
export type DDLDialect = 'sqlite' | 'postgres';
|
|
21
|
+
/**
|
|
22
|
+
* Generate a `CREATE TABLE IF NOT EXISTS` statement for a main table.
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateCreateMainTable(table: MainTableSchema, dialect?: DDLDialect): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a `CREATE TABLE IF NOT EXISTS` statement for a history table.
|
|
27
|
+
*
|
|
28
|
+
* v2: Handles versionSeq AUTOINCREMENT for SQLite and GENERATED ALWAYS for PG.
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateCreateHistoryTable(table: HistoryTableSchema, dialect?: DDLDialect): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a `CREATE TABLE IF NOT EXISTS` statement for a references table.
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateCreateReferencesTable(table: ReferencesTableSchema, dialect?: DDLDialect): string;
|
|
35
|
+
/**
|
|
36
|
+
* Generate a `CREATE INDEX IF NOT EXISTS` statement.
|
|
37
|
+
*
|
|
38
|
+
* Supports:
|
|
39
|
+
* - `opClass` — operator class appended to each column key (e.g., `gin_trgm_ops`)
|
|
40
|
+
* - `expression` — functional expression to index instead of plain columns
|
|
41
|
+
* (e.g., `to_tsvector('simple'::regconfig, family)`)
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateCreateIndex(index: IndexSchema, tableName: string, dialect?: DDLDialect): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Generate all DDL statements for a single resource type (3 tables + indexes).
|
|
46
|
+
*
|
|
47
|
+
* Returns an array of SQL statements in order:
|
|
48
|
+
* 1. CREATE TABLE for main table
|
|
49
|
+
* 2. CREATE TABLE for history table
|
|
50
|
+
* 3. CREATE TABLE for references table
|
|
51
|
+
* 4. All CREATE INDEX statements
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateResourceDDL(tableSet: ResourceTableSet, dialect?: DDLDialect): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Generate a `CREATE TABLE IF NOT EXISTS` statement for a lookup sub-table.
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateCreateLookupTable(table: LookupTableSchema, dialect?: DDLDialect): string;
|
|
58
|
+
/**
|
|
59
|
+
* Generate a `CREATE TABLE IF NOT EXISTS` statement for a global lookup table.
|
|
60
|
+
*/
|
|
61
|
+
export declare function generateCreateGlobalLookupTable(table: GlobalLookupTableSchema, dialect?: DDLDialect): string;
|
|
62
|
+
/**
|
|
63
|
+
* Generate all DDL statements for a complete schema definition.
|
|
64
|
+
*
|
|
65
|
+
* Order:
|
|
66
|
+
* 1. Global lookup tables (HumanName, Address, ContactPoint, Identifier)
|
|
67
|
+
* 2. Resource tables (main, history, references)
|
|
68
|
+
* 3. All indexes (global lookup + resource tables)
|
|
69
|
+
*
|
|
70
|
+
* @param schema - The complete schema definition.
|
|
71
|
+
* @returns Array of SQL DDL statements.
|
|
72
|
+
*/
|
|
73
|
+
export declare function generateSchemaDDL(schema: SchemaDefinition, dialect?: DDLDialect): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Generate the complete DDL as a single string, with statements
|
|
76
|
+
* separated by double newlines.
|
|
77
|
+
*
|
|
78
|
+
* Includes a header comment with version and generation timestamp.
|
|
79
|
+
*/
|
|
80
|
+
export declare function generateSchemaDDLString(schema: SchemaDefinition, dialect?: DDLDialect): string;
|
|
81
|
+
//# sourceMappingURL=ddl-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl-generator.d.ts","sourceRoot":"","sources":["../../../src/schema/ddl-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAEV,WAAW,EAEX,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAM3B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAqF/C;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CAiBxG;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CA0B9G;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,qBAAqB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CAsBpH;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,GAAG,IAAI,CA6C1H;AAMD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,EAAE,CA2B1G;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CAmB5G;AAMD;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,uBAAuB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CAcxH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,EAAE,CA+CtG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE,UAAuB,GAAG,MAAM,CAc1G"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema module — barrel exports
|
|
3
|
+
*
|
|
4
|
+
* @module fhir-persistence/schema
|
|
5
|
+
*/
|
|
6
|
+
export type { SqlColumnType, ColumnSchema, IndexSchema, ConstraintSchema, MainTableSchema, HistoryTableSchema, ReferencesTableSchema, ResourceTableSet, SchemaDefinition, SearchParamMeta, GlobalLookupTableSchema, LookupTableType, } from './table-schema.js';
|
|
7
|
+
export type { DDLDialect } from './ddl-generator.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table Schema Builder
|
|
3
|
+
*
|
|
4
|
+
* Core of Phase 8. Pure functions that derive `ResourceTableSet`
|
|
5
|
+
* (3 tables per resource) from `StructureDefinitionRegistry` and
|
|
6
|
+
* `SearchParameterRegistry`.
|
|
7
|
+
*
|
|
8
|
+
* ## Design
|
|
9
|
+
*
|
|
10
|
+
* Each FHIR resource type gets:
|
|
11
|
+
* - **Main table** — fixed columns + search columns
|
|
12
|
+
* - **History table** — fixed structure (no search columns)
|
|
13
|
+
* - **References table** — fixed structure with composite PK
|
|
14
|
+
*
|
|
15
|
+
* Search columns are generated from `SearchParameterImpl`:
|
|
16
|
+
* - `column` strategy → one column per param
|
|
17
|
+
* - `token-column` strategy → three columns per param (__X, __XText, __XSort)
|
|
18
|
+
* - `lookup-table` strategy → sort column only (__XSort)
|
|
19
|
+
*
|
|
20
|
+
* All functions are pure — no global state, no database dependency.
|
|
21
|
+
*
|
|
22
|
+
* @module fhir-persistence/schema
|
|
23
|
+
*/
|
|
24
|
+
import type { GlobalLookupTableSchema, ResourceTableSet, SchemaDefinition } from './table-schema.js';
|
|
25
|
+
import type { StructureDefinitionRegistry } from '../registry/structure-definition-registry.js';
|
|
26
|
+
import type { SearchParameterRegistry } from '../registry/search-parameter-registry.js';
|
|
27
|
+
/**
|
|
28
|
+
* Build the 4 global shared lookup tables matching Medplum's production design.
|
|
29
|
+
*
|
|
30
|
+
* These tables are shared across ALL resource types and store decomposed
|
|
31
|
+
* complex FHIR types for precise search via JOINs:
|
|
32
|
+
* - `HumanName` — name/given/family from Patient.name, Practitioner.name, etc.
|
|
33
|
+
* - `Address` — address/city/country/postalCode/state/use
|
|
34
|
+
* - `ContactPoint` — system/value/use from telecom fields
|
|
35
|
+
* - `Identifier` — system/value from identifier fields
|
|
36
|
+
*
|
|
37
|
+
* Each table has Medplum-style indexes: btree + trigram (gin_trgm_ops)
|
|
38
|
+
* for efficient prefix, exact, and substring search.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildGlobalLookupTables(): GlobalLookupTableSchema[];
|
|
41
|
+
/**
|
|
42
|
+
* Build the complete 3-table schema for a single resource type.
|
|
43
|
+
*
|
|
44
|
+
* @param resourceType - The FHIR resource type (e.g., `'Patient'`).
|
|
45
|
+
* @param sdRegistry - StructureDefinitionRegistry (used to verify the type exists).
|
|
46
|
+
* @param spRegistry - SearchParameterRegistry (provides search column definitions).
|
|
47
|
+
* @returns The complete `ResourceTableSet` for the resource type.
|
|
48
|
+
* @throws Error if the resource type is not found or is abstract.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildResourceTableSet(resourceType: string, sdRegistry: StructureDefinitionRegistry, spRegistry: SearchParameterRegistry): ResourceTableSet;
|
|
51
|
+
/**
|
|
52
|
+
* Build table schemas for ALL non-abstract resource types.
|
|
53
|
+
*
|
|
54
|
+
* @returns Array of `ResourceTableSet`, one per concrete resource type, sorted alphabetically.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildAllResourceTableSets(sdRegistry: StructureDefinitionRegistry, spRegistry: SearchParameterRegistry): ResourceTableSet[];
|
|
57
|
+
/**
|
|
58
|
+
* Build a complete `SchemaDefinition` for all resource types.
|
|
59
|
+
*
|
|
60
|
+
* @param sdRegistry - StructureDefinitionRegistry with indexed profiles.
|
|
61
|
+
* @param spRegistry - SearchParameterRegistry with indexed search params.
|
|
62
|
+
* @param version - Schema version string (default: `'fhir-r4-v4.0.1'`).
|
|
63
|
+
* @returns The complete `SchemaDefinition`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildSchemaDefinition(sdRegistry: StructureDefinitionRegistry, spRegistry: SearchParameterRegistry, version?: string): SchemaDefinition;
|
|
66
|
+
//# sourceMappingURL=table-schema-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-schema-builder.d.ts","sourceRoot":"","sources":["../../../src/schema/table-schema-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAOV,uBAAuB,EAEvB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AA2PxF;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,uBAAuB,EAAE,CAOnE;AA0ID;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,2BAA2B,EACvC,UAAU,EAAE,uBAAuB,GAClC,gBAAgB,CA8ElB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,2BAA2B,EACvC,UAAU,EAAE,uBAAuB,GAClC,gBAAgB,EAAE,CAGpB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,2BAA2B,EACvC,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,MAAyB,GACjC,gBAAgB,CAOlB"}
|