@jmruthers/pace-core 0.5.87 → 0.5.88

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 (242) hide show
  1. package/dist/{AuthService-Df3IozMG.d.ts → AuthService-DcTI5Ov4.d.ts} +9 -0
  2. package/dist/{DataTable-FA6EUX5M.js → DataTable-PWBMKMOG.js} +7 -7
  3. package/dist/{PublicLoadingSpinner-DecuJBX0.d.ts → PublicLoadingSpinner-BQXD1fbO.d.ts} +160 -130
  4. package/dist/{UnifiedAuthProvider-K2IZAY5F.js → UnifiedAuthProvider-5D3HEQND.js} +4 -4
  5. package/dist/{UnifiedAuthProvider-B391Aqum.d.ts → UnifiedAuthProvider-BVKmQd9u.d.ts} +4 -0
  6. package/dist/auth-DReDSLq9.d.ts +16 -0
  7. package/dist/{chunk-CBSD3BZ3.js → chunk-3RZBKQ5Y.js} +2 -6
  8. package/dist/{chunk-CBSD3BZ3.js.map → chunk-3RZBKQ5Y.js.map} +1 -1
  9. package/dist/{chunk-NTW3KGS4.js → chunk-6UHXQH7P.js} +5 -5
  10. package/dist/{chunk-YVUZWLQG.js → chunk-AQGF5OG7.js} +3 -3
  11. package/dist/{chunk-CVMVPYAL.js → chunk-BDZUMRBD.js} +3 -5
  12. package/dist/chunk-BDZUMRBD.js.map +1 -0
  13. package/dist/{chunk-KAY3K5TP.js → chunk-BNXBJOGL.js} +4 -4
  14. package/dist/{chunk-I7O3RSMN.js → chunk-CJIZS3UE.js} +1298 -769
  15. package/dist/chunk-CJIZS3UE.js.map +1 -0
  16. package/dist/{chunk-S3JKDMD5.js → chunk-CXKMRKRF.js} +4 -4
  17. package/dist/{chunk-5BN3YGNK.js → chunk-DP5X5ORK.js} +217 -27
  18. package/dist/chunk-DP5X5ORK.js.map +1 -0
  19. package/dist/{chunk-ZFLOV3OM.js → chunk-H3P2RGKZ.js} +352 -16
  20. package/dist/chunk-H3P2RGKZ.js.map +1 -0
  21. package/dist/{chunk-RIXPZJUB.js → chunk-KTPG5VCH.js} +2 -2
  22. package/dist/{chunk-WUXCWRL6.js → chunk-XJ2HZOBU.js} +6 -1
  23. package/dist/chunk-XJ2HZOBU.js.map +1 -0
  24. package/dist/{chunk-2FQEQUJT.js → chunk-XXVM53P4.js} +4 -4
  25. package/dist/{chunk-I2VVV5PQ.js → chunk-YY4YYM3E.js} +2 -2
  26. package/dist/components.d.ts +6 -55
  27. package/dist/components.js +24 -205
  28. package/dist/components.js.map +1 -1
  29. package/dist/{file-reference-9xUOnwyt.d.ts → file-reference-C9isKNPn.d.ts} +67 -2
  30. package/dist/hooks.js +9 -8
  31. package/dist/hooks.js.map +1 -1
  32. package/dist/index.d.ts +152 -26
  33. package/dist/index.js +64 -194
  34. package/dist/index.js.map +1 -1
  35. package/dist/providers.d.ts +5 -3
  36. package/dist/providers.js +3 -3
  37. package/dist/rbac/index.js +8 -8
  38. package/dist/types.d.ts +2 -1
  39. package/dist/types.js +3 -3
  40. package/dist/utils.js +2 -2
  41. package/docs/DOCUMENTATION_AUDIT.md +6 -6
  42. package/docs/DOCUMENTATION_STANDARD.md +137 -0
  43. package/docs/README.md +1 -1
  44. package/docs/api/classes/ColumnFactory.md +1 -1
  45. package/docs/api/classes/ErrorBoundary.md +1 -1
  46. package/docs/api/classes/InvalidScopeError.md +1 -1
  47. package/docs/api/classes/MissingUserContextError.md +1 -1
  48. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  49. package/docs/api/classes/PermissionDeniedError.md +1 -1
  50. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  51. package/docs/api/classes/RBACAuditManager.md +1 -1
  52. package/docs/api/classes/RBACCache.md +1 -1
  53. package/docs/api/classes/RBACEngine.md +1 -1
  54. package/docs/api/classes/RBACError.md +1 -1
  55. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  56. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  57. package/docs/api/classes/StorageUtils.md +83 -40
  58. package/docs/api/enums/FileCategory.md +56 -1
  59. package/docs/api/interfaces/AggregateConfig.md +1 -1
  60. package/docs/api/interfaces/ButtonProps.md +1 -1
  61. package/docs/api/interfaces/CardProps.md +1 -1
  62. package/docs/api/interfaces/ColorPalette.md +1 -1
  63. package/docs/api/interfaces/ColorShade.md +1 -1
  64. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  65. package/docs/api/interfaces/DataRecord.md +1 -1
  66. package/docs/api/interfaces/DataTableAction.md +1 -1
  67. package/docs/api/interfaces/DataTableColumn.md +1 -1
  68. package/docs/api/interfaces/DataTableProps.md +1 -1
  69. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  70. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  71. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  72. package/docs/api/interfaces/EventLogoProps.md +11 -11
  73. package/docs/api/interfaces/FileDisplayProps.md +10 -10
  74. package/docs/api/interfaces/FileMetadata.md +1 -1
  75. package/docs/api/interfaces/FileReference.md +1 -1
  76. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  77. package/docs/api/interfaces/FileUploadOptions.md +8 -8
  78. package/docs/api/interfaces/FileUploadProps.md +137 -42
  79. package/docs/api/interfaces/FooterProps.md +1 -1
  80. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  81. package/docs/api/interfaces/InputProps.md +1 -1
  82. package/docs/api/interfaces/LabelProps.md +1 -1
  83. package/docs/api/interfaces/LoginFormProps.md +1 -1
  84. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  85. package/docs/api/interfaces/NavigationContextType.md +1 -1
  86. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  87. package/docs/api/interfaces/NavigationItem.md +1 -1
  88. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  89. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  90. package/docs/api/interfaces/Organisation.md +1 -1
  91. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  92. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  93. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  94. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  95. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  96. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  97. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  98. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  99. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  100. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  101. package/docs/api/interfaces/PaletteData.md +1 -1
  102. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  103. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  104. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  105. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  106. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  107. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  108. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  109. package/docs/api/interfaces/RBACConfig.md +1 -1
  110. package/docs/api/interfaces/RBACLogger.md +1 -1
  111. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  112. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  113. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  114. package/docs/api/interfaces/RouteConfig.md +1 -1
  115. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  116. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  117. package/docs/api/interfaces/StorageConfig.md +1 -1
  118. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  119. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  120. package/docs/api/interfaces/StorageListOptions.md +1 -1
  121. package/docs/api/interfaces/StorageListResult.md +1 -1
  122. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  123. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  124. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  125. package/docs/api/interfaces/StyleImport.md +1 -1
  126. package/docs/api/interfaces/SwitchProps.md +1 -1
  127. package/docs/api/interfaces/ToastActionElement.md +1 -1
  128. package/docs/api/interfaces/ToastProps.md +1 -1
  129. package/docs/api/interfaces/UnifiedAuthContextType.md +83 -50
  130. package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
  131. package/docs/api/interfaces/UseEventLogoOptions.md +74 -0
  132. package/docs/api/interfaces/UseEventLogoReturn.md +81 -0
  133. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  134. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  135. package/docs/api/interfaces/UsePublicEventLogoOptions.md +6 -6
  136. package/docs/api/interfaces/UsePublicEventLogoReturn.md +6 -6
  137. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  138. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  139. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  140. package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
  141. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  142. package/docs/api/interfaces/UserEventAccess.md +11 -11
  143. package/docs/api/interfaces/UserMenuProps.md +1 -1
  144. package/docs/api/interfaces/UserProfile.md +1 -1
  145. package/docs/api/modules.md +290 -95
  146. package/docs/api-reference/components.md +1 -18
  147. package/docs/api-reference/hooks.md +1 -4
  148. package/docs/best-practices/testing.md +2 -0
  149. package/docs/documentation-index.md +1 -1
  150. package/docs/getting-started/faq.md +1 -1
  151. package/docs/implementation-guides/file-reference-system.md +592 -58
  152. package/docs/implementation-guides/file-upload-storage.md +137 -73
  153. package/docs/rbac/super-admin-guide.md +18 -70
  154. package/docs/testing/README.md +2 -0
  155. package/package.json +1 -1
  156. package/src/__tests__/TEST_STANDARD.md +674 -0
  157. package/src/__tests__/helpers/test-utils.tsx +3 -2
  158. package/src/components/DataTable/__tests__/{DataTable.comprehensive.test.tsx.skip → DataTable.comprehensive.test.tsx} +17 -18
  159. package/src/components/DataTable/__tests__/{DataTable.test.tsx.skip → DataTable.test.tsx} +14 -22
  160. package/src/components/DataTable/__tests__/{ssr.strict-mode.test.tsx.skip → ssr.strict-mode.test.tsx} +42 -47
  161. package/src/components/DataTable/components/__tests__/COVERAGE_NOTE.md +1 -1
  162. package/src/components/DataTable/examples/__tests__/PerformanceExample.test.tsx +13 -4
  163. package/src/components/DataTable/utils/__tests__/COVERAGE_NOTE.md +1 -1
  164. package/src/components/DataTable/utils/__tests__/performanceUtils.test.ts +10 -6
  165. package/src/components/FileDisplay/FileDisplay.test.tsx +257 -0
  166. package/src/components/{FileDisplay.tsx → FileDisplay/FileDisplay.tsx} +111 -10
  167. package/src/components/FileDisplay/index.tsx +4 -0
  168. package/src/components/FileUpload/FileUpload.test.tsx +171 -621
  169. package/src/components/FileUpload/FileUpload.tsx +512 -168
  170. package/src/components/FileUpload/index.tsx +4 -0
  171. package/src/components/Progress/Progress.test.tsx +38 -0
  172. package/src/components/PublicLayout/EventLogo.tsx +6 -4
  173. package/src/components/Select/Select.test.tsx +1 -1
  174. package/src/components/SessionRestorationLoader.tsx +48 -0
  175. package/src/components/Toast/Toast.tsx +13 -8
  176. package/src/components/index.ts +16 -16
  177. package/src/hooks/__tests__/ServiceHooks.test.tsx +615 -0
  178. package/src/hooks/public/usePublicEventLogo.ts +16 -20
  179. package/src/hooks/useEventLogo.ts +316 -0
  180. package/src/hooks/useEvents.ts +0 -5
  181. package/src/hooks/useFileReference.test.ts +659 -0
  182. package/src/hooks/useFileReference.ts +207 -3
  183. package/src/hooks/useSessionRestoration.ts +64 -0
  184. package/src/index.ts +17 -5
  185. package/src/providers/{UnifiedAuthProvider.test.simple.tsx → UnifiedAuthProvider.smoke.test.tsx} +81 -60
  186. package/src/providers/services/AuthServiceProvider.tsx +27 -3
  187. package/src/providers/services/UnifiedAuthProvider.tsx +34 -5
  188. package/src/rbac/{engine.test.simple.ts → RBACEngine.smoke.test.ts} +17 -12
  189. package/src/services/AuthService.ts +142 -20
  190. package/src/services/EventService.ts +0 -4
  191. package/src/types/auth.ts +15 -0
  192. package/src/types/file-reference.ts +73 -1
  193. package/src/types/index.ts +1 -0
  194. package/src/utils/__tests__/organisationContext.unit.test.ts +2 -4
  195. package/src/utils/appNameResolver.simple.test.ts +99 -29
  196. package/src/utils/file-reference.test.ts +535 -0
  197. package/src/utils/file-reference.ts +200 -30
  198. package/src/utils/organisationContext.test.ts +5 -19
  199. package/src/utils/organisationContext.ts +3 -5
  200. package/src/utils/storage/README.md +269 -262
  201. package/src/utils/storage/config.ts +9 -0
  202. package/src/utils/storage/helpers.test.ts +631 -0
  203. package/src/utils/storage/helpers.ts +112 -14
  204. package/src/utils/storage/index.ts +3 -0
  205. package/src/validation/__tests__/sanitization.unit.test.ts +1 -1
  206. package/src/validation/__tests__/schemaUtils.unit.test.ts +1 -1
  207. package/src/validation/__tests__/user.unit.test.ts +1 -1
  208. package/dist/chunk-5BN3YGNK.js.map +0 -1
  209. package/dist/chunk-CVMVPYAL.js.map +0 -1
  210. package/dist/chunk-I7O3RSMN.js.map +0 -1
  211. package/dist/chunk-WUXCWRL6.js.map +0 -1
  212. package/dist/chunk-ZFLOV3OM.js.map +0 -1
  213. package/docs/CONTENT_AUDIT_REPORT.md +0 -253
  214. package/docs/STYLE_GUIDE.md +0 -37
  215. package/examples/RBAC/__tests__/PermissionExample.test.tsx +0 -150
  216. package/examples/public-pages/__tests__/PublicPageUsageExample.test.tsx +0 -159
  217. package/src/__tests__/TEST_GUIDE_CURSOR.md +0 -1605
  218. package/src/__tests__/TEST_GUIDE_HUMAN.md +0 -103
  219. package/src/components/FileUpload/FileUpload.example.tsx +0 -218
  220. package/src/components/FileUpload/index.ts +0 -6
  221. package/src/components/FileUpload.tsx +0 -176
  222. package/src/components/Progress/index.ts +0 -3
  223. package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +0 -666
  224. package/src/components/SuperAdminGuard.tsx +0 -116
  225. package/src/components/__tests__/FileDisplay.test.tsx +0 -575
  226. package/src/components/__tests__/FileUpload.test.tsx +0 -446
  227. package/src/components/__tests__/SuperAdminGuard.test.tsx +0 -627
  228. package/src/components/examples/PermissionExample.tsx +0 -173
  229. package/src/hooks/__tests__/usePublicEvent.unit.test.ts +0 -583
  230. package/src/hooks/__tests__/usePublicEventLogo.unit.test.ts +0 -640
  231. package/src/types/__tests__/file-reference.test.ts +0 -447
  232. package/src/utils/__tests__/file-reference.test.ts +0 -383
  233. /package/dist/{DataTable-FA6EUX5M.js.map → DataTable-PWBMKMOG.js.map} +0 -0
  234. /package/dist/{UnifiedAuthProvider-K2IZAY5F.js.map → UnifiedAuthProvider-5D3HEQND.js.map} +0 -0
  235. /package/dist/{chunk-NTW3KGS4.js.map → chunk-6UHXQH7P.js.map} +0 -0
  236. /package/dist/{chunk-YVUZWLQG.js.map → chunk-AQGF5OG7.js.map} +0 -0
  237. /package/dist/{chunk-KAY3K5TP.js.map → chunk-BNXBJOGL.js.map} +0 -0
  238. /package/dist/{chunk-S3JKDMD5.js.map → chunk-CXKMRKRF.js.map} +0 -0
  239. /package/dist/{chunk-RIXPZJUB.js.map → chunk-KTPG5VCH.js.map} +0 -0
  240. /package/dist/{chunk-2FQEQUJT.js.map → chunk-XXVM53P4.js.map} +0 -0
  241. /package/dist/{chunk-I2VVV5PQ.js.map → chunk-YY4YYM3E.js.map} +0 -0
  242. /package/src/providers/{OrganisationProvider.test.simple.tsx → OrganisationProvider.context.test.tsx} +0 -0
