@medplum/core 0.9.17 → 0.9.20

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/esm/index.js CHANGED
@@ -6342,22 +6342,24 @@ class MedplumClient extends EventTarget {
6342
6342
  * @returns Promise to the authentication response.
6343
6343
  */
6344
6344
  startLogin(loginRequest) {
6345
+ var _a, _b;
6345
6346
  return __awaiter(this, void 0, void 0, function* () {
6346
6347
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6347
- return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
6348
+ return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
6348
6349
  });
6349
6350
  }
6350
6351
  /**
6351
6352
  * Tries to sign in with Google authentication.
6352
6353
  * The response parameter is the result of a Google authentication.
6353
6354
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
6354
- * @param googleResponse The Google credential response.
6355
+ * @param loginRequest Login request including Google credential response.
6355
6356
  * @returns Promise to the authentication response.
6356
6357
  */
6357
- startGoogleLogin(googleResponse) {
6358
+ startGoogleLogin(loginRequest) {
6359
+ var _a, _b;
6358
6360
  return __awaiter(this, void 0, void 0, function* () {
6359
6361
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6360
- return this.post('auth/google', googleResponse);
6362
+ return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE }));
6361
6363
  });
6362
6364
  }
6363
6365
  /**
@@ -6998,8 +7000,55 @@ class MedplumClient extends EventTarget {
6998
7000
  sendEmail(email) {
6999
7001
  return this.post('email/v1/send', email, 'application/json');
7000
7002
  }
7001
- graphql(query, options) {
7002
- return this.post(this.fhirUrl('$graphql'), { query }, JSON_CONTENT_TYPE, options);
7003
+ /**
7004
+ * Executes a GraphQL query.
7005
+ *
7006
+ * Example:
7007
+ *
7008
+ * ```typescript
7009
+ * const result = await medplum.graphql(`{
7010
+ * Patient(id: "123") {
7011
+ * resourceType
7012
+ * id
7013
+ * name {
7014
+ * given
7015
+ * family
7016
+ * }
7017
+ * }
7018
+ * }`);
7019
+ * ```
7020
+ *
7021
+ * Advanced queries such as named operations and variable substitution are supported:
7022
+ *
7023
+ * ```typescript
7024
+ * const result = await medplum.graphql(
7025
+ * `query GetPatientById($patientId: ID!) {
7026
+ * Patient(id: $patientId) {
7027
+ * resourceType
7028
+ * id
7029
+ * name {
7030
+ * given
7031
+ * family
7032
+ * }
7033
+ * }
7034
+ * }`,
7035
+ * 'GetPatientById',
7036
+ * { patientId: '123' }
7037
+ * );
7038
+ * ```
7039
+ *
7040
+ * See the GraphQL documentation for more details: https://graphql.org/learn/
7041
+ *
7042
+ * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
7043
+ *
7044
+ * @param query The GraphQL query.
7045
+ * @param operationName Optional GraphQL operation name.
7046
+ * @param variables Optional GraphQL variables.
7047
+ * @param options Optional fetch options.
7048
+ * @returns The GraphQL result.
7049
+ */
7050
+ graphql(query, operationName, variables, options) {
7051
+ return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);
7003
7052
  }
7004
7053
  getActiveLogin() {
7005
7054
  return __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('activeLogin');
@@ -7366,11 +7415,12 @@ function getTypedPropertyValue(input, path) {
7366
7415
  }
7367
7416
  const typeSchema = globalSchema.types[input.type];
7368
7417
  if (typeSchema) {
7369
- return getTypedPropertyValueWithSchema(input, path, typeSchema);
7370
- }
7371
- else {
7372
- return getTypedPropertyValueWithoutSchema(input, path);
7418
+ const typedResult = getTypedPropertyValueWithSchema(input, path, typeSchema);
7419
+ if (typedResult) {
7420
+ return typedResult;
7421
+ }
7373
7422
  }
7423
+ return getTypedPropertyValueWithoutSchema(input, path);
7374
7424
  }
7375
7425
  /**
7376
7426
  * Returns the value of the property and the property type using a type schema.