@trackunit/react-core-hooks 1.21.21 → 1.21.22-alpha-3e7014314a8.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/index.cjs.js CHANGED
@@ -81,11 +81,9 @@ const useCurrentUser = () => {
81
81
  * having to observe the synchronous `loading` flag themselves.
82
82
  */
83
83
  const useValidateAccessAsync = () => {
84
- const { hasAccessTo, hasAccountAction, hasFeatureFlag, hasPermission, loading } = useValidateAccess();
84
+ const { hasAccessTo, hasFeatureFlag, hasPermission, loading } = useValidateAccess();
85
85
  const hasAccessToRef = react.useRef(hasAccessTo);
86
86
  hasAccessToRef.current = hasAccessTo;
87
- const hasAccountActionRef = react.useRef(hasAccountAction);
88
- hasAccountActionRef.current = hasAccountAction;
89
87
  const hasFeatureFlagRef = react.useRef(hasFeatureFlag);
90
88
  hasFeatureFlagRef.current = hasFeatureFlag;
91
89
  const hasPermissionRef = react.useRef(hasPermission);
@@ -110,10 +108,6 @@ const useValidateAccessAsync = () => {
110
108
  await waitForLoading();
111
109
  return hasAccessToRef.current(requiredAccessTo);
112
110
  },
113
- hasAccountAction: async (action) => {
114
- await waitForLoading();
115
- return hasAccountActionRef.current(action);
116
- },
117
111
  hasFeatureFlag: async (flag) => {
118
112
  await waitForLoading();
119
113
  return hasFeatureFlagRef.current(flag);
@@ -123,7 +117,7 @@ const useValidateAccessAsync = () => {
123
117
  return hasPermissionRef.current(permission);
124
118
  },
125
119
  };
126
- }, [loadingRef, hasAccessToRef, hasAccountActionRef, hasFeatureFlagRef, hasPermissionRef]);
120
+ }, [loadingRef, hasAccessToRef, hasFeatureFlagRef, hasPermissionRef]);
127
121
  };
128
122
  /**
129
123
  * Synchronously evaluates the current user's access via subscription features,
@@ -131,7 +125,7 @@ const useValidateAccessAsync = () => {
131
125
  * flag that stays true until user, subscription, and flag data are all present.
132
126
  */
133
127
  const useValidateAccess = () => {
134
- const { accountActions, isAuthenticated, permissions: userPermissions } = useCurrentUser();
128
+ const { isAuthenticated, permissions: userPermissions } = useCurrentUser();
135
129
  const { features, loading: featuresLoading } = useUserSubscription();
136
130
  const { flags: allFlags } = useFeatureFlags();
137
131
  const loading = react.useMemo(() => allFlags === null || featuresLoading || !userPermissions, [allFlags, featuresLoading, userPermissions]);
@@ -150,23 +144,14 @@ const useValidateAccess = () => {
150
144
  }
151
145
  return false;
152
146
  }, [isAuthenticated, userPermissions]);
153
- // Actions land in the user store in the same write as `permissions`, so the `loading`
154
- // flag above already covers them and needs no term of its own.
155
- const hasAccountAction = react.useCallback((action) => {
156
- if (isAuthenticated) {
157
- return accountActions?.[action] ?? false;
158
- }
159
- return false;
160
- }, [accountActions, isAuthenticated]);
161
147
  return react.useMemo(() => {
162
148
  return {
163
149
  hasAccessTo,
164
- hasAccountAction,
165
150
  hasFeatureFlag,
166
151
  hasPermission,
167
152
  loading,
168
153
  };
169
- }, [hasAccessTo, hasAccountAction, hasFeatureFlag, hasPermission, loading]);
154
+ }, [hasAccessTo, hasFeatureFlag, hasPermission, loading]);
170
155
  };
171
156
  const hasAccessToFeature = (myFeatures, feature) => {
172
157
  return myFeatures?.some(x => x.id === feature) ?? null;
package/index.esm.js CHANGED
@@ -79,11 +79,9 @@ const useCurrentUser = () => {
79
79
  * having to observe the synchronous `loading` flag themselves.
80
80
  */
81
81
  const useValidateAccessAsync = () => {
82
- const { hasAccessTo, hasAccountAction, hasFeatureFlag, hasPermission, loading } = useValidateAccess();
82
+ const { hasAccessTo, hasFeatureFlag, hasPermission, loading } = useValidateAccess();
83
83
  const hasAccessToRef = useRef(hasAccessTo);
84
84
  hasAccessToRef.current = hasAccessTo;
85
- const hasAccountActionRef = useRef(hasAccountAction);
86
- hasAccountActionRef.current = hasAccountAction;
87
85
  const hasFeatureFlagRef = useRef(hasFeatureFlag);
88
86
  hasFeatureFlagRef.current = hasFeatureFlag;
89
87
  const hasPermissionRef = useRef(hasPermission);
@@ -108,10 +106,6 @@ const useValidateAccessAsync = () => {
108
106
  await waitForLoading();
109
107
  return hasAccessToRef.current(requiredAccessTo);
110
108
  },
111
- hasAccountAction: async (action) => {
112
- await waitForLoading();
113
- return hasAccountActionRef.current(action);
114
- },
115
109
  hasFeatureFlag: async (flag) => {
116
110
  await waitForLoading();
117
111
  return hasFeatureFlagRef.current(flag);
@@ -121,7 +115,7 @@ const useValidateAccessAsync = () => {
121
115
  return hasPermissionRef.current(permission);
122
116
  },
123
117
  };
124
- }, [loadingRef, hasAccessToRef, hasAccountActionRef, hasFeatureFlagRef, hasPermissionRef]);
118
+ }, [loadingRef, hasAccessToRef, hasFeatureFlagRef, hasPermissionRef]);
125
119
  };
