@elevasis/ui 1.3.3 → 1.3.5

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 (213) hide show
  1. package/dist/api/index.js +1 -1
  2. package/dist/auth/index.d.ts +174 -14
  3. package/dist/{chunk-XLV6LYN2.js → chunk-LBPALY25.js} +0 -1
  4. package/dist/{chunk-LTQAAIGE.js → chunk-Y2I5JJ3N.js} +1 -1
  5. package/dist/hooks/index.d.ts +4401 -11
  6. package/dist/hooks/published.d.ts +5013 -19
  7. package/dist/index.d.ts +6316 -15
  8. package/dist/index.js +18 -97
  9. package/dist/initialization/index.d.ts +2222 -22
  10. package/dist/organization/index.d.ts +266 -21
  11. package/dist/profile/index.d.ts +2158 -14
  12. package/dist/provider/index.d.ts +266 -7
  13. package/dist/provider/index.js +12 -3
  14. package/dist/provider/published.d.ts +263 -9
  15. package/dist/provider/published.js +2 -2
  16. package/package.json +47 -3
  17. package/dist/auth/guards/AdminGuard.d.ts +0 -32
  18. package/dist/auth/guards/AdminGuard.d.ts.map +0 -1
  19. package/dist/auth/guards/ProtectedRoute.d.ts +0 -60
  20. package/dist/auth/guards/ProtectedRoute.d.ts.map +0 -1
  21. package/dist/auth/guards/__tests__/AdminGuard.test.d.ts +0 -12
  22. package/dist/auth/guards/__tests__/AdminGuard.test.d.ts.map +0 -1
  23. package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts +0 -14
  24. package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts.map +0 -1
  25. package/dist/auth/index.d.ts.map +0 -1
  26. package/dist/hooks/command-queue/index.d.ts +0 -7
  27. package/dist/hooks/command-queue/index.d.ts.map +0 -1
  28. package/dist/hooks/command-queue/useCommandQueue.d.ts +0 -33
  29. package/dist/hooks/command-queue/useCommandQueue.d.ts.map +0 -1
  30. package/dist/hooks/command-queue/useCommandQueueTotals.d.ts +0 -17
  31. package/dist/hooks/command-queue/useCommandQueueTotals.d.ts.map +0 -1
  32. package/dist/hooks/command-queue/useDeleteTask.d.ts +0 -5
  33. package/dist/hooks/command-queue/useDeleteTask.d.ts.map +0 -1
  34. package/dist/hooks/command-queue/usePatchTask.d.ts +0 -6
  35. package/dist/hooks/command-queue/usePatchTask.d.ts.map +0 -1
  36. package/dist/hooks/command-queue/useSubmitAction.d.ts +0 -29
  37. package/dist/hooks/command-queue/useSubmitAction.d.ts.map +0 -1
  38. package/dist/hooks/executions/index.d.ts +0 -16
  39. package/dist/hooks/executions/index.d.ts.map +0 -1
  40. package/dist/hooks/executions/useBulkDeleteExecutions.d.ts +0 -15
  41. package/dist/hooks/executions/useBulkDeleteExecutions.d.ts.map +0 -1
  42. package/dist/hooks/executions/useCancelExecution.d.ts +0 -20
  43. package/dist/hooks/executions/useCancelExecution.d.ts.map +0 -1
  44. package/dist/hooks/executions/useDeleteExecution.d.ts +0 -13
  45. package/dist/hooks/executions/useDeleteExecution.d.ts.map +0 -1
  46. package/dist/hooks/executions/useExecuteAsync.d.ts +0 -21
  47. package/dist/hooks/executions/useExecuteAsync.d.ts.map +0 -1
  48. package/dist/hooks/executions/useExecution.d.ts +0 -10
  49. package/dist/hooks/executions/useExecution.d.ts.map +0 -1
  50. package/dist/hooks/executions/useExecutions.d.ts +0 -16
  51. package/dist/hooks/executions/useExecutions.d.ts.map +0 -1
  52. package/dist/hooks/executions/useResourceDefinition.d.ts +0 -9
  53. package/dist/hooks/executions/useResourceDefinition.d.ts.map +0 -1
  54. package/dist/hooks/executions/useResources.d.ts +0 -15
  55. package/dist/hooks/executions/useResources.d.ts.map +0 -1
  56. package/dist/hooks/executions/useRetryExecution.d.ts +0 -16
  57. package/dist/hooks/executions/useRetryExecution.d.ts.map +0 -1
  58. package/dist/hooks/feature-access/createUseFeatureAccess.d.ts +0 -44
  59. package/dist/hooks/feature-access/createUseFeatureAccess.d.ts.map +0 -1
  60. package/dist/hooks/feature-access/index.d.ts +0 -2
  61. package/dist/hooks/feature-access/index.d.ts.map +0 -1
  62. package/dist/hooks/index.d.ts.map +0 -1
  63. package/dist/hooks/monitoring/index.d.ts +0 -9
  64. package/dist/hooks/monitoring/index.d.ts.map +0 -1
  65. package/dist/hooks/monitoring/useActivities.d.ts +0 -52
  66. package/dist/hooks/monitoring/useActivities.d.ts.map +0 -1
  67. package/dist/hooks/monitoring/useCostSummary.d.ts +0 -7
  68. package/dist/hooks/monitoring/useCostSummary.d.ts.map +0 -1
  69. package/dist/hooks/monitoring/useExecutionHealth.d.ts +0 -10
  70. package/dist/hooks/monitoring/useExecutionHealth.d.ts.map +0 -1
  71. package/dist/hooks/monitoring/useExecutionLogs.d.ts +0 -56
  72. package/dist/hooks/monitoring/useExecutionLogs.d.ts.map +0 -1
  73. package/dist/hooks/monitoring/useNotifications.d.ts +0 -11
  74. package/dist/hooks/monitoring/useNotifications.d.ts.map +0 -1
  75. package/dist/hooks/notifications/index.d.ts +0 -8
  76. package/dist/hooks/notifications/index.d.ts.map +0 -1
  77. package/dist/hooks/notifications/useMarkAllAsRead.d.ts +0 -2
  78. package/dist/hooks/notifications/useMarkAllAsRead.d.ts.map +0 -1
  79. package/dist/hooks/notifications/useMarkAsRead.d.ts +0 -2
  80. package/dist/hooks/notifications/useMarkAsRead.d.ts.map +0 -1
  81. package/dist/hooks/notifications/useNotificationCount.d.ts +0 -8
  82. package/dist/hooks/notifications/useNotificationCount.d.ts.map +0 -1
  83. package/dist/hooks/observability/index.d.ts +0 -19
  84. package/dist/hooks/observability/index.d.ts.map +0 -1
  85. package/dist/hooks/observability/useBusinessImpact.d.ts +0 -9
  86. package/dist/hooks/observability/useBusinessImpact.d.ts.map +0 -1
  87. package/dist/hooks/observability/useCostBreakdown.d.ts +0 -10
  88. package/dist/hooks/observability/useCostBreakdown.d.ts.map +0 -1
  89. package/dist/hooks/observability/useCostByModel.d.ts +0 -3
  90. package/dist/hooks/observability/useCostByModel.d.ts.map +0 -1
  91. package/dist/hooks/observability/useCostTrends.d.ts +0 -3
  92. package/dist/hooks/observability/useCostTrends.d.ts.map +0 -1
  93. package/dist/hooks/observability/useDashboardMetrics.d.ts +0 -3
  94. package/dist/hooks/observability/useDashboardMetrics.d.ts.map +0 -1
  95. package/dist/hooks/observability/useErrorAnalysis.d.ts +0 -7
  96. package/dist/hooks/observability/useErrorAnalysis.d.ts.map +0 -1
  97. package/dist/hooks/observability/useErrorDetails.d.ts +0 -20
  98. package/dist/hooks/observability/useErrorDetails.d.ts.map +0 -1
  99. package/dist/hooks/observability/useErrorDistribution.d.ts +0 -12
  100. package/dist/hooks/observability/useErrorDistribution.d.ts.map +0 -1
  101. package/dist/hooks/observability/useErrorTrends.d.ts +0 -12
  102. package/dist/hooks/observability/useErrorTrends.d.ts.map +0 -1
  103. package/dist/hooks/observability/useResolveError.d.ts +0 -17
  104. package/dist/hooks/observability/useResolveError.d.ts.map +0 -1
  105. package/dist/hooks/observability/useTopFailingResources.d.ts +0 -13
  106. package/dist/hooks/observability/useTopFailingResources.d.ts.map +0 -1
  107. package/dist/hooks/published.d.ts.map +0 -1
  108. package/dist/hooks/scheduling/index.d.ts +0 -5
  109. package/dist/hooks/scheduling/index.d.ts.map +0 -1
  110. package/dist/hooks/scheduling/useSchedules.d.ts +0 -185
  111. package/dist/hooks/scheduling/useSchedules.d.ts.map +0 -1
  112. package/dist/hooks/sessions/index.d.ts +0 -8
  113. package/dist/hooks/sessions/index.d.ts.map +0 -1
  114. package/dist/hooks/sessions/useSessionExecutions.d.ts +0 -13
  115. package/dist/hooks/sessions/useSessionExecutions.d.ts.map +0 -1
  116. package/dist/hooks/sessions/useSessionMessages.d.ts +0 -7
  117. package/dist/hooks/sessions/useSessionMessages.d.ts.map +0 -1
  118. package/dist/hooks/sessions/useSessions.d.ts +0 -26
  119. package/dist/hooks/sessions/useSessions.d.ts.map +0 -1
  120. package/dist/index.d.ts.map +0 -1
  121. package/dist/initialization/InitializationProvider.d.ts +0 -48
  122. package/dist/initialization/InitializationProvider.d.ts.map +0 -1
  123. package/dist/initialization/hooks/useAppInitialization.d.ts +0 -32
  124. package/dist/initialization/hooks/useAppInitialization.d.ts.map +0 -1
  125. package/dist/initialization/index.d.ts.map +0 -1
  126. package/dist/organization/context/OrganizationProvider.d.ts +0 -20
  127. package/dist/organization/context/OrganizationProvider.d.ts.map +0 -1
  128. package/dist/organization/hooks/useOrgInitialization.d.ts +0 -56
  129. package/dist/organization/hooks/useOrgInitialization.d.ts.map +0 -1
  130. package/dist/organization/index.d.ts.map +0 -1
  131. package/dist/profile/context/ProfileProvider.d.ts +0 -27
  132. package/dist/profile/context/ProfileProvider.d.ts.map +0 -1
  133. package/dist/profile/hooks/useUserProfile.d.ts +0 -31
  134. package/dist/profile/hooks/useUserProfile.d.ts.map +0 -1
  135. package/dist/profile/index.d.ts.map +0 -1
  136. package/dist/provider/CoreAuthKitInner.d.ts +0 -12
  137. package/dist/provider/CoreAuthKitInner.d.ts.map +0 -1
  138. package/dist/provider/ElevasisCoreProvider.d.ts +0 -39
  139. package/dist/provider/ElevasisCoreProvider.d.ts.map +0 -1
  140. package/dist/provider/ElevasisServiceContext.d.ts +0 -31
  141. package/dist/provider/ElevasisServiceContext.d.ts.map +0 -1
  142. package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts +0 -2
  143. package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts.map +0 -1
  144. package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts +0 -2
  145. package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts.map +0 -1
  146. package/dist/provider/index.d.ts.map +0 -1
  147. package/dist/provider/published.d.ts.map +0 -1
  148. package/dist/provider/types.d.ts +0 -143
  149. package/dist/provider/types.d.ts.map +0 -1
  150. package/dist/provider/types.js +0 -1
  151. package/dist/sdk-barrel.d.ts +0 -20
  152. package/dist/sdk-barrel.d.ts.map +0 -1
  153. package/dist/theme/cssVariables.d.ts +0 -12
  154. package/dist/theme/cssVariables.d.ts.map +0 -1
  155. package/dist/theme/cssVariables.js +0 -93
  156. package/dist/theme/index.d.ts +0 -4
  157. package/dist/theme/index.d.ts.map +0 -1
  158. package/dist/theme/index.js +0 -1
  159. package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
  160. package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
  161. package/dist/theme/presets/abyss.d.ts +0 -3
  162. package/dist/theme/presets/abyss.d.ts.map +0 -1
  163. package/dist/theme/presets/abyss.js +0 -54
  164. package/dist/theme/presets/aurora.d.ts +0 -8
  165. package/dist/theme/presets/aurora.d.ts.map +0 -1
  166. package/dist/theme/presets/aurora.js +0 -59
  167. package/dist/theme/presets/canopy.d.ts +0 -3
  168. package/dist/theme/presets/canopy.d.ts.map +0 -1
  169. package/dist/theme/presets/canopy.js +0 -58
  170. package/dist/theme/presets/cyber-flux.d.ts +0 -8
  171. package/dist/theme/presets/cyber-flux.d.ts.map +0 -1
  172. package/dist/theme/presets/cyber-flux.js +0 -66
  173. package/dist/theme/presets/cyber-strike.d.ts +0 -9
  174. package/dist/theme/presets/cyber-strike.d.ts.map +0 -1
  175. package/dist/theme/presets/cyber-strike.js +0 -62
  176. package/dist/theme/presets/cyber-void.d.ts +0 -8
  177. package/dist/theme/presets/cyber-void.d.ts.map +0 -1
  178. package/dist/theme/presets/cyber-void.js +0 -62
  179. package/dist/theme/presets/cyber-volt.d.ts +0 -8
  180. package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
  181. package/dist/theme/presets/cyber-volt.js +0 -66
  182. package/dist/theme/presets/default.d.ts +0 -4
  183. package/dist/theme/presets/default.d.ts.map +0 -1
  184. package/dist/theme/presets/ember.d.ts +0 -8
  185. package/dist/theme/presets/ember.d.ts.map +0 -1
  186. package/dist/theme/presets/ember.js +0 -63
  187. package/dist/theme/presets/honey.d.ts +0 -3
  188. package/dist/theme/presets/honey.d.ts.map +0 -1
  189. package/dist/theme/presets/honey.js +0 -62
  190. package/dist/theme/presets/index.d.ts +0 -6
  191. package/dist/theme/presets/index.d.ts.map +0 -1
  192. package/dist/theme/presets/index.js +0 -39
  193. package/dist/theme/presets/midnight.d.ts +0 -8
  194. package/dist/theme/presets/midnight.d.ts.map +0 -1
  195. package/dist/theme/presets/midnight.js +0 -68
  196. package/dist/theme/presets/obsidian.d.ts +0 -3
  197. package/dist/theme/presets/obsidian.d.ts.map +0 -1
  198. package/dist/theme/presets/obsidian.js +0 -56
  199. package/dist/theme/presets/regal.d.ts +0 -8
  200. package/dist/theme/presets/regal.d.ts.map +0 -1
  201. package/dist/theme/presets/regal.js +0 -63
  202. package/dist/theme/presets/rose-gold.d.ts +0 -8
  203. package/dist/theme/presets/rose-gold.d.ts.map +0 -1
  204. package/dist/theme/presets/rose-gold.js +0 -63
  205. package/dist/theme/presets/slate.d.ts +0 -3
  206. package/dist/theme/presets/slate.d.ts.map +0 -1
  207. package/dist/theme/presets/slate.js +0 -56
  208. package/dist/theme/presets/tactical.d.ts +0 -8
  209. package/dist/theme/presets/tactical.d.ts.map +0 -1
  210. package/dist/theme/presets/tactical.js +0 -57
  211. package/dist/theme/presets/types.d.ts +0 -26
  212. package/dist/theme/presets/types.d.ts.map +0 -1
  213. 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
