@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
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import './chunk-Q47SPRY7.js';
2
- export { OperationsService, executionsKeys, observabilityKeys, scheduleKeys, useActivities, useActivityTrend, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateSchedule, useDashboardMetrics, useDeleteExecution, useDeleteSchedule, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogs, useExecutions, useGetExecutionHistory, useGetSchedule, useListSchedules, usePauseSchedule, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResources, useResumeSchedule, useRetryExecution, useTopFailingResources, useUnresolveError, useUpdateAnchor, useUpdateSchedule } from './chunk-BZTA7IIL.js';
1
+ import './chunk-TYV5NJV2.js';
2
+ export { OperationsService, createUseFeatureAccess, executionsKeys, observabilityKeys, scheduleKeys, sortData, useActivities, useActivityTrend, useBatchDelete, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateSchedule, useDashboardMetrics, useDeleteExecution, useDeleteSchedule, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogs, useExecutions, useGetExecutionHistory, useGetSchedule, useListSchedules, usePaginationState, usePauseSchedule, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResources, useResumeSchedule, useRetryExecution, useSSEConnection, useSortedData, useSuccessNotification, useTableSelection, useTableSort, useTopFailingResources, useUnresolveError, useUpdateAnchor, useUpdateSchedule, useWarningNotification } from './chunk-A3MCANC6.js';
3
+ import './chunk-JGJSZ3UE.js';
3
4
  export { TanStackRouterBridge } from './chunk-LHQTTUL2.js';
4
5
  export { AGENT_CONSTANTS, AgentExecutionTimeline, AgentExecutionVisualizer, AgentIterationEdge, AgentIterationNode, CONTAINER_CONSTANTS, EmptyVisualizer, ExecutionStats, ExecutionStatusBadge, SHARED_VIZ_CONSTANTS, STATUS_COLORS, TIMELINE_CONSTANTS, TimelineAxis, TimelineBar, TimelineContainer, TimelineRow, UnifiedWorkflowEdge, UnifiedWorkflowGraph, UnifiedWorkflowNode, VisualizerContainer, WORKFLOW_CONSTANTS, WorkflowExecutionTimeline, calculateBarPosition, getEdgeColor, getEdgeOpacity, getResourceStatusColor, getStatusColors, getStatusIcon, shouldAnimateEdge, useAgentIterationData, useExecutionPath, useMergedExecution, useReactFlowAgent, useTimelineData, useUnifiedWorkflowLayout, useWorkflowStepsLayout } from './chunk-RJCA5672.js';
5
- export { OrganizationSwitcher, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations } from './chunk-EZMRFWZQ.js';
6
+ export { OrganizationSwitcher, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations } from './chunk-JBFFCZI4.js';
6
7
  import './chunk-XCYKC6OZ.js';
7
- export { createUseAppInitialization } from './chunk-SITSZUFW.js';
8
+ export { createUseAppInitialization } from './chunk-PVVQTENF.js';
8
9
  import './chunk-RNP5R5I3.js';
9
10
  export { ChatHeader, ChatInputArea, ChatInterface, ChatSidebar, ConfirmationInputModal, ConfirmationModal, MessageBubble } from './chunk-TN3PU2WK.js';
10
11
  export { ExecutionLogsTable, ResourceHealthChart, getHealthColor } from './chunk-NE36BUGQ.js';