@@ -3,6 +3,7 @@ import React__default from 'react';
3
3
  import { SupabaseClient, User, Session, AuthError } from '@supabase/supabase-js';
4
4
  import { E as Event } from './unified-DQ4VcT7H.js';
5
5
  import { O as Organisation, a as OrganisationMembership, d as OrganisationHierarchy } from './organisation-D6qRDtbF.js';
6
+ import { S as SessionRestorationState } from './auth-DReDSLq9.js';
6
7
 
7
8
  /**
8
9
  * @file Base Service Class
@@ -394,6 +395,10 @@ declare class AuthService extends BaseService implements IAuthService {
394
395
  private authError;
395
396
  private supabaseClient;
396
397
  private authStateSubscription;
398
+ private sessionRestorationState;
399
+ private restorationTimeoutId;
400
+ private readonly restorationTimeoutMs;
401
+ private restorationStartTime;
397
402
  constructor(supabaseClient: SupabaseClient);
398
403
  getUser(): User | null;
399
404
  getSession(): Session | null;
@@ -401,6 +406,7 @@ declare class AuthService extends BaseService implements IAuthService {
401
406
  isLoading(): boolean;
402
407
  getError(): AuthError | null;
403
408
  getSupabaseClient(): SupabaseClient | null;
409
+ getSessionRestorationState(): SessionRestorationState;
404
410
  signIn(email: string, password?: string): Promise<AuthResult>;
405
411
  signUp(email: string, password: string): Promise<AuthResult>;
406
412
  signOut(): Promise<AuthResult>;
@@ -411,6 +417,9 @@ declare class AuthService extends BaseService implements IAuthService {
411
417
  cleanup(): void;
412
418
  protected doInitialize(): Promise<void>;
413
419
  protected doCleanup(): void;
420
+ private startSessionRestoration;
421
+ private finishSessionRestoration;
422
+ private clearRestorationTimeout;
414
423
  private setupAuthStateListener;
415
424
  private restoreSession;
416
425
  private setupErrorHandlers;
@@ -53,8 +53,8 @@ import {
53
53
  sortHierarchicalDataWithSorting,
54
54
  validateHierarchicalData,
55
55
  validatePaginationConfig
56
- } from "./chunk-KAY3K5TP.js";
57
- import "./chunk-YVUZWLQG.js";
56
+ } from "./chunk-BNXBJOGL.js";
57
+ import "./chunk-AQGF5OG7.js";
58
58
  import "./chunk-S63MFSY6.js";
59
59
  import "./chunk-Q7APDV6H.js";
60
60
  import {
@@ -75,12 +75,12 @@ import {
75
75
  throttle,
76
76
  useDataTablePerformance
77
77
  } from "./chunk-QPCAGLUS.js";
78
- import "./chunk-CBSD3BZ3.js";
79
- import "./chunk-RIXPZJUB.js";
80
- import "./chunk-5BN3YGNK.js";
78
+ import "./chunk-3RZBKQ5Y.js";
79
+ import "./chunk-KTPG5VCH.js";
80
+ import "./chunk-DP5X5ORK.js";
81
81
  import "./chunk-PYUXFQJ3.js";
82
82
  import "./chunk-JCQZ6LA7.js";
83
- import "./chunk-CVMVPYAL.js";
83
+ import "./chunk-BDZUMRBD.js";
84
84
  import "./chunk-PLDDJCW6.js";
85
85
  export {
86
86
  ActionButtons,
@@ -154,4 +154,4 @@ export {
154
154
  validateHierarchicalData,
155
155
  validatePaginationConfig
156
156
  };
157
- //# sourceMappingURL=DataTable-FA6EUX5M.js.map
157
+ //# sourceMappingURL=DataTable-PWBMKMOG.js.map
@@ -14,7 +14,7 @@ import { z } from 'zod';
14
14
  import { User, SupabaseClient, createClient } from '@supabase/supabase-js';
15
15
  import { E as Event } from './unified-DQ4VcT7H.js';
16
16
  import { O as Organisation } from './organisation-D6qRDtbF.js';
17
- import { b as FileCategory, c as FileUploadOptions, e as FileUploadResult, F as FileReference } from './file-reference-9xUOnwyt.js';
17
+ import { b as FileCategory, e as FileUploadResult, U as UploadProgress, c as FileUploadOptions, F as FileReference } from './file-reference-C9isKNPn.js';
18
18
 
19
19
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
20
20
  /** Visual variant of the button */
