@jmruthers/pace-core 0.5.183 → 0.5.185
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/CHANGELOG.md +38 -0
- package/README.md +60 -1
- package/core-usage-manifest.json +312 -0
- package/dist/{DataTable-QAB34V6K.js → DataTable-IX2NBUTP.js} +6 -6
- package/dist/{DataTable-Bz8ffqyA.d.ts → DataTable-Z9NLVJh0.d.ts} +1 -1
- package/dist/{index-Bl--n7-T.d.ts → PublicPageProvider-BABf6JCh.d.ts} +21 -10
- package/dist/{UnifiedAuthProvider-7F6T4B6K.js → UnifiedAuthProvider-A4BCQRJY.js} +4 -2
- package/dist/{UnifiedAuthProvider-F86d7dSi.d.ts → UnifiedAuthProvider-BG0AL5eE.d.ts} +2 -1
- package/dist/{api-ROMBCNKU.js → api-BMFCXVQX.js} +2 -2
- package/dist/{chunk-RA3JUFMW.js → chunk-445GEP27.js} +154 -4
- package/dist/{chunk-RA3JUFMW.js.map → chunk-445GEP27.js.map} +1 -1
- package/dist/{chunk-CSOFYHAG.js → chunk-AISXLWGZ.js} +374 -60
- package/dist/chunk-AISXLWGZ.js.map +1 -0
- package/dist/{chunk-FUEYYMX5.js → chunk-FXFJRTKI.js} +24 -3
- package/dist/chunk-FXFJRTKI.js.map +1 -0
- package/dist/{chunk-QETLRQI6.js → chunk-HC67NW5K.js} +380 -360
- package/dist/chunk-HC67NW5K.js.map +1 -0
- package/dist/chunk-HESYZWZW.js +388 -0
- package/dist/chunk-HESYZWZW.js.map +1 -0
- package/dist/{chunk-QUVSNGIP.js → chunk-HGPQUCBC.js} +34 -9
- package/dist/{chunk-QUVSNGIP.js.map → chunk-HGPQUCBC.js.map} +1 -1
- package/dist/{chunk-UHNYIBXL.js → chunk-IXSNYUCT.js} +1 -1
- package/dist/chunk-IXSNYUCT.js.map +1 -0
- package/dist/{chunk-MI7HBHN3.js → chunk-MX3EIJGQ.js} +4 -3
- package/dist/{chunk-MI7HBHN3.js.map → chunk-MX3EIJGQ.js.map} +1 -1
- package/dist/{chunk-PWAHJW4G.js → chunk-OKI34GZD.js} +86 -33
- package/dist/chunk-OKI34GZD.js.map +1 -0
- package/dist/{chunk-W22JP75J.js → chunk-STTZQK2I.js} +3 -3
- package/dist/chunk-THRPYOFK.js +215 -0
- package/dist/chunk-THRPYOFK.js.map +1 -0
- package/dist/{chunk-M7W4CP3M.js → chunk-U6WNSFX5.js} +2 -1
- package/dist/chunk-U6WNSFX5.js.map +1 -0
- package/dist/{chunk-QCDXODCA.js → chunk-XAUHJD3L.js} +2 -2
- package/dist/components.d.ts +182 -6
- package/dist/components.js +157 -11
- package/dist/components.js.map +1 -1
- package/dist/eslint-rules/pace-core-compliance.cjs +406 -0
- package/dist/{file-reference-D06mEEWW.d.ts → file-reference-BjR39ktt.d.ts} +7 -1
- package/dist/hooks.d.ts +7 -14
- package/dist/hooks.js +10 -22
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +79 -16
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +3 -1
- package/dist/rbac/index.d.ts +205 -14
- package/dist/rbac/index.js +28 -6
- package/dist/timezone-_pgH8qrY.d.ts +530 -0
- package/dist/{types-_x1f4QBF.d.ts → types-DUyCRSTj.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/{usePublicRouteParams-JJczomYq.d.ts → usePublicRouteParams-CvnC3d-e.d.ts} +113 -2
- package/dist/utils.d.ts +109 -151
- package/dist/utils.js +128 -138
- package/dist/utils.js.map +1 -1
- package/docs/api/README.md +60 -1
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/Logger.md +178 -0
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +2 -2
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +2 -2
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +5 -5
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/enums/LogLevel.md +54 -0
- package/docs/api/enums/RBACErrorCode.md +1 -1
- package/docs/api/enums/RPCFunction.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/BadgeProps.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CalendarProps.md +18 -2
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/ComplianceResult.md +30 -0
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/DatabaseComplianceResult.md +85 -0
- package/docs/api/interfaces/DatabaseIssue.md +41 -0
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventAppRoleData.md +6 -6
- package/docs/api/interfaces/ExportColumn.md +1 -1
- package/docs/api/interfaces/ExportOptions.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +24 -8
- package/docs/api/interfaces/FileUploadProps.md +24 -13
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/FormFieldProps.md +1 -1
- package/docs/api/interfaces/FormProps.md +1 -1
- package/docs/api/interfaces/GrantEventAppRoleParams.md +9 -9
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoggerConfig.md +62 -0
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +36 -23
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +11 -11
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/ProgressProps.md +1 -1
- package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/QuickFix.md +52 -0
- package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
- package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
- package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +4 -4
- package/docs/api/interfaces/RBACContext.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckResult.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
- package/docs/api/interfaces/RBACResult.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantParams.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeParams.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateParams.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
- package/docs/api/interfaces/RBACRolesListParams.md +1 -1
- package/docs/api/interfaces/RBACRolesListResult.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
- package/docs/api/interfaces/ResourcePermissions.md +1 -1
- package/docs/api/interfaces/RevokeEventAppRoleParams.md +7 -7
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RoleManagementResult.md +5 -5
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/RuntimeComplianceResult.md +55 -0
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/SetupIssue.md +41 -0
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/TabsContentProps.md +1 -1
- package/docs/api/interfaces/TabsListProps.md +1 -1
- package/docs/api/interfaces/TabsProps.md +1 -1
- package/docs/api/interfaces/TabsTriggerProps.md +1 -1
- package/docs/api/interfaces/TextareaProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- package/docs/api/interfaces/UseFormDialogOptions.md +62 -0
- package/docs/api/interfaces/UseFormDialogReturn.md +117 -0
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +2 -2
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +2 -2
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +2 -2
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +738 -42
- package/docs/api-reference/hooks.md +111 -0
- package/docs/api-reference/rpc-functions.md +1 -1
- package/docs/api-reference/utilities.md +184 -0
- package/docs/getting-started/installation-guide.md +75 -16
- package/docs/getting-started/quick-start.md +61 -11
- package/docs/implementation-guides/authentication.md +88 -12
- package/docs/implementation-guides/file-reference-system.md +2 -1
- package/docs/implementation-guides/file-upload-storage.md +21 -0
- package/docs/rbac/README.md +1 -0
- package/docs/rbac/compliance/compliance-guide.md +544 -0
- package/docs/rbac/getting-started.md +158 -33
- package/docs/standards/pace-core-compliance.md +432 -0
- package/eslint-config-pace-core.cjs +93 -0
- package/package.json +15 -3
- package/scripts/analyze-bundle.js +232 -0
- package/scripts/build-css.js +56 -0
- package/scripts/build-docs-incremental.js +1015 -0
- package/scripts/check-pace-core-compliance.cjs +2353 -0
- package/scripts/generate-docs.js +157 -0
- package/scripts/setup-build-cache.js +73 -0
- package/scripts/utils/command-runner.js +131 -0
- package/scripts/utils/env.js +33 -0
- package/scripts/utils/index.js +10 -0
- package/scripts/utils/logger.js +88 -0
- package/scripts/utils/path-helpers.js +37 -0
- package/scripts/validate-formats.js +133 -0
- package/scripts/validate-master.js +155 -0
- package/scripts/validate-pre-publish.js +140 -0
- package/scripts/validate-theme.js +142 -0
- package/src/components/Calendar/Calendar.tsx +8 -1
- package/src/components/Card/Card.tsx +47 -8
- package/src/components/DatePickerWithTimezone/DatePickerWithTimezone.test.tsx +314 -0
- package/src/components/DatePickerWithTimezone/DatePickerWithTimezone.tsx +126 -0
- package/src/components/DatePickerWithTimezone/README.md +135 -0
- package/src/components/DatePickerWithTimezone/index.ts +10 -0
- package/src/components/DateTimeField/DateTimeField.test.tsx +358 -0
- package/src/components/DateTimeField/DateTimeField.tsx +232 -0
- package/src/components/DateTimeField/README.md +148 -0
- package/src/components/DateTimeField/index.ts +10 -0
- package/src/components/FileUpload/FileUpload.tsx +3 -0
- package/src/components/Header/Header.test.tsx +47 -18
- package/src/components/Header/Header.tsx +24 -6
- package/src/components/PaceAppLayout/PaceAppLayout.tsx +29 -20
- package/src/components/PaceAppLayout/README.md +9 -0
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +1 -1
- package/src/components/ProtectedRoute/ProtectedRoute.test.tsx +37 -8
- package/src/components/ProtectedRoute/ProtectedRoute.tsx +12 -4
- package/src/components/index.ts +8 -0
- package/src/eslint-rules/pace-core-compliance.cjs +406 -0
- package/src/eslint-rules/pace-core-compliance.js +640 -0
- package/src/hooks/__tests__/useFormDialog.test.ts +478 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFileReference.test.ts +1 -0
- package/src/hooks/useFormDialog.ts +147 -0
- package/src/index.ts +27 -0
- package/src/providers/services/OrganisationServiceProvider.tsx +6 -5
- package/src/providers/services/UnifiedAuthProvider.tsx +24 -3
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +3 -0
- package/src/rbac/compliance/database-validator.ts +165 -0
- package/src/rbac/compliance/index.ts +38 -0
- package/src/rbac/compliance/quick-fix-suggestions.ts +209 -0
- package/src/rbac/compliance/runtime-compliance.ts +77 -0
- package/src/rbac/compliance/setup-validator.ts +131 -0
- package/src/rbac/components/PagePermissionGuard.tsx +8 -64
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +35 -21
- package/src/rbac/docs/event-based-apps.md +285 -0
- package/src/rbac/errors.ts +11 -0
- package/src/rbac/hooks/useRoleManagement.ts +292 -12
- package/src/rbac/index.ts +30 -0
- package/src/services/OrganisationService.ts +4 -0
- package/src/types/file-reference.ts +6 -0
- package/src/utils/__tests__/timezone.test.ts +345 -0
- package/src/utils/file-reference/__tests__/file-reference.test.ts +2 -0
- package/src/utils/file-reference/index.ts +1 -0
- package/src/utils/formatting/formatDateTimeTimezone.test.ts +167 -0
- package/src/utils/formatting/formatting.ts +179 -0
- package/src/utils/index.ts +27 -1
- package/src/utils/location/index.ts +16 -0
- package/src/utils/location/location.test.ts +286 -0
- package/src/utils/location/location.ts +175 -0
- package/src/utils/timezone/index.ts +17 -0
- package/src/utils/timezone/timezone.test.ts +349 -0
- package/src/utils/timezone/timezone.ts +281 -0
- package/dist/chunk-CSOFYHAG.js.map +0 -1
- package/dist/chunk-FUEYYMX5.js.map +0 -1
- package/dist/chunk-HKIT6O7W.js +0 -198
- package/dist/chunk-HKIT6O7W.js.map +0 -1
- package/dist/chunk-KUEN3HFB.js +0 -94
- package/dist/chunk-KUEN3HFB.js.map +0 -1
- package/dist/chunk-M7W4CP3M.js.map +0 -1
- package/dist/chunk-PWAHJW4G.js.map +0 -1
- package/dist/chunk-QETLRQI6.js.map +0 -1
- package/dist/chunk-UHNYIBXL.js.map +0 -1
- package/dist/formatting-5wETwiGF.d.ts +0 -162
- /package/dist/{DataTable-QAB34V6K.js.map → DataTable-IX2NBUTP.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-7F6T4B6K.js.map → UnifiedAuthProvider-A4BCQRJY.js.map} +0 -0
- /package/dist/{api-ROMBCNKU.js.map → api-BMFCXVQX.js.map} +0 -0
- /package/dist/{chunk-W22JP75J.js.map → chunk-STTZQK2I.js.map} +0 -0
- /package/dist/{chunk-QCDXODCA.js.map → chunk-XAUHJD3L.js.map} +0 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook for manual session tracking (event switches and session expiration).
|
|
7
|
+
*
|
|
8
|
+
* Note: Login and logout tracking is automatically handled by UnifiedAuthProvider.
|
|
9
|
+
* You should only use this hook for tracking event switches or session expirations.
|
|
10
|
+
*
|
|
11
|
+
* @param supabaseClient - Supabase client instance
|
|
12
|
+
* @param appName - Optional application name for tracking
|
|
13
|
+
* @returns Object containing tracking functions for event switches and session expiration
|
|
14
|
+
*/
|
|
15
|
+
declare function useSessionTracking(supabaseClient: SupabaseClient, appName?: string): {
|
|
16
|
+
trackEventSwitch: (eventId: string) => Promise<void>;
|
|
17
|
+
trackSessionExpired: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @file Common validation schemas
|
|
22
|
+
* @description Reusable validation schemas for common data types
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Email validation schema
|
|
27
|
+
*/
|
|
28
|
+
declare const emailSchema: z.ZodString;
|
|
29
|
+
/**
|
|
30
|
+
* Name validation schema
|
|
31
|
+
*/
|
|
32
|
+
declare const nameSchema: z.ZodString;
|
|
33
|
+
/**
|
|
34
|
+
* Phone number validation schema
|
|
35
|
+
*/
|
|
36
|
+
declare const phoneSchema: z.ZodString;
|
|
37
|
+
/**
|
|
38
|
+
* URL validation schema
|
|
39
|
+
*/
|
|
40
|
+
declare const urlSchema: z.ZodString;
|
|
41
|
+
/**
|
|
42
|
+
* Date validation schema
|
|
43
|
+
*/
|
|
44
|
+
declare const dateSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @file Enhanced Password Schema with Security Validations
|
|
48
|
+
* @description Comprehensive password validation with security checks
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Basic password schema for less strict requirements
|
|
53
|
+
*/
|
|
54
|
+
declare const passwordSchema: z.ZodString;
|
|
55
|
+
/**
|
|
56
|
+
* Password strength calculator
|
|
57
|
+
*/
|
|
58
|
+
declare function calculatePasswordStrength(password: string): {
|
|
59
|
+
score: number;
|
|
60
|
+
feedback: string[];
|
|
61
|
+
level: 'very-weak' | 'weak' | 'fair' | 'good' | 'strong';
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @file Secure Data Access Utility
|
|
66
|
+
* @package @jmruthers/pace-core
|
|
67
|
+
* @module Utils/SecureDataAccess
|
|
68
|
+
* @since 0.4.0
|
|
69
|
+
*
|
|
70
|
+
* Secure data access utilities that enforce organisation context for all database operations.
|
|
71
|
+
* Prevents data leakage between organisations and ensures proper access validation.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
interface DatabaseRecord {
|
|
75
|
+
id: string;
|
|
76
|
+
organisation_id: string;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
interface DatabaseData {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
interface DatabaseFilters {
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
}
|
|
85
|
+
interface SecureQueryOptions {
|
|
86
|
+
table: string;
|
|
87
|
+
select: string;
|
|
88
|
+
organisationId: string;
|
|
89
|
+
filters?: DatabaseFilters;
|
|
90
|
+
orderBy?: string;
|
|
91
|
+
limit?: number;
|
|
92
|
+
offset?: number;
|
|
93
|
+
}
|
|
94
|
+
interface SecureDataAccess {
|
|
95
|
+
secureQuery: <T extends DatabaseRecord = DatabaseRecord>(options: SecureQueryOptions) => Promise<T[]>;
|
|
96
|
+
secureSingleQuery: <T extends DatabaseRecord = DatabaseRecord>(options: SecureQueryOptions) => Promise<T | null>;
|
|
97
|
+
secureInsert: <T extends DatabaseRecord = DatabaseRecord>(table: string, data: DatabaseData, organisationId: string) => Promise<T | null>;
|
|
98
|
+
secureUpdate: <T extends DatabaseRecord = DatabaseRecord>(table: string, data: DatabaseData, filters: DatabaseFilters, organisationId: string) => Promise<T | null>;
|
|
99
|
+
secureDelete: (table: string, filters: DatabaseFilters, organisationId: string) => Promise<boolean>;
|
|
100
|
+
queryByOrganisation: <T extends DatabaseRecord = DatabaseRecord>(table: string, select: string, organisationId: string, filters?: DatabaseFilters) => Promise<T[]>;
|
|
101
|
+
validateOrganisationContext: (organisationId: string) => void;
|
|
102
|
+
ensureOrganisationColumn: (table: string) => boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a secure data access instance
|
|
106
|
+
* @param supabase - Supabase client instance
|
|
107
|
+
* @param organisationId - Current organisation context
|
|
108
|
+
* @param isSuperAdmin - Whether user has super admin privileges
|
|
109
|
+
* @returns Secure data access utilities
|
|
110
|
+
*/
|
|
111
|
+
declare const createSecureDataAccess: (supabase: SupabaseClient, organisationId: string, isSuperAdmin?: boolean) => SecureDataAccess;
|
|
112
|
+
|
|
113
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Application configuration utilities
|
|
117
|
+
*/
|
|
118
|
+
interface AppConfig {
|
|
119
|
+
appName: string;
|
|
120
|
+
appId: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Set the current application configuration
|
|
124
|
+
*/
|
|
125
|
+
declare function setAppConfig(config: AppConfig): void;
|
|
126
|
+
/**
|
|
127
|
+
* Get the current application configuration
|
|
128
|
+
*/
|
|
129
|
+
declare function getAppConfig(): AppConfig;
|
|
130
|
+
/**
|
|
131
|
+
* Get the current app name
|
|
132
|
+
*/
|
|
133
|
+
declare function getCurrentAppName(): string;
|
|
134
|
+
/**
|
|
135
|
+
* Get the current app ID
|
|
136
|
+
*/
|
|
137
|
+
declare function getCurrentAppId(): string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @file Production-Safe Logger Utility
|
|
141
|
+
* @package @jmruthers/pace-core
|
|
142
|
+
* @module Utils/Logger
|
|
143
|
+
* @since 0.4.76
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* Logger levels for different types of messages
|
|
147
|
+
*/
|
|
148
|
+
declare enum LogLevel {
|
|
149
|
+
DEBUG = 0,
|
|
150
|
+
INFO = 1,
|
|
151
|
+
WARN = 2,
|
|
152
|
+
ERROR = 3
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Logger configuration interface
|
|
156
|
+
*/
|
|
157
|
+
interface LoggerConfig {
|
|
158
|
+
/** Minimum log level to output */
|
|
159
|
+
level: LogLevel;
|
|
160
|
+
/** Whether to include timestamps */
|
|
161
|
+
includeTimestamp: boolean;
|
|
162
|
+
/** Whether to include component names */
|
|
163
|
+
includeComponent: boolean;
|
|
164
|
+
/** Custom prefix for all log messages */
|
|
165
|
+
prefix?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Production-safe logger that no-ops in production builds
|
|
169
|
+
* Only outputs logs in development mode to prevent production console spam
|
|
170
|
+
*/
|
|
171
|
+
declare class Logger {
|
|
172
|
+
private static config;
|
|
173
|
+
/**
|
|
174
|
+
* Check if we're in development or test mode
|
|
175
|
+
* Allows logging in both development and test environments
|
|
176
|
+
*/
|
|
177
|
+
private static get isDevelopment();
|
|
178
|
+
/**
|
|
179
|
+
* Configure the logger
|
|
180
|
+
*/
|
|
181
|
+
static configure(config: Partial<LoggerConfig>): void;
|
|
182
|
+
/**
|
|
183
|
+
* Format a log message with optional timestamp and component
|
|
184
|
+
*/
|
|
185
|
+
private static formatMessage;
|
|
186
|
+
/**
|
|
187
|
+
* Check if a log level should be output
|
|
188
|
+
*/
|
|
189
|
+
private static shouldLog;
|
|
190
|
+
/**
|
|
191
|
+
* Log debug information (development only)
|
|
192
|
+
*/
|
|
193
|
+
static debug(component: string, message: string, ...args: any[]): void;
|
|
194
|
+
/**
|
|
195
|
+
* Log info information (development only)
|
|
196
|
+
*/
|
|
197
|
+
static info(component: string, message: string, ...args: any[]): void;
|
|
198
|
+
/**
|
|
199
|
+
* Log warning information (development only)
|
|
200
|
+
*/
|
|
201
|
+
static warn(component: string, message: string, ...args: any[]): void;
|
|
202
|
+
/**
|
|
203
|
+
* Log error information (development only)
|
|
204
|
+
*/
|
|
205
|
+
static error(component: string, message: string, ...args: any[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* Create a scoped logger for a specific component
|
|
208
|
+
*/
|
|
209
|
+
static createScopedLogger(component: string): {
|
|
210
|
+
debug: (message: string, ...args: any[]) => void;
|
|
211
|
+
info: (message: string, ...args: any[]) => void;
|
|
212
|
+
warn: (message: string, ...args: any[]) => void;
|
|
213
|
+
error: (message: string, ...args: any[]) => void;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Default logger instance for convenience
|
|
218
|
+
*/
|
|
219
|
+
declare const logger: {
|
|
220
|
+
debug: (component: string, message: string, ...args: any[]) => void;
|
|
221
|
+
info: (component: string, message: string, ...args: any[]) => void;
|
|
222
|
+
warn: (component: string, message: string, ...args: any[]) => void;
|
|
223
|
+
error: (component: string, message: string, ...args: any[]) => void;
|
|
224
|
+
createScopedLogger: (component: string) => {
|
|
225
|
+
debug: (message: string, ...args: any[]) => void;
|
|
226
|
+
info: (message: string, ...args: any[]) => void;
|
|
227
|
+
warn: (message: string, ...args: any[]) => void;
|
|
228
|
+
error: (message: string, ...args: any[]) => void;
|
|
229
|
+
};
|
|
230
|
+
configure: (config: Partial<LoggerConfig>) => void;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Convenience function to create a scoped logger
|
|
234
|
+
*/
|
|
235
|
+
declare function createLogger(component: string): {
|
|
236
|
+
debug: (message: string, ...args: any[]) => void;
|
|
237
|
+
info: (message: string, ...args: any[]) => void;
|
|
238
|
+
warn: (message: string, ...args: any[]) => void;
|
|
239
|
+
error: (message: string, ...args: any[]) => void;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Utility functions for formatting data in the application
|
|
244
|
+
*/
|
|
245
|
+
/**
|
|
246
|
+
* Format a date as a readable string in "dd mmm yyyy" format (e.g., "15 Jun 2024")
|
|
247
|
+
*/
|
|
248
|
+
declare function formatDate(date: Date | string | number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Format a time as a readable string in "HH:mm" format (e.g., "14:30")
|
|
251
|
+
* Uses 24-hour format for consistency across pace apps
|
|
252
|
+
*/
|
|
253
|
+
declare function formatTime(date: Date | string | number): string;
|
|
254
|
+
/**
|
|
255
|
+
* Format a date and time as a readable string in "dd mmm yyyy, HH:mm" format (e.g., "15 Jun 2024, 14:30")
|
|
256
|
+
* Uses 24-hour format for consistency across pace apps
|
|
257
|
+
*/
|
|
258
|
+
declare function formatDateTime(date: Date | string | number): string;
|
|
259
|
+
/**
|
|
260
|
+
* Format a number as a currency
|
|
261
|
+
*/
|
|
262
|
+
declare function formatCurrency(value: number, currencyCode?: string, locale?: string): string;
|
|
263
|
+
/**
|
|
264
|
+
* Format a number with custom options
|
|
265
|
+
*/
|
|
266
|
+
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions, locale?: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Format a number as a percentage.
|
|
269
|
+
*
|
|
270
|
+
* The third parameter can be either:
|
|
271
|
+
* - A number for fixed decimal places (backward compatible): `formatPercent(0.81, 'en-US', 2)`
|
|
272
|
+
* - An options object with:
|
|
273
|
+
* - `decimals`: Fixed number of decimal places (default: 1)
|
|
274
|
+
* - `preserveDecimals`: Auto-detect and preserve decimal places from the input value
|
|
275
|
+
* - `maxDecimals`: Maximum decimal places when preserving (default: 10)
|
|
276
|
+
*
|
|
277
|
+
* @param value - The percentage value as a decimal (e.g., 0.81 for 0.81%)
|
|
278
|
+
* @param locale - The locale string (default: 'en-US')
|
|
279
|
+
* @param decimalsOrOptions - Either a number for fixed decimals, or an options object with:
|
|
280
|
+
* - `decimals` - Fixed number of decimal places (default: 1)
|
|
281
|
+
* - `preserveDecimals` - Auto-detect and preserve decimal places from the input value
|
|
282
|
+
* - `maxDecimals` - Maximum decimal places when preserving (default: 10)
|
|
283
|
+
* @returns Formatted percentage string (e.g., "0.81%", "81%")
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* // Fixed decimals (default behavior)
|
|
288
|
+
* formatPercent(0.5) // '0.5%'
|
|
289
|
+
* formatPercent(0.81, 'en-US', 1) // '0.8%' (loses precision)
|
|
290
|
+
*
|
|
291
|
+
* // Preserve decimal places dynamically
|
|
292
|
+
* formatPercent(0.81, 'en-US', { preserveDecimals: true }) // '0.81%'
|
|
293
|
+
* formatPercent(0.8123, 'en-US', { preserveDecimals: true, maxDecimals: 2 }) // '0.81%'
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
declare function formatPercent(value: number, locale?: string, decimalsOrOptions?: number | {
|
|
297
|
+
decimals?: number;
|
|
298
|
+
preserveDecimals?: boolean;
|
|
299
|
+
maxDecimals?: number;
|
|
300
|
+
}): string;
|
|
301
|
+
/**
|
|
302
|
+
* Format a large number with abbreviations (K, M, B)
|
|
303
|
+
*/
|
|
304
|
+
declare function formatCompactNumber(value: number, locale?: string): string;
|
|
305
|
+
/**
|
|
306
|
+
* Format a file size in bytes to a human-readable string
|
|
307
|
+
*/
|
|
308
|
+
declare function formatFileSize(bytes: number): string;
|
|
309
|
+
/**
|
|
310
|
+
* Options for formatting date/time with timezone
|
|
311
|
+
*/
|
|
312
|
+
interface DateTimeFormatOptions {
|
|
313
|
+
/**
|
|
314
|
+
* Include timezone abbreviation (default: true)
|
|
315
|
+
*/
|
|
316
|
+
includeTimezone?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Custom format string (default: 'MMM dd, yyyy HH:mm')
|
|
319
|
+
*/
|
|
320
|
+
format?: string;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Format a UTC date for display in a specific timezone
|
|
324
|
+
*
|
|
325
|
+
* @param utcDate - UTC date (ISO string, Date object, or undefined)
|
|
326
|
+
* @param timezone - IANA timezone string (e.g., 'America/New_York')
|
|
327
|
+
* @param options - Formatting options
|
|
328
|
+
* @returns Formatted date string or empty string if invalid
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* formatDateTimeForDisplay('2024-01-15T10:00:00Z', 'America/New_York');
|
|
333
|
+
* // "Jan 15, 2024 05:00 (EST)"
|
|
334
|
+
*
|
|
335
|
+
* formatDateTimeForDisplay('2024-01-15T10:00:00Z', 'America/New_York', { includeTimezone: false });
|
|
336
|
+
* // "Jan 15, 2024 05:00"
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
declare function formatDateTimeForDisplay(utcDate: string | Date | undefined, timezone: string | undefined, options?: DateTimeFormatOptions): string;
|
|
340
|
+
/**
|
|
341
|
+
* Format a UTC date for display (date only, no time)
|
|
342
|
+
*
|
|
343
|
+
* @param utcDate - UTC date (ISO string, Date object, or undefined)
|
|
344
|
+
* @returns Formatted date string or empty string if invalid
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* formatDateOnlyForDisplay('2024-01-15T10:00:00Z');
|
|
349
|
+
* // "15 January 2024"
|
|
350
|
+
* ```
|
|
351
|
+
*/
|
|
352
|
+
declare function formatDateOnlyForDisplay(utcDate: string | Date | undefined): string;
|
|
353
|
+
/**
|
|
354
|
+
* Format a UTC date for table display (compact format with timezone)
|
|
355
|
+
*
|
|
356
|
+
* @param utcDate - UTC date (ISO string, Date object, or undefined)
|
|
357
|
+
* @param timezone - IANA timezone string
|
|
358
|
+
* @returns Formatted date string or empty string if invalid
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* formatDateTimeForTable('2024-01-15T10:00:00Z', 'America/New_York');
|
|
363
|
+
* // "Jan 15, 2024 05:00 (EST)"
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
declare function formatDateTimeForTable(utcDate: string | Date | undefined, timezone: string | undefined): string;
|
|
367
|
+
/**
|
|
368
|
+
* Format a UTC date for map display (compact format)
|
|
369
|
+
*
|
|
370
|
+
* @param utcDate - UTC date (ISO string, Date object, or undefined)
|
|
371
|
+
* @param timezone - IANA timezone string
|
|
372
|
+
* @returns Formatted date string or empty string if invalid
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* formatDateTimeForMap('2024-01-15T10:00:00Z', 'America/New_York');
|
|
377
|
+
* // "Jan 15, 05:00 EST"
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function formatDateTimeForMap(utcDate: string | Date | undefined, timezone: string | undefined): string;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @file Timezone Utilities
|
|
384
|
+
* @package @jmruthers/pace-core
|
|
385
|
+
* @module Utils/Timezone
|
|
386
|
+
* @since 0.1.0
|
|
387
|
+
*
|
|
388
|
+
* Comprehensive timezone conversion and formatting utilities using date-fns-tz and native Intl APIs.
|
|
389
|
+
* Provides functions for timezone-aware date operations, conversions, and formatting.
|
|
390
|
+
*
|
|
391
|
+
* Features:
|
|
392
|
+
* - Format dates in specific timezones
|
|
393
|
+
* - Get timezone abbreviations
|
|
394
|
+
* - Convert between UTC and timezone local times
|
|
395
|
+
* - Round dates to nearest minutes
|
|
396
|
+
* - Calculate timezone differences
|
|
397
|
+
* - Get user's browser timezone
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* import { toZonedTime, fromZonedTime, formatInTimeZone, getUserTimeZone } from '@jmruthers/pace-core/utils/timezone';
|
|
402
|
+
*
|
|
403
|
+
* // Convert UTC to local timezone
|
|
404
|
+
* const utcDate = new Date('2024-01-15T10:00:00Z');
|
|
405
|
+
* const localDate = toZonedTime(utcDate, 'America/New_York');
|
|
406
|
+
*
|
|
407
|
+
* // Convert local time to UTC
|
|
408
|
+
* const localInput = new Date(2024, 0, 15, 10, 0);
|
|
409
|
+
* const utcDate = fromZonedTime(localInput, 'America/New_York');
|
|
410
|
+
*
|
|
411
|
+
* // Format with timezone
|
|
412
|
+
* const formatted = formatInTimeZone(utcDate, 'America/New_York', 'MMM dd, yyyy HH:mm');
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
/**
|
|
416
|
+
* Format a date in a specific timezone using date-fns format strings
|
|
417
|
+
*
|
|
418
|
+
* @param date - Date to format (Date object, ISO string, or timestamp)
|
|
419
|
+
* @param timeZone - IANA timezone string (e.g., 'America/New_York')
|
|
420
|
+
* @param formatStr - date-fns format string (e.g., 'MMM dd, yyyy HH:mm')
|
|
421
|
+
* @returns Formatted date string or 'Invalid date' on error
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* formatInTimeZone(new Date('2024-01-15T10:00:00Z'), 'America/New_York', 'MMM dd, yyyy HH:mm');
|
|
426
|
+
* // "Jan 15, 2024 05:00"
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
declare function formatInTimeZone(date: Date | string | number, timeZone: string, formatStr: string): string;
|
|
430
|
+
/**
|
|
431
|
+
* Get the timezone abbreviation (EST, PST, etc.) for a date in a specific timezone
|
|
432
|
+
*
|
|
433
|
+
* @param date - Date to get abbreviation for
|
|
434
|
+
* @param timeZone - IANA timezone string
|
|
435
|
+
* @returns Timezone abbreviation or timezone name on error
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* getTimezoneAbbreviation(new Date(), 'America/New_York');
|
|
440
|
+
* // "EST" or "EDT" depending on date
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
declare function getTimezoneAbbreviation(date: Date, timeZone: string): string;
|
|
444
|
+
/**
|
|
445
|
+
* Format time only in a specific timezone
|
|
446
|
+
*
|
|
447
|
+
* @param date - Date to format
|
|
448
|
+
* @param timeZone - IANA timezone string
|
|
449
|
+
* @returns Formatted time string (HH:mm format) or 'Invalid date' on error
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* formatTimeInTimeZone(new Date('2024-01-15T10:00:00Z'), 'America/New_York');
|
|
454
|
+
* // "05:00"
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function formatTimeInTimeZone(date: Date | string, timeZone: string): string;
|
|
458
|
+
/**
|
|
459
|
+
* Get the user's local timezone from the browser
|
|
460
|
+
*
|
|
461
|
+
* @returns IANA timezone string (e.g., 'America/New_York')
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* const userTz = getUserTimeZone();
|
|
466
|
+
* // "America/New_York" or user's actual timezone
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
declare function getUserTimeZone(): string;
|
|
470
|
+
/**
|
|
471
|
+
* Convert a UTC date to a specific timezone's local time representation
|
|
472
|
+
*
|
|
473
|
+
* @param date - UTC date to convert
|
|
474
|
+
* @param timezone - IANA timezone string
|
|
475
|
+
* @returns Date object representing local time in the timezone
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```ts
|
|
479
|
+
* const utcDate = new Date('2024-01-15T10:00:00Z');
|
|
480
|
+
* const localDate = toZonedTime(utcDate, 'America/New_York');
|
|
481
|
+
* // Returns Date object representing 5:00 AM in New York
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
declare function toZonedTime(date: Date, timezone: string): Date;
|
|
485
|
+
/**
|
|
486
|
+
* Convert a local time in a specific timezone to UTC
|
|
487
|
+
*
|
|
488
|
+
* @param localDate - Local date in the timezone
|
|
489
|
+
* @param timezone - IANA timezone string
|
|
490
|
+
* @returns Date object in UTC
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```ts
|
|
494
|
+
* const localDate = new Date(2024, 0, 15, 10, 0); // Jan 15, 2024 10:00 AM local
|
|
495
|
+
* const utcDate = fromZonedTime(localDate, 'America/New_York');
|
|
496
|
+
* // Returns Date object representing 3:00 PM UTC (if EST) or 2:00 PM UTC (if EDT)
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
declare function fromZonedTime(localDate: Date, timezone: string): Date;
|
|
500
|
+
/**
|
|
501
|
+
* Round a date to the nearest X minutes
|
|
502
|
+
*
|
|
503
|
+
* @param date - Date to round
|
|
504
|
+
* @param minutesStep - Number of minutes to round to (default: 5)
|
|
505
|
+
* @returns Rounded date
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```ts
|
|
509
|
+
* const date = new Date('2024-01-15T10:23:00Z');
|
|
510
|
+
* roundToNearestMinutes(date, 5);
|
|
511
|
+
* // Returns Date object for 10:25:00
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
declare function roundToNearestMinutes(date: Date, minutesStep?: number): Date;
|
|
515
|
+
/**
|
|
516
|
+
* Calculate the time difference between two timezones in hours
|
|
517
|
+
*
|
|
518
|
+
* @param fromTimeZone - Source timezone (IANA string)
|
|
519
|
+
* @param toTimeZone - Target timezone (IANA string)
|
|
520
|
+
* @returns Difference in hours (positive if toTimeZone is ahead)
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```ts
|
|
524
|
+
* getTimeZoneDifference('America/New_York', 'America/Los_Angeles');
|
|
525
|
+
* // -3 (Los Angeles is 3 hours behind New York)
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
528
|
+
declare function getTimeZoneDifference(fromTimeZone: string, toTimeZone: string): number;
|
|
529
|
+
|
|
530
|
+
export { formatTimeInTimeZone as A, getUserTimeZone as B, toZonedTime as C, fromZonedTime as D, roundToNearestMinutes as E, getTimeZoneDifference as F, formatDateTimeForDisplay as G, formatDateOnlyForDisplay as H, formatDateTimeForTable as I, formatDateTimeForMap as J, type DateTimeFormatOptions as K, Logger as L, dateSchema as M, calculatePasswordStrength as N, type SecureDataAccess as S, urlSchema as a, passwordSchema as b, createSecureDataAccess as c, cn as d, emailSchema as e, getCurrentAppName as f, getAppConfig as g, getCurrentAppId as h, createLogger as i, LogLevel as j, type LoggerConfig as k, logger as l, formatDate as m, nameSchema as n, formatTime as o, phoneSchema as p, formatDateTime as q, formatCurrency as r, setAppConfig as s, formatNumber as t, useSessionTracking as u, formatPercent as v, formatCompactNumber as w, formatFileSize as x, formatInTimeZone as y, getTimezoneAbbreviation as z };
|
|
@@ -457,4 +457,4 @@ interface ExportOptions<TData extends DataRecord> {
|
|
|
457
457
|
table: unknown;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
export type { AggregateConfig as A, ChunkingConfig as C,
|
|
460
|
+
export type { AggregateConfig as A, ChunkingConfig as C, DataTableColumn as D, EmptyStateConfig as E, GetRowId as G, HierarchicalConfig as H, PerformanceConfig as P, ServerSideConfig as S, DataTableAction as a, DataTableToolbarButton as b, DataRecord as c, DataTableRBACConfig as d, DataTableFeatureConfig as e, PaginationMode as f, SearchIndexConfig as g, ExportOptions as h, ServerSideParams as i, ServerSideResponse as j };
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { A as AppId, D as DataRecord, E as EventId, O as OrganisationId, P as Pa
|
|
|
3
3
|
import { U as User, a as Session } from './auth-BZOJqrdd.js';
|
|
4
4
|
export { S as SessionRestorationState } from './auth-BZOJqrdd.js';
|
|
5
5
|
export { E as Event, c as EventContextType, b as EventTheme, k as ORGANISATION_ROLE_PERMISSIONS, O as Organisation, n as OrganisationAccessLog, h as OrganisationContextType, j as OrganisationHierarchy, e as OrganisationInvitation, a as OrganisationMembership, m as OrganisationPermission, i as OrganisationProviderProps, l as OrganisationRole, f as OrganisationRoleDefinition, g as OrganisationSecurityError, d as OrganisationSettings, o as SecureQueryOptions, S as SuperAdminContext, T as ThemeColors, U as UserProfile } from './event-CW5YB_2p.js';
|
|
6
|
-
export { g as BucketInfo, B as BulkUploadResult,
|
|
6
|
+
export { g as BucketInfo, B as BulkUploadResult, F as FileCategory, b as FileMetadata, a as FileReference, d as FileReferenceService, f as FileReferenceWithUrl, c as FileUploadOptions, e as FileUploadResult, h as FileUrlInfo, S as StorageUploadOptions, U as UploadProgress } from './file-reference-BjR39ktt.js';
|
|
7
7
|
export { C as ChangePasswordFormValues, o as ContactFormData, F as FormData, k as LoginFormData, L as LoginFormValues, P as ProfileFormData, m as RegistrationFormData, R as RegistrationFormValues, S as SecureLoginFormValues, j as SecureRegistrationFormValues, U as UserProfileFormValues, V as ValidationError, a as ValidationResult, g as changePasswordSchema, t as combineSchemas, i as contactFormSchema, d as dateSchema, e as emailSchema, l as loginSchema, n as nameSchema, f as passwordResetSchema, b as passwordSchema, p as phoneSchema, q as pickSchema, r as registrationSchema, c as secureLoginSchema, s as securePasswordSchema, u as urlSchema, h as userProfileSchema } from './validation-643vUDZW.js';
|
|
8
8
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
9
9
|
export { D as Database, J as Json } from './database.generated-CBmg2950.js';
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,118 @@
|
|
|
1
|
+
import * as react_hook_form from 'react-hook-form';
|
|
2
|
+
import { z } from 'zod';
|
|
1
3
|
import { l as OrganisationRole, m as OrganisationPermission, S as SuperAdminContext, E as Event } from './event-CW5YB_2p.js';
|
|
2
4
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
3
5
|
import { D as Database } from './database.generated-CBmg2950.js';
|
|
4
|
-
import {
|
|
6
|
+
import { F as FileCategory, a as FileReference } from './file-reference-BjR39ktt.js';
|
|
7
|
+
|
|
8
|
+
interface UseZodFormProps<T extends z.ZodTypeAny> {
|
|
9
|
+
schema: T;
|
|
10
|
+
defaultValues?: Partial<z.infer<T>>;
|
|
11
|
+
mode?: 'onSubmit' | 'onBlur' | 'onChange' | 'onTouched' | 'all';
|
|
12
|
+
}
|
|
13
|
+
declare function useZodForm<T extends z.ZodTypeAny>({ schema, defaultValues, mode }: UseZodFormProps<T>): react_hook_form.UseFormReturn<z.TypeOf<T>, any, z.TypeOf<T>>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @file useFormDialog Hook
|
|
17
|
+
* @package @jmruthers/pace-core
|
|
18
|
+
* @module Hooks
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*
|
|
21
|
+
* Generic React hook for managing form dialog state (open/close, form data, reset behavior).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* interface ContactFormData {
|
|
26
|
+
* name: string;
|
|
27
|
+
* email: string;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* function ContactDialog() {
|
|
31
|
+
* const { isOpen, formData, openDialog, closeDialog, handleOpenChange } =
|
|
32
|
+
* useFormDialog<ContactFormData>();
|
|
33
|
+
*
|
|
34
|
+
* // Use in Dialog component
|
|
35
|
+
* // <Dialog open={isOpen} onOpenChange={handleOpenChange}>...</Dialog>
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Options for configuring the useFormDialog hook behavior
|
|
41
|
+
*/
|
|
42
|
+
interface UseFormDialogOptions<T = unknown> {
|
|
43
|
+
/**
|
|
44
|
+
* Callback invoked when the dialog open state changes
|
|
45
|
+
* @param open - The new open state
|
|
46
|
+
*/
|
|
47
|
+
onOpenChange?: (open: boolean) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to reset form data when the dialog closes
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
resetOnClose?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Return type for the useFormDialog hook
|
|
56
|
+
*/
|
|
57
|
+
interface UseFormDialogReturn<T = unknown> {
|
|
58
|
+
/**
|
|
59
|
+
* Current open state of the dialog
|
|
60
|
+
*/
|
|
61
|
+
isOpen: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Current form data (null when dialog is closed or no data provided)
|
|
64
|
+
*/
|
|
65
|
+
formData: T | null;
|
|
66
|
+
/**
|
|
67
|
+
* Open the dialog with optional form data
|
|
68
|
+
* @param data - Optional form data to populate the dialog
|
|
69
|
+
*/
|
|
70
|
+
openDialog: (data?: T | null) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Close the dialog
|
|
73
|
+
*/
|
|
74
|
+
closeDialog: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Handler for controlled dialog components (e.g., Radix UI Dialog)
|
|
77
|
+
* @param open - The new open state
|
|
78
|
+
*/
|
|
79
|
+
handleOpenChange: (open: boolean) => void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Generic React hook for managing form dialog state.
|
|
83
|
+
*
|
|
84
|
+
* Provides state management for form dialogs including:
|
|
85
|
+
* - Open/close state
|
|
86
|
+
* - Form data management
|
|
87
|
+
* - Automatic reset on close (configurable)
|
|
88
|
+
* - Controlled and uncontrolled usage patterns
|
|
89
|
+
*
|
|
90
|
+
* @param options - Configuration options for the hook
|
|
91
|
+
* @returns Object containing dialog state and control functions
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* // Basic usage
|
|
96
|
+
* const { isOpen, openDialog, closeDialog } = useFormDialog();
|
|
97
|
+
*
|
|
98
|
+
* // With form data
|
|
99
|
+
* interface UserData {
|
|
100
|
+
* id: string;
|
|
101
|
+
* name: string;
|
|
102
|
+
* }
|
|
103
|
+
* const { isOpen, formData, openDialog } = useFormDialog<UserData>();
|
|
104
|
+
*
|
|
105
|
+
* // Open with data
|
|
106
|
+
* openDialog({ id: '1', name: 'John' });
|
|
107
|
+
*
|
|
108
|
+
* // Controlled usage with callback
|
|
109
|
+
* const { handleOpenChange, isOpen } = useFormDialog({
|
|
110
|
+
* onOpenChange: (open) => console.log('Dialog state:', open),
|
|
111
|
+
* resetOnClose: false
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function useFormDialog<T = unknown>({ onOpenChange, resetOnClose, }?: UseFormDialogOptions<T>): UseFormDialogReturn<T>;
|
|
5
116
|
|
|
6
117
|
/**
|
|
7
118
|
* @file useOrganisationPermissions Hook
|
|
@@ -734,4 +845,4 @@ declare function generatePublicRoutePath(eventCode: string, pageName?: string):
|
|
|
734
845
|
*/
|
|
735
846
|
declare function extractEventCodeFromPath(path: string): string | null;
|
|
736
847
|
|
|
737
|
-
export { type
|
|
848
|
+
export { type UsePublicEventReturn as A, type UsePublicEventOptions as B, type UsePublicFileDisplayReturn as C, type UsePublicFileDisplayOptions as D, type UsePublicEventLogoReturn as E, type UsePublicEventLogoOptions as F, type UsePublicRouteParamsReturn as G, type FileSizeLimits as H, type StorageConfig as I, type StorageFileMetadata as J, type StorageUrlOptions as K, type OrganisationSecurityHook as O, type StorageUploadOptions as S, type UseOrganisationPermissionsReturn as U, type StorageUploadResult as a, type StorageListOptions as b, type StorageListResult as c, type StorageFileInfo as d, useOrganisationPermissions as e, useOrganisationSecurity as f, useZodForm as g, useFormDialog as h, type UseFormDialogOptions as i, type UseFormDialogReturn as j, useAppConfig as k, type UseAppConfigReturn as l, usePublicEvent as m, clearPublicEventCache as n, getPublicEventCacheStats as o, usePublicFileDisplay as p, clearPublicFileDisplayCache as q, getPublicFileDisplayCacheStats as r, usePublicEventLogo as s, clearPublicLogoCache as t, useEventTheme as u, getPublicLogoCacheStats as v, usePublicRouteParams as w, usePublicEventCode as x, generatePublicRoutePath as y, extractEventCodeFromPath as z };
|