@@ -20,19 +21,18 @@ export { BaseEdge, BaseNode, GRAPH_CONSTANTS, GlowingHandle, GraphBackground, Gr
20
21
  export { APIErrorAlert, CollapsibleSection, ContextViewer, CustomSelector, DetailCardSkeleton, EmptyState, JsonViewer, ListSkeleton, NavigationButton, PageNotFound, PageTitleCaption, ResourceCard, StatCard, StatCardSkeleton, StatsCardSkeleton, TabCountBadge, TimeRangeSelector, TrendIndicator, catalogItemToResourceDefinition } from './chunk-O3PY6B6E.js';
21
22
  export { StyledMarkdown } from './chunk-3KMDHCAR.js';
22
23
  import './chunk-YZ6GTZXL.js';
23
- export { ElevasisProvider, ElevasisUIProvider, createCssVariablesResolver, generateShades, getPreset, mantineNotificationAdapter, mantineThemeOverride } from './chunk-PCBXNHKY.js';
24
- export { ElevasisCoreProvider } from './chunk-OLD3NQLI.js';
25
- export { OrganizationProvider } from './chunk-FLJXZ7YC.js';
26
- export { ApiClientProvider, createUseApiClient, useApiClient, useApiClientContext } from './chunk-BWCC6ZJC.js';
24
+ export { ElevasisProvider, ElevasisUIProvider, createCssVariablesResolver, generateShades, getPreset, mantineNotificationAdapter, mantineThemeOverride } from './chunk-TZPAA4RC.js';
25
+ export { ElevasisCoreProvider } from './chunk-72HOBFMP.js';
26
+ export { OrganizationProvider } from './chunk-UMXDDEAG.js';
27
+ export { ApiClientProvider, useApiClient, useApiClientContext } from './chunk-XLV6LYN2.js';
27
28
  export { NotificationProvider, useNotificationAdapter } from './chunk-TIRMFDM4.js';
28
29
  export { formatDate, getResourceColor, getResourceIcon, showApiErrorNotification, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, validateEmail } from './chunk-JVAZHVNV.js';
29
30
  export { APIClientError, formatErrorMessage, getErrorInfo, getErrorTitle, isAPIClientError } from './chunk-4VGWQ5AN.js';
30
- export { AdminGuard, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken } from './chunk-FDCVFCOQ.js';
31
- export { WorkOSAuthBridge } from './chunk-NIAVTSMB.js';
32
- export { useOAuthContext } from './chunk-QSVZP2NU.js';
33
- export { InitializationContext, InitializationProvider, useInitialization } from './chunk-QQOLC46E.js';
31
+ export { AdminGuard, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck } from './chunk-2JBWPFHF.js';
32
+ export { useStableAccessToken } from './chunk-FWZJH3TL.js';
33
+ export { InitializationContext, InitializationProvider, useInitialization } from './chunk-NEK6JKPW.js';
34
+ export { ProfileProvider, UserProfileService, useProfile, useUserProfile } from './chunk-L2CM2CUA.js';
34
35
  export { useOrganization } from './chunk-DD3CCMCZ.js';
35
- export { ProfileProvider, UserProfileService, useProfile, useUserProfile } from './chunk-4KAG5U7A.js';
36
36
  export { ElevasisServiceProvider, useElevasisServices } from './chunk-KA7LO7U5.js';
37
37
  export { AuthProvider, useAuthContext } from './chunk-7PLEQFHO.js';
38
38
  export { RouterProvider, useRouterContext } from './chunk-Q7DJKLEN.js';
@@ -1,7 +1,7 @@
1
- export { createUseAppInitialization } from '../chunk-SITSZUFW.js';
1
+ export { createUseAppInitialization } from '../chunk-PVVQTENF.js';
2
2
  import '../chunk-RNP5R5I3.js';
3
- export { InitializationContext, InitializationProvider, useInitialization } from '../chunk-QQOLC46E.js';
3
+ export { InitializationContext, InitializationProvider, useInitialization } from '../chunk-NEK6JKPW.js';
4
+ import '../chunk-L2CM2CUA.js';
4
5
  import '../chunk-DD3CCMCZ.js';
5
- import '../chunk-4KAG5U7A.js';
6
6
  import '../chunk-KA7LO7U5.js';
7
7
  import '../chunk-7PLEQFHO.js';
@@ -1,7 +1,7 @@
1
- export { OrganizationSwitcher, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations } from '../chunk-EZMRFWZQ.js';
1
+ export { OrganizationSwitcher, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations } from '../chunk-JBFFCZI4.js';
2
2
  import '../chunk-RNP5R5I3.js';
3
- export { OrganizationProvider } from '../chunk-FLJXZ7YC.js';
3
+ export { OrganizationProvider } from '../chunk-UMXDDEAG.js';
4
+ import '../chunk-L2CM2CUA.js';
4
5
  export { useOrganization } from '../chunk-DD3CCMCZ.js';
5
- import '../chunk-4KAG5U7A.js';
6
6
  import '../chunk-KA7LO7U5.js';
7
7
  import '../chunk-7PLEQFHO.js';
@@ -1,4 +1,4 @@
1
1
  import '../chunk-RNP5R5I3.js';
2
- export { ProfileProvider, UserProfileService, useProfile, useUserProfile } from '../chunk-4KAG5U7A.js';
2
+ export { ProfileProvider, UserProfileService, useProfile, useUserProfile } from '../chunk-L2CM2CUA.js';
3
3
  import '../chunk-KA7LO7U5.js';
4
4
  import '../chunk-7PLEQFHO.js';
@@ -118,10 +118,10 @@ interface ElevasisThemeConfig extends ElevasisCoreThemeConfig {
118
118
  }
119
119
  /**
120
120
  * Auth configuration union.
121
- * 'authkit' (WorkOS AuthKit) and 'oauth' (WorkOS Connect) are implemented.
121
+ * 'authkit' (WorkOS AuthKit) is the supported mode.
122
122
  * 'apiKey' is defined for forward type compatibility but will throw at runtime.
123
123
  */
124
- type AuthConfig = AuthKitConfig | OAuthConfig | ApiKeyConfig;
124
+ type AuthConfig = AuthKitConfig | ApiKeyConfig;
125
125
  interface AuthKitConfig {
126
126
  mode: 'authkit';
127
127
  clientId: string;
@@ -132,25 +132,13 @@ interface AuthKitConfig {
132
132
  /** Keep refresh tokens in localStorage. Defaults to false. */
133
133
  devMode?: boolean;
134
134
  }
135
- /** OAuth config for "Sign in with Elevasis" via WorkOS Connect. */
136
- interface OAuthConfig {
137
- mode: 'oauth';
138
- clientId: string;
139
- redirectUri: string;
140
- /** Persist tokens in sessionStorage. Default is memory-only. */
141
- tokenStorage?: 'session';
142
- /** Pre-select organization in WorkOS flow. */
143
- organizationId?: string;
144
- /** Auth provider for the authorize request. Defaults to 'authkit' (hosted login UI). */
145
- provider?: 'authkit' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'GitHubOAuth' | 'AppleOAuth';
146
- }
147
135
  /** Deferred -- will throw at runtime. */
148
136
  interface ApiKeyConfig {
149
137
  mode: 'apiKey';
150
138
  key: string;
151
139
  }
152
140
  interface ElevasisCoreProviderProps {
153
- /** Auth configuration. Supports 'authkit' and 'oauth' modes. */
141
+ /** Auth configuration. Supports 'authkit' mode. */
154
142
  auth: AuthConfig;
155
143
  /**
156
144
  * Elevasis core theme configuration (Mantine-free).
@@ -202,7 +190,7 @@ interface ElevasisCoreProviderProps {
202
190
  children: ReactNode;
203
191
  }
204
192
  interface ElevasisProviderProps {
205
- /** Auth configuration. Supports 'authkit' and 'oauth' modes. */
193
+ /** Auth configuration. Supports 'authkit' mode. */
206
194
  auth: AuthConfig;
207
195
  /**
208
196
  * Elevasis theme configuration.
@@ -381,4 +369,4 @@ declare function ElevasisServiceProvider({ apiRequest, organizationId, isReady,
381
369
  declare const mantineNotificationAdapter: NotificationAdapter;
382
370
 
383
371
  export { ElevasisCoreProvider, ElevasisProvider, ElevasisServiceProvider, ElevasisUIProvider, NotificationProvider, mantineNotificationAdapter, useElevasisServices, useNotificationAdapter };
384
- export type { ApiKeyConfig, AuthConfig, AuthKitConfig, ElevasisCoreProviderProps, ElevasisCoreThemeConfig, ElevasisProviderProps, ElevasisServiceContextValue, ElevasisServiceProviderProps, ElevasisThemeConfig, ElevasisTokenOverrides, NotificationAdapter, OAuthConfig, PresetName, WithSchemes };
372
+ export type { ApiKeyConfig, AuthConfig, AuthKitConfig, ElevasisCoreProviderProps, ElevasisCoreThemeConfig, ElevasisProviderProps, ElevasisServiceContextValue, ElevasisServiceProviderProps, ElevasisThemeConfig, ElevasisTokenOverrides, NotificationAdapter, PresetName, WithSchemes };
@@ -1,13 +1,12 @@
1
- export { ElevasisProvider, ElevasisUIProvider, mantineNotificationAdapter } from '../chunk-PCBXNHKY.js';
2
- export { ElevasisCoreProvider } from '../chunk-OLD3NQLI.js';
3
- import '../chunk-FLJXZ7YC.js';
4
- import '../chunk-BWCC6ZJC.js';
1
+ export { ElevasisProvider, ElevasisUIProvider, mantineNotificationAdapter } from '../chunk-TZPAA4RC.js';
2
+ export { ElevasisCoreProvider } from '../chunk-72HOBFMP.js';
3
+ import '../chunk-UMXDDEAG.js';
4
+ import '../chunk-XLV6LYN2.js';
5
5
  export { NotificationProvider, useNotificationAdapter } from '../chunk-TIRMFDM4.js';
6
6
  import '../chunk-JVAZHVNV.js';
7
7
  import '../chunk-4VGWQ5AN.js';
8
- import '../chunk-QSVZP2NU.js';
9
- import '../chunk-QQOLC46E.js';
8
+ import '../chunk-NEK6JKPW.js';
9
+ import '../chunk-L2CM2CUA.js';
10
10
  import '../chunk-DD3CCMCZ.js';
11
- import '../chunk-4KAG5U7A.js';
12
11
  export { ElevasisServiceProvider, useElevasisServices } from '../chunk-KA7LO7U5.js';
13
12
  import '../chunk-7PLEQFHO.js';
@@ -105,10 +105,10 @@ interface ElevasisCoreThemeConfig {
105
105
  }
106
106
  /**
107
107
  * Auth configuration union.
108
- * 'authkit' (WorkOS AuthKit) and 'oauth' (WorkOS Connect) are implemented.
108
+ * 'authkit' (WorkOS AuthKit) is the supported mode.
109
109
  * 'apiKey' is defined for forward type compatibility but will throw at runtime.
110
110
  */
111
- type AuthConfig = AuthKitConfig | OAuthConfig | ApiKeyConfig;
111
+ type AuthConfig = AuthKitConfig | ApiKeyConfig;
112
112
  interface AuthKitConfig {
113
113
  mode: 'authkit';
114
114
  clientId: string;
@@ -119,25 +119,13 @@ interface AuthKitConfig {
119
119
  /** Keep refresh tokens in localStorage. Defaults to false. */
120
120
  devMode?: boolean;
121
121
  }
122
- /** OAuth config for "Sign in with Elevasis" via WorkOS Connect. */
123
- interface OAuthConfig {
124
- mode: 'oauth';
125
- clientId: string;
126
- redirectUri: string;
127
- /** Persist tokens in sessionStorage. Default is memory-only. */
128
- tokenStorage?: 'session';
129
- /** Pre-select organization in WorkOS flow. */
130
- organizationId?: string;
131
- /** Auth provider for the authorize request. Defaults to 'authkit' (hosted login UI). */
132
- provider?: 'authkit' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'GitHubOAuth' | 'AppleOAuth';
133
- }
134
122
  /** Deferred -- will throw at runtime. */
135
123
  interface ApiKeyConfig {
136
124
  mode: 'apiKey';
137
125
  key: string;
138
126
  }
139
127
  interface ElevasisCoreProviderProps {
140
- /** Auth configuration. Supports 'authkit' and 'oauth' modes. */
128
+ /** Auth configuration. Supports 'authkit' mode. */
141
129
  auth: AuthConfig;
142
130
  /**
143
131
  * Elevasis core theme configuration (Mantine-free).
@@ -275,4 +263,4 @@ declare function useElevasisServices(): ElevasisServiceContextValue;
275
263
  declare function ElevasisServiceProvider({ apiRequest, organizationId, isReady, children }: ElevasisServiceProviderProps): react_jsx_runtime.JSX.Element;
276
264
 
277
265
  export { ElevasisCoreProvider, ElevasisServiceProvider, NotificationProvider, useElevasisServices, useNotificationAdapter };
278
- export type { ApiKeyConfig, AuthConfig, AuthKitConfig, ElevasisCoreProviderProps, ElevasisCoreThemeConfig, ElevasisServiceContextValue, ElevasisServiceProviderProps, ElevasisTokenOverrides, NotificationAdapter, OAuthConfig, WithSchemes };
266
+ export type { ApiKeyConfig, AuthConfig, AuthKitConfig, ElevasisCoreProviderProps, ElevasisCoreThemeConfig, ElevasisServiceContextValue, ElevasisServiceProviderProps, ElevasisTokenOverrides, NotificationAdapter, WithSchemes };
@@ -1,12 +1,11 @@
1
- export { ElevasisCoreProvider } from '../chunk-OLD3NQLI.js';
2
- import '../chunk-FLJXZ7YC.js';
3
- import '../chunk-BWCC6ZJC.js';
1
+ export { ElevasisCoreProvider } from '../chunk-72HOBFMP.js';
2
+ import '../chunk-UMXDDEAG.js';
3
+ import '../chunk-XLV6LYN2.js';
4
4
  export { NotificationProvider, useNotificationAdapter } from '../chunk-TIRMFDM4.js';
5
5
  import '../chunk-JVAZHVNV.js';
6
6
  import '../chunk-4VGWQ5AN.js';
7
- import '../chunk-QSVZP2NU.js';
8
- import '../chunk-QQOLC46E.js';
7
+ import '../chunk-NEK6JKPW.js';
8
+ import '../chunk-L2CM2CUA.js';
9
9
  import '../chunk-DD3CCMCZ.js';
10
- import '../chunk-4KAG5U7A.js';
11
10
  export { ElevasisServiceProvider, useElevasisServices } from '../chunk-KA7LO7U5.js';
12
11
  import '../chunk-7PLEQFHO.js';
@@ -1,47 +1,2 @@
1
- import { useAuthContext } from '../chunk-7PLEQFHO.js';
2
- import { createClient } from '@supabase/supabase-js';
3
- import { useMemo } from 'react';
4
-
5
- function getSupabaseConfig() {
6
- const url = import.meta.env?.VITE_SUPABASE_URL;
7
- const anonKey = import.meta.env?.VITE_SUPABASE_ANON_KEY;
8
- if (!url || !anonKey) {
9
- throw new Error("Missing Supabase environment variables (VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY)");
10
- }
11
- return { url, anonKey };
12
- }
13
- var _supabase = null;
14
- function getSupabaseClient() {
15
- if (!_supabase) {
16
- const { url, anonKey } = getSupabaseConfig();
17
- _supabase = createClient(url, anonKey);
18
- }
19
- return _supabase;
20
- }
21
- var useSupabase = () => {
22
- const { getAccessToken } = useAuthContext();
23
- const { url, anonKey } = getSupabaseConfig();
24
- return useMemo(
25
- () => createClient(url, anonKey, {
26
- global: {
27
- headers: {
28
- // Additional headers if needed
29
- }
30
- },
31
- accessToken: async () => {
32
- try {
33
- const token = await getAccessToken();
34
- if (!token) {
35
- return null;
36
- }
37
- return token;
38
- } catch {
39
- return null;
40
- }
41
- }
42
- }),
43
- [getAccessToken, url, anonKey]
44
- );
45
- };
46
-
47
- export { getSupabaseClient, useSupabase };
1
+ export { getSupabaseClient, useSupabase } from '../chunk-JGJSZ3UE.js';
2
+ import '../chunk-7PLEQFHO.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevasis/ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "UI components and platform-aware hooks for building custom frontends on the Elevasis platform",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -80,8 +80,8 @@
80
80
  "typescript": "5.9.2",
81
81
  "vite": "^7.0.0",
82
82
  "@repo/core": "0.0.0",
83
- "@repo/typescript-config": "0.0.0",
84
- "@repo/eslint-config": "0.0.0"
83
+ "@repo/eslint-config": "0.0.0",
84
+ "@repo/typescript-config": "0.0.0"
85
85
  },
86
86
  "dependencies": {
87
87
  "@dagrejs/dagre": "^1.1.4",
@@ -1,19 +0,0 @@
1
- import { WorkOSAuthBridge } from './chunk-NIAVTSMB.js';
2
- import './chunk-7PLEQFHO.js';
3
- import { AuthKitProvider } from '@workos-inc/authkit-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(WorkOSAuthBridge, { children })
15
- }
16
- );
17
- }
18
-
19
- export { CoreAuthKitInner };
@@ -1,54 +0,0 @@
1
- /**
2
- * Return type of useOrganizations hook (subset needed by the factory)
3
- */
4
- interface UseOrganizationsReturn {
5
- isInitializing: boolean;
6
- isOrgRefreshing: boolean;
7
- }
8
- /**
9
- * Hook that returns apiRequest and deferredApiRequest bound to the current
10
- * ApiClientContext. apiUrl is the only parameter because org ID is resolved
11
- * at call time via getOrganizationId() from context.
12
- *
13
- * Usage:
14
- * ```typescript
15
- * import { useApiClient } from '@repo/ui/api'
16
- *
17
- * const API_URL = import.meta.env.VITE_API_SERVER || 'http://localhost:5170'
18
- *
19
- * function useMyClient() {
20
- * return useApiClient(API_URL)
21
- * }
22
- * ```
23
- */
24
- export declare function useApiClient(apiUrl: string): {
25
- apiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
26
- deferredApiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
27
- isOrganizationReady: boolean;
28
- isInitializing: boolean;
29
- };
30
- /**
31
- * Factory function to create a useApiClient hook for your app.
32
- *
33
- * @deprecated Use the plain `useApiClient(apiUrl)` hook instead.
34
- * The factory pattern is no longer needed because org ID is resolved at
35
- * call time via getOrganizationId() from ApiClientContext.
36
- *
37
- * Migration:
38
- * ```typescript
39
- * // Before
40
- * export const useApiClient = createUseApiClient(useOrganizations, API_URL)
41
- *
42
- * // After
43
- * import { useApiClient } from '@repo/ui/api'
44
- * // call useApiClient(API_URL) directly in your hook/component
45
- * ```
46
- */
47
- export declare function createUseApiClient(useOrganizations: () => UseOrganizationsReturn, apiUrl: string): () => {
48
- apiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
49
- deferredApiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>;
50
- isOrganizationReady: boolean;
51
- isInitializing: boolean;
52
- };
53
- export {};
54
- //# sourceMappingURL=useApiClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useApiClient.d.ts","sourceRoot":"","sources":["../../../src/api/hooks/useApiClient.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,UAAU,sBAAsB;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,OAAO,CAAA;CACzB;AA+FD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;iBA+BtC,CAAC,YAAY,MAAM,YAAW,WAAW,KAAQ,OAAO,CAAC,CAAC,CAAC;yBAMrD,CAAC,YAAY,MAAM,YAAW,WAAW,KAAQ,OAAO,CAAC,CAAC,CAAC;;;EAerE;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,sBAAsB,EAAE,MAAM,EAAE,MAAM;iBAqC1F,CAAC,YAAY,MAAM,YAAW,WAAW,KAAQ,OAAO,CAAC,CAAC,CAAC;yBAMrD,CAAC,YAAY,MAAM,YAAW,WAAW,KAAQ,OAAO,CAAC,CAAC,CAAC;;;EAqBvE"}
@@ -1,185 +0,0 @@
1
- import { useCallback } from 'react';
2
- import { HTTP_HEADERS } from '@repo/core';
3
- import { APIClientError } from '../../utils';
4
- import { useApiClientContext } from '../context/ApiClientProvider';
5
- const DEFAULT_TIMEOUT_MS = 60_000;
6
- // ---------------------------------------------------------------------------
7
- // Shared request logic builder — used by both the plain hook and the factory.
8
- // ---------------------------------------------------------------------------
9
- function buildApiRequest(getAccessToken, getOrganizationId, apiUrl, handleResponseError) {
10
- return async function apiRequest(endpoint, options = {}) {
11
- try {
12
- // Get the access token from context
13
- const token = await getAccessToken();
14
- // Read org ID at call time — reflects org switches without re-render
15
- const organizationId = getOrganizationId();
16
- // DEBUG
17
- if (organizationId)
18
- console.log('[apiRequest]', endpoint, 'org:', organizationId);
19
- // Only set Content-Type if there's a body
20
- const headers = {
21
- ...(options.body ? { 'Content-Type': 'application/json' } : {}),
22
- ...(token ? { Authorization: `Bearer ${token}` } : {}),
23
- ...(organizationId && { [HTTP_HEADERS.WORKOS_ORGANIZATION_ID]: organizationId }),
24
- ...options.headers
25
- };
26
- const timeoutSignal = AbortSignal.timeout(DEFAULT_TIMEOUT_MS);
27
- const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
28
- const response = await fetch(`${apiUrl}/api${endpoint}`, {
29
- ...options,
30
- headers,
31
- signal
32
- });
33
- if (!response.ok) {
34
- await handleResponseError(endpoint, response, options);
35
- }
36
- // Handle 204 No Content responses
37
- if (response.status === 204) {
38
- return undefined;
39
- }
40
- const data = await response.json();
41
- // DEBUG
42
- if (organizationId && endpoint.includes('dashboard'))
43
- console.log('[apiResponse] dashboard:', data);
44
- return data;
45
- }
46
- catch (error) {
47
- // If getAccessToken fails, still make the request without auth
48
- // This allows public endpoints to work
49
- if (error instanceof Error && error.message.includes('No access token')) {
50
- // Only set Content-Type if there's a body
51
- const headers = {
52
- ...(options.body ? { 'Content-Type': 'application/json' } : {}),
53
- ...options.headers
54
- };
55
- const fallbackTimeoutSignal = AbortSignal.timeout(DEFAULT_TIMEOUT_MS);
56
- const fallbackSignal = options.signal
57
- ? AbortSignal.any([options.signal, fallbackTimeoutSignal])
58
- : fallbackTimeoutSignal;
59
- const response = await fetch(`${apiUrl}/api${endpoint}`, {
60
- ...options,
61
- headers,
62
- signal: fallbackSignal
63
- });
64
- if (!response.ok) {
65
- await handleResponseError(endpoint, response, options);
66
- }
67
- if (response.status === 204) {
68
- return undefined;
69
- }
70
- return response.json();
71
- }
72
- throw error;
73
- }
74
- };
75
- }
76
- // ---------------------------------------------------------------------------
77
- // Plain hook — reads everything from ApiClientContext directly.
78
- // apiUrl must be provided because the context does not store it.
79
- // ---------------------------------------------------------------------------
80
- /**
81
- * Hook that returns apiRequest and deferredApiRequest bound to the current
82
- * ApiClientContext. apiUrl is the only parameter because org ID is resolved
83
- * at call time via getOrganizationId() from context.
84
- *
85
- * Usage:
86
- * ```typescript
87
- * import { useApiClient } from '@repo/ui/api'
88
- *
89
- * const API_URL = import.meta.env.VITE_API_SERVER || 'http://localhost:5170'
90
- *
91
- * function useMyClient() {
92
- * return useApiClient(API_URL)
93
- * }
94
- * ```
95
- */
96
- export function useApiClient(apiUrl) {
97
- const { getAccessToken, getOrganizationId, isOrganizationReady, onError } = useApiClientContext();
98
- const handleResponseError = useCallback(async (endpoint, response, options) => {
99
- const errorData = await response.json().catch(() => ({
100
- error: `HTTP ${response.status}`,
101
- code: 'INTERNAL_SERVER_ERROR'
102
- }));
103
- if (response.status >= 500 && onError) {
104
- onError(endpoint, new Error(errorData.error), {
105
- method: options.method || 'GET',
106
- statusCode: response.status,
107
- requestId: errorData.requestId
108
- });
109
- }
110
- throw new APIClientError(errorData.error, errorData.code, response.status, errorData.requestId, errorData.fields, errorData.retryAfter);
111
- }, [onError]);
112
- const apiRequest = useCallback((endpoint, options = {}) => buildApiRequest(getAccessToken, getOrganizationId, apiUrl, handleResponseError)(endpoint, options), [getAccessToken, getOrganizationId, apiUrl, handleResponseError]);
113
- const deferredApiRequest = useCallback(async (endpoint, options = {}) => {
114
- if (!isOrganizationReady) {
115
- throw new Error('No organization selected. Please select an organization.');
116
- }
117
- return apiRequest(endpoint, options);
118
- }, [apiRequest, isOrganizationReady]);
119
- return {
120
- apiRequest,
121
- deferredApiRequest,
122
- isOrganizationReady,
123
- isInitializing: false
124
- };
125
- }
126
- // ---------------------------------------------------------------------------
127
- // Factory — kept for backwards compatibility during migration.
128
- // ---------------------------------------------------------------------------
129
- /**
130
- * Factory function to create a useApiClient hook for your app.
131
- *
132
- * @deprecated Use the plain `useApiClient(apiUrl)` hook instead.
133
- * The factory pattern is no longer needed because org ID is resolved at
134
- * call time via getOrganizationId() from ApiClientContext.
135
- *
136
- * Migration:
137
- * ```typescript
138
- * // Before
139
- * export const useApiClient = createUseApiClient(useOrganizations, API_URL)
140
- *
141
- * // After
142
- * import { useApiClient } from '@repo/ui/api'
143
- * // call useApiClient(API_URL) directly in your hook/component
144
- * ```
145
- */
146
- export function createUseApiClient(useOrganizations, apiUrl) {
147
- return function useApiClientCompat() {
148
- const { getAccessToken, getOrganizationId, isOrganizationReady, onError } = useApiClientContext();
149
- const { isInitializing, isOrgRefreshing } = useOrganizations();
150
- /**
151
- * Handle API response errors
152
- * Logs 5xx errors via onError callback and throws APIClientError
153
- */
154
- const handleResponseError = useCallback(async (endpoint, response, options) => {
155
- const errorData = await response.json().catch(() => ({
156
- error: `HTTP ${response.status}`,
157
- code: 'INTERNAL_SERVER_ERROR'
158
- }));
159
- if (response.status >= 500 && onError) {
160
- onError(endpoint, new Error(errorData.error), {
161
- method: options.method || 'GET',
162
- statusCode: response.status,
163
- requestId: errorData.requestId
164
- });
165
- }
166
- throw new APIClientError(errorData.error, errorData.code, response.status, errorData.requestId, errorData.fields, errorData.retryAfter);
167
- }, [onError]);
168
- const apiRequest = useCallback((endpoint, options = {}) => buildApiRequest(getAccessToken, getOrganizationId, apiUrl, handleResponseError)(endpoint, options), [getAccessToken, getOrganizationId, handleResponseError]);
169
- const deferredApiRequest = useCallback(async (endpoint, options = {}) => {
170
- if (isInitializing || isOrgRefreshing) {
171
- throw new Error('Organization context is still initializing. Please wait.');
172
- }
173
- if (!isOrganizationReady) {
174
- throw new Error('No organization selected. Please select an organization.');
175
- }
176
- return apiRequest(endpoint, options);
177
- }, [apiRequest, isInitializing, isOrgRefreshing, isOrganizationReady]);
178
- return {
179
- apiRequest,
180
- deferredApiRequest,
181
- isOrganizationReady,
182
- isInitializing: isInitializing || isOrgRefreshing
183
- };
184
- };
185
- }
@@ -1,21 +0,0 @@
1
- import { AuthProvider } from './chunk-7PLEQFHO.js';
2
- import { useAuth } from '@workos-inc/authkit-react';
3
- import { useMemo } from 'react';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- function WorkOSAuthBridge({ children }) {
7
- const { user, isLoading, getAccessToken, organizationId } = useAuth();
8
- const adaptedUser = useMemo(() => user ? { id: user.id } : null, [user?.id]);
9
- const value = useMemo(
10
- () => ({
11
- user: adaptedUser,
12
- isLoading,
13
- getAccessToken,
14
- organizationId: organizationId ?? null
15
- }),
16
- [adaptedUser, isLoading, getAccessToken, organizationId]
17
- );
18
- return /* @__PURE__ */ jsx(AuthProvider, { value, children });
19
- }
20
-
21
- export { WorkOSAuthBridge };