@@ -2703,6 +2703,22 @@ interface LoadingSpinnerProps {
2703
2703
  */
2704
2704
  declare const LoadingSpinner: React__default.FC<LoadingSpinnerProps>;
2705
2705
 
2706
+ /**
2707
+ * @file SessionRestorationLoader Component
2708
+ * @package @jmruthers/pace-core
2709
+ * @module Components
2710
+ * @since 0.1.0
2711
+ *
2712
+ * Displays a consistent loading state while the authentication service
2713
+ * restores the Supabase session from persistent storage.
2714
+ */
2715
+
2716
+ interface SessionRestorationLoaderProps {
2717
+ /** Customise the status message displayed under the spinner */
2718
+ message?: string;
2719
+ }
2720
+ declare const SessionRestorationLoader: React__default.FC<SessionRestorationLoaderProps>;
2721
+
2706
2722
  interface EventSelectorProps {
2707
2723
  /** Placeholder text for the dropdown */
2708
2724
  placeholder?: string;
@@ -2855,6 +2871,29 @@ interface PasswordResetFormProps {
2855
2871
  }
2856
2872
  declare function PasswordResetForm({ onSuccess, onError, className }: PasswordResetFormProps): react_jsx_runtime.JSX.Element;
2857
2873
 
2874
+ interface FileUploadProps {
2875
+ supabase: SupabaseClient;
2876
+ table_name: string;
2877
+ record_id: string;
2878
+ organisation_id: string;
2879
+ app_id?: string;
2880
+ category: FileCategory;
2881
+ accept?: string;
2882
+ maxSize?: number;
2883
+ multiple?: boolean;
2884
+ disabled?: boolean;
2885
+ isPublic?: boolean;
2886
+ className?: string;
2887
+ showPreview?: boolean;
2888
+ showProgress?: boolean;
2889
+ onUploadSuccess?: (result: FileUploadResult) => void;
2890
+ onUploadError?: (error: string, file?: File) => void;
2891
+ onProgress?: (progress: UploadProgress) => void;
2892
+ children?: React__default.ReactNode;
2893
+ }
2894
+ declare function FileUpload({ supabase, table_name, record_id, organisation_id, app_id, category, accept, maxSize, // 10MB default
2895
+ multiple, disabled, isPublic, className, showPreview, showProgress, onUploadSuccess, onUploadError, onProgress, children }: FileUploadProps): react_jsx_runtime.JSX.Element;
2896
+
2858
2897
  interface FileDisplayProps {
2859
2898
  supabase: SupabaseClient;
2860
2899
  table_name: string;
@@ -2868,144 +2907,18 @@ interface FileDisplayProps {
2868
2907
  }
2869
2908
  declare function FileDisplay({ supabase, table_name, record_id, organisation_id, category, showUpload, showDelete, className, children }: FileDisplayProps): react_jsx_runtime.JSX.Element;
2870
2909
 
2871
- /**
2872
- * Storage utility types for pace-core
2873
- */
2874
- interface StorageUploadOptions {
2875
- /** The app name from rbac_apps */
2876
- appName: string;
2877
- /** Organisation ID for scoping */
2878
- orgId: string;
2879
- /** Whether the file should be publicly accessible */
2880
- isPublic?: boolean;
2881
- /** Optional tags for categorisation */
2882
- tags?: string[];
2883
- /** Optional custom path within the app/org structure */
2884
- customPath?: string;
2885
- /** Optional metadata to store with the file */
2886
- metadata?: Record<string, any>;
2887
- }
2888
- interface StorageFileMetadata {
2889
- mimeType: string;
2890
- size: number;
2891
- width?: number;
2892
- height?: number;
2893
- hash?: string;
2894
- orgId: string;
2895
- appName: string;
2896
- uploadedBy: string;
2897
- uploadedAt: string;
2898
- tags?: string[];
2899
- isPublic: boolean;
2900
- customMetadata?: Record<string, any>;
2901
- }
2902
- interface StorageUploadResult {
2903
- success: boolean;
2904
- path?: string;
2905
- publicUrl?: string;
2906
- metadata?: StorageFileMetadata;
2907
- error?: string;
2908
- }
2909
- interface StorageUrlOptions {
2910
- /** The app name from rbac_apps */
2911
- appName: string;
2912
- /** Organisation ID for scoping */
2913
- orgId: string;
2914
- /** Expiry time in seconds for signed URLs (default: 3600) */
2915
- expiresIn?: number;
2916
- }
2917
- interface StorageListOptions {
2918
- /** The app name from rbac_apps */
2919
- appName: string;
2920
- /** Organisation ID for scoping */
2921
- orgId: string;
2922
- /** Optional path prefix to filter by */
2923
- pathPrefix?: string;
2924
- /** Optional tags to filter by */
2925
- tags?: string[];
2926
- /** Maximum number of files to return */
2927
- limit?: number;
2928
- /** Offset for pagination */
2929
- offset?: number;
2930
- }
2931
- interface StorageFileInfo {
2932
- name: string;
2933
- path: string;
2934
- size: number;
2935
- mimeType: string;
2936
- lastModified: string;
2937
- metadata: StorageFileMetadata;
2938
- }
2939
- interface StorageListResult {
2940
- files: StorageFileInfo[];
2941
- totalCount: number;
2942
- hasMore: boolean;
2943
- }
2944
- interface FileSizeLimits {
2945
- [mimeType: string]: number;
2946
- }
2947
- interface StorageConfig {
2948
- bucketName: string;
2949
- fileSizeLimits: FileSizeLimits;
2950
- defaultFileSizeLimit: number;
2951
- }
2952
-
2953
- /**
2954
- * React hook for storage operations
2955
- */
2956
-
2957
- interface UseStorageOptions {
2958
- supabase: SupabaseClient;
2959
- appName: string;
2960
- orgId: string;
2961
- }
2962
- interface UseStorageReturn {
2963
- uploadFile: (file: File, options?: Partial<StorageUploadOptions>) => Promise<StorageUploadResult>;
2964
- isUploading: boolean;
2965
- uploadError: string | null;
2966
- getPublicUrl: (path: string) => string;
2967
- getSignedUrl: (path: string, expiresIn?: number) => Promise<string | null>;
2968
- getFileUrl: (path: string) => string;
2969
- deleteFile: (path: string) => Promise<{
2970
- success: boolean;
2971
- error?: string;
2972
- }>;
2973
- archiveFile: (path: string) => Promise<{
2974
- success: boolean;
2975
- error?: string;
2976
- }>;
2977
- listFiles: (options?: Partial<StorageListOptions>) => Promise<StorageListResult>;
2978
- isListing: boolean;
2979
- listError: string | null;
2980
- isLoading: boolean;
2981
- error: string | null;
2982
- files: StorageFileInfo[];
2983
- refreshFiles: () => Promise<void>;
2984
- }
2985
- /**
2986
- * Hook for storage operations with app and organisation context
2987
- */
2988
- declare function useStorage({ supabase, appName, orgId }: UseStorageOptions): UseStorageReturn;
2989
- /**
2990
- * Hook for file upload with progress tracking
2991
- */
2992
- declare function useFileUpload({ supabase, appName, orgId }: UseStorageOptions): {
2993
- uploadWithProgress: (file: File, options?: Partial<StorageUploadOptions>) => Promise<StorageUploadResult>;
2994
- uploadProgress: number;
2995
- isUploading: boolean;
2996
- uploadError: string | null;
2997
- };
2998
-
2999
2910
  declare function useFileReference(supabase: SupabaseClient): {
3000
2911
  isLoading: boolean;
3001
2912
  error: string | null;
3002
2913
  uploadFile: (options: FileUploadOptions, file: File) => Promise<FileUploadResult | null>;
3003
2914
  getFileReference: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference | null>;
2915
+ getFileReferenceById: (id: string, organisation_id: string) => Promise<FileReference | null>;
3004
2916
  getFileUrl: (table_name: string, record_id: string, organisation_id: string) => Promise<string | null>;
3005
2917
  getSignedUrl: (table_name: string, record_id: string, organisation_id: string, expires_in?: number) => Promise<string | null>;
3006
2918
  updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
3007
2919
  deleteFileReference: (table_name: string, record_id: string, organisation_id: string, delete_file?: boolean) => Promise<boolean>;
3008
2920
  listFileReferences: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference[]>;
2921
+ getFilesByCategory: (table_name: string, record_id: string, category: FileCategory, organisation_id: string) => Promise<FileReference[]>;
3009
2922
  getFileCount: (table_name: string, record_id: string, organisation_id: string) => Promise<number>;
3010
2923
  clearError: () => void;
3011
2924
  };
@@ -3024,6 +2937,28 @@ declare function useFileReferenceForRecord(supabase: SupabaseClient, table_name:
3024
2937
  updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
3025
2938
  clearError: () => void;
3026
2939
  };
2940
+ /**
2941
+ * Hook for getting a file reference by ID
2942
+ */
2943
+ declare function useFileReferenceById(supabase: SupabaseClient, fileReferenceId: string | null, organisationId: string | null): {
2944
+ isLoading: boolean;
2945
+ error: string | null;
2946
+ fileReference: FileReference | null;
2947
+ fileUrl: string | null;
2948
+ loadFileReference: () => Promise<FileReference | null>;
2949
+ clearError: () => void;
2950
+ };
2951
+ /**
2952
+ * Hook for getting files by category
2953
+ */
2954
+ declare function useFilesByCategory(supabase: SupabaseClient, table_name: string, record_id: string, category: FileCategory | null, organisation_id: string | null): {
2955
+ isLoading: boolean;
2956
+ error: string | null;
2957
+ fileReferences: FileReference[];
2958
+ fileUrls: Map<string, string>;
2959
+ loadFiles: () => Promise<FileReference[]>;
2960
+ clearError: () => void;
2961
+ };
3027
2962
  type UseFileReferenceOptions = {
3028
2963
  table_name: string;
3029
2964
  record_id: string;
@@ -3058,6 +2993,101 @@ type UseFileReferenceForRecordReturn = {
3058
2993
  clearError: () => void;
3059
2994
  };
3060
2995
 
2996
+ /**
2997
+ * @file Event Logo Hook (Authenticated)
2998
+ * @package @jmruthers/pace-core
2999
+ * @module Hooks
3000
+ *
3001
+ * A React hook for accessing event logos in authenticated contexts.
3002
+ * Can handle both public and private event logos using the file_references system.
3003
+ *
3004
+ * Features:
3005
+ * - Works in authenticated contexts
3006
+ * - Supports both public and private event logos
3007
+ * - Automatic fallback to event initials
3008
+ * - Bucket-aware URL generation
3009
+ * - Signed URL support for private files
3010
+ * - Caching for performance
3011
+ * - Error handling and loading states
3012
+ *
3013
+ * @example
3014
+ * ```tsx
3015
+ * import { useEventLogo } from '@jmruthers/pace-core';
3016
+ *
3017
+ * function EventHeader() {
3018
+ * const { logoUrl, fallbackText, isLoading, error } = useEventLogo(
3019
+ * supabase,
3020
+ * eventId,
3021
+ * eventName,
3022
+ * organisationId
3023
+ * );
3024
+ *
3025
+ * if (isLoading) return <div>Loading...</div>;
3026
+ * if (error) return <div>Error: {error.message}</div>;
3027
+ *
3028
+ * return (
3029
+ * <div>
3030
+ * {logoUrl ? (
3031
+ * <img src={logoUrl} alt={`${eventName} logo`} />
3032
+ * ) : (
3033
+ * <div className="logo-fallback">{fallbackText}</div>
3034
+ * )}
3035
+ * </div>
3036
+ * );
3037
+ * }
3038
+ * ```
3039
+ */
3040
+
3041
+ interface UseEventLogoReturn {
3042
+ /** The logo URL if available, null if not found or error */
3043
+ logoUrl: string | null;
3044
+ /** Fallback text (event initials) if no logo is available */
3045
+ fallbackText: string;
3046
+ /** Whether the logo is currently loading */
3047
+ isLoading: boolean;
3048
+ /** Any error that occurred during loading */
3049
+ error: Error | null;
3050
+ /** Function to manually refetch the logo */
3051
+ refetch: () => Promise<void>;
3052
+ }
3053
+ interface UseEventLogoOptions {
3054
+ /** Cache TTL in milliseconds (default: 30 minutes) */
3055
+ cacheTtl?: number;
3056
+ /** Whether to enable caching (default: true) */
3057
+ enableCache?: boolean;
3058
+ /** Whether to validate image existence (default: true) */
3059
+ validateImage?: boolean;
3060
+ /** Custom fallback text generator */
3061
+ generateFallbackText?: (eventName: string) => string;
3062
+ }
3063
+ /**
3064
+ * Hook for accessing event logo URLs in authenticated contexts
3065
+ *
3066
+ * This hook provides access to event logo URLs for authenticated users.
3067
+ * It supports both public and private logos, generating appropriate URLs
3068
+ * (public URLs for public files, signed URLs for private files).
3069
+ *
3070
+ * @param supabase - Supabase client instance (required)
3071
+ * @param eventId - The event ID to fetch logo for
3072
+ * @param eventName - The event name for fallback text generation
3073
+ * @param organisationId - The organisation ID for storage path
3074
+ * @param options - Configuration options for caching and behavior
3075
+ * @returns Object containing logo URL, fallback text, loading state, error, and refetch function
3076
+ */
3077
+ declare function useEventLogo(supabase: SupabaseClient | null, eventId: string | undefined, eventName: string | undefined, organisationId: string | undefined, options?: UseEventLogoOptions): UseEventLogoReturn;
3078
+ /**
3079
+ * Clear all cached authenticated event logo data
3080
+ * Useful for testing or when you need to force refresh all data
3081
+ */
3082
+ declare function clearEventLogoCache(): void;
3083
+ /**
3084
+ * Get cache statistics for debugging
3085
+ */
3086
+ declare function getEventLogoCacheStats(): {
3087
+ size: number;
3088
+ keys: string[];
3089
+ };
3090
+
3061
3091
  /**
3062
3092
  * @file Table Component System
3063
3093
  * @package @jmruthers/pace-core
@@ -3567,4 +3597,4 @@ declare function PublicLoadingSkeleton({ lines, className }: {
3567
3597
  className?: string;
3568
3598
  }): react_jsx_runtime.JSX.Element;
3569
3599
 
3570
- export { Select as $, Alert as A, Button as B, Card as C, Dialog as D, DialogOverlay as E, DialogTrigger as F, DialogClose as G, DialogContent as H, Input as I, DialogHeader as J, DialogBody as K, Label as L, DialogFooter as M, DialogTitle as N, DialogDescription as O, Progress as P, type DialogProps as Q, type DialogTriggerProps as R, Switch as S, Table as T, type DialogContentProps as U, type DialogOverlayProps as V, type DialogHeaderProps as W, type DialogFooterProps as X, type DialogTitleProps as Y, type DialogDescriptionProps as Z, type DialogSize as _, type ButtonProps as a, EventLogoCompact as a$, SelectGroup as a0, SelectValue as a1, SelectTrigger as a2, SelectContent as a3, SelectLabel as a4, SelectItem as a5, SelectSeparator as a6, Toast as a7, Toaster as a8, ToastAction as a9, type ErrorBoundaryProps as aA, type ErrorBoundaryState as aB, LoadingSpinner as aC, EventSelector as aD, PasswordResetForm as aE, FileDisplay as aF, type FileDisplayProps as aG, useStorage as aH, useFileUpload as aI, type UseStorageOptions as aJ, type UseStorageReturn as aK, useFileReference as aL, useFileReferenceForRecord as aM, type UseFileReferenceOptions as aN, type UseFileReferenceReturn as aO, type UseFileReferenceForRecordReturn as aP, PublicPageLayout as aQ, usePublicPageContext$1 as aR, PublicPageHeader as aS, PublicPageProvider as aT, usePublicPageContext as aU, useIsPublicPage as aV, PublicPageFooter as aW, PublicPageDebugger as aX, PublicPageDiagnostic as aY, PublicPageContextChecker as aZ, EventLogo as a_, ToastProvider as aa, ToastViewport as ab, ToastTitle as ac, ToastDescription as ad, ToastClose as ae, type ToastActionElement as af, type ToastProps as ag, Tooltip as ah, TooltipTrigger as ai, TooltipContent as aj, TooltipProvider as ak, TooltipRoot as al, Form as am, type FormProps as an, LoginForm as ao, type LoginFormProps as ap, Header as aq, Footer as ar, type FooterProps as as, NavigationMenu as at, type NavigationMenuProps as au, type NavigationItem as av, OrganisationSelector as aw, type OrganisationSelectorProps as ax, UserMenu as ay, ErrorBoundary as az, CardHeader as b, EventLogoLarge as b0, PublicErrorBoundary as b1, useErrorBoundary as b2, DefaultPublicErrorFallback as b3, PublicLoadingSpinner as b4, PublicLoadingSpinnerFullPage as b5, PublicLoadingSkeleton as b6, type PublicPageLayoutProps as b7, type PublicPageHeaderProps as b8, type PublicPageFooterProps as b9, type EventLogoProps as ba, type PublicErrorBoundaryProps as bb, type PublicErrorBoundaryState as bc, type PublicLoadingSpinnerProps as bd, type PaceAppLayoutProps as be, PaceAppLayout as bf, type PaceLoginPageProps as bg, PaceLoginPage as bh, type FileSizeLimits as bi, type StorageConfig as bj, type StorageUploadOptions as bk, type StorageFileMetadata as bl, type StorageUploadResult as bm, type StorageUrlOptions as bn, type StorageListOptions as bo, type StorageListResult as bp, type UserMenuProps as bq, type StorageFileInfo as br, CardFooter as c, CardTitle as d, CardDescription as e, CardContent as f, CardActions as g, type CardProps as h, type CardActionsProps as i, type InputProps as j, type LabelProps as k, AlertTitle as l, AlertDescription as m, Avatar as n, AvatarImage as o, AvatarFallback as p, Checkbox as q, type SwitchProps as r, TableHeader as s, TableBody as t, TableCaption as u, TableCell as v, TableFooter as w, TableHead as x, TableRow as y, DialogPortal as z };
3600
+ export { Select as $, Alert as A, Button as B, Card as C, Dialog as D, DialogOverlay as E, DialogTrigger as F, DialogClose as G, DialogContent as H, Input as I, DialogHeader as J, DialogBody as K, Label as L, DialogFooter as M, DialogTitle as N, DialogDescription as O, Progress as P, type DialogProps as Q, type DialogTriggerProps as R, Switch as S, Table as T, type DialogContentProps as U, type DialogOverlayProps as V, type DialogHeaderProps as W, type DialogFooterProps as X, type DialogTitleProps as Y, type DialogDescriptionProps as Z, type DialogSize as _, type ButtonProps as a, useIsPublicPage as a$, SelectGroup as a0, SelectValue as a1, SelectTrigger as a2, SelectContent as a3, SelectLabel as a4, SelectItem as a5, SelectSeparator as a6, Toast as a7, Toaster as a8, ToastAction as a9, type ErrorBoundaryProps as aA, type ErrorBoundaryState as aB, LoadingSpinner as aC, SessionRestorationLoader as aD, EventSelector as aE, PasswordResetForm as aF, FileUpload as aG, type FileUploadProps as aH, FileDisplay as aI, type FileDisplayProps as aJ, useFileReference as aK, useFileReferenceForRecord as aL, useFileReferenceById as aM, useFilesByCategory as aN, type UseFileReferenceOptions as aO, type UseFileReferenceReturn as aP, type UseFileReferenceForRecordReturn as aQ, useEventLogo as aR, clearEventLogoCache as aS, getEventLogoCacheStats as aT, type UseEventLogoReturn as aU, type UseEventLogoOptions as aV, PublicPageLayout as aW, usePublicPageContext$1 as aX, PublicPageHeader as aY, PublicPageProvider as aZ, usePublicPageContext as a_, ToastProvider as aa, ToastViewport as ab, ToastTitle as ac, ToastDescription as ad, ToastClose as ae, type ToastActionElement as af, type ToastProps as ag, Tooltip as ah, TooltipTrigger as ai, TooltipContent as aj, TooltipProvider as ak, TooltipRoot as al, Form as am, type FormProps as an, LoginForm as ao, type LoginFormProps as ap, Header as aq, Footer as ar, type FooterProps as as, NavigationMenu as at, type NavigationMenuProps as au, type NavigationItem as av, OrganisationSelector as aw, type OrganisationSelectorProps as ax, UserMenu as ay, ErrorBoundary as az, CardHeader as b, PublicPageFooter as b0, PublicPageDebugger as b1, PublicPageDiagnostic as b2, PublicPageContextChecker as b3, EventLogo as b4, EventLogoCompact as b5, EventLogoLarge as b6, PublicErrorBoundary as b7, useErrorBoundary as b8, DefaultPublicErrorFallback as b9, PublicLoadingSpinner as ba, PublicLoadingSpinnerFullPage as bb, PublicLoadingSkeleton as bc, type PublicPageLayoutProps as bd, type PublicPageHeaderProps as be, type PublicPageFooterProps as bf, type EventLogoProps as bg, type PublicErrorBoundaryProps as bh, type PublicErrorBoundaryState as bi, type PublicLoadingSpinnerProps as bj, type PaceAppLayoutProps as bk, PaceAppLayout as bl, type PaceLoginPageProps as bm, PaceLoginPage as bn, type UserMenuProps as bo, CardFooter as c, CardTitle as d, CardDescription as e, CardContent as f, CardActions as g, type CardProps as h, type CardActionsProps as i, type InputProps as j, type LabelProps as k, AlertTitle as l, AlertDescription as m, Avatar as n, AvatarImage as o, AvatarFallback as p, Checkbox as q, type SwitchProps as r, TableHeader as s, TableBody as t, TableCaption as u, TableCell as v, TableFooter as w, TableHead as x, TableRow as y, DialogPortal as z };
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  init_UnifiedAuthProvider
3
- } from "./chunk-RIXPZJUB.js";
3
+ } from "./chunk-KTPG5VCH.js";
4
4
  import {
5
5
  UnifiedAuthProvider,
6
6
  useUnifiedAuth
7
- } from "./chunk-5BN3YGNK.js";
8
- import "./chunk-CVMVPYAL.js";
7
+ } from "./chunk-DP5X5ORK.js";
8
+ import "./chunk-BDZUMRBD.js";
9
9
  import "./chunk-PLDDJCW6.js";
10
10
  init_UnifiedAuthProvider();
11
11
  export {
12
12
  UnifiedAuthProvider,
13
13
  useUnifiedAuth
14
14
  };
15
- //# sourceMappingURL=UnifiedAuthProvider-K2IZAY5F.js.map
15
+ //# sourceMappingURL=UnifiedAuthProvider-5D3HEQND.js.map
@@ -3,6 +3,7 @@ import React__default from 'react';
3
3
  import { SupabaseClient, User, Session, AuthError } from '@supabase/supabase-js';
4
4
  import { O as Organisation, a as OrganisationMembership } from './organisation-D6qRDtbF.js';
5
5
  import { E as Event } from './unified-DQ4VcT7H.js';
6
+ import { S as SessionRestorationState } from './auth-DReDSLq9.js';
6
7
 
7
8
  interface UserEventAccess {
8
9
  event_id: string;
@@ -80,6 +81,9 @@ interface UnifiedAuthContextType {
80
81
  } | null;
81
82
  isLoading: boolean;
82
83
  hasErrors: boolean;
84
+ sessionRestoration: SessionRestorationState;
85
+ sessionRestorationTimedOut: boolean;
86
+ sessionRestorationTimeoutMs: number;
83
87
  }
84
88
  declare const useUnifiedAuth: () => UnifiedAuthContextType;
85
89
  interface UnifiedAuthProviderProps {
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Auth related types
3
+ * @package @jmruthers/pace-core
4
+ * @module Types/Auth
5
+ * @since 0.1.0
6
+ */
7
+ interface SessionRestorationState {
8
+ /** True while Supabase is hydrating the local session */
9
+ isRestoring: boolean;
10
+ /** Indicates the restoration completed successfully */
11
+ restorationComplete: boolean;
12
+ /** Error encountered during restoration (timeout or Supabase error) */
13
+ restorationError: Error | null;
14
+ }
15
+
16
+ export type { SessionRestorationState as S };
@@ -3,7 +3,7 @@ import {
3
3
  init_useOrganisationService,
4
4
  useEventService2 as useEventService,
5
5
  useOrganisationService2 as useOrganisationService
6
- } from "./chunk-5BN3YGNK.js";
6
+ } from "./chunk-DP5X5ORK.js";
7
7
  import {
8
8
  __esm
9
9
  } from "./chunk-PLDDJCW6.js";
@@ -42,10 +42,6 @@ init_useEventService();
42
42
  function useEvents() {
43
43
  const eventService = useEventService();
44
44
  const events = eventService.getEvents();
45
- console.log("[useEvents] Hook called, returning events:", {
46
- count: events.length,
47
- events: events.map((e) => ({ id: e.event_id, name: e.event_name }))
48
- });
49
45
  return {
50
46
  events,
51
47
  selectedEvent: eventService.getSelectedEvent(),
@@ -61,4 +57,4 @@ export {
61
57
  init_useOrganisations,
62
58
  useEvents
63
59
  };
64
- //# sourceMappingURL=chunk-CBSD3BZ3.js.map
60
+ //# sourceMappingURL=chunk-3RZBKQ5Y.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useOrganisations.ts","../src/hooks/useEvents.ts"],"sourcesContent":["/**\n * @file Organisation Hook\n * @package @jmruthers/pace-core\n * @module Hooks\n * @since 0.1.0\n *\n * Convenience hook for accessing organisation context.\n * This hook provides a simple interface for working with organisations.\n * \n * Note: This is a convenience wrapper around the OrganisationService.\n * For better performance, consider using useOrganisationService directly.\n */\n\nimport { useOrganisationService } from './services/useOrganisationService';\nimport { Organisation, OrganisationMembership, OrganisationContextType } from '../types/organisation';\n\n/**\n * Hook to access organisation context\n * \n * @returns Organisation context with selected organisation, organisations list, and helper methods\n * @throws {Error} If used outside OrganisationServiceProvider\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { selectedOrganisation, organisations, switchOrganisation } = useOrganisations();\n * \n * return (\n * <div>\n * <h1>Current Organisation: {selectedOrganisation.display_name}</h1>\n * {organisations.map(org => (\n * <button key={org.id} onClick={() => switchOrganisation(org.id)}>\n * {org.display_name}\n * </button>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useOrganisations(): OrganisationContextType {\n const organisationService = useOrganisationService();\n\n const selectedOrg = organisationService.getSelectedOrganisation();\n \n return {\n selectedOrganisation: selectedOrg as Organisation | null,\n organisations: organisationService.getOrganisations(),\n userMemberships: organisationService.getUserMemberships(),\n isLoading: organisationService.isLoading(),\n error: organisationService.getError(),\n hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),\n isContextReady: organisationService.isContextReady(),\n setSelectedOrganisation: (org: Organisation | null) => organisationService.setSelectedOrganisation(org),\n switchOrganisation: (orgId: string) => organisationService.switchOrganisation(orgId),\n getUserRole: (orgId?: string) => organisationService.getUserRole(orgId),\n validateOrganisationAccess: (orgId: string) => organisationService.validateOrganisationAccess(orgId),\n refreshOrganisations: () => organisationService.refreshOrganisations(),\n ensureOrganisationContext: () => organisationService.ensureOrganisationContext(),\n isOrganisationSecure: () => organisationService.isOrganisationSecure(),\n getPrimaryOrganisation: () => organisationService.getPrimaryOrganisation(),\n };\n}\n\n","/**\n * @file Event Hook\n * @package @jmruthers/pace-core\n * @module Hooks\n * @since 0.1.0\n *\n * Convenience hook for accessing event context.\n * This hook provides a simple interface for working with events.\n * \n * Note: This is a convenience wrapper around the EventService.\n * For better performance, consider using useEventService directly.\n */\n\nimport { useEventService } from './services/useEventService';\nimport { Event } from '../types/unified';\n\nexport interface EventContextType {\n events: Event[];\n selectedEvent: Event | null;\n isLoading: boolean;\n error: Error | null;\n setSelectedEvent: (event: Event | null) => void;\n refreshEvents: () => Promise<void>;\n}\n\n/**\n * Hook to access event context\n * \n * @returns Event context with events, selected event, and helper methods\n * @throws {Error} If used outside EventServiceProvider\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { events, selectedEvent, setSelectedEvent } = useEvents();\n * \n * return (\n * <div>\n * {events.map(event => (\n * <button key={event.id} onClick={() => setSelectedEvent(event)}>\n * {event.event_name}\n * </button>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useEvents(): EventContextType {\n const eventService = useEventService();\n\n const events = eventService.getEvents();\n \n console.log('[useEvents] Hook called, returning events:', {\n count: events.length,\n events: events.map(e => ({ id: e.event_id, name: e.event_name }))\n });\n\n return {\n events,\n selectedEvent: eventService.getSelectedEvent(),\n isLoading: eventService.isLoading(),\n error: eventService.getError(),\n setSelectedEvent: (event: Event | null) => eventService.setSelectedEvent(event),\n refreshEvents: () => eventService.refreshEvents(),\n };\n}\n\n"],"mappings":";;;;;;;;;;;AAwCO,SAAS,mBAA4C;AAC1D,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,cAAc,oBAAoB,wBAAwB;AAEhE,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,eAAe,oBAAoB,iBAAiB;AAAA,IACpD,iBAAiB,oBAAoB,mBAAmB;AAAA,IACxD,WAAW,oBAAoB,UAAU;AAAA,IACzC,OAAO,oBAAoB,SAAS;AAAA,IACpC,6BAA6B,oBAAoB,4BAA4B;AAAA,IAC7E,gBAAgB,oBAAoB,eAAe;AAAA,IACnD,yBAAyB,CAAC,QAA6B,oBAAoB,wBAAwB,GAAG;AAAA,IACtG,oBAAoB,CAAC,UAAkB,oBAAoB,mBAAmB,KAAK;AAAA,IACnF,aAAa,CAAC,UAAmB,oBAAoB,YAAY,KAAK;AAAA,IACtE,4BAA4B,CAAC,UAAkB,oBAAoB,2BAA2B,KAAK;AAAA,IACnG,sBAAsB,MAAM,oBAAoB,qBAAqB;AAAA,IACrE,2BAA2B,MAAM,oBAAoB,0BAA0B;AAAA,IAC/E,sBAAsB,MAAM,oBAAoB,qBAAqB;AAAA,IACrE,wBAAwB,MAAM,oBAAoB,uBAAuB;AAAA,EAC3E;AACF;AA9DA;AAAA;AAAA;AAaA;AAAA;AAAA;;;ACAA;AAmCO,SAAS,YAA8B;AAC5C,QAAM,eAAe,gBAAgB;AAErC,QAAM,SAAS,aAAa,UAAU;AAEtC,UAAQ,IAAI,8CAA8C;AAAA,IACxD,OAAO,OAAO;AAAA,IACd,QAAQ,OAAO,IAAI,QAAM,EAAE,IAAI,EAAE,UAAU,MAAM,EAAE,WAAW,EAAE;AAAA,EAClE,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,eAAe,aAAa,iBAAiB;AAAA,IAC7C,WAAW,aAAa,UAAU;AAAA,IAClC,OAAO,aAAa,SAAS;AAAA,IAC7B,kBAAkB,CAAC,UAAwB,aAAa,iBAAiB,KAAK;AAAA,IAC9E,eAAe,MAAM,aAAa,cAAc;AAAA,EAClD;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/hooks/useOrganisations.ts","../src/hooks/useEvents.ts"],"sourcesContent":["/**\n * @file Organisation Hook\n * @package @jmruthers/pace-core\n * @module Hooks\n * @since 0.1.0\n *\n * Convenience hook for accessing organisation context.\n * This hook provides a simple interface for working with organisations.\n * \n * Note: This is a convenience wrapper around the OrganisationService.\n * For better performance, consider using useOrganisationService directly.\n */\n\nimport { useOrganisationService } from './services/useOrganisationService';\nimport { Organisation, OrganisationMembership, OrganisationContextType } from '../types/organisation';\n\n/**\n * Hook to access organisation context\n * \n * @returns Organisation context with selected organisation, organisations list, and helper methods\n * @throws {Error} If used outside OrganisationServiceProvider\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { selectedOrganisation, organisations, switchOrganisation } = useOrganisations();\n * \n * return (\n * <div>\n * <h1>Current Organisation: {selectedOrganisation.display_name}</h1>\n * {organisations.map(org => (\n * <button key={org.id} onClick={() => switchOrganisation(org.id)}>\n * {org.display_name}\n * </button>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useOrganisations(): OrganisationContextType {\n const organisationService = useOrganisationService();\n\n const selectedOrg = organisationService.getSelectedOrganisation();\n \n return {\n selectedOrganisation: selectedOrg as Organisation | null,\n organisations: organisationService.getOrganisations(),\n userMemberships: organisationService.getUserMemberships(),\n isLoading: organisationService.isLoading(),\n error: organisationService.getError(),\n hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),\n isContextReady: organisationService.isContextReady(),\n setSelectedOrganisation: (org: Organisation | null) => organisationService.setSelectedOrganisation(org),\n switchOrganisation: (orgId: string) => organisationService.switchOrganisation(orgId),\n getUserRole: (orgId?: string) => organisationService.getUserRole(orgId),\n validateOrganisationAccess: (orgId: string) => organisationService.validateOrganisationAccess(orgId),\n refreshOrganisations: () => organisationService.refreshOrganisations(),\n ensureOrganisationContext: () => organisationService.ensureOrganisationContext(),\n isOrganisationSecure: () => organisationService.isOrganisationSecure(),\n getPrimaryOrganisation: () => organisationService.getPrimaryOrganisation(),\n };\n}\n\n","/**\n * @file Event Hook\n * @package @jmruthers/pace-core\n * @module Hooks\n * @since 0.1.0\n *\n * Convenience hook for accessing event context.\n * This hook provides a simple interface for working with events.\n * \n * Note: This is a convenience wrapper around the EventService.\n * For better performance, consider using useEventService directly.\n */\n\nimport { useEventService } from './services/useEventService';\nimport { Event } from '../types/unified';\n\nexport interface EventContextType {\n events: Event[];\n selectedEvent: Event | null;\n isLoading: boolean;\n error: Error | null;\n setSelectedEvent: (event: Event | null) => void;\n refreshEvents: () => Promise<void>;\n}\n\n/**\n * Hook to access event context\n * \n * @returns Event context with events, selected event, and helper methods\n * @throws {Error} If used outside EventServiceProvider\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { events, selectedEvent, setSelectedEvent } = useEvents();\n * \n * return (\n * <div>\n * {events.map(event => (\n * <button key={event.id} onClick={() => setSelectedEvent(event)}>\n * {event.event_name}\n * </button>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useEvents(): EventContextType {\n const eventService = useEventService();\n\n const events = eventService.getEvents();\n\n return {\n events,\n selectedEvent: eventService.getSelectedEvent(),\n isLoading: eventService.isLoading(),\n error: eventService.getError(),\n setSelectedEvent: (event: Event | null) => eventService.setSelectedEvent(event),\n refreshEvents: () => eventService.refreshEvents(),\n };\n}\n\n"],"mappings":";;;;;;;;;;;AAwCO,SAAS,mBAA4C;AAC1D,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,cAAc,oBAAoB,wBAAwB;AAEhE,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,eAAe,oBAAoB,iBAAiB;AAAA,IACpD,iBAAiB,oBAAoB,mBAAmB;AAAA,IACxD,WAAW,oBAAoB,UAAU;AAAA,IACzC,OAAO,oBAAoB,SAAS;AAAA,IACpC,6BAA6B,oBAAoB,4BAA4B;AAAA,IAC7E,gBAAgB,oBAAoB,eAAe;AAAA,IACnD,yBAAyB,CAAC,QAA6B,oBAAoB,wBAAwB,GAAG;AAAA,IACtG,oBAAoB,CAAC,UAAkB,oBAAoB,mBAAmB,KAAK;AAAA,IACnF,aAAa,CAAC,UAAmB,oBAAoB,YAAY,KAAK;AAAA,IACtE,4BAA4B,CAAC,UAAkB,oBAAoB,2BAA2B,KAAK;AAAA,IACnG,sBAAsB,MAAM,oBAAoB,qBAAqB;AAAA,IACrE,2BAA2B,MAAM,oBAAoB,0BAA0B;AAAA,IAC/E,sBAAsB,MAAM,oBAAoB,qBAAqB;AAAA,IACrE,wBAAwB,MAAM,oBAAoB,uBAAuB;AAAA,EAC3E;AACF;AA9DA;AAAA;AAAA;AAaA;AAAA;AAAA;;;ACAA;AAmCO,SAAS,YAA8B;AAC5C,QAAM,eAAe,gBAAgB;AAErC,QAAM,SAAS,aAAa,UAAU;AAEtC,SAAO;AAAA,IACL;AAAA,IACA,eAAe,aAAa,iBAAiB;AAAA,IAC7C,WAAW,aAAa,UAAU;AAAA,IAClC,OAAO,aAAa,SAAS;AAAA,IAC7B,kBAAkB,CAAC,UAAwB,aAAa,iBAAiB,KAAK;AAAA,IAC9E,eAAe,MAAM,aAAa,cAAc;AAAA,EAClD;AACF;","names":[]}
@@ -2,7 +2,7 @@ import {
2
2
  createScopeFromEvent,
3
3
  useAccessLevel,
4
4
  useCan
5
- } from "./chunk-YVUZWLQG.js";
5
+ } from "./chunk-AQGF5OG7.js";
6
6
  import {
7
7
  OrganisationContextRequiredError,
8
8
  RBACCache,
@@ -11,13 +11,13 @@ import {
11
11
  } from "./chunk-S63MFSY6.js";
12
12
  import {
13
13
  useSecureDataAccess
14
- } from "./chunk-S3JKDMD5.js";
14
+ } from "./chunk-CXKMRKRF.js";
15
15
  import {
16
16
  init_UnifiedAuthProvider
17
- } from "./chunk-RIXPZJUB.js";
17
+ } from "./chunk-KTPG5VCH.js";
18
18
  import {
19
19
  useUnifiedAuth
20
- } from "./chunk-5BN3YGNK.js";
20
+ } from "./chunk-DP5X5ORK.js";
21
21
  import {
22
22
  getCurrentAppName
23
23
  } from "./chunk-JCQZ6LA7.js";
@@ -1860,4 +1860,4 @@ export {
1860
1860
  getPermissionsForRole,
1861
1861
  ALL_PERMISSIONS
1862
1862
  };
1863
- //# sourceMappingURL=chunk-NTW3KGS4.js.map
1863
+ //# sourceMappingURL=chunk-6UHXQH7P.js.map
@@ -11,11 +11,11 @@ import {
11
11
  init_useOrganisations,
12
12
  useEvents,
13
13
  useOrganisations
14
- } from "./chunk-CBSD3BZ3.js";
14
+ } from "./chunk-3RZBKQ5Y.js";
15
15
  import {
16
16
  init_UnifiedAuthProvider,
17
17
  useUnifiedAuth
18
- } from "./chunk-5BN3YGNK.js";
18
+ } from "./chunk-DP5X5ORK.js";
19
19
  import {
20
20
  getCurrentAppName
21
21
  } from "./chunk-JCQZ6LA7.js";
