@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/cjs/index.js CHANGED
@@ -6348,22 +6348,24 @@
6348
6348
  * @returns Promise to the authentication response.
6349
6349
  */
6350
6350
  startLogin(loginRequest) {
6351
+ var _a, _b;
6351
6352
  return __awaiter(this, void 0, void 0, function* () {
6352
6353
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6353
- 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') }));
6354
+ 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') }));
6354
6355
  });
6355
6356
  }
6356
6357
  /**
6357
6358
  * Tries to sign in with Google authentication.
6358
6359
  * The response parameter is the result of a Google authentication.
6359
6360
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
6360
- * @param googleResponse The Google credential response.
6361
+ * @param loginRequest Login request including Google credential response.
6361
6362
  * @returns Promise to the authentication response.
6362
6363
  */
6363
- startGoogleLogin(googleResponse) {
6364
+ startGoogleLogin(loginRequest) {
6365
+ var _a, _b;
6364
6366
  return __awaiter(this, void 0, void 0, function* () {
6365
6367
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6366
- return this.post('auth/google', googleResponse);
6368
+ 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 }));
6367
6369
  });
6368
6370
  }
6369
6371
  /**
@@ -7004,8 +7006,55 @@
7004
7006
  sendEmail(email) {
7005
7007
  return this.post('email/v1/send', email, 'application/json');
7006
7008
  }
7007
- graphql(query, options) {
7008
- return this.post(this.fhirUrl('$graphql'), { query }, JSON_CONTENT_TYPE, options);
7009
+ /**
7010
+ * Executes a GraphQL query.
7011
+ *
7012
+ * Example:
7013
+ *
7014
+ * ```typescript
7015
+ * const result = await medplum.graphql(`{
7016
+ * Patient(id: "123") {
7017
+ * resourceType
7018
+ * id
7019
+ * name {
7020
+ * given
7021
+ * family
7022
+ * }
7023
+ * }
7024
+ * }`);
7025
+ * ```
7026
+ *
7027
+ * Advanced queries such as named operations and variable substitution are supported:
7028
+ *
7029
+ * ```typescript
7030
+ * const result = await medplum.graphql(
7031
+ * `query GetPatientById($patientId: ID!) {
7032
+ * Patient(id: $patientId) {
7033
+ * resourceType
7034
+ * id
7035
+ * name {
7036
+ * given
7037
+ * family
7038
+ * }
7039
+ * }
7040
+ * }`,
7041
+ * 'GetPatientById',
7042
+ * { patientId: '123' }
7043
+ * );
7044
+ * ```
7045
+ *
7046
+ * See the GraphQL documentation for more details: https://graphql.org/learn/
7047
+ *
7048
+ * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
7049
+ *
7050
+ * @param query The GraphQL query.
7051
+ * @param operationName Optional GraphQL operation name.
7052
+ * @param variables Optional GraphQL variables.
7053
+ * @param options Optional fetch options.
7054
+ * @returns The GraphQL result.
7055
+ */
7056
+ graphql(query, operationName, variables, options) {
7057
+ return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);
7009
7058
  }
7010
7059
  getActiveLogin() {
7011
7060
  return __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('activeLogin');
@@ -7372,11 +7421,12 @@
7372
7421
  }
7373
7422
  const typeSchema = globalSchema.types[input.type];
7374
7423
  if (typeSchema) {
7375
- return getTypedPropertyValueWithSchema(input, path, typeSchema);
7376
- }
7377
- else {
7378
- return getTypedPropertyValueWithoutSchema(input, path);
7424
+ const typedResult = getTypedPropertyValueWithSchema(input, path, typeSchema);
7425
+ if (typedResult) {
7426
+ return typedResult;
7427
+ }
7379
7428
  }
7429
+ return getTypedPropertyValueWithoutSchema(input, path);
7380
7430
  }
7381
7431
  /**
7382
7432
  * Returns the value of the property and the property type using a type schema.