@elevasis/ui 1.3.0 → 1.3.1

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.
Files changed (40) hide show
  1. package/dist/CoreAuthKitInner-3J4RVQO6.js +43 -0
  2. package/dist/api/index.d.ts +7 -31
  3. package/dist/api/index.js +2 -1
  4. package/dist/auth/context.d.ts +23 -5
  5. package/dist/auth/index.d.ts +37 -34
  6. package/dist/auth/index.js +4 -5
  7. package/dist/{chunk-FDCVFCOQ.js → chunk-2JBWPFHF.js} +23 -20
  8. package/dist/{chunk-OLD3NQLI.js → chunk-72HOBFMP.js} +13 -17
  9. package/dist/{chunk-BZTA7IIL.js → chunk-A3MCANC6.js} +295 -1
  10. package/dist/chunk-FWZJH3TL.js +13 -0
  11. package/dist/{chunk-EZMRFWZQ.js → chunk-JBFFCZI4.js} +1 -1
  12. package/dist/chunk-JGJSZ3UE.js +47 -0
  13. package/dist/{chunk-4KAG5U7A.js → chunk-L2CM2CUA.js} +0 -2
  14. package/dist/{chunk-QQOLC46E.js → chunk-NEK6JKPW.js} +1 -1
  15. package/dist/{chunk-SITSZUFW.js → chunk-PVVQTENF.js} +1 -1
  16. package/dist/{chunk-PCBXNHKY.js → chunk-TZPAA4RC.js} +3 -2
  17. package/dist/{chunk-FLJXZ7YC.js → chunk-UMXDDEAG.js} +1 -3
  18. package/dist/{chunk-BWCC6ZJC.js → chunk-XLV6LYN2.js} +15 -60
  19. package/dist/hooks/index.d.ts +2629 -2
  20. package/dist/hooks/index.js +5 -2
  21. package/dist/hooks/published.d.ts +2629 -2
  22. package/dist/hooks/published.js +4 -1
  23. package/dist/index.d.ts +427 -162
  24. package/dist/index.js +13 -13
  25. package/dist/initialization/index.js +3 -3
  26. package/dist/organization/index.js +3 -3
  27. package/dist/profile/index.js +1 -1
  28. package/dist/provider/index.d.ts +5 -17
  29. package/dist/provider/index.js +6 -7
  30. package/dist/provider/published.d.ts +4 -16
  31. package/dist/provider/published.js +5 -6
  32. package/dist/supabase/index.js +2 -47
  33. package/package.json +3 -3
  34. package/dist/CoreAuthKitInner-KM72EYJS.js +0 -19
  35. package/dist/api/hooks/useApiClient.d.ts +0 -54
  36. package/dist/api/hooks/useApiClient.d.ts.map +0 -1
  37. package/dist/api/hooks/useApiClient.js +0 -185
  38. package/dist/chunk-NIAVTSMB.js +0 -21
  39. package/dist/chunk-QSVZP2NU.js +0 -214
  40. /package/dist/{chunk-Q47SPRY7.js → chunk-TYV5NJV2.js} +0 -0
