@elevasis/ui 1.3.4 → 1.3.6
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/api/index.js +1 -1
- package/dist/auth/index.d.ts +174 -14
- package/dist/{chunk-XLV6LYN2.js → chunk-LBPALY25.js} +0 -1
- package/dist/{chunk-LTQAAIGE.js → chunk-Y2I5JJ3N.js} +1 -1
- package/dist/hooks/index.d.ts +4401 -11
- package/dist/hooks/published.d.ts +4529 -19
- package/dist/index.d.ts +6316 -15
- package/dist/index.js +18 -97
- package/dist/initialization/index.d.ts +2222 -22
- package/dist/organization/index.d.ts +266 -21
- package/dist/profile/index.d.ts +2158 -14
- package/dist/provider/index.d.ts +266 -7
- package/dist/provider/index.js +12 -3
- package/dist/provider/published.d.ts +263 -9
- package/dist/provider/published.js +2 -2
- package/dist/types/index.d.ts +3403 -0
- package/dist/types/index.js +1 -0
- package/package.json +50 -5
- package/dist/auth/guards/AdminGuard.d.ts +0 -32
- package/dist/auth/guards/AdminGuard.d.ts.map +0 -1
- package/dist/auth/guards/ProtectedRoute.d.ts +0 -60
- package/dist/auth/guards/ProtectedRoute.d.ts.map +0 -1
- package/dist/auth/guards/__tests__/AdminGuard.test.d.ts +0 -12
- package/dist/auth/guards/__tests__/AdminGuard.test.d.ts.map +0 -1
- package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts +0 -14
- package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/hooks/command-queue/index.d.ts +0 -7
- package/dist/hooks/command-queue/index.d.ts.map +0 -1
- package/dist/hooks/command-queue/useCommandQueue.d.ts +0 -33
- package/dist/hooks/command-queue/useCommandQueue.d.ts.map +0 -1
- package/dist/hooks/command-queue/useCommandQueueTotals.d.ts +0 -17
- package/dist/hooks/command-queue/useCommandQueueTotals.d.ts.map +0 -1
- package/dist/hooks/command-queue/useDeleteTask.d.ts +0 -5
- package/dist/hooks/command-queue/useDeleteTask.d.ts.map +0 -1
- package/dist/hooks/command-queue/usePatchTask.d.ts +0 -6
- package/dist/hooks/command-queue/usePatchTask.d.ts.map +0 -1
- package/dist/hooks/command-queue/useSubmitAction.d.ts +0 -29
- package/dist/hooks/command-queue/useSubmitAction.d.ts.map +0 -1
- package/dist/hooks/executions/index.d.ts +0 -16
- package/dist/hooks/executions/index.d.ts.map +0 -1
- package/dist/hooks/executions/useBulkDeleteExecutions.d.ts +0 -15
- package/dist/hooks/executions/useBulkDeleteExecutions.d.ts.map +0 -1
- package/dist/hooks/executions/useCancelExecution.d.ts +0 -20
- package/dist/hooks/executions/useCancelExecution.d.ts.map +0 -1
- package/dist/hooks/executions/useDeleteExecution.d.ts +0 -13
- package/dist/hooks/executions/useDeleteExecution.d.ts.map +0 -1
- package/dist/hooks/executions/useExecuteAsync.d.ts +0 -21
- package/dist/hooks/executions/useExecuteAsync.d.ts.map +0 -1
- package/dist/hooks/executions/useExecution.d.ts +0 -10
- package/dist/hooks/executions/useExecution.d.ts.map +0 -1
- package/dist/hooks/executions/useExecutions.d.ts +0 -16
- package/dist/hooks/executions/useExecutions.d.ts.map +0 -1
- package/dist/hooks/executions/useResourceDefinition.d.ts +0 -9
- package/dist/hooks/executions/useResourceDefinition.d.ts.map +0 -1
- package/dist/hooks/executions/useResources.d.ts +0 -15
- package/dist/hooks/executions/useResources.d.ts.map +0 -1
- package/dist/hooks/executions/useRetryExecution.d.ts +0 -16
- package/dist/hooks/executions/useRetryExecution.d.ts.map +0 -1
- package/dist/hooks/feature-access/createUseFeatureAccess.d.ts +0 -44
- package/dist/hooks/feature-access/createUseFeatureAccess.d.ts.map +0 -1
- package/dist/hooks/feature-access/index.d.ts +0 -2
- package/dist/hooks/feature-access/index.d.ts.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/monitoring/index.d.ts +0 -9
- package/dist/hooks/monitoring/index.d.ts.map +0 -1
- package/dist/hooks/monitoring/useActivities.d.ts +0 -52
- package/dist/hooks/monitoring/useActivities.d.ts.map +0 -1
- package/dist/hooks/monitoring/useCostSummary.d.ts +0 -7
- package/dist/hooks/monitoring/useCostSummary.d.ts.map +0 -1
- package/dist/hooks/monitoring/useExecutionHealth.d.ts +0 -10
- package/dist/hooks/monitoring/useExecutionHealth.d.ts.map +0 -1
- package/dist/hooks/monitoring/useExecutionLogs.d.ts +0 -56
- package/dist/hooks/monitoring/useExecutionLogs.d.ts.map +0 -1
- package/dist/hooks/monitoring/useNotifications.d.ts +0 -11
- package/dist/hooks/monitoring/useNotifications.d.ts.map +0 -1
- package/dist/hooks/notifications/index.d.ts +0 -8
- package/dist/hooks/notifications/index.d.ts.map +0 -1
- package/dist/hooks/notifications/useMarkAllAsRead.d.ts +0 -2
- package/dist/hooks/notifications/useMarkAllAsRead.d.ts.map +0 -1
- package/dist/hooks/notifications/useMarkAsRead.d.ts +0 -2
- package/dist/hooks/notifications/useMarkAsRead.d.ts.map +0 -1
- package/dist/hooks/notifications/useNotificationCount.d.ts +0 -8
- package/dist/hooks/notifications/useNotificationCount.d.ts.map +0 -1
- package/dist/hooks/observability/index.d.ts +0 -19
- package/dist/hooks/observability/index.d.ts.map +0 -1
- package/dist/hooks/observability/useBusinessImpact.d.ts +0 -9
- package/dist/hooks/observability/useBusinessImpact.d.ts.map +0 -1
- package/dist/hooks/observability/useCostBreakdown.d.ts +0 -10
- package/dist/hooks/observability/useCostBreakdown.d.ts.map +0 -1
- package/dist/hooks/observability/useCostByModel.d.ts +0 -3
- package/dist/hooks/observability/useCostByModel.d.ts.map +0 -1
- package/dist/hooks/observability/useCostTrends.d.ts +0 -3
- package/dist/hooks/observability/useCostTrends.d.ts.map +0 -1
- package/dist/hooks/observability/useDashboardMetrics.d.ts +0 -3
- package/dist/hooks/observability/useDashboardMetrics.d.ts.map +0 -1
- package/dist/hooks/observability/useErrorAnalysis.d.ts +0 -7
- package/dist/hooks/observability/useErrorAnalysis.d.ts.map +0 -1
- package/dist/hooks/observability/useErrorDetails.d.ts +0 -20
- package/dist/hooks/observability/useErrorDetails.d.ts.map +0 -1
- package/dist/hooks/observability/useErrorDistribution.d.ts +0 -12
- package/dist/hooks/observability/useErrorDistribution.d.ts.map +0 -1
- package/dist/hooks/observability/useErrorTrends.d.ts +0 -12
- package/dist/hooks/observability/useErrorTrends.d.ts.map +0 -1
- package/dist/hooks/observability/useResolveError.d.ts +0 -17
- package/dist/hooks/observability/useResolveError.d.ts.map +0 -1
- package/dist/hooks/observability/useTopFailingResources.d.ts +0 -13
- package/dist/hooks/observability/useTopFailingResources.d.ts.map +0 -1
- package/dist/hooks/published.d.ts.map +0 -1
- package/dist/hooks/scheduling/index.d.ts +0 -5
- package/dist/hooks/scheduling/index.d.ts.map +0 -1
- package/dist/hooks/scheduling/useSchedules.d.ts +0 -185
- package/dist/hooks/scheduling/useSchedules.d.ts.map +0 -1
- package/dist/hooks/sessions/index.d.ts +0 -8
- package/dist/hooks/sessions/index.d.ts.map +0 -1
- package/dist/hooks/sessions/useSessionExecutions.d.ts +0 -13
- package/dist/hooks/sessions/useSessionExecutions.d.ts.map +0 -1
- package/dist/hooks/sessions/useSessionMessages.d.ts +0 -7
- package/dist/hooks/sessions/useSessionMessages.d.ts.map +0 -1
- package/dist/hooks/sessions/useSessions.d.ts +0 -26
- package/dist/hooks/sessions/useSessions.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/initialization/InitializationProvider.d.ts +0 -48
- package/dist/initialization/InitializationProvider.d.ts.map +0 -1
- package/dist/initialization/hooks/useAppInitialization.d.ts +0 -32
- package/dist/initialization/hooks/useAppInitialization.d.ts.map +0 -1
- package/dist/initialization/index.d.ts.map +0 -1
- package/dist/organization/context/OrganizationProvider.d.ts +0 -20
- package/dist/organization/context/OrganizationProvider.d.ts.map +0 -1
- package/dist/organization/hooks/useOrgInitialization.d.ts +0 -56
- package/dist/organization/hooks/useOrgInitialization.d.ts.map +0 -1
- package/dist/organization/index.d.ts.map +0 -1
- package/dist/profile/context/ProfileProvider.d.ts +0 -27
- package/dist/profile/context/ProfileProvider.d.ts.map +0 -1
- package/dist/profile/hooks/useUserProfile.d.ts +0 -31
- package/dist/profile/hooks/useUserProfile.d.ts.map +0 -1
- package/dist/profile/index.d.ts.map +0 -1
- package/dist/provider/CoreAuthKitInner.d.ts +0 -12
- package/dist/provider/CoreAuthKitInner.d.ts.map +0 -1
- package/dist/provider/ElevasisCoreProvider.d.ts +0 -39
- package/dist/provider/ElevasisCoreProvider.d.ts.map +0 -1
- package/dist/provider/ElevasisServiceContext.d.ts +0 -31
- package/dist/provider/ElevasisServiceContext.d.ts.map +0 -1
- package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts +0 -2
- package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts.map +0 -1
- package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts +0 -2
- package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts.map +0 -1
- package/dist/provider/index.d.ts.map +0 -1
- package/dist/provider/published.d.ts.map +0 -1
- package/dist/provider/types.d.ts +0 -143
- package/dist/provider/types.d.ts.map +0 -1
- package/dist/provider/types.js +0 -1
- package/dist/sdk-barrel.d.ts +0 -20
- package/dist/sdk-barrel.d.ts.map +0 -1
- package/dist/theme/cssVariables.d.ts +0 -12
- package/dist/theme/cssVariables.d.ts.map +0 -1
- package/dist/theme/cssVariables.js +0 -93
- package/dist/theme/index.d.ts +0 -4
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js +0 -1
- package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
- package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
- package/dist/theme/presets/abyss.d.ts +0 -3
- package/dist/theme/presets/abyss.d.ts.map +0 -1
- package/dist/theme/presets/abyss.js +0 -54
- package/dist/theme/presets/aurora.d.ts +0 -8
- package/dist/theme/presets/aurora.d.ts.map +0 -1
- package/dist/theme/presets/aurora.js +0 -59
- package/dist/theme/presets/canopy.d.ts +0 -3
- package/dist/theme/presets/canopy.d.ts.map +0 -1
- package/dist/theme/presets/canopy.js +0 -58
- package/dist/theme/presets/cyber-flux.d.ts +0 -8
- package/dist/theme/presets/cyber-flux.d.ts.map +0 -1
- package/dist/theme/presets/cyber-flux.js +0 -66
- package/dist/theme/presets/cyber-strike.d.ts +0 -9
- package/dist/theme/presets/cyber-strike.d.ts.map +0 -1
- package/dist/theme/presets/cyber-strike.js +0 -62
- package/dist/theme/presets/cyber-void.d.ts +0 -8
- package/dist/theme/presets/cyber-void.d.ts.map +0 -1
- package/dist/theme/presets/cyber-void.js +0 -62
- package/dist/theme/presets/cyber-volt.d.ts +0 -8
- package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
- package/dist/theme/presets/cyber-volt.js +0 -66
- package/dist/theme/presets/default.d.ts +0 -4
- package/dist/theme/presets/default.d.ts.map +0 -1
- package/dist/theme/presets/ember.d.ts +0 -8
- package/dist/theme/presets/ember.d.ts.map +0 -1
- package/dist/theme/presets/ember.js +0 -63
- package/dist/theme/presets/honey.d.ts +0 -3
- package/dist/theme/presets/honey.d.ts.map +0 -1
- package/dist/theme/presets/honey.js +0 -62
- package/dist/theme/presets/index.d.ts +0 -6
- package/dist/theme/presets/index.d.ts.map +0 -1
- package/dist/theme/presets/index.js +0 -39
- package/dist/theme/presets/midnight.d.ts +0 -8
- package/dist/theme/presets/midnight.d.ts.map +0 -1
- package/dist/theme/presets/midnight.js +0 -68
- package/dist/theme/presets/obsidian.d.ts +0 -3
- package/dist/theme/presets/obsidian.d.ts.map +0 -1
- package/dist/theme/presets/obsidian.js +0 -56
- package/dist/theme/presets/regal.d.ts +0 -8
- package/dist/theme/presets/regal.d.ts.map +0 -1
- package/dist/theme/presets/regal.js +0 -63
- package/dist/theme/presets/rose-gold.d.ts +0 -8
- package/dist/theme/presets/rose-gold.d.ts.map +0 -1
- package/dist/theme/presets/rose-gold.js +0 -63
- package/dist/theme/presets/slate.d.ts +0 -3
- package/dist/theme/presets/slate.d.ts.map +0 -1
- package/dist/theme/presets/slate.js +0 -56
- package/dist/theme/presets/tactical.d.ts +0 -8
- package/dist/theme/presets/tactical.d.ts.map +0 -1
- package/dist/theme/presets/tactical.js +0 -57
- package/dist/theme/presets/types.d.ts +0 -26
- package/dist/theme/presets/types.d.ts.map +0 -1
- package/dist/theme/presets/types.js +0 -1
|
@@ -1,22 +1,267 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { UseBoundStore, StoreApi } from 'zustand';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
* Multi-tenancy configuration types
|
|
7
|
+
*
|
|
8
|
+
* Config is stored in dedicated `config` columns (NOT nested in metadata):
|
|
9
|
+
* - organizations.config: Org-level feature config
|
|
10
|
+
* - org_memberships.config: Per-user-per-org feature overrides
|
|
11
|
+
* - users.config: User-global config
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Org-level feature config (stored in organizations.config)
|
|
15
|
+
* Controls which features are available to all org members
|
|
16
|
+
* Valid feature keys: operations, monitoring, acquisition, calibration, seo
|
|
17
|
+
*/
|
|
18
|
+
interface OrgFeatureConfig {
|
|
19
|
+
features?: {
|
|
20
|
+
operations?: boolean;
|
|
21
|
+
monitoring?: boolean;
|
|
22
|
+
acquisition?: boolean;
|
|
23
|
+
calibration?: boolean;
|
|
24
|
+
seo?: boolean;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Per-user-per-org config (stored in org_memberships.config)
|
|
29
|
+
* Overrides org-level feature config for specific users
|
|
30
|
+
*/
|
|
31
|
+
type MembershipFeatureConfig = OrgFeatureConfig;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Organization Membership types based on WorkOS API
|
|
35
|
+
*/
|
|
36
|
+
interface OrganizationMembership {
|
|
37
|
+
object: 'organization_membership';
|
|
38
|
+
id: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
organizationId: string;
|
|
41
|
+
role: {
|
|
42
|
+
slug: string;
|
|
43
|
+
};
|
|
44
|
+
status: 'active' | 'inactive';
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extended membership with user and organization details for UI
|
|
50
|
+
*/
|
|
51
|
+
interface MembershipWithDetails extends OrganizationMembership {
|
|
52
|
+
user?: {
|
|
53
|
+
id: string;
|
|
54
|
+
email: string;
|
|
55
|
+
firstName?: string;
|
|
56
|
+
lastName?: string;
|
|
57
|
+
profilePictureUrl?: string;
|
|
58
|
+
};
|
|
59
|
+
organization?: {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
workos_org_id: string;
|
|
63
|
+
primaryDomain?: string;
|
|
64
|
+
is_test?: boolean;
|
|
65
|
+
status?: string;
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
67
|
+
config?: OrgFeatureConfig;
|
|
68
|
+
};
|
|
69
|
+
config?: MembershipFeatureConfig;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The value exposed by OrganizationProvider to all consumers.
|
|
74
|
+
*/
|
|
75
|
+
interface OrganizationContextValue {
|
|
76
|
+
/** WorkOS organization ID of the currently selected organization. */
|
|
77
|
+
currentWorkOSOrganizationId: string | null;
|
|
78
|
+
/** Supabase (UUID) organization ID of the currently selected organization. */
|
|
79
|
+
currentSupabaseOrganizationId: string | null;
|
|
80
|
+
/** Full membership record for the currently selected organization. */
|
|
81
|
+
currentMembership: MembershipWithDetails | null;
|
|
82
|
+
/** All memberships for the authenticated user. */
|
|
83
|
+
memberships: MembershipWithDetails[];
|
|
84
|
+
/** True while the initial membership list is being fetched. */
|
|
85
|
+
isInitializing: boolean;
|
|
86
|
+
/** True while a subsequent org switch / refresh is in flight. */
|
|
87
|
+
isOrgRefreshing: boolean;
|
|
88
|
+
/** Error message if the membership fetch or org switch failed. */
|
|
89
|
+
error: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Switch the active organization.
|
|
92
|
+
*
|
|
93
|
+
* Persists the selection to `last_visited_org` on the user profile and
|
|
94
|
+
* invalidates all org-scoped TanStack Query cache entries.
|
|
95
|
+
*
|
|
96
|
+
* @param workosOrgId - WorkOS organization ID to switch to.
|
|
97
|
+
*/
|
|
98
|
+
switchOrganization: (workosOrgId: string) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Re-fetch memberships and retry org selection after an error.
|
|
101
|
+
*/
|
|
102
|
+
retry: () => Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Consumes the nearest OrganizationProvider.
|
|
106
|
+
*
|
|
107
|
+
* @throws {Error} If called outside of an OrganizationProvider tree.
|
|
108
|
+
*/
|
|
109
|
+
declare function useOrganization(): OrganizationContextValue;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Provides organization state to its subtree via React Context.
|
|
113
|
+
*
|
|
114
|
+
* Must be rendered inside:
|
|
115
|
+
* - ElevasisServiceProvider (needs apiRequest)
|
|
116
|
+
* - ProfileProvider (needs useProfile for last_visited_org preference)
|
|
117
|
+
* - A TanStack QueryClientProvider (needs useQueryClient for cache invalidation)
|
|
118
|
+
*
|
|
119
|
+
* Behaviors:
|
|
120
|
+
* - Fetches all memberships for the authenticated user via GET /memberships/my-memberships
|
|
121
|
+
* - Selects the active org by priority: saved preference > WorkOS org ID > first membership
|
|
122
|
+
* - Persists org switches to PATCH /users/me { last_visited_org }
|
|
123
|
+
* - Clears all state when the user signs out (user becomes null)
|
|
124
|
+
*/
|
|
125
|
+
declare function OrganizationProvider({ children }: {
|
|
126
|
+
children: ReactNode;
|
|
127
|
+
}): react.FunctionComponentElement<react.ProviderProps<OrganizationContextValue | null>>;
|
|
128
|
+
|
|
129
|
+
interface OrganizationsState {
|
|
130
|
+
currentWorkOSOrganizationId: string | null;
|
|
131
|
+
currentSupabaseOrganizationId: string | null;
|
|
132
|
+
currentMembership: MembershipWithDetails | null;
|
|
133
|
+
isInitializing: boolean;
|
|
134
|
+
isOrgRefreshing: boolean;
|
|
135
|
+
error: string | null;
|
|
136
|
+
}
|
|
137
|
+
interface OrganizationsActions {
|
|
138
|
+
setCurrentWorkOSOrganizationId: (workOSorgId: string | null) => void;
|
|
139
|
+
setCurrentMembership: (membership: MembershipWithDetails | null) => void;
|
|
140
|
+
setOrganizationsInitializing: (initializing: boolean) => void;
|
|
141
|
+
setOrganizationsLoading: (loading: boolean) => void;
|
|
142
|
+
setOrganizationsError: (error: string | null) => void;
|
|
143
|
+
}
|
|
144
|
+
interface OrganizationsSlice extends OrganizationsActions {
|
|
145
|
+
organizations: OrganizationsState;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Type for Zustand's immer set function.
|
|
150
|
+
* This is a simplified version that works with immer middleware.
|
|
151
|
+
* The replace parameter uses false | undefined to match Zustand's type for immer mutation support.
|
|
152
|
+
*/
|
|
153
|
+
type ImmerSet<T> = (partial: T | Partial<T> | ((state: T) => void), replace?: false | undefined, action?: string) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Creates the organizations slice for Zustand store.
|
|
156
|
+
*
|
|
157
|
+
* Usage in app:
|
|
158
|
+
* ```typescript
|
|
159
|
+
* import { createOrganizationsSlice } from '@repo/ui/organization'
|
|
160
|
+
*
|
|
161
|
+
* // Define AppState that extends OrganizationsSlice
|
|
162
|
+
* interface AppState extends OrganizationsSlice {
|
|
163
|
+
* // other slices...
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* // Pass the slice creator to your store
|
|
167
|
+
* const useAppStore = create<AppState>()(
|
|
168
|
+
* devtools(
|
|
169
|
+
* immer((...a) => ({
|
|
170
|
+
* ...createOrganizationsSlice(...a),
|
|
171
|
+
* // other slices...
|
|
172
|
+
* }))
|
|
173
|
+
* )
|
|
174
|
+
* )
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* Note: The slice creator accepts set/get/store from any Zustand store
|
|
178
|
+
* that extends OrganizationsSlice. It returns the slice state and actions.
|
|
179
|
+
*/
|
|
180
|
+
declare const createOrganizationsSlice: <TAppState extends OrganizationsSlice>(set: ImmerSet<TAppState>, _get: () => TAppState, _store: unknown) => OrganizationsSlice;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Factory function to create a useOrganizations hook for your app's store.
|
|
184
|
+
*
|
|
185
|
+
* Usage in app:
|
|
186
|
+
* ```typescript
|
|
187
|
+
* import { createUseOrganizations } from '@repo/ui/organization'
|
|
188
|
+
* import { useAppStore } from './zustand/store'
|
|
189
|
+
*
|
|
190
|
+
* export const useOrganizations = createUseOrganizations(useAppStore)
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* This pattern allows the shared package to provide the hook logic
|
|
194
|
+
* while each app provides its own store instance.
|
|
195
|
+
*/
|
|
196
|
+
declare function createUseOrganizations<TStore extends OrganizationsSlice>(useStore: UseBoundStore<StoreApi<TStore>>): () => {
|
|
197
|
+
setCurrentWorkOSOrganizationId: (workOSorgId: string | null) => void;
|
|
198
|
+
setCurrentMembership: (membership: MembershipWithDetails | null) => void;
|
|
199
|
+
setOrganizationsInitializing: (initializing: boolean) => void;
|
|
200
|
+
setOrganizationsLoading: (loading: boolean) => void;
|
|
201
|
+
setOrganizationsError: (error: string | null) => void;
|
|
202
|
+
organizations: OrganizationsState;
|
|
203
|
+
currentWorkOSOrganizationId: string | null;
|
|
204
|
+
currentSupabaseOrganizationId: string | null;
|
|
205
|
+
currentMembership: MembershipWithDetails | null;
|
|
206
|
+
isInitializing: boolean;
|
|
207
|
+
isOrgRefreshing: boolean;
|
|
208
|
+
error: string | null;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Type for the useOrganizations hook return value
|
|
213
|
+
*/
|
|
214
|
+
interface UseOrganizationsReturn {
|
|
215
|
+
currentWorkOSOrganizationId: string | null;
|
|
216
|
+
currentMembership: MembershipWithDetails | null;
|
|
217
|
+
setCurrentWorkOSOrganizationId: (id: string | null) => void;
|
|
218
|
+
setCurrentMembership: (membership: MembershipWithDetails | null) => void;
|
|
219
|
+
setOrganizationsInitializing: (initializing: boolean) => void;
|
|
220
|
+
setOrganizationsLoading: (loading: boolean) => void;
|
|
221
|
+
setOrganizationsError: (error: string | null) => void;
|
|
222
|
+
organizations: {
|
|
223
|
+
isInitializing: boolean;
|
|
224
|
+
isOrgRefreshing: boolean;
|
|
225
|
+
error: string | null;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Type for the useApiClient hook return value
|
|
230
|
+
*/
|
|
231
|
+
interface UseApiClientReturn {
|
|
232
|
+
apiRequest: <T = unknown>(path: string, options?: RequestInit) => Promise<T>;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Return type for useOrgInitialization hook
|
|
236
|
+
*/
|
|
237
|
+
interface UseOrgInitializationReturn {
|
|
238
|
+
memberships: MembershipWithDetails[];
|
|
239
|
+
isInitializing: boolean;
|
|
240
|
+
isLoading: boolean;
|
|
241
|
+
isInitialized: boolean;
|
|
242
|
+
error: string | null;
|
|
243
|
+
currentOrganization: MembershipWithDetails['organization'] | null;
|
|
244
|
+
retry: () => Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Factory function to create a useOrgInitialization hook for your app.
|
|
248
|
+
*
|
|
249
|
+
* Usage in app:
|
|
250
|
+
* ```typescript
|
|
251
|
+
* import { createUseOrgInitialization } from '@repo/ui/organization'
|
|
252
|
+
* import { useOrganizations } from './hooks/useOrganizations'
|
|
253
|
+
* import { useApiClient } from './api/hooks/useApiClient'
|
|
254
|
+
*
|
|
255
|
+
* export const useOrgInitialization = createUseOrgInitialization(
|
|
256
|
+
* useOrganizations,
|
|
257
|
+
* useApiClient
|
|
258
|
+
* )
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* This pattern allows the shared package to provide the hook logic
|
|
262
|
+
* while each app provides its own hook instances.
|
|
263
|
+
*/
|
|
264
|
+
declare function createUseOrgInitialization(useOrganizations: () => UseOrganizationsReturn, useApiClient: () => UseApiClientReturn): () => UseOrgInitializationReturn;
|
|
265
|
+
|
|
266
|
+
export { OrganizationProvider, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations, useOrganization };
|
|
267
|
+
export type { MembershipWithDetails, OrganizationContextValue, OrganizationsActions, OrganizationsSlice, OrganizationsState, UseApiClientReturn, UseOrgInitializationReturn, UseOrganizationsReturn };
|