- * Organization module - Multi-tenancy concerns
3
- *
4
- * Exports:
5
- * - OrganizationProvider: Context provider that internalizes org state (replaces Zustand slice)
6
- * - useOrganization: Hook for consuming OrganizationProvider context
7
- * - OrganizationContextValue: Value type exposed by OrganizationProvider
8
- * - OrganizationsState, OrganizationsActions, OrganizationsSlice: Store types (legacy)
9
- * - createOrganizationsSlice: Zustand slice creator for organization state (legacy)
10
- * - createUseOrganizations: Factory to create useOrganizations hook for app's store (deprecated)
11
- * - createUseOrgInitialization: Factory to create useOrgInitialization hook (deprecated)
12
- * - OrganizationSwitcher: Component for switching organizations
13
- */
14
- export { OrganizationProvider } from './context/OrganizationProvider';
15
- export { useOrganization } from './context/OrganizationContext';
16
- export type { OrganizationContextValue } from './context/OrganizationContext';
17
- export * from './store/types';
18
- export { createOrganizationsSlice } from './store/organizationsSlice';
19
- export { createUseOrganizations } from './hooks/useOrganizations';
20
- export { createUseOrgInitialization } from './hooks/useOrgInitialization';
21
- export type { UseOrganizationsReturn, UseApiClientReturn, UseOrgInitializationReturn } from './hooks/useOrgInitialization';
22
- //# sourceMappingURL=index.d.ts.map
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 };