126
120
  /**
127
121
  * Synchronously evaluates the current user's access via subscription features,
@@ -129,7 +123,7 @@ const useValidateAccessAsync = () => {
129
123
  * flag that stays true until user, subscription, and flag data are all present.
130
124
  */
131
125
  const useValidateAccess = () => {
132
- const { accountActions, isAuthenticated, permissions: userPermissions } = useCurrentUser();
126
+ const { isAuthenticated, permissions: userPermissions } = useCurrentUser();
133
127
  const { features, loading: featuresLoading } = useUserSubscription();
134
128
  const { flags: allFlags } = useFeatureFlags();
135
129
  const loading = useMemo(() => allFlags === null || featuresLoading || !userPermissions, [allFlags, featuresLoading, userPermissions]);
@@ -148,23 +142,14 @@ const useValidateAccess = () => {
148
142
  }
149
143
  return false;
150
144
  }, [isAuthenticated, userPermissions]);
151
- // Actions land in the user store in the same write as `permissions`, so the `loading`
152
- // flag above already covers them and needs no term of its own.
153
- const hasAccountAction = useCallback((action) => {
154
- if (isAuthenticated) {
155
- return accountActions?.[action] ?? false;
156
- }
157
- return false;
158
- }, [accountActions, isAuthenticated]);
159
145
  return useMemo(() => {
160
146
  return {
161
147
  hasAccessTo,
162
- hasAccountAction,
163
148
  hasFeatureFlag,
164
149
  hasPermission,
165
150
  loading,
166
151
  };
167
- }, [hasAccessTo, hasAccountAction, hasFeatureFlag, hasPermission, loading]);
152
+ }, [hasAccessTo, hasFeatureFlag, hasPermission, loading]);
168
153
  };
169
154
  const hasAccessToFeature = (myFeatures, feature) => {
170
155
  return myFeatures?.some(x => x.id === feature) ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-hooks",
3
- "version": "1.21.21",
3
+ "version": "1.21.22-alpha-3e7014314a8.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "es-toolkit": "^1.39.10",
11
- "@trackunit/iris-app-runtime-core": "1.18.27",
12
- "@trackunit/iris-app-runtime-core-api": "1.17.27",
13
- "@trackunit/react-core-contexts-api": "1.18.27",
11
+ "@trackunit/iris-app-runtime-core": "1.18.28-alpha-3e7014314a8.0",
12
+ "@trackunit/iris-app-runtime-core-api": "1.17.28-alpha-3e7014314a8.0",
13
+ "@trackunit/react-core-contexts-api": "1.18.28-alpha-3e7014314a8.0",
14
14
  "zod": "^3.25.76"
15
15
  },
16
16
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import { AccountActionName, LegacyFeature } from "@trackunit/iris-app-runtime-core-api";
1
+ import { LegacyFeature } from "@trackunit/iris-app-runtime-core-api";
2
2
  export type HasAccess = boolean | null;
3
3
  export type ValidateAccess = LegacyFeature;
4
4
  /**
@@ -9,7 +9,6 @@ export type ValidateAccess = LegacyFeature;
9
9
  */
10
10
  export declare const useValidateAccessAsync: () => {
11
11
  hasAccessTo: (requiredAccessTo: ValidateAccess) => Promise<HasAccess>;
12
- hasAccountAction: (action: AccountActionName) => Promise<HasAccess>;
13
12
  hasFeatureFlag: (flag: string) => Promise<HasAccess>;
14
13
  hasPermission: (permission: string) => Promise<HasAccess>;
15
14
  };
@@ -20,7 +19,6 @@ export declare const useValidateAccessAsync: () => {
20
19
  */
21
20
  export declare const useValidateAccess: () => {
22
21
  hasAccessTo: (requiredAccessTo: ValidateAccess) => HasAccess;
23
- hasAccountAction: (action: AccountActionName) => HasAccess;
24
22
  hasFeatureFlag: (flag: string) => HasAccess;
25
23
  hasPermission: (permission: string) => HasAccess;
26
24
  loading: boolean;
@@ -1,5 +1,4 @@
1
- import { AccountActionName } from "@trackunit/iris-app-runtime-core-api";
2
- export type AccountAction = AccountActionName;
1
+ export type AccountAction = "manageUsers";
3
2
  /**
4
3
  * Hook that checks whether the current user is allowed to perform a per-account,
5
4
  * FGA-backed `Account.actions` action for the active account.
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/core-hooks/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}