@@ -729,4 +729,4 @@ export {
729
729
  useHasAllPermissions,
730
730
  useCachedPermissions
731
731
  };
732
- //# sourceMappingURL=chunk-YVUZWLQG.js.map
732
+ //# sourceMappingURL=chunk-AQGF5OG7.js.map
@@ -11,10 +11,8 @@ async function setOrganisationContext(supabase, organisationId) {
11
11
  const timeoutPromise = new Promise((_, reject) => {
12
12
  setTimeout(() => reject(new Error("RPC timeout after 3 seconds")), 3e3);
13
13
  });
14
- const rpcPromise = supabase.rpc("rbac_audit_log", {
15
- p_event_type: "organisation_switched",
16
- p_organisation_id: organisationId,
17
- p_metadata: { action: "set_context" }
14
+ const rpcPromise = supabase.rpc("set_organisation_context", {
15
+ org_id: organisationId
18
16
  });
19
17
  const { error } = await Promise.race([rpcPromise, timeoutPromise]);
20
18
  if (error) {
@@ -86,4 +84,4 @@ export {
86
84
  isOrganisationContextAvailable,
87
85
  init_organisationContext
88
86
  };
89
- //# sourceMappingURL=chunk-CVMVPYAL.js.map
87
+ //# sourceMappingURL=chunk-BDZUMRBD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/organisationContext.ts"],"sourcesContent":["/**\n * @file Organisation Context Utility\n * @package @jmruthers/pace-core\n * @module Utils/OrganisationContext\n * @since 0.4.0\n *\n * Utility functions for managing organisation context in database sessions.\n * Provides fallback mechanisms for when database functions are not available.\n */\n\nimport type { SupabaseClient } from '@supabase/supabase-js';\n\n/**\n * Set organisation context in the database session\n * \n * This function attempts to set the organisation context using a database function.\n * If the function is not available, it falls back gracefully without throwing errors.\n * \n * @param supabase - Supabase client instance\n * @param organisationId - The organisation ID to set as context\n * @returns Promise that resolves when context is set (or falls back gracefully)\n */\nexport async function setOrganisationContext(\n supabase: SupabaseClient,\n organisationId: string\n): Promise<void> {\n if (!supabase || !organisationId) {\n // TODO: Replace with proper logging service integration\n return;\n }\n\n try {\n // Add timeout to prevent hanging RPC calls\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('RPC timeout after 3 seconds')), 3000);\n });\n \n // Call the database function to set organisation context\n const rpcPromise = supabase.rpc('set_organisation_context', {\n org_id: organisationId\n });\n\n const { error } = await Promise.race([rpcPromise, timeoutPromise]) as any;\n\n if (error) {\n // Function might not exist yet - this is expected during migration\n // Silent fail - will fall back to client-side filtering\n console.log('[organisationContext] RPC function not available or failed, continuing without database context');\n } else {\n console.log('[organisationContext] Organisation context set in database successfully');\n }\n } catch (error) {\n // Handle any other errors gracefully\n // Silent fail - will fall back to client-side filtering\n console.log('[organisationContext] Failed to set database context, continuing without it:', error);\n }\n}\n\n/**\n * Clear organisation context from the database session\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves when context is cleared\n */\nexport async function clearOrganisationContext(\n supabase: SupabaseClient\n): Promise<void> {\n if (!supabase) {\n // TODO: Replace with proper logging service integration\n return;\n }\n\n try {\n const { error } = await supabase.rpc('rbac_audit_log', {\n p_event_type: 'organisation_switched',\n p_metadata: { action: 'clear_context' }\n });\n \n if (error) {\n // Silent fail - function not available\n // TODO: Replace with proper logging service integration\n } else {\n // TODO: Replace with proper logging service integration\n }\n } catch (error) {\n // Silent fail - error occurred\n // TODO: Replace with proper logging service integration\n }\n}\n\n/**\n * Get current organisation context from the database session\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves to the current organisation ID or null\n */\nexport async function getOrganisationContext(\n supabase: SupabaseClient\n): Promise<string | null> {\n if (!supabase) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n\n try {\n // For now, return null since we're not using database context\n // This will be replaced with proper context management\n const data = null;\n const error = null;\n \n if (error) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n \n // Validate that data is a string (allow empty strings)\n if (typeof data === 'string') {\n return data;\n }\n \n // Return null for invalid data formats\n return null;\n } catch (error) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n}\n\n/**\n * Check if organisation context functions are available in the database\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves to true if functions are available\n */\nexport async function isOrganisationContextAvailable(\n supabase: SupabaseClient\n): Promise<boolean> {\n if (!supabase) {\n return false;\n }\n\n try {\n const { error } = await supabase.rpc('get_organisation_context');\n \n if (error) {\n return false;\n }\n \n return true;\n } catch (error) {\n return false;\n }\n} "],"mappings":";;;;;AAsBA,eAAsB,uBACpB,UACA,gBACe;AACf,MAAI,CAAC,YAAY,CAAC,gBAAgB;AAEhC;AAAA,EACF;AAEA,MAAI;AAEF,UAAM,iBAAiB,IAAI,QAAQ,CAAC,GAAG,WAAW;AAChD,iBAAW,MAAM,OAAO,IAAI,MAAM,6BAA6B,CAAC,GAAG,GAAI;AAAA,IACzE,CAAC;AAGD,UAAM,aAAa,SAAS,IAAI,4BAA4B;AAAA,MAC1D,QAAQ;AAAA,IACV,CAAC;AAED,UAAM,EAAE,MAAM,IAAI,MAAM,QAAQ,KAAK,CAAC,YAAY,cAAc,CAAC;AAEjE,QAAI,OAAO;AAGT,cAAQ,IAAI,iGAAiG;AAAA,IAC/G,OAAO;AACL,cAAQ,IAAI,yEAAyE;AAAA,IACvF;AAAA,EACF,SAAS,OAAO;AAGd,YAAQ,IAAI,gFAAgF,KAAK;AAAA,EACnG;AACF;AAQA,eAAsB,yBACpB,UACe;AACf,MAAI,CAAC,UAAU;AAEb;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,kBAAkB;AAAA,MACrD,cAAc;AAAA,MACd,YAAY,EAAE,QAAQ,gBAAgB;AAAA,IACxC,CAAC;AAED,QAAI,OAAO;AAAA,IAGX,OAAO;AAAA,IAEP;AAAA,EACF,SAAS,OAAO;AAAA,EAGhB;AACF;AAQA,eAAsB,uBACpB,UACwB;AACxB,MAAI,CAAC,UAAU;AAEb,WAAO;AAAA,EACT;AAEA,MAAI;AAGF,UAAM,OAAO;AACb,UAAM,QAAQ;AAEd,QAAI,OAAO;AAET,aAAO;AAAA,IACT;AAGA,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO;AAAA,IACT;AAGA,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,WAAO;AAAA,EACT;AACF;AAQA,eAAsB,+BACpB,UACkB;AAClB,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,0BAA0B;AAE/D,QAAI,OAAO;AACT,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAxJA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  useCan,
3
3
  useResolvedScope
4
- } from "./chunk-YVUZWLQG.js";
4
+ } from "./chunk-AQGF5OG7.js";
5
5
  import {
6
6
  toast,
7
7
  useDataTablePerformance
8
8
  } from "./chunk-QPCAGLUS.js";
9
9
  import {
10
10
  init_UnifiedAuthProvider
11
- } from "./chunk-RIXPZJUB.js";
11
+ } from "./chunk-KTPG5VCH.js";
12
12
  import {
13
13
  useUnifiedAuth
14
- } from "./chunk-5BN3YGNK.js";
14
+ } from "./chunk-DP5X5ORK.js";
15
15
  import {
16
16
  cn
17
17
  } from "./chunk-PYUXFQJ3.js";
@@ -12059,4 +12059,4 @@ lodash/lodash.js:
12059
12059
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12060
12060
  *)
12061
12061
  */
12062
- //# sourceMappingURL=chunk-KAY3K5TP.js.map
12062
+ //# sourceMappingURL=chunk-BNXBJOGL.js.map