@jmruthers/pace-core 0.5.86 → 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.
- package/dist/{AuthService-Df3IozMG.d.ts → AuthService-DcTI5Ov4.d.ts} +9 -0
- package/dist/{DataTable-DKGTBLWT.js → DataTable-PWBMKMOG.js} +8 -8
- package/dist/{PublicLoadingSpinner-CnUaz0vG.d.ts → PublicLoadingSpinner-BQXD1fbO.d.ts} +161 -131
- package/dist/{UnifiedAuthProvider-K2IZAY5F.js → UnifiedAuthProvider-5D3HEQND.js} +4 -4
- package/dist/{UnifiedAuthProvider-B391Aqum.d.ts → UnifiedAuthProvider-BVKmQd9u.d.ts} +4 -0
- package/dist/auth-DReDSLq9.d.ts +16 -0
- package/dist/{chunk-CBSD3BZ3.js → chunk-3RZBKQ5Y.js} +2 -6
- package/dist/{chunk-CBSD3BZ3.js.map → chunk-3RZBKQ5Y.js.map} +1 -1
- package/dist/{chunk-NTW3KGS4.js → chunk-6UHXQH7P.js} +5 -5
- package/dist/{chunk-YVUZWLQG.js → chunk-AQGF5OG7.js} +3 -3
- package/dist/{chunk-CVMVPYAL.js → chunk-BDZUMRBD.js} +3 -5
- package/dist/chunk-BDZUMRBD.js.map +1 -0
- package/dist/{chunk-QCCJ3P4W.js → chunk-BNXBJOGL.js} +5 -5
- package/dist/{chunk-IBMPGOCN.js → chunk-CJIZS3UE.js} +1430 -783
- package/dist/chunk-CJIZS3UE.js.map +1 -0
- package/dist/{chunk-S3JKDMD5.js → chunk-CXKMRKRF.js} +4 -4
- package/dist/{chunk-5BN3YGNK.js → chunk-DP5X5ORK.js} +217 -27
- package/dist/chunk-DP5X5ORK.js.map +1 -0
- package/dist/{chunk-KUYWZVR2.js → chunk-H3P2RGKZ.js} +353 -9
- package/dist/chunk-H3P2RGKZ.js.map +1 -0
- package/dist/{chunk-RIXPZJUB.js → chunk-KTPG5VCH.js} +2 -2
- package/dist/{chunk-YCKPEMJA.js → chunk-QPCAGLUS.js} +2 -3
- package/dist/chunk-QPCAGLUS.js.map +1 -0
- package/dist/{chunk-WUXCWRL6.js → chunk-XJ2HZOBU.js} +6 -1
- package/dist/chunk-XJ2HZOBU.js.map +1 -0
- package/dist/{chunk-V5SWX6KL.js → chunk-XXVM53P4.js} +4 -4
- package/dist/{chunk-I2VVV5PQ.js → chunk-YY4YYM3E.js} +2 -2
- package/dist/components.d.ts +6 -55
- package/dist/components.js +25 -206
- package/dist/components.js.map +1 -1
- package/dist/{file-reference-9xUOnwyt.d.ts → file-reference-C9isKNPn.d.ts} +67 -2
- package/dist/hooks.js +10 -9
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +152 -26
- package/dist/index.js +65 -195
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +5 -3
- package/dist/providers.js +3 -3
- package/dist/rbac/index.js +8 -8
- package/dist/types.d.ts +2 -1
- package/dist/types.js +3 -3
- package/dist/utils.js +2 -2
- package/docs/DOCUMENTATION_AUDIT.md +6 -6
- package/docs/DOCUMENTATION_STANDARD.md +137 -0
- package/docs/README.md +1 -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/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +83 -40
- package/docs/api/enums/FileCategory.md +56 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- 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/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/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +11 -11
- package/docs/api/interfaces/FileDisplayProps.md +10 -10
- 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 +8 -8
- package/docs/api/interfaces/FileUploadProps.md +137 -42
- package/docs/api/interfaces/FooterProps.md +1 -1
- 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/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 +1 -1
- 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 +1 -1
- 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/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.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/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- 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/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +83 -50
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
- package/docs/api/interfaces/UseEventLogoOptions.md +74 -0
- package/docs/api/interfaces/UseEventLogoReturn.md +81 -0
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +6 -6
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +6 -6
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +292 -97
- package/docs/api-reference/components.md +1 -18
- package/docs/api-reference/hooks.md +1 -4
- package/docs/best-practices/testing.md +2 -0
- package/docs/documentation-index.md +1 -1
- package/docs/getting-started/faq.md +1 -1
- package/docs/implementation-guides/file-reference-system.md +592 -58
- package/docs/implementation-guides/file-upload-storage.md +137 -73
- package/docs/rbac/super-admin-guide.md +18 -70
- package/docs/testing/README.md +2 -0
- package/package.json +1 -1
- package/src/__tests__/TEST_STANDARD.md +674 -0
- package/src/__tests__/helpers/test-utils.tsx +3 -2
- package/src/components/DataTable/__tests__/{DataTable.comprehensive.test.tsx.skip → DataTable.comprehensive.test.tsx} +17 -18
- package/src/components/DataTable/__tests__/{DataTable.test.tsx.skip → DataTable.test.tsx} +14 -22
- package/src/components/DataTable/__tests__/{ssr.strict-mode.test.tsx.skip → ssr.strict-mode.test.tsx} +42 -47
- package/src/components/DataTable/components/__tests__/COVERAGE_NOTE.md +1 -1
- package/src/components/DataTable/examples/__tests__/PerformanceExample.test.tsx +13 -4
- package/src/components/DataTable/utils/__tests__/COVERAGE_NOTE.md +1 -1
- package/src/components/DataTable/utils/__tests__/performanceUtils.test.ts +10 -6
- package/src/components/DataTable/utils/performanceUtils.ts +12 -3
- package/src/components/FileDisplay/FileDisplay.test.tsx +257 -0
- package/src/components/{FileDisplay.tsx → FileDisplay/FileDisplay.tsx} +111 -10
- package/src/components/FileDisplay/index.tsx +4 -0
- package/src/components/FileUpload/FileUpload.test.tsx +171 -621
- package/src/components/FileUpload/FileUpload.tsx +512 -168
- package/src/components/FileUpload/index.tsx +4 -0
- package/src/components/Progress/Progress.test.tsx +38 -0
- package/src/components/PublicLayout/EventLogo.tsx +220 -39
- package/src/components/PublicLayout/PublicPageProvider.tsx +1 -1
- package/src/components/Select/Select.test.tsx +1 -1
- package/src/components/SessionRestorationLoader.tsx +48 -0
- package/src/components/Toast/Toast.tsx +13 -8
- package/src/components/index.ts +16 -16
- package/src/hooks/__tests__/ServiceHooks.test.tsx +615 -0
- package/src/hooks/public/usePublicEventLogo.ts +17 -7
- package/src/hooks/useDataTablePerformance.ts +4 -0
- package/src/hooks/useEventLogo.ts +316 -0
- package/src/hooks/useEvents.ts +0 -5
- package/src/hooks/useFileReference.test.ts +659 -0
- package/src/hooks/useFileReference.ts +207 -3
- package/src/hooks/useSessionRestoration.ts +64 -0
- package/src/index.ts +17 -5
- package/src/providers/{UnifiedAuthProvider.test.simple.tsx → UnifiedAuthProvider.smoke.test.tsx} +81 -60
- package/src/providers/services/AuthServiceProvider.tsx +27 -3
- package/src/providers/services/UnifiedAuthProvider.tsx +34 -5
- package/src/rbac/{engine.test.simple.ts → RBACEngine.smoke.test.ts} +17 -12
- package/src/services/AuthService.ts +142 -20
- package/src/services/EventService.ts +0 -4
- package/src/types/auth.ts +15 -0
- package/src/types/file-reference.ts +73 -1
- package/src/types/index.ts +1 -0
- package/src/utils/__tests__/organisationContext.unit.test.ts +2 -4
- package/src/utils/appNameResolver.simple.test.ts +99 -29
- package/src/utils/file-reference.test.ts +535 -0
- package/src/utils/file-reference.ts +200 -30
- package/src/utils/organisationContext.test.ts +5 -19
- package/src/utils/organisationContext.ts +3 -5
- package/src/utils/storage/README.md +269 -262
- package/src/utils/storage/config.ts +9 -0
- package/src/utils/storage/helpers.test.ts +631 -0
- package/src/utils/storage/helpers.ts +112 -14
- package/src/utils/storage/index.ts +3 -0
- package/src/validation/__tests__/sanitization.unit.test.ts +1 -1
- package/src/validation/__tests__/schemaUtils.unit.test.ts +1 -1
- package/src/validation/__tests__/user.unit.test.ts +1 -1
- package/dist/chunk-5BN3YGNK.js.map +0 -1
- package/dist/chunk-CVMVPYAL.js.map +0 -1
- package/dist/chunk-IBMPGOCN.js.map +0 -1
- package/dist/chunk-KUYWZVR2.js.map +0 -1
- package/dist/chunk-WUXCWRL6.js.map +0 -1
- package/dist/chunk-YCKPEMJA.js.map +0 -1
- package/docs/CONTENT_AUDIT_REPORT.md +0 -253
- package/docs/STYLE_GUIDE.md +0 -37
- package/examples/RBAC/__tests__/PermissionExample.test.tsx +0 -150
- package/examples/public-pages/__tests__/PublicPageUsageExample.test.tsx +0 -159
- package/src/__tests__/TEST_GUIDE_CURSOR.md +0 -1605
- package/src/__tests__/TEST_GUIDE_HUMAN.md +0 -103
- package/src/components/FileUpload/FileUpload.example.tsx +0 -218
- package/src/components/FileUpload/index.ts +0 -6
- package/src/components/FileUpload.tsx +0 -176
- package/src/components/Progress/index.ts +0 -3
- package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +0 -666
- package/src/components/SuperAdminGuard.tsx +0 -116
- package/src/components/__tests__/FileDisplay.test.tsx +0 -575
- package/src/components/__tests__/FileUpload.test.tsx +0 -446
- package/src/components/__tests__/SuperAdminGuard.test.tsx +0 -627
- package/src/components/examples/PermissionExample.tsx +0 -173
- package/src/hooks/__tests__/usePublicEvent.unit.test.ts +0 -583
- package/src/hooks/__tests__/usePublicEventLogo.unit.test.ts +0 -640
- package/src/types/__tests__/file-reference.test.ts +0 -447
- package/src/utils/__tests__/file-reference.test.ts +0 -383
- /package/dist/{DataTable-DKGTBLWT.js.map → DataTable-PWBMKMOG.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-K2IZAY5F.js.map → UnifiedAuthProvider-5D3HEQND.js.map} +0 -0
- /package/dist/{chunk-NTW3KGS4.js.map → chunk-6UHXQH7P.js.map} +0 -0
- /package/dist/{chunk-YVUZWLQG.js.map → chunk-AQGF5OG7.js.map} +0 -0
- /package/dist/{chunk-QCCJ3P4W.js.map → chunk-BNXBJOGL.js.map} +0 -0
- /package/dist/{chunk-S3JKDMD5.js.map → chunk-CXKMRKRF.js.map} +0 -0
- /package/dist/{chunk-RIXPZJUB.js.map → chunk-KTPG5VCH.js.map} +0 -0
- /package/dist/{chunk-V5SWX6KL.js.map → chunk-XXVM53P4.js.map} +0 -0
- /package/dist/{chunk-I2VVV5PQ.js.map → chunk-YY4YYM3E.js.map} +0 -0
- /package/src/providers/{OrganisationProvider.test.simple.tsx → OrganisationProvider.context.test.tsx} +0 -0
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file File Reference Type Tests
|
|
3
|
-
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Types/__tests__
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect } from 'vitest';
|
|
9
|
-
import type {
|
|
10
|
-
FileReference,
|
|
11
|
-
FileUploadOptions,
|
|
12
|
-
FileUploadResult,
|
|
13
|
-
FileValidationError,
|
|
14
|
-
FileMetadata,
|
|
15
|
-
FileStorageConfig,
|
|
16
|
-
FileAccessLevel
|
|
17
|
-
} from '../file-reference';
|
|
18
|
-
|
|
19
|
-
describe('[types] File Reference Types', () => {
|
|
20
|
-
describe('FileReference interface', () => {
|
|
21
|
-
it('validates FileReference type structure', () => {
|
|
22
|
-
const fileRef: FileReference = {
|
|
23
|
-
id: 'test-file-id',
|
|
24
|
-
filename: 'test-file.pdf',
|
|
25
|
-
originalName: 'Test File.pdf',
|
|
26
|
-
mimeType: 'application/pdf',
|
|
27
|
-
size: 1024,
|
|
28
|
-
url: 'https://example.com/files/test-file.pdf',
|
|
29
|
-
uploadedAt: '2024-01-01T00:00:00Z',
|
|
30
|
-
uploadedBy: 'user-123',
|
|
31
|
-
organisationId: 'org-123',
|
|
32
|
-
eventId: 'event-123',
|
|
33
|
-
accessLevel: 'private',
|
|
34
|
-
metadata: {
|
|
35
|
-
description: 'Test file description',
|
|
36
|
-
tags: ['document', 'test']
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
expect(fileRef).toHaveProperty('id');
|
|
41
|
-
expect(fileRef).toHaveProperty('filename');
|
|
42
|
-
expect(fileRef).toHaveProperty('originalName');
|
|
43
|
-
expect(fileRef).toHaveProperty('mimeType');
|
|
44
|
-
expect(fileRef).toHaveProperty('size');
|
|
45
|
-
expect(fileRef).toHaveProperty('url');
|
|
46
|
-
expect(fileRef).toHaveProperty('uploadedAt');
|
|
47
|
-
expect(fileRef).toHaveProperty('uploadedBy');
|
|
48
|
-
expect(fileRef).toHaveProperty('organisationId');
|
|
49
|
-
expect(fileRef).toHaveProperty('eventId');
|
|
50
|
-
expect(fileRef).toHaveProperty('accessLevel');
|
|
51
|
-
expect(fileRef).toHaveProperty('metadata');
|
|
52
|
-
|
|
53
|
-
expect(typeof fileRef.id).toBe('string');
|
|
54
|
-
expect(typeof fileRef.filename).toBe('string');
|
|
55
|
-
expect(typeof fileRef.originalName).toBe('string');
|
|
56
|
-
expect(typeof fileRef.mimeType).toBe('string');
|
|
57
|
-
expect(typeof fileRef.size).toBe('number');
|
|
58
|
-
expect(typeof fileRef.url).toBe('string');
|
|
59
|
-
expect(typeof fileRef.uploadedAt).toBe('string');
|
|
60
|
-
expect(typeof fileRef.uploadedBy).toBe('string');
|
|
61
|
-
expect(typeof fileRef.organisationId).toBe('string');
|
|
62
|
-
expect(typeof fileRef.eventId).toBe('string');
|
|
63
|
-
expect(typeof fileRef.accessLevel).toBe('string');
|
|
64
|
-
expect(typeof fileRef.metadata).toBe('object');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('validates FileReference with minimal required fields', () => {
|
|
68
|
-
const fileRef: FileReference = {
|
|
69
|
-
id: 'test-file-id',
|
|
70
|
-
filename: 'test-file.pdf',
|
|
71
|
-
originalName: 'Test File.pdf',
|
|
72
|
-
mimeType: 'application/pdf',
|
|
73
|
-
size: 1024,
|
|
74
|
-
url: 'https://example.com/files/test-file.pdf',
|
|
75
|
-
uploadedAt: '2024-01-01T00:00:00Z',
|
|
76
|
-
uploadedBy: 'user-123',
|
|
77
|
-
organisationId: 'org-123',
|
|
78
|
-
accessLevel: 'private'
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
expect(fileRef).toHaveProperty('id');
|
|
82
|
-
expect(fileRef).toHaveProperty('filename');
|
|
83
|
-
expect(fileRef.eventId).toBeUndefined();
|
|
84
|
-
expect(fileRef.metadata).toBeUndefined();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('FileUploadOptions interface', () => {
|
|
89
|
-
it('validates FileUploadOptions type structure', () => {
|
|
90
|
-
const uploadOptions: FileUploadOptions = {
|
|
91
|
-
maxSize: 5 * 1024 * 1024, // 5MB
|
|
92
|
-
allowedTypes: ['image/jpeg', 'image/png', 'application/pdf'],
|
|
93
|
-
allowedExtensions: ['.jpg', '.jpeg', '.png', '.pdf'],
|
|
94
|
-
generateThumbnail: true,
|
|
95
|
-
compressImage: true,
|
|
96
|
-
quality: 0.8,
|
|
97
|
-
resize: {
|
|
98
|
-
width: 1920,
|
|
99
|
-
height: 1080,
|
|
100
|
-
maintainAspectRatio: true
|
|
101
|
-
},
|
|
102
|
-
metadata: {
|
|
103
|
-
description: 'Uploaded file',
|
|
104
|
-
tags: ['upload']
|
|
105
|
-
},
|
|
106
|
-
accessLevel: 'private',
|
|
107
|
-
organisationId: 'org-123',
|
|
108
|
-
eventId: 'event-123'
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
expect(uploadOptions).toHaveProperty('maxSize');
|
|
112
|
-
expect(uploadOptions).toHaveProperty('allowedTypes');
|
|
113
|
-
expect(uploadOptions).toHaveProperty('allowedExtensions');
|
|
114
|
-
expect(uploadOptions).toHaveProperty('generateThumbnail');
|
|
115
|
-
expect(uploadOptions).toHaveProperty('compressImage');
|
|
116
|
-
expect(uploadOptions).toHaveProperty('quality');
|
|
117
|
-
expect(uploadOptions).toHaveProperty('resize');
|
|
118
|
-
expect(uploadOptions).toHaveProperty('metadata');
|
|
119
|
-
expect(uploadOptions).toHaveProperty('accessLevel');
|
|
120
|
-
expect(uploadOptions).toHaveProperty('organisationId');
|
|
121
|
-
expect(uploadOptions).toHaveProperty('eventId');
|
|
122
|
-
|
|
123
|
-
expect(typeof uploadOptions.maxSize).toBe('number');
|
|
124
|
-
expect(Array.isArray(uploadOptions.allowedTypes)).toBe(true);
|
|
125
|
-
expect(Array.isArray(uploadOptions.allowedExtensions)).toBe(true);
|
|
126
|
-
expect(typeof uploadOptions.generateThumbnail).toBe('boolean');
|
|
127
|
-
expect(typeof uploadOptions.compressImage).toBe('boolean');
|
|
128
|
-
expect(typeof uploadOptions.quality).toBe('number');
|
|
129
|
-
expect(typeof uploadOptions.resize).toBe('object');
|
|
130
|
-
expect(typeof uploadOptions.metadata).toBe('object');
|
|
131
|
-
expect(typeof uploadOptions.accessLevel).toBe('string');
|
|
132
|
-
expect(typeof uploadOptions.organisationId).toBe('string');
|
|
133
|
-
expect(typeof uploadOptions.eventId).toBe('string');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('validates FileUploadOptions with minimal fields', () => {
|
|
137
|
-
const uploadOptions: FileUploadOptions = {
|
|
138
|
-
maxSize: 1024 * 1024, // 1MB
|
|
139
|
-
allowedTypes: ['image/jpeg'],
|
|
140
|
-
accessLevel: 'public'
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
expect(uploadOptions).toHaveProperty('maxSize');
|
|
144
|
-
expect(uploadOptions).toHaveProperty('allowedTypes');
|
|
145
|
-
expect(uploadOptions).toHaveProperty('accessLevel');
|
|
146
|
-
expect(uploadOptions.allowedExtensions).toBeUndefined();
|
|
147
|
-
expect(uploadOptions.generateThumbnail).toBeUndefined();
|
|
148
|
-
expect(uploadOptions.compressImage).toBeUndefined();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe('FileUploadResult interface', () => {
|
|
153
|
-
it('validates FileUploadResult success structure', () => {
|
|
154
|
-
const successResult: FileUploadResult = {
|
|
155
|
-
success: true,
|
|
156
|
-
file: {
|
|
157
|
-
id: 'test-file-id',
|
|
158
|
-
filename: 'test-file.pdf',
|
|
159
|
-
originalName: 'Test File.pdf',
|
|
160
|
-
mimeType: 'application/pdf',
|
|
161
|
-
size: 1024,
|
|
162
|
-
url: 'https://example.com/files/test-file.pdf',
|
|
163
|
-
uploadedAt: '2024-01-01T00:00:00Z',
|
|
164
|
-
uploadedBy: 'user-123',
|
|
165
|
-
organisationId: 'org-123',
|
|
166
|
-
accessLevel: 'private'
|
|
167
|
-
},
|
|
168
|
-
thumbnailUrl: 'https://example.com/thumbnails/test-file.jpg',
|
|
169
|
-
message: 'File uploaded successfully'
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
expect(successResult).toHaveProperty('success');
|
|
173
|
-
expect(successResult).toHaveProperty('file');
|
|
174
|
-
expect(successResult).toHaveProperty('thumbnailUrl');
|
|
175
|
-
expect(successResult).toHaveProperty('message');
|
|
176
|
-
expect(successResult.success).toBe(true);
|
|
177
|
-
expect(typeof successResult.file).toBe('object');
|
|
178
|
-
expect(typeof successResult.thumbnailUrl).toBe('string');
|
|
179
|
-
expect(typeof successResult.message).toBe('string');
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('validates FileUploadResult error structure', () => {
|
|
183
|
-
const errorResult: FileUploadResult = {
|
|
184
|
-
success: false,
|
|
185
|
-
error: 'File size exceeds maximum allowed size',
|
|
186
|
-
code: 'FILE_TOO_LARGE',
|
|
187
|
-
details: {
|
|
188
|
-
maxSize: 5 * 1024 * 1024,
|
|
189
|
-
actualSize: 10 * 1024 * 1024
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
expect(errorResult).toHaveProperty('success');
|
|
194
|
-
expect(errorResult).toHaveProperty('error');
|
|
195
|
-
expect(errorResult).toHaveProperty('code');
|
|
196
|
-
expect(errorResult).toHaveProperty('details');
|
|
197
|
-
expect(errorResult.success).toBe(false);
|
|
198
|
-
expect(typeof errorResult.error).toBe('string');
|
|
199
|
-
expect(typeof errorResult.code).toBe('string');
|
|
200
|
-
expect(typeof errorResult.details).toBe('object');
|
|
201
|
-
expect(errorResult.file).toBeUndefined();
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe('FileValidationError interface', () => {
|
|
206
|
-
it('validates FileValidationError type structure', () => {
|
|
207
|
-
const validationError: FileValidationError = {
|
|
208
|
-
field: 'file',
|
|
209
|
-
message: 'File type not allowed',
|
|
210
|
-
code: 'INVALID_FILE_TYPE',
|
|
211
|
-
value: 'test.exe',
|
|
212
|
-
allowedValues: ['image/jpeg', 'image/png', 'application/pdf']
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
expect(validationError).toHaveProperty('field');
|
|
216
|
-
expect(validationError).toHaveProperty('message');
|
|
217
|
-
expect(validationError).toHaveProperty('code');
|
|
218
|
-
expect(validationError).toHaveProperty('value');
|
|
219
|
-
expect(validationError).toHaveProperty('allowedValues');
|
|
220
|
-
expect(typeof validationError.field).toBe('string');
|
|
221
|
-
expect(typeof validationError.message).toBe('string');
|
|
222
|
-
expect(typeof validationError.code).toBe('string');
|
|
223
|
-
expect(typeof validationError.value).toBe('string');
|
|
224
|
-
expect(Array.isArray(validationError.allowedValues)).toBe(true);
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
describe('FileMetadata interface', () => {
|
|
229
|
-
it('validates FileMetadata type structure', () => {
|
|
230
|
-
const metadata: FileMetadata = {
|
|
231
|
-
description: 'Test file description',
|
|
232
|
-
tags: ['document', 'test', 'important'],
|
|
233
|
-
category: 'documents',
|
|
234
|
-
author: 'John Doe',
|
|
235
|
-
version: '1.0',
|
|
236
|
-
customFields: {
|
|
237
|
-
department: 'IT',
|
|
238
|
-
project: 'Test Project',
|
|
239
|
-
priority: 'high'
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
expect(metadata).toHaveProperty('description');
|
|
244
|
-
expect(metadata).toHaveProperty('tags');
|
|
245
|
-
expect(metadata).toHaveProperty('category');
|
|
246
|
-
expect(metadata).toHaveProperty('author');
|
|
247
|
-
expect(metadata).toHaveProperty('version');
|
|
248
|
-
expect(metadata).toHaveProperty('customFields');
|
|
249
|
-
expect(typeof metadata.description).toBe('string');
|
|
250
|
-
expect(Array.isArray(metadata.tags)).toBe(true);
|
|
251
|
-
expect(typeof metadata.category).toBe('string');
|
|
252
|
-
expect(typeof metadata.author).toBe('string');
|
|
253
|
-
expect(typeof metadata.version).toBe('string');
|
|
254
|
-
expect(typeof metadata.customFields).toBe('object');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('validates FileMetadata with minimal fields', () => {
|
|
258
|
-
const metadata: FileMetadata = {
|
|
259
|
-
description: 'Test file'
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
expect(metadata).toHaveProperty('description');
|
|
263
|
-
expect(metadata.tags).toBeUndefined();
|
|
264
|
-
expect(metadata.category).toBeUndefined();
|
|
265
|
-
expect(metadata.author).toBeUndefined();
|
|
266
|
-
expect(metadata.version).toBeUndefined();
|
|
267
|
-
expect(metadata.customFields).toBeUndefined();
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
describe('FileStorageConfig interface', () => {
|
|
272
|
-
it('validates FileStorageConfig type structure', () => {
|
|
273
|
-
const storageConfig: FileStorageConfig = {
|
|
274
|
-
provider: 'supabase',
|
|
275
|
-
bucket: 'pace-files',
|
|
276
|
-
region: 'us-east-1',
|
|
277
|
-
cdnUrl: 'https://cdn.example.com',
|
|
278
|
-
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
279
|
-
allowedMimeTypes: ['image/*', 'application/pdf', 'text/*'],
|
|
280
|
-
compressionEnabled: true,
|
|
281
|
-
encryptionEnabled: true,
|
|
282
|
-
retentionPolicy: {
|
|
283
|
-
days: 365,
|
|
284
|
-
autoDelete: true
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
expect(storageConfig).toHaveProperty('provider');
|
|
289
|
-
expect(storageConfig).toHaveProperty('bucket');
|
|
290
|
-
expect(storageConfig).toHaveProperty('region');
|
|
291
|
-
expect(storageConfig).toHaveProperty('cdnUrl');
|
|
292
|
-
expect(storageConfig).toHaveProperty('maxFileSize');
|
|
293
|
-
expect(storageConfig).toHaveProperty('allowedMimeTypes');
|
|
294
|
-
expect(storageConfig).toHaveProperty('compressionEnabled');
|
|
295
|
-
expect(storageConfig).toHaveProperty('encryptionEnabled');
|
|
296
|
-
expect(storageConfig).toHaveProperty('retentionPolicy');
|
|
297
|
-
expect(typeof storageConfig.provider).toBe('string');
|
|
298
|
-
expect(typeof storageConfig.bucket).toBe('string');
|
|
299
|
-
expect(typeof storageConfig.region).toBe('string');
|
|
300
|
-
expect(typeof storageConfig.cdnUrl).toBe('string');
|
|
301
|
-
expect(typeof storageConfig.maxFileSize).toBe('number');
|
|
302
|
-
expect(Array.isArray(storageConfig.allowedMimeTypes)).toBe(true);
|
|
303
|
-
expect(typeof storageConfig.compressionEnabled).toBe('boolean');
|
|
304
|
-
expect(typeof storageConfig.encryptionEnabled).toBe('boolean');
|
|
305
|
-
expect(typeof storageConfig.retentionPolicy).toBe('object');
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
describe('FileAccessLevel type', () => {
|
|
310
|
-
it('validates FileAccessLevel values', () => {
|
|
311
|
-
const accessLevels: FileAccessLevel[] = ['public', 'private', 'restricted'];
|
|
312
|
-
|
|
313
|
-
expect(accessLevels).toContain('public');
|
|
314
|
-
expect(accessLevels).toContain('private');
|
|
315
|
-
expect(accessLevels).toContain('restricted');
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('validates FileAccessLevel type usage', () => {
|
|
319
|
-
const accessLevel: FileAccessLevel = 'private';
|
|
320
|
-
expect(typeof accessLevel).toBe('string');
|
|
321
|
-
expect(['public', 'private', 'restricted']).toContain(accessLevel);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
describe('[types] File Reference Usage Patterns', () => {
|
|
327
|
-
describe('File Upload Flow', () => {
|
|
328
|
-
it('validates complete file upload flow types', () => {
|
|
329
|
-
interface FileUploadFlow {
|
|
330
|
-
file: File;
|
|
331
|
-
options: FileUploadOptions;
|
|
332
|
-
onProgress: (progress: number) => void;
|
|
333
|
-
onSuccess: (result: FileUploadResult) => void;
|
|
334
|
-
onError: (error: FileValidationError) => void;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const uploadFlow: FileUploadFlow = {
|
|
338
|
-
file: new File(['test'], 'test.txt', { type: 'text/plain' }),
|
|
339
|
-
options: {
|
|
340
|
-
maxSize: 1024 * 1024,
|
|
341
|
-
allowedTypes: ['text/plain'],
|
|
342
|
-
accessLevel: 'private'
|
|
343
|
-
},
|
|
344
|
-
onProgress: (progress) => {
|
|
345
|
-
expect(typeof progress).toBe('number');
|
|
346
|
-
expect(progress).toBeGreaterThanOrEqual(0);
|
|
347
|
-
expect(progress).toBeLessThanOrEqual(100);
|
|
348
|
-
},
|
|
349
|
-
onSuccess: (result) => {
|
|
350
|
-
expect(result).toHaveProperty('success');
|
|
351
|
-
expect(result).toHaveProperty('file');
|
|
352
|
-
},
|
|
353
|
-
onError: (error) => {
|
|
354
|
-
expect(error).toHaveProperty('field');
|
|
355
|
-
expect(error).toHaveProperty('message');
|
|
356
|
-
expect(error).toHaveProperty('code');
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
expect(uploadFlow).toHaveProperty('file');
|
|
361
|
-
expect(uploadFlow).toHaveProperty('options');
|
|
362
|
-
expect(uploadFlow).toHaveProperty('onProgress');
|
|
363
|
-
expect(uploadFlow).toHaveProperty('onSuccess');
|
|
364
|
-
expect(uploadFlow).toHaveProperty('onError');
|
|
365
|
-
expect(uploadFlow.file).toBeInstanceOf(File);
|
|
366
|
-
expect(typeof uploadFlow.options).toBe('object');
|
|
367
|
-
expect(typeof uploadFlow.onProgress).toBe('function');
|
|
368
|
-
expect(typeof uploadFlow.onSuccess).toBe('function');
|
|
369
|
-
expect(typeof uploadFlow.onError).toBe('function');
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
describe('File Management Operations', () => {
|
|
374
|
-
it('validates file management operation types', () => {
|
|
375
|
-
interface FileManagementOperation {
|
|
376
|
-
operation: 'upload' | 'download' | 'delete' | 'update' | 'list';
|
|
377
|
-
fileId?: string;
|
|
378
|
-
options?: FileUploadOptions;
|
|
379
|
-
metadata?: FileMetadata;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const operations: FileManagementOperation[] = [
|
|
383
|
-
{ operation: 'upload', options: { maxSize: 1024, allowedTypes: ['image/*'] } },
|
|
384
|
-
{ operation: 'download', fileId: 'file-123' },
|
|
385
|
-
{ operation: 'delete', fileId: 'file-123' },
|
|
386
|
-
{ operation: 'update', fileId: 'file-123', metadata: { description: 'Updated' } },
|
|
387
|
-
{ operation: 'list' }
|
|
388
|
-
];
|
|
389
|
-
|
|
390
|
-
operations.forEach(op => {
|
|
391
|
-
expect(op).toHaveProperty('operation');
|
|
392
|
-
expect(['upload', 'download', 'delete', 'update', 'list']).toContain(op.operation);
|
|
393
|
-
if (op.fileId) {
|
|
394
|
-
expect(typeof op.fileId).toBe('string');
|
|
395
|
-
}
|
|
396
|
-
if (op.options) {
|
|
397
|
-
expect(typeof op.options).toBe('object');
|
|
398
|
-
}
|
|
399
|
-
if (op.metadata) {
|
|
400
|
-
expect(typeof op.metadata).toBe('object');
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
describe('File Validation Rules', () => {
|
|
407
|
-
it('validates file validation rule types', () => {
|
|
408
|
-
interface FileValidationRule {
|
|
409
|
-
field: keyof FileReference;
|
|
410
|
-
validator: (value: any) => boolean;
|
|
411
|
-
message: string;
|
|
412
|
-
required?: boolean;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
const validationRules: FileValidationRule[] = [
|
|
416
|
-
{
|
|
417
|
-
field: 'filename',
|
|
418
|
-
validator: (value) => typeof value === 'string' && value.length > 0,
|
|
419
|
-
message: 'Filename is required',
|
|
420
|
-
required: true
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
field: 'size',
|
|
424
|
-
validator: (value) => typeof value === 'number' && value > 0,
|
|
425
|
-
message: 'File size must be greater than 0'
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
field: 'mimeType',
|
|
429
|
-
validator: (value) => typeof value === 'string' && value.includes('/'),
|
|
430
|
-
message: 'Invalid MIME type format'
|
|
431
|
-
}
|
|
432
|
-
];
|
|
433
|
-
|
|
434
|
-
validationRules.forEach(rule => {
|
|
435
|
-
expect(rule).toHaveProperty('field');
|
|
436
|
-
expect(rule).toHaveProperty('validator');
|
|
437
|
-
expect(rule).toHaveProperty('message');
|
|
438
|
-
expect(typeof rule.field).toBe('string');
|
|
439
|
-
expect(typeof rule.validator).toBe('function');
|
|
440
|
-
expect(typeof rule.message).toBe('string');
|
|
441
|
-
if (rule.required !== undefined) {
|
|
442
|
-
expect(typeof rule.required).toBe('boolean');
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
});
|