@rebasepro/client-firebase 0.3.0 → 0.5.0

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/index.umd.js CHANGED
@@ -19,9 +19,7 @@
19
19
  const [userRoles, _setUserRoles] = React.useState();
20
20
  const [extra, setExtra] = React.useState();
21
21
  const setUserRoles = React.useCallback((roles) => {
22
- const currentRoleIds = userRoles?.map((r) => r.id);
23
- const newRoleIds = roles?.map((r_0) => r_0.id);
24
- if (!fastEquals.deepEqual(currentRoleIds, newRoleIds)) {
22
+ if (!fastEquals.deepEqual(userRoles, roles)) {
25
23
  _setUserRoles(roles);
26
24
  }
27
25
  }, [userRoles]);
@@ -209,8 +207,7 @@
209
207
  }, []);
210
208
  const firebaseUserWrapper = loggedUser ? {
211
209
  ...loggedUser,
212
- roles: userRoles?.map((r_1) => r_1.id),
213
- // User.roles is string[], keep Role[] internally only
210
+ roles: userRoles,
214
211
  firebaseUser: loggedUser
215
212
  } : null;
216
213
  return {
@@ -599,7 +596,8 @@
599
596
  if (normalizedProperty.enum) {
600
597
  normalizedProperty.enum = normalizeEnumValuesToArray(normalizedProperty.enum, sortObjectFormat);
601
598
  }
602
- if (normalizedProperty.dataType === "array" && typeof normalizedProperty.of === "object" && normalizedProperty.of !== null) {
599
+ const propType = normalizedProperty.type ?? normalizedProperty.dataType;
600
+ if (propType === "array" && typeof normalizedProperty.of === "object" && normalizedProperty.of !== null) {
603
601
  const ofProp = normalizedProperty.of;
604
602
  if (ofProp.enum) {
605
603
  normalizedProperty.of = {
@@ -608,7 +606,7 @@
608
606
  };
609
607
  }
610
608
  }
611
- if (normalizedProperty.dataType === "map" && normalizedProperty.properties) {
609
+ if (propType === "map" && normalizedProperty.properties) {
612
610
  normalizedProperty.properties = normalizePropertiesEnumValues(normalizedProperty.properties, sortObjectFormat);
613
611
  }
614
612
  result[key] = normalizedProperty;
@@ -2009,8 +2007,8 @@
2009
2007
  if (!usersWithRoleIds) throw Error("Users not loaded");
2010
2008
  const mgmtUser = usersWithRoleIds.find((u_1) => u_1.email?.toLowerCase() === user_1?.email?.toLowerCase());
2011
2009
  if (!mgmtUser || !mgmtUser.roles) return void 0;
2012
- return roles.filter((r) => mgmtUser.roles.includes(r.id));
2013
- }, [roles, usersWithRoleIds]);
2010
+ return mgmtUser.roles;
2011
+ }, [usersWithRoleIds]);
2014
2012
  const accessGate = React.useCallback(({
2015
2013
  user: user_2
2016
2014
  }) => {
@@ -2050,8 +2048,8 @@
2050
2048
  throw Error("Could not find a user with the provided email in the user management system.");
2051
2049
  }, [loading, users]);
2052
2050
  const userRoles = authController.user ? defineRolesFor(authController.user) : void 0;
2053
- const isAdmin = (userRoles ?? []).some((r_0) => r_0.id === "admin");
2054
- const userRoleIds = userRoles?.map((r_1) => r_1.id);
2051
+ const isAdmin = (userRoles ?? []).some((r) => r === "admin");
2052
+ const userRoleIds = userRoles;
2055
2053
  React.useEffect(() => {
2056
2054
  console.debug("Setting user roles", {
2057
2055
  userRoles,