@@ -0,0 +1,43 @@
1
+ import { AuthProvider } from './chunk-7PLEQFHO.js';
2
+ import { AuthKitProvider, useAuth } from '@workos-inc/authkit-react';
3
+ import { useMemo } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ function CoreAuthKitInner({ auth, children }) {
7
+ return /* @__PURE__ */ jsx(
8
+ AuthKitProvider,
9
+ {
10
+ clientId: auth.clientId,
11
+ apiHostname: auth.apiHostname ?? "api.workos.com",
12
+ redirectUri: auth.redirectUri,
13
+ devMode: auth.devMode ?? false,
14
+ children: /* @__PURE__ */ jsx(WorkOSAuthAdapter, { children })
15
+ }
16
+ );
17
+ }
18
+ var WORKOS_REFRESH_TOKEN_KEY = "workos:refresh-token";
19
+ function hasWorkOSRefreshToken() {
20
+ try {
21
+ return !!localStorage.getItem(WORKOS_REFRESH_TOKEN_KEY);
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+ function WorkOSAuthAdapter({ children }) {
27
+ const { user, isLoading, getAccessToken, organizationId, signIn } = useAuth();
28
+ const adaptedUser = useMemo(() => user ? { id: user.id } : null, [user?.id]);
29
+ const value = useMemo(
30
+ () => ({
31
+ user: adaptedUser,
32
+ isLoading,
33
+ getAccessToken,
34
+ organizationId: organizationId ?? null,
35
+ signIn,
36
+ canRecover: hasWorkOSRefreshToken
37
+ }),
38
+ [adaptedUser, isLoading, getAccessToken, organizationId, signIn]
39
+ );
40
+ return /* @__PURE__ */ jsx(AuthProvider, { value, children });
41
+ }
42
+
43
+ export { CoreAuthKitInner };
@@ -68,18 +68,17 @@ declare function useApiClientContext(): ApiClientContextValue;
68
68
  */
69
69
  declare function ApiClientProvider({ children, getAccessToken, organizationId, getOrganizationId: getOrganizationIdProp, isOrganizationReady, onError }: ApiClientProviderProps): react_jsx_runtime.JSX.Element;
70
70
 
71
- /**
72
- * Return type of useOrganizations hook (subset needed by the factory)
73
- */
74
- interface UseOrganizationsReturn {
75
- isInitializing: boolean;
76
- isOrgRefreshing: boolean;
77
- }
78
71
  /**
79
72
  * Hook that returns apiRequest and deferredApiRequest bound to the current
80
73
  * ApiClientContext. apiUrl is the only parameter because org ID is resolved
81
74
  * at call time via getOrganizationId() from context.
82
75
  *
76
+ * When OrganizationProvider is present in the tree, isOrganizationReady and
77
+ * isInitializing reflect the live org state (currentWorkOSOrganizationId,
78
+ * isInitializing, isOrgRefreshing). When OrganizationProvider is absent
79
+ * (e.g. theme-only mode, testing), the hook falls back to the values from
80
+ * ApiClientContext.
81
+ *
83
82
  * Usage:
84
83
  * ```typescript
85
84
  * import { useApiClient } from '@repo/ui/api'
@@ -97,29 +96,6 @@ declare function useApiClient(apiUrl: string): {
97
96
  isOrganizationReady: boolean;
98
97
  isInitializing: boolean;
99
98
  };
100
- /**
101
- * Factory function to create a useApiClient hook for your app.
102
- *
103
- * @deprecated Use the plain `useApiClient(apiUrl)` hook instead.
104
- * The factory pattern is no longer needed because org ID is resolved at
105
- * call time via getOrganizationId() from ApiClientContext.
106
- *
107
- * Migration:
108
- * ```typescript
109
- * // Before
110
- * export const useApiClient = createUseApiClient(useOrganizations, API_URL)
111
- *
112
- * // After
113
- * import { useApiClient } from '@repo/ui/api'
114
- * // call useApiClient(API_URL) directly in your hook/component
115
- * ```
116
- */
117
- declare function createUseApiClient(useOrganizations: () => UseOrganizationsReturn, apiUrl: string): () => {
118
- apiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
119
- deferredApiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
120
- isOrganizationReady: boolean;
121
- isInitializing: boolean;
122
- };
123
99
 
124
- export { ApiClientProvider, createUseApiClient, useApiClient, useApiClientContext };
100
+ export { ApiClientProvider, useApiClient, useApiClientContext };
125
101
  export type { ApiClientContextValue, ApiClientProviderProps, ApiErrorDetails };
package/dist/api/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import '../chunk-XCYKC6OZ.js';
2
- export { ApiClientProvider, createUseApiClient, useApiClient, useApiClientContext } from '../chunk-BWCC6ZJC.js';
2
+ export { ApiClientProvider, useApiClient, useApiClientContext } from '../chunk-XLV6LYN2.js';
3
3
  import '../chunk-JVAZHVNV.js';
4
4
  import '../chunk-4VGWQ5AN.js';
5
+ import '../chunk-DD3CCMCZ.js';
@@ -1,19 +1,37 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- interface AuthAdapter {
4
+ interface AuthContextValue {
5
5
  user: {
6
6
  id: string;
7
7
  } | null;
8
8
  isLoading: boolean;
9
9
  getAccessToken: () => Promise<string>;
10
10
  organizationId?: string | null;
11
+ /**
12
+ * Trigger WorkOS AuthKit's sign-in flow (redirect to WorkOS hosted auth page).
13
+ * Used by ProtectedRoute for auto-recovery when `canRecover()` returns true.
14
+ */
15
+ signIn: (options?: {
16
+ state?: {
17
+ returnTo?: string;
18
+ };
19
+ }) => void;
20
+ /**
21
+ * Returns true when a previous session can be recovered (refresh token
22
+ * exists in storage). ProtectedRoute calls `signIn()` only when this returns
23
+ * true; otherwise it navigates to the login page.
24
+ *
25
+ * Explicit logout clears the stored token, so canRecover() returns false
26
+ * and the user sees the login page as expected.
27
+ */
28
+ canRecover: () => boolean;
11
29
  }
12
- declare function useAuthContext(): AuthAdapter;
30
+ declare function useAuthContext(): AuthContextValue;
13
31
  declare function AuthProvider({ value, children }: {
14
- value: AuthAdapter;
32
+ value: AuthContextValue;
15
33
  children: ReactNode;
16
- }): react.FunctionComponentElement<react.ProviderProps<AuthAdapter | null>>;
34
+ }): react.FunctionComponentElement<react.ProviderProps<AuthContextValue | null>>;
17
35
 
18
36
  export { AuthProvider, useAuthContext };
19
- export type { AuthAdapter };
37
+ export type { AuthContextValue };
@@ -2,43 +2,37 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
 
5
- interface AuthAdapter {
5
+ interface AuthContextValue {
6
6
  user: {
7
7
  id: string;
8
8
  } | null;
9
9
  isLoading: boolean;
10
10
  getAccessToken: () => Promise<string>;
11
11
  organizationId?: string | null;
12
+ /**
13
+ * Trigger WorkOS AuthKit's sign-in flow (redirect to WorkOS hosted auth page).
14
+ * Used by ProtectedRoute for auto-recovery when `canRecover()` returns true.
15
+ */
16
+ signIn: (options?: {
17
+ state?: {
18
+ returnTo?: string;
19
+ };
20
+ }) => void;
21
+ /**
22
+ * Returns true when a previous session can be recovered (refresh token
23
+ * exists in storage). ProtectedRoute calls `signIn()` only when this returns
24
+ * true; otherwise it navigates to the login page.
25
+ *
26
+ * Explicit logout clears the stored token, so canRecover() returns false
27
+ * and the user sees the login page as expected.
28
+ */
29
+ canRecover: () => boolean;
12
30
  }
13
- declare function useAuthContext(): AuthAdapter;
31
+ declare function useAuthContext(): AuthContextValue;
14
32
  declare function AuthProvider({ value, children }: {
15
- value: AuthAdapter;
16
- children: ReactNode;
17
- }): react.FunctionComponentElement<react.ProviderProps<AuthAdapter | null>>;
18
-
19
- /**
20
- * Bridge component that reads WorkOS AuthKit state and provides it
21
- * via the generic AuthContext. Place inside AuthKitProvider.
22
- *
23
- * Narrows WorkOS User to { id: string } -- @repo/ui hooks only need the ID.
24
- * Uses useMemo to stabilize the user object and prevent unnecessary
25
- * useEffect re-runs in downstream hooks.
26
- */
27
- declare function WorkOSAuthBridge({ children }: {
33
+ value: AuthContextValue;
28
34
  children: ReactNode;
29
- }): react_jsx_runtime.JSX.Element;
30
-
31
- interface OAuthContextValue {
32
- user: {
33
- id: string;
34
- } | null;
35
- isLoading: boolean;
36
- organizationId: string | null;
37
- getAccessToken: () => Promise<string>;
38
- error: string | null;
39
- initiateOAuthFlow: () => void;
40
- }
41
- declare function useOAuthContext(): OAuthContextValue;
35
+ }): react.FunctionComponentElement<react.ProviderProps<AuthContextValue | null>>;
42
36
 
