@medplum/core 2.0.19 → 2.0.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/README.md CHANGED
@@ -39,7 +39,7 @@ const medplum = new MedplumClient({
39
39
  });
40
40
  ```
41
41
 
42
- ## Authenticate with client credenials
42
+ ## Authenticate with client credentials
43
43
 
44
44
  ```ts
45
45
  const medplum = new MedplumClient();
@@ -6417,7 +6417,7 @@
6417
6417
 
6418
6418
  // PKCE auth based on:
6419
6419
  // https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
6420
- const MEDPLUM_VERSION = "2.0.19-40e6e27d" ;
6420
+ const MEDPLUM_VERSION = "2.0.20-effeb76c" ;
6421
6421
  const DEFAULT_BASE_URL = 'https://api.medplum.com/';
6422
6422
  const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
6423
6423
  const DEFAULT_CACHE_TIME = 60000; // 60 seconds
@@ -6588,6 +6588,13 @@
6588
6588
  url = url.toString();
6589
6589
  this.requestCache?.delete(url);
6590
6590
  }
6591
+ /**
6592
+ * Invalidates all cached values and flushes the cache.
6593
+ * @category Caching
6594
+ */
6595
+ invalidateAll() {
6596
+ this.requestCache?.clear();
6597
+ }
6591
6598
  /**
6592
6599
  * Invalidates all cached search results or cached requests for the given resourceType.
6593
6600
  * @category Caching
@@ -12628,26 +12635,28 @@
12628
12635
  // In the future, explore returning multiple column definitions
12629
12636
  return { columnName, type: exports.SearchParameterType.TEXT };
12630
12637
  }
12631
- const defaultType = getSearchParameterType(searchParam);
12632
12638
  let baseType = resourceType;
12633
12639
  let elementDefinition = undefined;
12634
12640
  let propertyType = undefined;
12635
12641
  let array = false;
12636
12642
  for (let i = 1; i < expression.length; i++) {
12637
- const propertyName = expression[i];
12643
+ let propertyName = expression[i];
12644
+ let hasArrayIndex = false;
12645
+ const arrayIndexMatch = /\[\d+\]$/.exec(propertyName);
12646
+ if (arrayIndexMatch) {
12647
+ propertyName = propertyName.substring(0, propertyName.length - arrayIndexMatch[0].length);
12648
+ hasArrayIndex = true;
12649
+ }
12638
12650
  elementDefinition = getElementDefinition(baseType, propertyName);
12639
12651
  if (!elementDefinition) {
12640
12652
  throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);
12641
12653
  }
12642
- if (elementDefinition.max !== '0' && elementDefinition.max !== '1') {
12654
+ if (elementDefinition.max !== '0' && elementDefinition.max !== '1' && !hasArrayIndex) {
12643
12655
  array = true;
12644
12656
  }
12657
+ // "code" is only missing when using "contentReference"
12658
+ // "contentReference" is handled above in "getElementDefinition"
12645
12659
  propertyType = elementDefinition.type?.[0].code;
12646
- if (!propertyType) {
12647
- // This happens when one of parent properties uses contentReference
12648
- // In the future, explore following the reference
12649
- return { columnName, type: defaultType, array };
12650
- }
12651
12660
  if (i < expression.length - 1) {
12652
12661
  if (isBackboneElement(propertyType)) {
12653
12662
  baseType = buildTypeName(elementDefinition.path?.split('.'));
@@ -12727,9 +12736,6 @@
12727
12736
  if (result.startsWith('(') && result.endsWith(')')) {
12728
12737
  result = result.substring(1, result.length - 1);
12729
12738
  }
12730
- if (result.includes('[0]')) {
12731
- result = result.replaceAll('[0]', '');
12732
- }
12733
12739
  const stopStrings = [' != ', ' as ', '.as(', '.exists(', '.resolve(', '.where('];
12734
12740
  for (const stopString of stopStrings) {
12735
12741
  if (result.includes(stopString)) {