code: function addSharedMembers(terria, initSources) {
    const catalogForSharing = flattenCatalog(
      terria.catalog.serializeToJson({
        itemFilter: combineFilters([CatalogMember.itemFilters.noLocalData]),
        propertyFilter: combineFilters([
          CatalogMember.propertyFilters.sharedOnly,
          function(property) {
            return property !== "name";
          }
        ])
      })
    )
      .filter(function(item) {
        return item.isEnabled || item.isOpen;
      })
      .reduce(function(soFar, item) {
        soFar[item.id] = item;
        item.id = undefined;
        return soFar;
      }, {});
  
    // Eliminate open groups without all ancestors open
    Object.keys(catalogForSharing).forEach(key => {
      const item = catalogForSharing[key];
      const isGroupWithClosedParent =
        item.isOpen &&
        item.parents.some(parentId => !catalogForSharing[parentId]);
  
      if (isGroupWithClosedParent) {
        catalogForSharing[key] = undefined;
      }
    });
  
    if (Object.keys(catalogForSharing).length > 0) {
      initSources.push({
        sharedCatalogMembers: catalogForSharing
      });
    }
  }
docs: Adds existing catalog members that the user has enabled or opened to the passed initSources object.
  @private