@medplum/core 2.0.23 → 2.0.24

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 (55) hide show
  1. package/dist/cjs/index.cjs +14080 -13352
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/access.mjs +142 -0
  5. package/dist/esm/access.mjs.map +1 -0
  6. package/dist/esm/bundle.mjs +3 -3
  7. package/dist/esm/bundle.mjs.map +1 -1
  8. package/dist/esm/client.mjs +49 -25
  9. package/dist/esm/client.mjs.map +1 -1
  10. package/dist/esm/fhirlexer/parse.mjs.map +1 -1
  11. package/dist/esm/fhirmapper/parse.mjs +1 -1
  12. package/dist/esm/fhirmapper/parse.mjs.map +1 -1
  13. package/dist/esm/fhirpath/functions.mjs +2 -2
  14. package/dist/esm/fhirpath/functions.mjs.map +1 -1
  15. package/dist/esm/fhirpath/parse.mjs +2 -1
  16. package/dist/esm/fhirpath/parse.mjs.map +1 -1
  17. package/dist/esm/fhirpath/utils.mjs +4 -5
  18. package/dist/esm/fhirpath/utils.mjs.map +1 -1
  19. package/dist/esm/format.mjs +1 -1
  20. package/dist/esm/format.mjs.map +1 -1
  21. package/dist/esm/hl7.mjs +6 -6
  22. package/dist/esm/hl7.mjs.map +1 -1
  23. package/dist/esm/index.min.mjs +1 -1
  24. package/dist/esm/index.mjs +5 -2
  25. package/dist/esm/index.mjs.map +1 -1
  26. package/dist/esm/outcomes.mjs +38 -14
  27. package/dist/esm/outcomes.mjs.map +1 -1
  28. package/dist/esm/readablepromise.mjs +1 -1
  29. package/dist/esm/readablepromise.mjs.map +1 -1
  30. package/dist/esm/schema.mjs +1 -1
  31. package/dist/esm/schema.mjs.map +1 -1
  32. package/dist/esm/search/details.mjs +14 -16
  33. package/dist/esm/search/details.mjs.map +1 -1
  34. package/dist/esm/search/match.mjs +7 -5
  35. package/dist/esm/search/match.mjs.map +1 -1
  36. package/dist/esm/search/search.mjs +14 -5
  37. package/dist/esm/search/search.mjs.map +1 -1
  38. package/dist/esm/types.mjs +1 -1
  39. package/dist/esm/types.mjs.map +1 -1
  40. package/dist/esm/typeschema/types.mjs +278 -0
  41. package/dist/esm/typeschema/types.mjs.map +1 -0
  42. package/dist/esm/typeschema/validation.mjs +262 -0
  43. package/dist/esm/typeschema/validation.mjs.map +1 -0
  44. package/dist/esm/utils.mjs +3 -3
  45. package/dist/esm/utils.mjs.map +1 -1
  46. package/dist/types/access.d.ts +48 -0
  47. package/dist/types/client.d.ts +15 -20
  48. package/dist/types/fhirlexer/parse.d.ts +5 -4
  49. package/dist/types/fhirpath/functions.d.ts +1 -3
  50. package/dist/types/index.d.ts +3 -0
  51. package/dist/types/outcomes.d.ts +3 -1
  52. package/dist/types/search/search.d.ts +7 -0
  53. package/dist/types/typeschema/types.d.ts +5 -2
  54. package/dist/types/typeschema/validation.d.ts +2 -0
  55. package/package.json +1 -1
