@medplum/fhir-router 2.0.21 → 2.0.23

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.
@@ -5,7 +5,6 @@ import { FhirRepository } from './repo';
5
5
  * Processes a FHIR batch request.
6
6
  *
7
7
  * See: https://www.hl7.org/fhir/http.html#transaction
8
- *
9
8
  * @param router The FHIR router.
10
9
  * @param repo The FHIR repository.
11
10
  * @param bundle The input bundle.
@@ -10,8 +10,13 @@ export type FhirRequest = {
10
10
  };
11
11
  export type FhirResponse = [OperationOutcome] | [OperationOutcome, Resource];
12
12
  export type FhirRouteHandler = (req: FhirRequest, repo: FhirRepository, router: FhirRouter) => Promise<FhirResponse>;
13
+ interface FhirOptions {
14
+ introspectionEnabled?: boolean;
15
+ }
13
16
  export declare class FhirRouter {
14
17
  readonly router: Router<FhirRouteHandler>;
15
- constructor();
18
+ readonly options: FhirOptions;
19
+ constructor(options?: {});
16
20
  handleRequest(req: FhirRequest, repo: FhirRepository): Promise<FhirResponse>;
17
21
  }
22
+ export {};
@@ -0,0 +1,14 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { FhirRequest, FhirResponse, FhirRouter } from '../fhirrouter';
3
+ import { FhirRepository } from '../repo';
4
+ /**
5
+ * Handles FHIR GraphQL requests.
6
+ *
7
+ * See: https://www.hl7.org/fhir/graphql.html
8
+ * @param req The request details.
9
+ * @param repo The current user FHIR repository.
10
+ * @param router The router for router options.
11
+ * @returns The response.
12
+ */
13
+ export declare function graphqlHandler(req: FhirRequest, repo: FhirRepository, router: FhirRouter): Promise<FhirResponse>;
14
+ export declare function getRootSchema(): GraphQLSchema;
@@ -0,0 +1 @@
1
+ export * from './graphql';
@@ -0,0 +1,2 @@
1
+ import { GraphQLInputType } from 'graphql';
2
+ export declare function getGraphQLInputType(inputType: string, nameSuffix: string): GraphQLInputType;
@@ -0,0 +1,4 @@
1
+ import { GraphQLOutputType } from 'graphql';
2
+ export declare const outputTypeCache: Record<string, GraphQLOutputType | undefined>;
3
+ export declare function getGraphQLOutputType(inputType: string): GraphQLOutputType;
4
+ export declare function buildGraphQLOutputType(resourceType: string): GraphQLOutputType;
@@ -0,0 +1,46 @@
1
+ import { GraphQLError, GraphQLFieldConfigArgumentMap, GraphQLResolveInfo, GraphQLScalarType } from 'graphql';
2
+ import { FhirRepository } from '../repo';
3
+ import DataLoader from 'dataloader';
4
+ import { OperationOutcome, Reference, Resource, ResourceType } from '@medplum/fhirtypes';
5
+ import { SearchRequest } from '@medplum/core';
6
+ export interface GraphQLContext {
7
+ repo: FhirRepository;
8
+ dataLoader: DataLoader<Reference, Resource>;
9
+ }
10
+ export declare const typeCache: Record<string, GraphQLScalarType | undefined>;
11
+ export declare function parseSearchArgs(resourceType: ResourceType, source: any, args: Record<string, string>): SearchRequest;
12
+ export declare function graphQLFieldToFhirParam(code: string): string;
13
+ export declare function fhirParamToGraphQLField(code: string): string;
14
+ /**
15
+ * GraphQL data loader for search requests.
16
+ * The field name should always end with "List" (i.e., "Patient" search uses "PatientList").
17
+ * The search args should be FHIR search parameters.
18
+ * @param source The source/root. This should always be null for our top level readers.
19
+ * @param args The GraphQL search arguments.
20
+ * @param ctx The GraphQL context.
21
+ * @param info The GraphQL resolve info. This includes the schema, and additional field details.
22
+ * @returns Promise to read the resoures for the query.
23
+ */
24
+ export declare function resolveBySearch(source: any, args: Record<string, string>, ctx: GraphQLContext, info: GraphQLResolveInfo): Promise<Resource[] | undefined>;
25
+ export declare function buildSearchArgs(resourceType: string): GraphQLFieldConfigArgumentMap;
26
+ /**
27
+ * Returns the depth of the GraphQL node in a query.
28
+ * We use "selections" as the representation of depth.
29
+ * As a rough approximation, it's the number of indentations in a well formatted query.
30
+ * @param path The GraphQL node path.
31
+ * @returns The "depth" of the node.
32
+ */
33
+ export declare function getDepth(path: ReadonlyArray<string | number>): number;
34
+ /**
35
+ * Returns true if the field is requested in the GraphQL query.
36
+ * @param info The GraphQL resolve info. This includes the field name.
37
+ * @param fieldName The field name to check.
38
+ * @returns True if the field is requested in the GraphQL query.
39
+ */
40
+ export declare function isFieldRequested(info: GraphQLResolveInfo, fieldName: string): boolean;
41
+ /**
42
+ * Returns an OperationOutcome for GraphQL errors.
43
+ * @param errors Array of GraphQL errors.
44
+ * @returns OperationOutcome with the GraphQL errors as OperationOutcome issues.
45
+ */
46
+ export declare function invalidRequest(errors: ReadonlyArray<GraphQLError>): OperationOutcome;
@@ -14,7 +14,6 @@ export interface FhirRepository {
14
14
  * Creates a FHIR resource.
15
15
  *
16
16
  * See: https://www.hl7.org/fhir/http.html#create
17
- *
18
17
  * @param resource The FHIR resource to create.
19
18
  * @returns The created resource.
20
19
  */
@@ -23,7 +22,6 @@ export interface FhirRepository {
23
22
  * Reads a FHIR resource by ID.
24
23
  *
25
24
  * See: https://www.hl7.org/fhir/http.html#read
26
- *
27
25
  * @param resourceType The FHIR resource type.
28
26
  * @param id The FHIR resource ID.
29
27
  * @returns The FHIR resource.
@@ -33,7 +31,6 @@ export interface FhirRepository {
33
31
  * Reads a FHIR resource by reference.
34
32
  *
35
33
  * See: https://www.hl7.org/fhir/http.html#read
36
- *
37
34
  * @param reference The FHIR reference.
38
35
  * @returns The FHIR resource.
39
36
  */
@@ -42,7 +39,6 @@ export interface FhirRepository {
42
39
  * Reads a collection of FHIR resources by reference.
43
40
  *
44
41
  * See: https://www.hl7.org/fhir/http.html#read
45
- *
46
42
  * @param references The FHIR references.
47
43
  * @returns The FHIR resources.
48
44
  */
@@ -53,7 +49,6 @@ export interface FhirRepository {
53
49
  * Results are sorted with oldest versions last
54
50
  *
55
51
  * See: https://www.hl7.org/fhir/http.html#history
56
- *
57
52
  * @param resourceType The FHIR resource type.
58
53
  * @param id The FHIR resource ID.
59
54
  * @returns Operation outcome and a history bundle.
@@ -63,7 +58,6 @@ export interface FhirRepository {
63
58
  * Reads a FHIR resource version.
64
59
  *
65
60
  * See: https://www.hl7.org/fhir/http.html#vread
66
- *
67
61
  * @param resourceType The FHIR resource type.
68
62
  * @param id The FHIR resource ID.
69
63
  * @param vid The FHIR resource version ID.
@@ -73,7 +67,6 @@ export interface FhirRepository {
73
67
  * Updates a FHIR resource.
74
68
  *
75
69
  * See: https://www.hl7.org/fhir/http.html#update
76
- *
77
70
  * @param resource The FHIR resource to update.
78
71
  * @returns The updated resource.
79
72
  */
@@ -82,7 +75,6 @@ export interface FhirRepository {
82
75
  * Deletes a FHIR resource.
83
76
  *
84
77
  * See: https://www.hl7.org/fhir/http.html#delete
85
- *
86
78
  * @param resourceType The FHIR resource type.
87
79
  * @param id The FHIR resource ID.
88
80
  */
@@ -91,7 +83,6 @@ export interface FhirRepository {
91
83
  * Patches a FHIR resource.
92
84
  *
93
85
  * See: https://www.hl7.org/fhir/http.html#patch
94
- *
95
86
  * @param resourceType The FHIR resource type.
96
87
  * @param id The FHIR resource ID.
97
88
  * @param patch The JSONPatch operations.
@@ -102,7 +93,6 @@ export interface FhirRepository {
102
93
  * Searches for FHIR resources.
103
94
  *
104
95
  * See: https://www.hl7.org/fhir/http.html#search
105
- *
106
96
  * @param searchRequest The FHIR search request.
107
97
  * @returns The search results.
108
98
  */
@@ -115,7 +105,6 @@ export interface FhirRepository {
115
105
  * The return value is the resource, if available; otherwise, undefined.
116
106
  *
117
107
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
118
- *
119
108
  * @param searchRequest The FHIR search request.
120
109
  * @returns Promise to the first search result or undefined.
121
110
  */
@@ -128,7 +117,6 @@ export interface FhirRepository {
128
117
  * The return value is an array of resources.
129
118
  *
130
119
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
131
- *
132
120
  * @param searchRequest The FHIR search request.
133
121
  * @returns Promise to the array of search results.
134
122
  */
@@ -139,7 +127,6 @@ export declare abstract class BaseRepository {
139
127
  * Searches for FHIR resources.
140
128
  *
141
129
  * See: https://www.hl7.org/fhir/http.html#search
142
- *
143
130
  * @param searchRequest The FHIR search request.
144
131
  * @returns The search results.
145
132
  */
@@ -152,7 +139,6 @@ export declare abstract class BaseRepository {
152
139
  * The return value is the resource, if available; otherwise, undefined.
153
140
  *
154
141
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
155
- *
156
142
  * @param searchRequest The FHIR search request.
157
143
  * @returns Promise to the first search result or undefined.
158
144
  */
@@ -165,7 +151,6 @@ export declare abstract class BaseRepository {
165
151
  * The return value is an array of resources.
166
152
  *
167
153
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
168
- *
169
154
  * @param searchRequest The FHIR search request.
170
155
  * @returns Promise to the array of search results.
171
156
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/fhir-router",
3
- "version": "2.0.21",
3
+ "version": "2.0.23",
4
4
  "description": "Medplum FHIR Router",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -1,10 +0,0 @@
1
- import { GraphQLSchema } from 'graphql';
2
- import { FhirRequest, FhirResponse } from './fhirrouter';
3
- import { FhirRepository } from './repo';
4
- /**
5
- * Handles FHIR GraphQL requests.
6
- *
7
- * See: https://www.hl7.org/fhir/graphql.html
8
- */
9
- export declare function graphqlHandler(req: FhirRequest, repo: FhirRepository): Promise<FhirResponse>;
10
- export declare function getRootSchema(): GraphQLSchema;