@medplum/core 0.4.0 → 0.5.1
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/README.md +1 -1
- package/dist/cjs/index.js +402 -329
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +401 -330
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/cache.d.ts +1 -3
- package/dist/types/client.d.ts +9 -66
- package/dist/types/eventtarget.d.ts +3 -3
- package/dist/types/search.d.ts +1 -0
- package/dist/types/searchparams.d.ts +2 -1
- package/dist/types/storage.d.ts +2 -2
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils.d.ts +6 -0
- package/package.json +2 -2
- package/rollup.config.js +0 -36
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, ValueSet } from '@medplum/fhirtypes';
|
|
1
|
+
import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
2
|
import { EventTarget } from './eventtarget';
|
|
3
3
|
import { SearchRequest } from './search';
|
|
4
4
|
import { IndexedStructureDefinition } from './types';
|
|
@@ -98,18 +98,7 @@ export interface TokenResponse {
|
|
|
98
98
|
readonly profile: Reference<ProfileResource>;
|
|
99
99
|
}
|
|
100
100
|
export declare class MedplumClient extends EventTarget {
|
|
101
|
-
private
|
|
102
|
-
private readonly storage;
|
|
103
|
-
private readonly schema;
|
|
104
|
-
private readonly resourceCache;
|
|
105
|
-
private readonly baseUrl;
|
|
106
|
-
private readonly clientId;
|
|
107
|
-
private readonly authorizeUrl;
|
|
108
|
-
private readonly tokenUrl;
|
|
109
|
-
private readonly logoutUrl;
|
|
110
|
-
private readonly onUnauthenticated?;
|
|
111
|
-
private refreshPromise?;
|
|
112
|
-
private loading;
|
|
101
|
+
#private;
|
|
113
102
|
constructor(options?: MedplumClientOptions);
|
|
114
103
|
/**
|
|
115
104
|
* Clears all auth state including local storage and session storage.
|
|
@@ -222,66 +211,20 @@ export declare class MedplumClient extends EventTarget {
|
|
|
222
211
|
getActiveLogin(): LoginState | undefined;
|
|
223
212
|
setActiveLogin(login: LoginState): Promise<void>;
|
|
224
213
|
getLogins(): LoginState[];
|
|
225
|
-
private addLogin;
|
|
226
|
-
private refreshProfile;
|
|
227
|
-
getProfile(): ProfileResource | undefined;
|
|
228
214
|
isLoading(): boolean;
|
|
215
|
+
getProfile(): ProfileResource | undefined;
|
|
216
|
+
getProfileAsync(): Promise<ProfileResource | undefined>;
|
|
217
|
+
getUserConfiguration(): UserConfiguration | undefined;
|
|
229
218
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param
|
|
232
|
-
* @
|
|
233
|
-
* @param {string=} contentType
|
|
234
|
-
* @param {Object=} body
|
|
235
|
-
*/
|
|
236
|
-
private request;
|
|
237
|
-
/**
|
|
238
|
-
* Handles an unauthenticated response from the server.
|
|
239
|
-
* First, tries to refresh the access token and retry the request.
|
|
240
|
-
* Otherwise, calls unauthenticated callbacks and rejects.
|
|
241
|
-
* @param method The HTTP method of the original request.
|
|
242
|
-
* @param url The URL of the original request.
|
|
243
|
-
* @param contentType The content type of the original request.
|
|
244
|
-
* @param body The body of the original request.
|
|
245
|
-
*/
|
|
246
|
-
private handleUnauthenticated;
|
|
247
|
-
/**
|
|
248
|
-
* Starts a new PKCE flow.
|
|
249
|
-
* These PKCE values are stateful, and must survive redirects and page refreshes.
|
|
250
|
-
*/
|
|
251
|
-
private startPkce;
|
|
252
|
-
/**
|
|
253
|
-
* Redirects the user to the login screen for authorization.
|
|
254
|
-
* Clears all auth state including local storage and session storage.
|
|
255
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
|
|
219
|
+
* Downloads the URL as a blob.
|
|
220
|
+
* @param url The URL to request.
|
|
221
|
+
* @returns Promise to the response body as a blob.
|
|
256
222
|
*/
|
|
257
|
-
|
|
223
|
+
download(url: string): Promise<Blob>;
|
|
258
224
|
/**
|
|
259
225
|
* Processes an OAuth authorization code.
|
|
260
226
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
261
227
|
* @param code The authorization code received by URL parameter.
|
|
262
228
|
*/
|
|
263
229
|
processCode(code: string): Promise<ProfileResource>;
|
|
264
|
-
/**
|
|
265
|
-
* Tries to refresh the auth tokens.
|
|
266
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
|
|
267
|
-
*/
|
|
268
|
-
private refresh;
|
|
269
|
-
/**
|
|
270
|
-
* Makes a POST request to the tokens endpoint.
|
|
271
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
272
|
-
* @param formBody Token parameters in URL encoded format.
|
|
273
|
-
*/
|
|
274
|
-
private fetchTokens;
|
|
275
|
-
/**
|
|
276
|
-
* Verifies the tokens received from the auth server.
|
|
277
|
-
* Validates the JWT against the JWKS.
|
|
278
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
279
|
-
* @param tokens
|
|
280
|
-
*/
|
|
281
|
-
private verifyTokens;
|
|
282
|
-
/**
|
|
283
|
-
* Sets up a listener for window storage events.
|
|
284
|
-
* This synchronizes state across browser windows and browser tabs.
|
|
285
|
-
*/
|
|
286
|
-
private setupStorageListener;
|
|
287
230
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
interface Event {
|
|
2
|
-
type: string;
|
|
3
|
-
defaultPrevented?: boolean;
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly defaultPrevented?: boolean;
|
|
4
4
|
}
|
|
5
5
|
declare type EventListener = (e: Event) => void;
|
|
6
6
|
export declare class EventTarget {
|
|
7
|
-
private
|
|
7
|
+
#private;
|
|
8
8
|
constructor();
|
|
9
9
|
addEventListener(type: string, callback: EventListener): void;
|
|
10
10
|
removeEventListeneer(type: string, callback: EventListener): void;
|
package/dist/types/search.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SearchParameter } from '@medplum/fhirtypes';
|
|
1
|
+
import { ElementDefinition, SearchParameter } from '@medplum/fhirtypes';
|
|
2
2
|
import { IndexedStructureDefinition } from './types';
|
|
3
3
|
export declare enum SearchParameterType {
|
|
4
4
|
BOOLEAN = "BOOLEAN",
|
|
@@ -13,6 +13,7 @@ export declare enum SearchParameterType {
|
|
|
13
13
|
export interface SearchParameterDetails {
|
|
14
14
|
readonly columnName: string;
|
|
15
15
|
readonly type: SearchParameterType;
|
|
16
|
+
readonly elementDefinition?: ElementDefinition;
|
|
16
17
|
readonly array?: boolean;
|
|
17
18
|
}
|
|
18
19
|
/**
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* When Using MedplumClient in the server, it will be backed by the MemoryStorage class.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ClientStorage {
|
|
9
|
-
private
|
|
9
|
+
#private;
|
|
10
10
|
constructor();
|
|
11
11
|
clear(): void;
|
|
12
12
|
getString(key: string): string | undefined;
|
|
@@ -18,7 +18,7 @@ export declare class ClientStorage {
|
|
|
18
18
|
* The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
|
|
19
19
|
*/
|
|
20
20
|
export declare class MemoryStorage implements Storage {
|
|
21
|
-
private
|
|
21
|
+
#private;
|
|
22
22
|
constructor();
|
|
23
23
|
/**
|
|
24
24
|
* Returns the number of key/value pairs.
|
package/dist/types/types.d.ts
CHANGED
|
@@ -120,6 +120,7 @@ export interface TypeSchema {
|
|
|
120
120
|
* @returns The empty IndexedStructureDefinition.
|
|
121
121
|
*/
|
|
122
122
|
export declare function createSchema(): IndexedStructureDefinition;
|
|
123
|
+
export declare function createTypeSchema(typeName: string, description: string | undefined): TypeSchema;
|
|
123
124
|
/**
|
|
124
125
|
* Indexes a StructureDefinition for fast lookup.
|
|
125
126
|
* See comments on IndexedStructureDefinition for more details.
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function createReference<T extends Resource>(resource: T): Refere
|
|
|
12
12
|
* @returns A reference string of the form resourceType/id.
|
|
13
13
|
*/
|
|
14
14
|
export declare function getReferenceString(resource: Resource): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the ID portion of a reference.
|
|
17
|
+
* @param reference A FHIR reference.
|
|
18
|
+
* @returns The ID portion of a reference.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveId(reference: Reference | undefined): string | undefined;
|
|
15
21
|
/**
|
|
16
22
|
* Returns true if the resource is a "ProfileResource".
|
|
17
23
|
* @param resource The FHIR resource.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Medplum TS/JS Library",
|
|
5
5
|
"author": "Medplum <hello@medplum.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test": "jest"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@medplum/fhirtypes": "0.
|
|
20
|
+
"@medplum/fhirtypes": "0.5.1"
|
|
21
21
|
},
|
|
22
22
|
"main": "dist/cjs/index.js",
|
|
23
23
|
"module": "dist/esm/index.js",
|
package/rollup.config.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
-
import typescript from '@rollup/plugin-typescript';
|
|
3
|
-
import { terser } from 'rollup-plugin-terser';
|
|
4
|
-
|
|
5
|
-
const extensions = ['.ts'];
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
input: 'src/index.ts',
|
|
9
|
-
output: [
|
|
10
|
-
{
|
|
11
|
-
file: 'dist/esm/index.js',
|
|
12
|
-
format: 'esm',
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
file: 'dist/esm/index.min.js',
|
|
17
|
-
format: 'esm',
|
|
18
|
-
plugins: [terser()],
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
file: 'dist/cjs/index.js',
|
|
23
|
-
format: 'umd',
|
|
24
|
-
name: 'medplum.core',
|
|
25
|
-
sourcemap: true,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
file: 'dist/cjs/index.min.js',
|
|
29
|
-
format: 'umd',
|
|
30
|
-
name: 'medplum.core',
|
|
31
|
-
plugins: [terser()],
|
|
32
|
-
sourcemap: true,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
plugins: [resolve({ extensions }), typescript()],
|
|
36
|
-
};
|