@@ -178,9 +178,7 @@ export interface FetchLike {
178
178
  */
179
179
  export type QueryTypes = URLSearchParams | string[][] | Record<string, any> | string | undefined;
180
180
  export interface CreatePdfFunction {
181
- (docDefinition: TDocumentDefinitions, tableLayouts?: {
182
- [name: string]: CustomTableLayout;
183
- } | undefined, fonts?: TFontDictionary | undefined): Promise<any>;
181
+ (docDefinition: TDocumentDefinitions, tableLayouts?: Record<string, CustomTableLayout> | undefined, fonts?: TFontDictionary | undefined): Promise<any>;
184
182
  }
185
183
  export interface BaseLoginRequest {
186
184
  readonly projectId?: string;
@@ -610,7 +608,7 @@ export declare class MedplumClient extends EventTarget {
610
608
  * @param loginParams Optional login parameters.
611
609
  * @returns The user profile resource if available.
612
610
  */
613
- signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void>;
611
+ signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | undefined>;
614
612
  /**
615
613
  * Tries to sign out the user.
616
614
  * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
@@ -1026,9 +1024,7 @@ export declare class MedplumClient extends EventTarget {
1026
1024
  * @param fonts Optional pdfmake custom font dictionary.
1027
1025
  * @returns The result of the create operation.
1028
1026
  */
1029
- createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: {
1030
- [name: string]: CustomTableLayout;
1031
- }, fonts?: TFontDictionary): Promise<Binary>;
1027
+ createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<Binary>;
1032
1028
  /**
1033
1029
  * Creates a FHIR `Communication` resource with the provided data content.
1034
1030
  *
@@ -1127,23 +1123,14 @@ export declare class MedplumClient extends EventTarget {
1127
1123
  */
1128
1124
  validateResource<T extends Resource>(resource: T, options?: RequestInit): Promise<OperationOutcome>;
1129
1125
  /**
1130
- * Executes a bot by ID.
1131
- * @param id The Bot ID.
1126
+ * Executes a bot by ID or Identifier.
1127
+ * @param idOrIdentifier The Bot ID or Identifier.
1132
1128
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
1133
1129
  * @param contentType The content type to be included in the "Content-Type" header.
1134
1130
  * @param options Optional fetch options.
1135
1131
  * @returns The Bot return value.
1136
1132
  */
1137
- executeBot(id: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
1138
- /**
1139
- * Executes a bot by Identifier.
1140
- * @param id The Bot Identifier.
1141
- * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
1142
- * @param contentType The content type to be included in the "Content-Type" header.
1143
- * @param options Optional fetch options.
1144
- * @returns The Bot return value.
1145
- */
1146
- executeBot(identifier: Identifier, body: any, contentType?: string, options?: RequestInit): Promise<any>;
1133
+ executeBot(idOrIdentifier: string | Identifier, body: any, contentType?: string, options?: RequestInit): Promise<any>;
1147
1134
  /**
1148
1135
  * Executes a batch or transaction of FHIR operations.
1149
1136
  *
@@ -1291,7 +1278,7 @@ export declare class MedplumClient extends EventTarget {
1291
1278
  * @param options Optional fetch options.
1292
1279
  * @returns A Bundle
1293
1280
  */
1294
- readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string, options?: RequestInit): ReadablePromise<Bundle<Resource>>;
1281
+ readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string, options?: RequestInit): ReadablePromise<Bundle>;
1295
1282
  /**
1296
1283
  * @category Authentication
1297
1284
  * @returns The Login State
@@ -1406,6 +1393,14 @@ export declare class MedplumClient extends EventTarget {
1406
1393
  * @returns Bulk Data Response containing links to Bulk Data files. See "Response - Complete Status" for full details: https://build.fhir.org/ig/HL7/bulk-data/export.html#response---complete-status
1407
1394
  */
1408
1395
  bulkExport(exportLevel?: string, resourceTypes?: string, since?: string, options?: RequestInit): Promise<Partial<BulkDataExport>>;
1396
+ /**
1397
+ * Starts an async request following the FHIR "Asynchronous Request Pattern".
1398
+ * See: https://hl7.org/fhir/r4/async.html
1399
+ * @param url The URL to request.
1400
+ * @param options Optional fetch options.
1401
+ * @returns The response body.
1402
+ */
1403
+ startAsyncRequest<T>(url: string, options?: RequestInit): Promise<T>;
1409
1404
  /**
1410
1405
  * Returns the cache entry if available and not expired.
1411
1406
  * @param key The cache key to retrieve.
@@ -6,6 +6,7 @@ export interface AtomContext {
6
6
  }
7
7
  export interface Atom {
8
8
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
9
+ toString(): string;
9
10
  }
10
11
  export declare abstract class PrefixOperatorAtom implements Atom {
11
12
  readonly operator: string;
@@ -32,10 +33,10 @@ export interface InfixParselet {
32
33
  export declare class ParserBuilder {
33
34
  private readonly prefixParselets;
34
35
  private readonly infixParselets;
35
- registerInfix(tokenType: string, parselet: InfixParselet): ParserBuilder;
36
- registerPrefix(tokenType: string, parselet: PrefixParselet): ParserBuilder;
37
- prefix(tokenType: string, precedence: number, builder: (token: Token, right: Atom) => Atom): ParserBuilder;
38
- infixLeft(tokenType: string, precedence: number, builder: (left: Atom, token: Token, right: Atom) => Atom): ParserBuilder;
36
+ registerInfix(tokenType: string, parselet: InfixParselet): this;
37
+ registerPrefix(tokenType: string, parselet: PrefixParselet): this;
38
+ prefix(tokenType: string, precedence: number, builder: (token: Token, right: Atom) => Atom): this;
39
+ infixLeft(tokenType: string, precedence: number, builder: (left: Atom, token: Token, right: Atom) => Atom): this;
39
40
  construct(input: Token[]): Parser;
40
41
  }
41
42
  export declare class Parser {
@@ -1,6 +1,4 @@
1
1
  import { Atom, AtomContext } from '../fhirlexer';
2
2
  import { TypedValue } from '../types';
3
- export interface FhirPathFunction {
4
- (context: AtomContext, input: TypedValue[], ...args: Atom[]): TypedValue[];
5
- }
3
+ export type FhirPathFunction = (context: AtomContext, input: TypedValue[], ...args: Atom[]) => TypedValue[];
6
4
  export declare const functions: Record<string, FhirPathFunction>;
@@ -1,3 +1,4 @@
1
+ export * from './access';
1
2
  export * from './base64';
2
3
  export * from './bundle';
3
4
  export * from './cache';
@@ -20,3 +21,5 @@ export * from './sftp';
20
21
  export * from './storage';
21
22
  export * from './types';
22
23
  export * from './utils';
24
+ export { loadDataTypes } from './typeschema/types';
25
+ export { validateResource as experimentalValidateResource } from './typeschema/validation';
@@ -7,11 +7,13 @@ export declare const unauthorized: OperationOutcome;
7
7
  export declare const forbidden: OperationOutcome;
8
8
  export declare const gone: OperationOutcome;
9
9
  export declare const tooManyRequests: OperationOutcome;
10
- export declare const accepted: OperationOutcome;
10
+ export declare function accepted(location: string): OperationOutcome;
11
11
  export declare function badRequest(details: string, expression?: string): OperationOutcome;
12
12
  export declare function validationError(details: string): OperationOutcome;
13
+ export declare function serverError(err: Error): OperationOutcome;
13
14
  export declare function isOperationOutcome(value: unknown): value is OperationOutcome;
14
15
  export declare function isOk(outcome: OperationOutcome): boolean;
16
+ export declare function isAccepted(outcome: OperationOutcome): boolean;
15
17
  export declare function isNotFound(outcome: OperationOutcome): boolean;
16
18
  export declare function isGone(outcome: OperationOutcome): boolean;
17
19
  export declare function getStatus(outcome: OperationOutcome): number;
@@ -76,6 +76,13 @@ export declare function parseSearchUrl<T extends Resource = Resource>(url: URL):
76
76
  * @returns Parsed search definition.
77
77
  */
78
78
  export declare function parseSearchDefinition<T extends Resource = Resource>(url: string): SearchRequest<T>;
79
+ /**
80
+ * Parses a FHIR criteria string into a SearchRequest.
81
+ * FHIR criteria strings are found on resources such as Subscription.
82
+ * @param criteria The FHIR criteria string.
83
+ * @returns Parsed search definition.
84
+ */
85
+ export declare function parseCriteriaAsSearchRequest(criteria: string): SearchRequest;
79
86
  /**
80
87
  * Formats a search definition object into a query string.
81
88
  * Note: The return value does not include the resource type.
@@ -1,12 +1,13 @@
1
- import { ResourceType, StructureDefinition } from '@medplum/fhirtypes';
1
+ import { Bundle, StructureDefinition } from '@medplum/fhirtypes';
2
2
  import { TypedValue } from '../types';
3
3
  /**
4
4
  * Internal representation of a non-primitive FHIR type, suitable for use in resource validation
5
5
  */
6
6
  export interface InternalTypeSchema {
7
- name: ResourceType;
7
+ name: string;
8
8
  fields: Record<string, ElementValidator>;
9
9
  constraints: Constraint[];
10
+ innerTypes: InternalTypeSchema[];
10
11
  }
11
12
  export interface ElementValidator {
12
13
  min: number;
@@ -53,3 +54,5 @@ export interface SliceDiscriminator {
53
54
  * @experimental
54
55
  */
55
56
  export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
57
+ export declare function loadDataTypes(bundle: Bundle<StructureDefinition>): void;
58
+ export declare function getDataType(type: string): InternalTypeSchema;
@@ -0,0 +1,2 @@
1
+ import { Resource, StructureDefinition } from '@medplum/fhirtypes';
2
+ export declare function validateResource(resource: Resource, profile?: StructureDefinition): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",