43
37
  /**
44
38
  * Returns a stable reference to getAccessToken that won't change between renders
@@ -92,7 +86,8 @@ interface InitializationError {
92
86
  interface ProtectedRouteProps {
93
87
  children: ReactNode;
94
88
  /**
95
- * Path to redirect to when user is unauthenticated.
89
+ * Path to redirect to when user is unauthenticated and the auth adapter
90
+ * does not provide a `signIn` function.
96
91
  * @default '/login'
97
92
  */
98
93
  redirectTo?: string;
@@ -118,10 +113,18 @@ interface ProtectedRouteProps {
118
113
  * Headless route guard for authenticated pages.
119
114
  *
120
115
  * Reads initialization state from the nearest InitializationProvider.
121
- * Redirects unauthenticated users to `redirectTo` (default: '/login')
122
- * with a `returnTo` search param preserving the current location.
123
116
  *
124
- * Organization-layer errors are allowed through routes like /invitations
117
+ * When `canRecover()` returns true (refresh token exists), unauthenticated users
118
+ * are sent directly to WorkOS AuthKit via `signIn()`. WorkOS checks its
119
+ * server-side session and either signs the user in immediately (page-reload case)
120
+ * or shows a login form (logged-out case). Explicit logout destroys the
121
+ * server-side session, so the next auto-signIn correctly presents a login form
122
+ * rather than looping.
123
+ *
124
+ * When `canRecover()` returns false, falls back to navigating to `redirectTo`
125
+ * (default: '/login') with a `returnTo` search param.
126
+ *
127
+ * Organization-layer errors are allowed through -- routes like /invitations
125
128
  * must be accessible even when the user has no org membership.
126
129
  *
127
130
  * @example
@@ -169,5 +172,5 @@ interface AdminGuardProps {
169
172
  */
170
173
  declare function AdminGuard({ children, redirectTo, fallback }: AdminGuardProps): react_jsx_runtime.JSX.Element | null;
171
174
 
172
- export { AdminGuard, AuthProvider, ProtectedRoute, WorkOSAuthBridge, useAuthContext, useOAuthContext, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken };
173
- export type { AdminGuardProps, AuthAdapter, OAuthContextValue, ProtectedRouteProps };
175
+ export { AdminGuard, AuthProvider, ProtectedRoute, useAuthContext, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken };
176
+ export type { AdminGuardProps, AuthContextValue, ProtectedRouteProps };
@@ -1,8 +1,7 @@
1
- export { AdminGuard, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken } from '../chunk-FDCVFCOQ.js';
2
- export { WorkOSAuthBridge } from '../chunk-NIAVTSMB.js';
3
- export { useOAuthContext } from '../chunk-QSVZP2NU.js';
4
- import '../chunk-QQOLC46E.js';
1
+ export { AdminGuard, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck } from '../chunk-2JBWPFHF.js';
2
+ export { useStableAccessToken } from '../chunk-FWZJH3TL.js';
3
+ import '../chunk-NEK6JKPW.js';
4
+ import '../chunk-L2CM2CUA.js';
5
5
  import '../chunk-DD3CCMCZ.js';
6
- import '../chunk-4KAG5U7A.js';
7
6
  import '../chunk-KA7LO7U5.js';
8
7
  export { AuthProvider, useAuthContext } from '../chunk-7PLEQFHO.js';
@@ -1,22 +1,18 @@
1
- import { useInitialization } from './chunk-QQOLC46E.js';
1
+ import { useInitialization } from './chunk-NEK6JKPW.js';
2
2
  import { useAuthContext } from './chunk-7PLEQFHO.js';
3
- import { useRef, useCallback, useEffect } from 'react';
3
+ import { useRef, useEffect } from 'react';
4
4
  import { useQueryClient } from '@tanstack/react-query';
5
5
  import { useNavigate, useLocation } from '@tanstack/react-router';
6
6
  import { jsx, Fragment } from 'react/jsx-runtime';
7
7
 
8
- function useStableAccessToken() {
9
- const { getAccessToken } = useAuthContext();
10
- const getAccessTokenRef = useRef(getAccessToken);
11
- getAccessTokenRef.current = getAccessToken;
12
- return useCallback(() => {
13
- return getAccessTokenRef.current();
14
- }, []);
15
- }
16
8
  function useSessionCheck() {
17
9
  const { user } = useAuthContext();
18
10
  const queryClient = useQueryClient();
19
11
  const isCheckingRef = useRef(false);
12
+ const hadUserRef = useRef(false);
13
+ if (user) {
14
+ hadUserRef.current = true;
15
+ }
20
16
  useEffect(() => {
21
17
  const handleVisibilityChange = async () => {
22
18
  if (isCheckingRef.current || document.visibilityState !== "visible") {
@@ -24,12 +20,14 @@ function useSessionCheck() {
24
20
  }
25
21
  isCheckingRef.current = true;
26
22
  try {
27
- if (!user) {
23
+ if (!user && hadUserRef.current) {
28
24
  window.location.replace("/login");
29
25
  return;
30
26
  }
31
- await queryClient.cancelQueries();
32
- queryClient.invalidateQueries();
27
+ if (user) {
28
+ await queryClient.cancelQueries();
29
+ queryClient.invalidateQueries();
30
+ }
33
31
  } finally {
34
32
  isCheckingRef.current = false;
35
33
  }
@@ -50,6 +48,7 @@ function ProtectedRoute({
50
48
  waitForOrganization = true
51
49
  }) {
52
50
  const { userReady, allReady, isInitializing, error, retry } = useInitialization();
51
+ const { signIn, canRecover } = useAuthContext();
53
52
  const navigate = useNavigate();
54
53
  const location = useLocation();
55
54
  const hasRedirected = useRef(false);
@@ -59,12 +58,16 @@ function ProtectedRoute({
59
58
  hasRedirected.current = true;
60
59
  const searchStr = location.searchStr ?? "";
61
60
  const returnTo = location.pathname + searchStr;
62
- navigate({
63
- to: redirectTo,
64
- search: returnTo !== "/" ? { returnTo } : {}
65
- });
61
+ if (canRecover()) {
62
+ signIn({ state: { returnTo: returnTo !== "/" ? returnTo : void 0 } });
63
+ } else {
64
+ navigate({
65
+ to: redirectTo,
66
+ search: returnTo !== "/" ? { returnTo } : {}
67
+ });
68
+ }
66
69
  }
67
- }, [unauthenticated, navigate, redirectTo, location]);
70
+ }, [unauthenticated, signIn, canRecover, navigate, redirectTo, location]);
68
71
  if (isInitializing) {
69
72
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
70
73
  }
@@ -75,7 +78,7 @@ function ProtectedRoute({
75
78
  return null;
76
79
  }
77
80
  if (unauthenticated) {
78
- return null;
81
+ return /* @__PURE__ */ jsx(Fragment, { children: fallback });
79
82
  }
80
83
  if (waitForOrganization && !allReady && error?.layer !== "organization") {
81
84
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
@@ -102,4 +105,4 @@ function AdminGuard({ children, redirectTo = "/", fallback = null }) {
102
105
  return /* @__PURE__ */ jsx(Fragment, { children });
103
106
  }
104
107
 
105
- export { AdminGuard, ProtectedRoute, useSessionCheck, useStableAccessToken };
108
+ export { AdminGuard, ProtectedRoute, useSessionCheck };
@@ -1,17 +1,16 @@
1
- import { OrganizationProvider } from './chunk-FLJXZ7YC.js';
2
- import { ApiClientProvider, createUseApiClient } from './chunk-BWCC6ZJC.js';
1
+ import { OrganizationProvider } from './chunk-UMXDDEAG.js';
2
+ import { ApiClientProvider, useApiClient } from './chunk-XLV6LYN2.js';
3
3
  import { NotificationProvider } from './chunk-TIRMFDM4.js';
4
- import { OAuthProvider } from './chunk-QSVZP2NU.js';
5
- import { InitializationProvider } from './chunk-QQOLC46E.js';
4
+ import { InitializationProvider } from './chunk-NEK6JKPW.js';
5
+ import { ProfileProvider } from './chunk-L2CM2CUA.js';
6
6
  import { useOrganization } from './chunk-DD3CCMCZ.js';
7
- import { ProfileProvider } from './chunk-4KAG5U7A.js';
8
- import { ElevasisServiceProvider } from './chunk-KA7LO7U5.js';
7
+ import { ElevasisServiceProvider, useElevasisServices } from './chunk-KA7LO7U5.js';
9
8
  import { useAuthContext } from './chunk-7PLEQFHO.js';
10
9
  import { lazy, Suspense, useRef } from 'react';
11
10
  import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
12
11
  import { jsx, Fragment } from 'react/jsx-runtime';
13
12
 
14
- var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-KM72EYJS.js').then((m) => ({ default: m.CoreAuthKitInner })));
13
+ var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-3J4RVQO6.js').then((m) => ({ default: m.CoreAuthKitInner })));
15
14
  var defaultQueryClient = null;
16
15
  function getDefaultQueryClient() {
17
16
  if (!defaultQueryClient) {
@@ -21,7 +20,6 @@ function getDefaultQueryClient() {
21
20
  }
22
21
  return defaultQueryClient;
23
22
  }
24
- var defaultUseOrganizations = () => ({ isInitializing: false, isOrgRefreshing: false });
25
23
  function ElevasisCoreProvider({
26
24
  auth,
27
25
  queryClient,
@@ -32,17 +30,14 @@ function ElevasisCoreProvider({
32
30
  }) {
33
31
  if (auth.mode === "apiKey") {
34
32
  throw new Error(
35
- `ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' and 'oauth' modes are supported.`
33
+ `ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' mode is supported.`
36
34
  );
37
35
  }
38
36
  const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
39
37
  const content = apiUrl ? /* @__PURE__ */ jsx(CoreServiceBridge, { apiUrl, onError, notifications, children }) : children;
40
- const AuthInner = auth.mode === "authkit" ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) }) : /* @__PURE__ */ jsx(CoreOAuthInner, { auth, children: content });
38
+ const AuthInner = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) });
41
39
  return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: AuthInner });
42
40
  }
43
- function CoreOAuthInner({ auth, children }) {
44
- return /* @__PURE__ */ jsx(OAuthProvider, { config: auth, children });
45
- }
46
41
  function CoreServiceBridge({
47
42
  apiUrl,
48
43
  onError,
@@ -69,14 +64,15 @@ function CoreServiceBridgeInner({
69
64
  notifications,
70
65
  children
71
66
  }) {
72
- const useApiClient = useRef(createUseApiClient(defaultUseOrganizations, apiUrl)).current;
73
- const { apiRequest } = useApiClient();
67
+ const { apiRequest } = useApiClient(apiUrl);
74
68
  return /* @__PURE__ */ jsx(ElevasisServiceProvider, { apiRequest, organizationId: null, isReady: false, children: /* @__PURE__ */ jsx(ProfileProvider, { children: /* @__PURE__ */ jsx(OrganizationProvider, { children: /* @__PURE__ */ jsx(OrgIdBridge, { orgIdRef, children: /* @__PURE__ */ jsx(CoreNotificationLayer, { notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) }) }) }) }) });
75
69
  }
76
70
  function OrgIdBridge({ orgIdRef, children }) {
77
- const { currentWorkOSOrganizationId } = useOrganization();
71
+ const { currentWorkOSOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
72
+ const { apiRequest } = useElevasisServices();
78
73
  orgIdRef.current = currentWorkOSOrganizationId;
79
- return /* @__PURE__ */ jsx(Fragment, { children });
74
+ const isReady = !!currentWorkOSOrganizationId && !isInitializing && !isOrgRefreshing;
75
+ return /* @__PURE__ */ jsx(ElevasisServiceProvider, { apiRequest, organizationId: currentWorkOSOrganizationId, isReady, children });
80
76
  }
81
77
  function CoreNotificationLayer({
82
78
  notifications,