@medplum/fhir-router 5.1.26 → 5.1.28
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/cjs/index.cjs +42 -49
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/cjs/index.d.ts +96 -17
- package/dist/esm/index.d.ts +96 -17
- package/dist/esm/index.mjs +42 -49
- package/dist/esm/index.mjs.map +4 -4
- package/package.json +5 -5
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CapabilityStatementRestInteraction } from '@medplum/fhirtypes';
|
|
|
4
4
|
import type { CapabilityStatementRestResourceInteraction } from '@medplum/fhirtypes';
|
|
5
5
|
import type { Event as Event_2 } from '@medplum/core';
|
|
6
6
|
import { EventTarget as EventTarget_2 } from '@medplum/core';
|
|
7
|
+
import type { IncludeTarget } from '@medplum/core';
|
|
7
8
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
8
9
|
import type { Operation } from '@medplum/core';
|
|
9
10
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
@@ -11,6 +12,7 @@ import { OperationOutcomeError } from '@medplum/core';
|
|
|
11
12
|
import type { Parameters as Parameters_2 } from '@medplum/fhirtypes';
|
|
12
13
|
import type { Reference } from '@medplum/fhirtypes';
|
|
13
14
|
import type { Resource } from '@medplum/fhirtypes';
|
|
15
|
+
import type { ResourceType } from '@medplum/fhirtypes';
|
|
14
16
|
import type { SearchRequest } from '@medplum/core';
|
|
15
17
|
import type { WithId } from '@medplum/core';
|
|
16
18
|
|
|
@@ -73,13 +75,8 @@ export declare class BatchProcessor {
|
|
|
73
75
|
private readonly req;
|
|
74
76
|
private resolvedIdentities;
|
|
75
77
|
private bundleInfo;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
private position;
|
|
79
|
-
/** Indices (into the original bundle) of results produced since the last {@link BatchProcessor.takePendingResults} call. */
|
|
80
|
-
private pendingIndices;
|
|
81
|
-
/** Error messages accumulated across processed entries, for the post-batch telemetry event. */
|
|
82
|
-
private readonly errors;
|
|
78
|
+
/** The state mutated through processing (and preprocessing) */
|
|
79
|
+
private state;
|
|
83
80
|
/**
|
|
84
81
|
* Creates a batch processor.
|
|
85
82
|
* @param router - The FHIR router.
|
|
@@ -157,7 +154,6 @@ export declare class BatchProcessor {
|
|
|
157
154
|
* Scans the Bundle in order to ensure entries are processed in the correct sequence,
|
|
158
155
|
* as well as to identify any operations that might require specific handling.
|
|
159
156
|
*
|
|
160
|
-
* @param results - The array of result entries, to track partial results.
|
|
161
157
|
* @returns The information gathered from scanning the Bundle.
|
|
162
158
|
*/
|
|
163
159
|
private preprocessBundle;
|
|
@@ -232,11 +228,12 @@ export declare class BatchProcessor {
|
|
|
232
228
|
*/
|
|
233
229
|
export declare function buildBatchResponseBundle(bundleType: Bundle['type'], entryCount: number, results: Record<number, BundleEntry>): Bundle;
|
|
234
230
|
|
|
235
|
-
export declare
|
|
231
|
+
export declare interface BundlePreprocessInfo {
|
|
236
232
|
ordering: number[];
|
|
237
233
|
requiresStrongTransaction: boolean;
|
|
238
234
|
updates: number;
|
|
239
|
-
|
|
235
|
+
resourceTypes: Set<ResourceType>;
|
|
236
|
+
}
|
|
240
237
|
|
|
241
238
|
export declare function createResourceImpl<T extends Resource>(resourceType: T['resourceType'], resource: T, repo: FhirRepository, options?: CreateResourceOptions): Promise<FhirResponse>;
|
|
242
239
|
|
|
@@ -353,7 +350,7 @@ export declare abstract class FhirRepository {
|
|
|
353
350
|
* @param patch - The JSONPatch operations.
|
|
354
351
|
* @returns The patched resource.
|
|
355
352
|
*/
|
|
356
|
-
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
353
|
+
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
357
354
|
/**
|
|
358
355
|
* Searches for FHIR resources.
|
|
359
356
|
*
|
|
@@ -377,10 +374,10 @@ export declare abstract class FhirRepository {
|
|
|
377
374
|
* Runs a callback function within a transaction.
|
|
378
375
|
*
|
|
379
376
|
* @param callback - The callback function to be run within a transaction.
|
|
377
|
+
* @param options - The transaction options.
|
|
378
|
+
* @returns The result of the callback function.
|
|
380
379
|
*/
|
|
381
|
-
abstract withTransaction<TResult>(callback: (txRepo: this) => Promise<TResult>, options
|
|
382
|
-
serializable?: boolean;
|
|
383
|
-
}): Promise<TResult>;
|
|
380
|
+
abstract withTransaction<TResult>(callback: (txRepo: this) => Promise<TResult>, options: TransactionOptions): Promise<TResult>;
|
|
384
381
|
/**
|
|
385
382
|
* Searches for a single FHIR resource.
|
|
386
383
|
*
|
|
@@ -461,7 +458,7 @@ export declare abstract class FhirRepository {
|
|
|
461
458
|
* @returns A promise that resolves when the operation is complete.
|
|
462
459
|
*/
|
|
463
460
|
conditionalDelete(search: SearchRequest): Promise<void>;
|
|
464
|
-
conditionalPatch(search: SearchRequest, patch: Operation[]): Promise<WithId<Resource>>;
|
|
461
|
+
conditionalPatch(search: SearchRequest, patch: Operation[], options?: UpdateResourceOptions): Promise<WithId<Resource>>;
|
|
465
462
|
}
|
|
466
463
|
|
|
467
464
|
export declare type FhirRequest = {
|
|
@@ -483,7 +480,9 @@ export declare type FhirRequestConfig = {
|
|
|
483
480
|
transactions?: boolean;
|
|
484
481
|
};
|
|
485
482
|
|
|
486
|
-
export declare type FhirResponse = [
|
|
483
|
+
export declare type FhirResponse = [
|
|
484
|
+
OperationOutcome
|
|
485
|
+
] | [OperationOutcome, Resource] | [OperationOutcome, Resource, FhirResponseOptions];
|
|
487
486
|
|
|
488
487
|
export declare type FhirResponseOptions = {
|
|
489
488
|
contentType?: string;
|
|
@@ -510,8 +509,75 @@ export declare class FhirRouter extends EventTarget_2 {
|
|
|
510
509
|
log(level: string, message: string, data?: Record<string, any>): void;
|
|
511
510
|
}
|
|
512
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Gets the extra search entries for the _include and _revinclude parameters.
|
|
514
|
+
*
|
|
515
|
+
* The `entries` array is appended to in place.
|
|
516
|
+
*
|
|
517
|
+
* @param repo - The FHIR repository.
|
|
518
|
+
* @param searchRequest - The original search request.
|
|
519
|
+
* @param resources - The resources returned by the original search.
|
|
520
|
+
* @param entries - The output bundle entries.
|
|
521
|
+
* @param options - Optional repository-specific behavior.
|
|
522
|
+
*/
|
|
523
|
+
export declare function getExtraEntries<T extends Resource>(repo: FhirRepository, searchRequest: SearchRequest<T>, resources: T[], entries: BundleEntry[], options?: IncludeOptions): Promise<void>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Returns bundle entries for the resources that are included in the search result.
|
|
527
|
+
*
|
|
528
|
+
* See documentation on _include: https://hl7.org/fhir/R4/search.html#include
|
|
529
|
+
* @param repo - The repository.
|
|
530
|
+
* @param include - The include parameter.
|
|
531
|
+
* @param resources - The base search result resources.
|
|
532
|
+
* @param options - Optional repository-specific behavior.
|
|
533
|
+
* @returns The bundle entries for the included resources.
|
|
534
|
+
*/
|
|
535
|
+
export declare function getSearchIncludeEntries(repo: FhirRepository, include: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns bundle entries for the resources that are reverse included in the search result.
|
|
539
|
+
*
|
|
540
|
+
* See documentation on _revinclude: https://hl7.org/fhir/R4/search.html#revinclude
|
|
541
|
+
* @param repo - The repository.
|
|
542
|
+
* @param revInclude - The revInclude parameter.
|
|
543
|
+
* @param resources - The base search result resources.
|
|
544
|
+
* @param options - Optional repository-specific behavior.
|
|
545
|
+
* @returns The bundle entries for the reverse included resources.
|
|
546
|
+
*/
|
|
547
|
+
export declare function getSearchRevIncludeEntries(repo: FhirRepository, revInclude: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
548
|
+
|
|
513
549
|
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
514
550
|
|
|
551
|
+
export declare interface IncludeOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Builds the `Bundle.entry.fullUrl` for an included resource.
|
|
554
|
+
* When omitted, `fullUrl` is not set on the resulting entries.
|
|
555
|
+
*/
|
|
556
|
+
readonly fullUrl?: (resourceType: string, id: string) => string;
|
|
557
|
+
/**
|
|
558
|
+
* The maximum number of `:iterate` rounds before the search is rejected. Defaults to 5.
|
|
559
|
+
*/
|
|
560
|
+
readonly maxDepth?: number;
|
|
561
|
+
/**
|
|
562
|
+
* The maximum total number of bundle entries before the search is rejected.
|
|
563
|
+
* Defaults to `DEFAULT_MAX_SEARCH_COUNT`.
|
|
564
|
+
*/
|
|
565
|
+
readonly maxResults?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Executes the sub-searches needed for canonical `_include` and for all `_revinclude` targets.
|
|
568
|
+
* Defaults to `repo.searchResources()`.
|
|
569
|
+
*/
|
|
570
|
+
readonly executeSearch?: IncludeSearchFn;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Executes a search on behalf of the include logic.
|
|
575
|
+
*
|
|
576
|
+
* The default implementation uses {@link FhirRepository.searchResources}. The server overrides this
|
|
577
|
+
* to reuse its already-built query pipeline rather than re-entering the public `search()` entry point.
|
|
578
|
+
*/
|
|
579
|
+
export declare type IncludeSearchFn = (searchRequest: SearchRequest) => Promise<WithId<Resource>[]>;
|
|
580
|
+
|
|
515
581
|
export declare interface LogEvent extends Event_2 {
|
|
516
582
|
message: string;
|
|
517
583
|
data?: Record<string, any>;
|
|
@@ -527,16 +593,22 @@ export declare class MemoryRepository extends FhirRepository {
|
|
|
527
593
|
withSeeding<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
528
594
|
clear(): void;
|
|
529
595
|
setMode(_mode: RepositoryMode): void;
|
|
596
|
+
private createResourceSync;
|
|
530
597
|
createResource<T extends Resource>(resource: T, options?: CreateResourceOptions, update?: boolean): Promise<WithId<T>>;
|
|
531
598
|
generateId(): string;
|
|
532
599
|
updateResource<T extends Resource>(resource: T, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
533
|
-
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
600
|
+
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
534
601
|
readResource<T extends Resource>(resourceType: string, id: string): Promise<T>;
|
|
535
602
|
readReference<T extends Resource>(reference: Reference<T>): Promise<WithId<T>>;
|
|
536
603
|
readReferences<T extends Resource>(references: readonly Reference<T>[]): Promise<(T | OperationOutcomeError)[]>;
|
|
537
604
|
readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
|
|
538
605
|
readVersion<T extends Resource>(resourceType: string, id: string, versionId: string): Promise<T>;
|
|
606
|
+
private searchSync;
|
|
539
607
|
search<T extends Resource>(searchRequest: SearchRequest<T>): Promise<Bundle<WithId<T>>>;
|
|
608
|
+
conditionalCreate<T extends Resource>(resource: T, search: SearchRequest<T>, options?: CreateResourceOptions): Promise<{
|
|
609
|
+
resource: WithId<T>;
|
|
610
|
+
outcome: OperationOutcome;
|
|
611
|
+
}>;
|
|
540
612
|
searchByReference<T extends Resource>(searchRequest: SearchRequest<T>, referenceField: string, references: string[]): Promise<Record<string, WithId<T>[]>>;
|
|
541
613
|
deleteResource(resourceType: string, id: string): Promise<void>;
|
|
542
614
|
withTransaction<TResult>(callback: (repo: this) => Promise<TResult>): Promise<TResult>;
|
|
@@ -571,6 +643,8 @@ export declare const RepositoryMode: {
|
|
|
571
643
|
|
|
572
644
|
export declare type RepositoryMode = (typeof RepositoryMode)[keyof typeof RepositoryMode];
|
|
573
645
|
|
|
646
|
+
declare type ResourceTypeInput = ResourceType | readonly ResourceType[] | ReadonlySet<ResourceType>;
|
|
647
|
+
|
|
574
648
|
/** @see http://hl7.org/fhir/R4/codesystem-restful-interaction.html */
|
|
575
649
|
export declare type RestInteraction = CapabilityStatementRestInteraction['code'] | CapabilityStatementRestResourceInteraction['code'] | 'operation';
|
|
576
650
|
|
|
@@ -595,6 +669,11 @@ export declare type RouteResult<Handler, Metadata> = {
|
|
|
595
669
|
data?: Metadata;
|
|
596
670
|
};
|
|
597
671
|
|
|
672
|
+
export declare interface TransactionOptions {
|
|
673
|
+
readonly resourceTypes: ResourceTypeInput;
|
|
674
|
+
readonly serializable?: boolean;
|
|
675
|
+
}
|
|
676
|
+
|
|
598
677
|
export declare function updateResourceImpl<T extends Resource>(resourceType: T['resourceType'], id: string, resource: T, repo: FhirRepository, options?: UpdateResourceOptions): Promise<FhirResponse>;
|
|
599
678
|
|
|
600
679
|
export declare type UpdateResourceOptions = {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CapabilityStatementRestInteraction } from '@medplum/fhirtypes';
|
|
|
4
4
|
import type { CapabilityStatementRestResourceInteraction } from '@medplum/fhirtypes';
|
|
5
5
|
import type { Event as Event_2 } from '@medplum/core';
|
|
6
6
|
import { EventTarget as EventTarget_2 } from '@medplum/core';
|
|
7
|
+
import type { IncludeTarget } from '@medplum/core';
|
|
7
8
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
8
9
|
import type { Operation } from '@medplum/core';
|
|
9
10
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
@@ -11,6 +12,7 @@ import { OperationOutcomeError } from '@medplum/core';
|
|
|
11
12
|
import type { Parameters as Parameters_2 } from '@medplum/fhirtypes';
|
|
12
13
|
import type { Reference } from '@medplum/fhirtypes';
|
|
13
14
|
import type { Resource } from '@medplum/fhirtypes';
|
|
15
|
+
import type { ResourceType } from '@medplum/fhirtypes';
|
|
14
16
|
import type { SearchRequest } from '@medplum/core';
|
|
15
17
|
import type { WithId } from '@medplum/core';
|
|
16
18
|
|
|
@@ -73,13 +75,8 @@ export declare class BatchProcessor {
|
|
|
73
75
|
private readonly req;
|
|
74
76
|
private resolvedIdentities;
|
|
75
77
|
private bundleInfo;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
private position;
|
|
79
|
-
/** Indices (into the original bundle) of results produced since the last {@link BatchProcessor.takePendingResults} call. */
|
|
80
|
-
private pendingIndices;
|
|
81
|
-
/** Error messages accumulated across processed entries, for the post-batch telemetry event. */
|
|
82
|
-
private readonly errors;
|
|
78
|
+
/** The state mutated through processing (and preprocessing) */
|
|
79
|
+
private state;
|
|
83
80
|
/**
|
|
84
81
|
* Creates a batch processor.
|
|
85
82
|
* @param router - The FHIR router.
|
|
@@ -157,7 +154,6 @@ export declare class BatchProcessor {
|
|
|
157
154
|
* Scans the Bundle in order to ensure entries are processed in the correct sequence,
|
|
158
155
|
* as well as to identify any operations that might require specific handling.
|
|
159
156
|
*
|
|
160
|
-
* @param results - The array of result entries, to track partial results.
|
|
161
157
|
* @returns The information gathered from scanning the Bundle.
|
|
162
158
|
*/
|
|
163
159
|
private preprocessBundle;
|
|
@@ -232,11 +228,12 @@ export declare class BatchProcessor {
|
|
|
232
228
|
*/
|
|
233
229
|
export declare function buildBatchResponseBundle(bundleType: Bundle['type'], entryCount: number, results: Record<number, BundleEntry>): Bundle;
|
|
234
230
|
|
|
235
|
-
export declare
|
|
231
|
+
export declare interface BundlePreprocessInfo {
|
|
236
232
|
ordering: number[];
|
|
237
233
|
requiresStrongTransaction: boolean;
|
|
238
234
|
updates: number;
|
|
239
|
-
|
|
235
|
+
resourceTypes: Set<ResourceType>;
|
|
236
|
+
}
|
|
240
237
|
|
|
241
238
|
export declare function createResourceImpl<T extends Resource>(resourceType: T['resourceType'], resource: T, repo: FhirRepository, options?: CreateResourceOptions): Promise<FhirResponse>;
|
|
242
239
|
|
|
@@ -353,7 +350,7 @@ export declare abstract class FhirRepository {
|
|
|
353
350
|
* @param patch - The JSONPatch operations.
|
|
354
351
|
* @returns The patched resource.
|
|
355
352
|
*/
|
|
356
|
-
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
353
|
+
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
357
354
|
/**
|
|
358
355
|
* Searches for FHIR resources.
|
|
359
356
|
*
|
|
@@ -377,10 +374,10 @@ export declare abstract class FhirRepository {
|
|
|
377
374
|
* Runs a callback function within a transaction.
|
|
378
375
|
*
|
|
379
376
|
* @param callback - The callback function to be run within a transaction.
|
|
377
|
+
* @param options - The transaction options.
|
|
378
|
+
* @returns The result of the callback function.
|
|
380
379
|
*/
|
|
381
|
-
abstract withTransaction<TResult>(callback: (txRepo: this) => Promise<TResult>, options
|
|
382
|
-
serializable?: boolean;
|
|
383
|
-
}): Promise<TResult>;
|
|
380
|
+
abstract withTransaction<TResult>(callback: (txRepo: this) => Promise<TResult>, options: TransactionOptions): Promise<TResult>;
|
|
384
381
|
/**
|
|
385
382
|
* Searches for a single FHIR resource.
|
|
386
383
|
*
|
|
@@ -461,7 +458,7 @@ export declare abstract class FhirRepository {
|
|
|
461
458
|
* @returns A promise that resolves when the operation is complete.
|
|
462
459
|
*/
|
|
463
460
|
conditionalDelete(search: SearchRequest): Promise<void>;
|
|
464
|
-
conditionalPatch(search: SearchRequest, patch: Operation[]): Promise<WithId<Resource>>;
|
|
461
|
+
conditionalPatch(search: SearchRequest, patch: Operation[], options?: UpdateResourceOptions): Promise<WithId<Resource>>;
|
|
465
462
|
}
|
|
466
463
|
|
|
467
464
|
export declare type FhirRequest = {
|
|
@@ -483,7 +480,9 @@ export declare type FhirRequestConfig = {
|
|
|
483
480
|
transactions?: boolean;
|
|
484
481
|
};
|
|
485
482
|
|
|
486
|
-
export declare type FhirResponse = [
|
|
483
|
+
export declare type FhirResponse = [
|
|
484
|
+
OperationOutcome
|
|
485
|
+
] | [OperationOutcome, Resource] | [OperationOutcome, Resource, FhirResponseOptions];
|
|
487
486
|
|
|
488
487
|
export declare type FhirResponseOptions = {
|
|
489
488
|
contentType?: string;
|
|
@@ -510,8 +509,75 @@ export declare class FhirRouter extends EventTarget_2 {
|
|
|
510
509
|
log(level: string, message: string, data?: Record<string, any>): void;
|
|
511
510
|
}
|
|
512
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Gets the extra search entries for the _include and _revinclude parameters.
|
|
514
|
+
*
|
|
515
|
+
* The `entries` array is appended to in place.
|
|
516
|
+
*
|
|
517
|
+
* @param repo - The FHIR repository.
|
|
518
|
+
* @param searchRequest - The original search request.
|
|
519
|
+
* @param resources - The resources returned by the original search.
|
|
520
|
+
* @param entries - The output bundle entries.
|
|
521
|
+
* @param options - Optional repository-specific behavior.
|
|
522
|
+
*/
|
|
523
|
+
export declare function getExtraEntries<T extends Resource>(repo: FhirRepository, searchRequest: SearchRequest<T>, resources: T[], entries: BundleEntry[], options?: IncludeOptions): Promise<void>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Returns bundle entries for the resources that are included in the search result.
|
|
527
|
+
*
|
|
528
|
+
* See documentation on _include: https://hl7.org/fhir/R4/search.html#include
|
|
529
|
+
* @param repo - The repository.
|
|
530
|
+
* @param include - The include parameter.
|
|
531
|
+
* @param resources - The base search result resources.
|
|
532
|
+
* @param options - Optional repository-specific behavior.
|
|
533
|
+
* @returns The bundle entries for the included resources.
|
|
534
|
+
*/
|
|
535
|
+
export declare function getSearchIncludeEntries(repo: FhirRepository, include: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns bundle entries for the resources that are reverse included in the search result.
|
|
539
|
+
*
|
|
540
|
+
* See documentation on _revinclude: https://hl7.org/fhir/R4/search.html#revinclude
|
|
541
|
+
* @param repo - The repository.
|
|
542
|
+
* @param revInclude - The revInclude parameter.
|
|
543
|
+
* @param resources - The base search result resources.
|
|
544
|
+
* @param options - Optional repository-specific behavior.
|
|
545
|
+
* @returns The bundle entries for the reverse included resources.
|
|
546
|
+
*/
|
|
547
|
+
export declare function getSearchRevIncludeEntries(repo: FhirRepository, revInclude: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
548
|
+
|
|
513
549
|
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
514
550
|
|
|
551
|
+
export declare interface IncludeOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Builds the `Bundle.entry.fullUrl` for an included resource.
|
|
554
|
+
* When omitted, `fullUrl` is not set on the resulting entries.
|
|
555
|
+
*/
|
|
556
|
+
readonly fullUrl?: (resourceType: string, id: string) => string;
|
|
557
|
+
/**
|
|
558
|
+
* The maximum number of `:iterate` rounds before the search is rejected. Defaults to 5.
|
|
559
|
+
*/
|
|
560
|
+
readonly maxDepth?: number;
|
|
561
|
+
/**
|
|
562
|
+
* The maximum total number of bundle entries before the search is rejected.
|
|
563
|
+
* Defaults to `DEFAULT_MAX_SEARCH_COUNT`.
|
|
564
|
+
*/
|
|
565
|
+
readonly maxResults?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Executes the sub-searches needed for canonical `_include` and for all `_revinclude` targets.
|
|
568
|
+
* Defaults to `repo.searchResources()`.
|
|
569
|
+
*/
|
|
570
|
+
readonly executeSearch?: IncludeSearchFn;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Executes a search on behalf of the include logic.
|
|
575
|
+
*
|
|
576
|
+
* The default implementation uses {@link FhirRepository.searchResources}. The server overrides this
|
|
577
|
+
* to reuse its already-built query pipeline rather than re-entering the public `search()` entry point.
|
|
578
|
+
*/
|
|
579
|
+
export declare type IncludeSearchFn = (searchRequest: SearchRequest) => Promise<WithId<Resource>[]>;
|
|
580
|
+
|
|
515
581
|
export declare interface LogEvent extends Event_2 {
|
|
516
582
|
message: string;
|
|
517
583
|
data?: Record<string, any>;
|
|
@@ -527,16 +593,22 @@ export declare class MemoryRepository extends FhirRepository {
|
|
|
527
593
|
withSeeding<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
528
594
|
clear(): void;
|
|
529
595
|
setMode(_mode: RepositoryMode): void;
|
|
596
|
+
private createResourceSync;
|
|
530
597
|
createResource<T extends Resource>(resource: T, options?: CreateResourceOptions, update?: boolean): Promise<WithId<T>>;
|
|
531
598
|
generateId(): string;
|
|
532
599
|
updateResource<T extends Resource>(resource: T, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
533
|
-
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
600
|
+
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
534
601
|
readResource<T extends Resource>(resourceType: string, id: string): Promise<T>;
|
|
535
602
|
readReference<T extends Resource>(reference: Reference<T>): Promise<WithId<T>>;
|
|
536
603
|
readReferences<T extends Resource>(references: readonly Reference<T>[]): Promise<(T | OperationOutcomeError)[]>;
|
|
537
604
|
readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
|
|
538
605
|
readVersion<T extends Resource>(resourceType: string, id: string, versionId: string): Promise<T>;
|
|
606
|
+
private searchSync;
|
|
539
607
|
search<T extends Resource>(searchRequest: SearchRequest<T>): Promise<Bundle<WithId<T>>>;
|
|
608
|
+
conditionalCreate<T extends Resource>(resource: T, search: SearchRequest<T>, options?: CreateResourceOptions): Promise<{
|
|
609
|
+
resource: WithId<T>;
|
|
610
|
+
outcome: OperationOutcome;
|
|
611
|
+
}>;
|
|
540
612
|
searchByReference<T extends Resource>(searchRequest: SearchRequest<T>, referenceField: string, references: string[]): Promise<Record<string, WithId<T>[]>>;
|
|
541
613
|
deleteResource(resourceType: string, id: string): Promise<void>;
|
|
542
614
|
withTransaction<TResult>(callback: (repo: this) => Promise<TResult>): Promise<TResult>;
|
|
@@ -571,6 +643,8 @@ export declare const RepositoryMode: {
|
|
|
571
643
|
|
|
572
644
|
export declare type RepositoryMode = (typeof RepositoryMode)[keyof typeof RepositoryMode];
|
|
573
645
|
|
|
646
|
+
declare type ResourceTypeInput = ResourceType | readonly ResourceType[] | ReadonlySet<ResourceType>;
|
|
647
|
+
|
|
574
648
|
/** @see http://hl7.org/fhir/R4/codesystem-restful-interaction.html */
|
|
575
649
|
export declare type RestInteraction = CapabilityStatementRestInteraction['code'] | CapabilityStatementRestResourceInteraction['code'] | 'operation';
|
|
576
650
|
|
|
@@ -595,6 +669,11 @@ export declare type RouteResult<Handler, Metadata> = {
|
|
|
595
669
|
data?: Metadata;
|
|
596
670
|
};
|
|
597
671
|
|
|
672
|
+
export declare interface TransactionOptions {
|
|
673
|
+
readonly resourceTypes: ResourceTypeInput;
|
|
674
|
+
readonly serializable?: boolean;
|
|
675
|
+
}
|
|
676
|
+
|
|
598
677
|
export declare function updateResourceImpl<T extends Resource>(resourceType: T['resourceType'], id: string, resource: T, repo: FhirRepository, options?: UpdateResourceOptions): Promise<FhirResponse>;
|
|
599
678
|
|
|
600
679
|
export declare type UpdateResourceOptions = {
|