@umituz/react-native-firebase 2.6.2 → 2.6.4
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/package.json +1 -1
- package/src/application/auth/index.ts +2 -34
- package/src/application/auth/use-cases/index.ts +1 -21
- package/src/domains/account-deletion/domain/index.ts +1 -8
- package/src/domains/account-deletion/index.ts +0 -42
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +79 -0
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +0 -1
- package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +2 -14
- package/src/domains/auth/index.ts +3 -12
- package/src/domains/auth/infrastructure.ts +11 -0
- package/src/domains/firestore/domain/entities/Collection.ts +0 -2
- package/src/domains/firestore/domain/index.ts +8 -12
- package/src/domains/firestore/domain/value-objects/{QueryOptions.ts.bak → QueryOptions.ts} +20 -68
- package/src/domains/firestore/domain/value-objects/QueryOptionsFactory.ts +95 -0
- package/src/domains/firestore/domain/value-objects/QueryOptionsHelpers.ts +110 -0
- package/src/domains/firestore/domain/value-objects/WhereClause.ts +115 -0
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts +101 -0
- package/src/domains/firestore/domain/value-objects/WhereClauseHelpers.ts +123 -0
- package/src/domains/firestore/domain/value-objects/WhereClauseValidation.ts +83 -0
- package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
- package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +29 -0
- package/src/application/auth/ports/AuthPort.ts.bak +0 -164
- package/src/application/auth/ports/AuthPort_part_aa +0 -150
- package/src/application/auth/ports/AuthPort_part_ab +0 -14
- package/src/application/auth/use-cases/SignInUseCase.ts.bak +0 -253
- package/src/application/auth/use-cases/SignInUseCaseHelpers.ts +0 -0
- package/src/application/auth/use-cases/SignInUseCaseMain.ts +0 -0
- package/src/application/auth/use-cases/SignInUseCase_part_aa +0 -150
- package/src/application/auth/use-cases/SignInUseCase_part_ab +0 -103
- package/src/application/auth/use-cases/SignOutUseCase.ts.bak +0 -288
- package/src/application/auth/use-cases/SignOutUseCaseCleanup.ts +0 -0
- package/src/application/auth/use-cases/SignOutUseCaseMain.ts +0 -0
- package/src/application/auth/use-cases/SignOutUseCase_part_aa +0 -150
- package/src/application/auth/use-cases/SignOutUseCase_part_ab +0 -138
- package/src/domains/account-deletion/domain/services/UserValidationHelpers.ts.bak +0 -181
- package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_aa +0 -150
- package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_ab +0 -31
- package/src/domains/account-deletion/domain/services/UserValidationService.ts.bak +0 -286
- package/src/domains/account-deletion/domain/services/UserValidationService_part_aa +0 -150
- package/src/domains/account-deletion/domain/services/UserValidationService_part_ab +0 -136
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts.bak +0 -230
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_ab +0 -80
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler.ts.bak +0 -174
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_ab +0 -24
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository.ts.bak +0 -266
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_ab +0 -116
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service.ts.bak +0 -160
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_ab +0 -10
- package/src/domains/auth/infrastructure.ts.bak +0 -156
- package/src/domains/auth/infrastructure_part_aa +0 -150
- package/src/domains/auth/infrastructure_part_ab +0 -6
- package/src/domains/auth/presentation/hooks/GoogleOAuthHelpers.ts +0 -0
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService.ts.bak +0 -247
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_aa +0 -150
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_ab +0 -97
- package/src/domains/auth/presentation/hooks/GoogleOAuthService.ts +0 -0
- package/src/domains/firestore/domain/entities/Collection.ts.bak +0 -288
- package/src/domains/firestore/domain/entities/Collection_part_aa +0 -150
- package/src/domains/firestore/domain/entities/Collection_part_ab +0 -138
- package/src/domains/firestore/domain/entities/Document.ts.bak +0 -233
- package/src/domains/firestore/domain/entities/DocumentHelpers.ts +0 -0
- package/src/domains/firestore/domain/entities/DocumentMain.ts +0 -0
- package/src/domains/firestore/domain/entities/Document_part_aa +0 -150
- package/src/domains/firestore/domain/entities/Document_part_ab +0 -83
- package/src/domains/firestore/domain/services/QueryService.ts.bak +0 -182
- package/src/domains/firestore/domain/services/QueryServiceAnalysis.ts.bak +0 -169
- package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_ab +0 -19
- package/src/domains/firestore/domain/services/QueryServiceHelpers.ts.bak +0 -151
- package/src/domains/firestore/domain/services/QueryServiceHelpers_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryServiceHelpers_part_ab +0 -1
- package/src/domains/firestore/domain/services/QueryService_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryService_part_ab +0 -32
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization.ts.bak +0 -207
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_ab +0 -57
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation.ts.bak +0 -182
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_ab +0 -32
- package/src/domains/firestore/domain/value-objects/QueryOptions_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptions_part_ab +0 -41
- package/src/domains/firestore/domain/value-objects/WhereClause.ts.bak +0 -299
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts.bak +0 -207
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_ab +0 -57
- package/src/domains/firestore/domain/value-objects/WhereClause_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/WhereClause_part_ab +0 -149
- package/src/shared/infrastructure/base/ErrorHandler.ts.bak +0 -189
- package/src/shared/infrastructure/base/ErrorHandler_part_aa +0 -150
- package/src/shared/infrastructure/base/ErrorHandler_part_ab +0 -39
- package/src/shared/infrastructure/base/ServiceBase.ts.bak +0 -220
- package/src/shared/infrastructure/base/ServiceBase_part_aa +0 -150
- package/src/shared/infrastructure/base/ServiceBase_part_ab +0 -70
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts.bak +0 -155
- package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_aa +0 -150
- package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_ab +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -6,37 +6,5 @@
|
|
|
6
6
|
* Coordinates domain services and infrastructure.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
EmailCredentials,
|
|
12
|
-
SignInResult,
|
|
13
|
-
SignUpResult,
|
|
14
|
-
AuthPortOptions,
|
|
15
|
-
AuthPortConfig,
|
|
16
|
-
IAuthPortFactory,
|
|
17
|
-
} from './ports/AuthPort';
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
type IAuthPort,
|
|
21
|
-
createAuthPortConfig,
|
|
22
|
-
AuthPortFactory,
|
|
23
|
-
authPortFactory,
|
|
24
|
-
createAuthPort,
|
|
25
|
-
} from './ports/AuthPort';
|
|
26
|
-
|
|
27
|
-
// Use Cases
|
|
28
|
-
export type {
|
|
29
|
-
SignInUseCaseResult,
|
|
30
|
-
SignInOptions,
|
|
31
|
-
SignOutUseCaseResult,
|
|
32
|
-
SignOutOptions,
|
|
33
|
-
} from './use-cases';
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
SignInUseCase,
|
|
37
|
-
createSignInUseCase,
|
|
38
|
-
createDefaultSignInUseCase,
|
|
39
|
-
SignOutUseCase,
|
|
40
|
-
createSignOutUseCase,
|
|
41
|
-
createDefaultSignOutUseCase,
|
|
42
|
-
} from './use-cases';
|
|
9
|
+
// Export types when files are available
|
|
10
|
+
// TODO: Implement AuthPort and UseCases
|
|
@@ -3,24 +3,4 @@
|
|
|
3
3
|
* Application layer use cases for authentication
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
SignInUseCaseResult,
|
|
8
|
-
SignInOptions,
|
|
9
|
-
} from './SignInUseCase';
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
SignInUseCase,
|
|
13
|
-
createSignInUseCase,
|
|
14
|
-
createDefaultSignInUseCase,
|
|
15
|
-
} from './SignInUseCase';
|
|
16
|
-
|
|
17
|
-
export type {
|
|
18
|
-
SignOutUseCaseResult,
|
|
19
|
-
SignOutOptions,
|
|
20
|
-
} from './SignOutUseCase';
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
SignOutUseCase,
|
|
24
|
-
createSignOutUseCase,
|
|
25
|
-
createDefaultSignOutUseCase,
|
|
26
|
-
} from './SignOutUseCase';
|
|
6
|
+
// TODO: Implement SignInUseCase and SignOutUseCase
|
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
* Domain-Driven Design (DDD) - Domain Exports
|
|
4
4
|
*
|
|
5
5
|
* Pure domain logic without infrastructure concerns.
|
|
6
|
-
* Exports domain services for account deletion operations.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
//
|
|
10
|
-
export {
|
|
11
|
-
UserValidationService,
|
|
12
|
-
createUserValidationService,
|
|
13
|
-
userValidationService,
|
|
14
|
-
} from './services/UserValidationService';
|
|
15
|
-
export type { UserValidationResult } from './services/UserValidationService';
|
|
8
|
+
// TODO: Implement UserValidationService
|
|
@@ -5,21 +5,6 @@
|
|
|
5
5
|
* Domain-Driven Design (DDD) Architecture
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// DOMAIN LAYER - Business Logic
|
|
10
|
-
// =============================================================================
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
UserValidationService,
|
|
14
|
-
createUserValidationService,
|
|
15
|
-
userValidationService,
|
|
16
|
-
} from './domain';
|
|
17
|
-
export type { UserValidationResult } from './domain';
|
|
18
|
-
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// APPLICATION LAYER - Use Cases & Ports
|
|
21
|
-
// =============================================================================
|
|
22
|
-
|
|
23
8
|
export type {
|
|
24
9
|
AccountDeletionOptions,
|
|
25
10
|
ReauthenticationResult,
|
|
@@ -27,11 +12,6 @@ export type {
|
|
|
27
12
|
ReauthCredentialResult,
|
|
28
13
|
} from './application/ports/reauthentication.types';
|
|
29
14
|
|
|
30
|
-
// =============================================================================
|
|
31
|
-
// INFRASTRUCTURE LAYER - Implementation
|
|
32
|
-
// =============================================================================
|
|
33
|
-
|
|
34
|
-
// Main Service (Refactored)
|
|
35
15
|
export {
|
|
36
16
|
deleteCurrentUser,
|
|
37
17
|
deleteUserAccount,
|
|
@@ -41,25 +21,3 @@ export {
|
|
|
41
21
|
export type {
|
|
42
22
|
AccountDeletionResult,
|
|
43
23
|
} from './infrastructure/services/account-deletion.service';
|
|
44
|
-
|
|
45
|
-
// Deletion Components
|
|
46
|
-
export {
|
|
47
|
-
AccountDeletionRepository,
|
|
48
|
-
createAccountDeletionRepository,
|
|
49
|
-
accountDeletionRepository,
|
|
50
|
-
} from './infrastructure/services/AccountDeletionRepository';
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
AccountDeletionExecutor,
|
|
54
|
-
createAccountDeletionExecutor,
|
|
55
|
-
accountDeletionExecutor,
|
|
56
|
-
} from './infrastructure/services/AccountDeletionExecutor';
|
|
57
|
-
|
|
58
|
-
// Reauthentication Service
|
|
59
|
-
export {
|
|
60
|
-
getUserAuthProvider,
|
|
61
|
-
reauthenticateWithPassword,
|
|
62
|
-
reauthenticateWithGoogle,
|
|
63
|
-
reauthenticateWithApple,
|
|
64
|
-
getAppleReauthCredential,
|
|
65
|
-
} from './infrastructure/services/reauthentication.service';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account Deletion Executor
|
|
3
|
+
* Handles Firebase account deletion with reauthentication support
|
|
4
|
+
*
|
|
5
|
+
* Max lines: 150 (enforced for maintainability)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { User } from 'firebase/auth';
|
|
9
|
+
import type { AccountDeletionOptions } from '../../application/ports/reauthentication.types';
|
|
10
|
+
import type { AccountDeletionResult } from './AccountDeletionTypes';
|
|
11
|
+
|
|
12
|
+
export class AccountDeletionExecutor {
|
|
13
|
+
private deletionInProgress = false;
|
|
14
|
+
|
|
15
|
+
async deleteCurrentUser(options: AccountDeletionOptions): Promise<AccountDeletionResult> {
|
|
16
|
+
if (this.deletionInProgress) {
|
|
17
|
+
return {
|
|
18
|
+
success: false,
|
|
19
|
+
error: {
|
|
20
|
+
code: 'deletion-in-progress',
|
|
21
|
+
message: 'Account deletion is already in progress',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.deletionInProgress = true;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// TODO: Implement actual deletion logic
|
|
30
|
+
return {
|
|
31
|
+
success: true,
|
|
32
|
+
};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
error: {
|
|
37
|
+
code: 'deletion-failed',
|
|
38
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
} finally {
|
|
42
|
+
this.deletionInProgress = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async deleteUserAccount(user: User | null): Promise<AccountDeletionResult> {
|
|
47
|
+
if (!user) {
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: {
|
|
51
|
+
code: 'no-user',
|
|
52
|
+
message: 'No user provided',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await user.delete();
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
error: {
|
|
66
|
+
code: 'deletion-failed',
|
|
67
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
isDeletionInProgress(): boolean {
|
|
74
|
+
return this.deletionInProgress;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const accountDeletionExecutor = new AccountDeletionExecutor();
|
|
79
|
+
export const createAccountDeletionExecutor = () => new AccountDeletionExecutor();
|
|
@@ -21,7 +21,6 @@ export interface ReauthenticationContext {
|
|
|
21
21
|
readonly user: import('firebase/auth').User;
|
|
22
22
|
readonly options: import('../../application/ports/reauthentication.types').AccountDeletionOptions;
|
|
23
23
|
readonly originalUserId?: string;
|
|
24
|
-
readonly repository: AccountDeletionRepository;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Account Deletion Service
|
|
2
|
+
* Account Deletion Service
|
|
3
3
|
* Handles Firebase account deletion with reauthentication support
|
|
4
4
|
*
|
|
5
|
-
* This file now delegates to the new DDD architecture:
|
|
6
|
-
* - AccountDeletionExecutor for deletion logic
|
|
7
|
-
* - UserValidationService for validation
|
|
8
|
-
* - AccountDeletionRepository for persistence
|
|
9
|
-
*
|
|
10
5
|
* Max lines: 150 (enforced for maintainability)
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
8
|
import type { User } from "firebase/auth";
|
|
14
9
|
import type { AccountDeletionOptions } from "../../application/ports/reauthentication.types";
|
|
15
10
|
import { accountDeletionExecutor } from "./AccountDeletionExecutor";
|
|
16
|
-
import type { AccountDeletionResult } from "./
|
|
11
|
+
import type { AccountDeletionResult } from "./AccountDeletionTypes";
|
|
17
12
|
|
|
18
|
-
/**
|
|
19
|
-
* Delete current user account
|
|
20
|
-
* Handles reauthentication automatically if enabled
|
|
21
|
-
*
|
|
22
|
-
* @param options - Deletion options including reauthentication settings
|
|
23
|
-
* @returns Result of deletion operation
|
|
24
|
-
*/
|
|
25
13
|
export async function deleteCurrentUser(
|
|
26
14
|
options: AccountDeletionOptions = { autoReauthenticate: true }
|
|
27
15
|
): Promise<AccountDeletionResult> {
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Firebase Auth Module
|
|
3
3
|
* Domain-Driven Design (DDD) Architecture
|
|
4
|
-
*
|
|
5
|
-
* Exports organized by DDD layers for better maintainability.
|
|
6
|
-
* Main re-exports everything for backward compatibility.
|
|
7
4
|
*/
|
|
8
5
|
|
|
9
|
-
//
|
|
10
|
-
// DOMAIN LAYER - Business Logic
|
|
11
|
-
// =============================================================================
|
|
6
|
+
// Domain Layer
|
|
12
7
|
export * from './domain';
|
|
13
8
|
|
|
14
|
-
//
|
|
15
|
-
// INFRASTRUCTURE LAYER - Implementation
|
|
16
|
-
// =============================================================================
|
|
9
|
+
// Infrastructure Layer
|
|
17
10
|
export * from './infrastructure';
|
|
18
11
|
|
|
19
|
-
//
|
|
20
|
-
// PRESENTATION LAYER - React Hooks
|
|
21
|
-
// =============================================================================
|
|
12
|
+
// Presentation Layer
|
|
22
13
|
export * from './presentation';
|
|
23
14
|
|
|
24
15
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Infrastructure Layer
|
|
3
|
+
* Domain-Driven Design (DDD) - Infrastructure Exports
|
|
4
|
+
*
|
|
5
|
+
* Infrastructure implementations for authentication.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './infrastructure/config';
|
|
9
|
+
export * from './infrastructure/services';
|
|
10
|
+
export * from './infrastructure/stores';
|
|
11
|
+
export * from './infrastructure/utils';
|
|
@@ -14,13 +14,10 @@ export {
|
|
|
14
14
|
} from './errors/FirebaseFirestoreError';
|
|
15
15
|
|
|
16
16
|
// Domain Entities
|
|
17
|
-
export { Collection
|
|
17
|
+
export { Collection } from './entities/Collection';
|
|
18
|
+
export { fromReference, fromQuery, createCollection } from './entities/CollectionFactory';
|
|
18
19
|
export type { CollectionMetadata } from './entities/Collection';
|
|
19
20
|
|
|
20
|
-
// Document entity (if exists)
|
|
21
|
-
// export { Document, createDocument } from './entities/Document';
|
|
22
|
-
// export type { DocumentMetadata } from './entities/Document';
|
|
23
|
-
|
|
24
21
|
// Collection Entity Helpers
|
|
25
22
|
export {
|
|
26
23
|
isParentOf,
|
|
@@ -55,11 +52,10 @@ export {
|
|
|
55
52
|
} from './entities/CollectionValidation';
|
|
56
53
|
|
|
57
54
|
// Domain Value Objects
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// export type { SortOptions, DateRangeOptions, PaginationOptions } from './value-objects/QueryOptions';
|
|
61
|
-
// export type { WhereOperator } from './value-objects/WhereClause';
|
|
55
|
+
export { QueryOptions, createQueryOptions } from './value-objects/QueryOptions';
|
|
56
|
+
export type { SortOptions, DateRangeOptions, PaginationOptions } from './value-objects/QueryOptions';
|
|
62
57
|
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
// Where Clause
|
|
59
|
+
export { WhereClause } from './value-objects/WhereClause';
|
|
60
|
+
export { equals, where, fromObject as createWhereClause } from './value-objects/WhereClauseFactory';
|
|
61
|
+
export type { WhereOperator } from './value-objects/WhereClause';
|
|
@@ -2,35 +2,24 @@
|
|
|
2
2
|
* Query Options Value Object (Main)
|
|
3
3
|
* Single Responsibility: Encapsulate query configuration options
|
|
4
4
|
*
|
|
5
|
-
* Value object that represents query options in a type-safe way.
|
|
6
|
-
* Provides validation and business logic for query configuration.
|
|
7
|
-
*
|
|
8
5
|
* Max lines: 150 (enforced for maintainability)
|
|
9
6
|
*/
|
|
10
7
|
|
|
11
8
|
import type { WhereFilterOp, OrderByDirection } from 'firebase/firestore';
|
|
12
9
|
import { WhereClause } from './WhereClause';
|
|
10
|
+
import * as Factory from './QueryOptionsFactory';
|
|
13
11
|
|
|
14
|
-
/**
|
|
15
|
-
* Sort options
|
|
16
|
-
*/
|
|
17
12
|
export interface SortOptions {
|
|
18
13
|
readonly field: string;
|
|
19
14
|
readonly direction: OrderByDirection;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
/**
|
|
23
|
-
* Date range options
|
|
24
|
-
*/
|
|
25
17
|
export interface DateRangeOptions {
|
|
26
18
|
readonly field: string;
|
|
27
19
|
readonly startDate?: Date;
|
|
28
20
|
readonly endDate?: Date;
|
|
29
21
|
}
|
|
30
22
|
|
|
31
|
-
/**
|
|
32
|
-
* Pagination options
|
|
33
|
-
*/
|
|
34
23
|
export interface PaginationOptions {
|
|
35
24
|
readonly cursor?: number;
|
|
36
25
|
readonly limit?: number;
|
|
@@ -38,10 +27,6 @@ export interface PaginationOptions {
|
|
|
38
27
|
readonly startAt?: number;
|
|
39
28
|
}
|
|
40
29
|
|
|
41
|
-
/**
|
|
42
|
-
* Query options value object
|
|
43
|
-
* Immutable configuration for Firestore queries
|
|
44
|
-
*/
|
|
45
30
|
export class QueryOptions {
|
|
46
31
|
readonly whereClauses: readonly WhereClause[];
|
|
47
32
|
readonly sortOptions: readonly SortOptions[];
|
|
@@ -60,16 +45,10 @@ export class QueryOptions {
|
|
|
60
45
|
this.pagination = pagination ? Object.freeze(pagination) : null;
|
|
61
46
|
}
|
|
62
47
|
|
|
63
|
-
/**
|
|
64
|
-
* Create empty query options
|
|
65
|
-
*/
|
|
66
48
|
static empty(): QueryOptions {
|
|
67
49
|
return new QueryOptions([], [], null, null);
|
|
68
50
|
}
|
|
69
51
|
|
|
70
|
-
/**
|
|
71
|
-
* Create query options from partial configuration
|
|
72
|
-
*/
|
|
73
52
|
static create(options: {
|
|
74
53
|
where?: WhereClause[];
|
|
75
54
|
sort?: SortOptions[];
|
|
@@ -84,103 +63,76 @@ export class QueryOptions {
|
|
|
84
63
|
);
|
|
85
64
|
}
|
|
86
65
|
|
|
87
|
-
/**
|
|
88
|
-
* Add where clause
|
|
89
|
-
*/
|
|
90
66
|
withWhere(clause: WhereClause): QueryOptions {
|
|
91
67
|
return new QueryOptions(
|
|
92
68
|
[...this.whereClauses, clause] as WhereClause[],
|
|
93
|
-
this.sortOptions,
|
|
69
|
+
[...this.sortOptions] as SortOptions[],
|
|
94
70
|
this.dateRange,
|
|
95
71
|
this.pagination
|
|
96
72
|
);
|
|
97
73
|
}
|
|
98
74
|
|
|
99
|
-
/**
|
|
100
|
-
* Add sort option
|
|
101
|
-
*/
|
|
102
75
|
withSort(sort: SortOptions): QueryOptions {
|
|
103
76
|
return new QueryOptions(
|
|
104
|
-
this.whereClauses,
|
|
77
|
+
[...this.whereClauses] as WhereClause[],
|
|
105
78
|
[...this.sortOptions, sort] as SortOptions[],
|
|
106
79
|
this.dateRange,
|
|
107
80
|
this.pagination
|
|
108
81
|
);
|
|
109
82
|
}
|
|
110
83
|
|
|
111
|
-
/**
|
|
112
|
-
* Set date range
|
|
113
|
-
*/
|
|
114
84
|
withDateRange(dateRange: DateRangeOptions): QueryOptions {
|
|
115
85
|
return new QueryOptions(
|
|
116
|
-
this.whereClauses,
|
|
117
|
-
this.sortOptions,
|
|
86
|
+
[...this.whereClauses] as WhereClause[],
|
|
87
|
+
[...this.sortOptions] as SortOptions[],
|
|
118
88
|
dateRange,
|
|
119
89
|
this.pagination
|
|
120
90
|
);
|
|
121
91
|
}
|
|
122
92
|
|
|
123
|
-
/**
|
|
124
|
-
* Set pagination
|
|
125
|
-
*/
|
|
126
93
|
withPagination(pagination: PaginationOptions): QueryOptions {
|
|
127
94
|
return new QueryOptions(
|
|
128
|
-
this.whereClauses,
|
|
129
|
-
this.sortOptions,
|
|
95
|
+
[...this.whereClauses] as WhereClause[],
|
|
96
|
+
[...this.sortOptions] as SortOptions[],
|
|
130
97
|
this.dateRange,
|
|
131
98
|
pagination
|
|
132
99
|
);
|
|
133
100
|
}
|
|
134
101
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
102
|
+
withLimit(limit: number): QueryOptions {
|
|
103
|
+
return this.withPagination({
|
|
104
|
+
...this.pagination,
|
|
105
|
+
limit,
|
|
106
|
+
} as PaginationOptions);
|
|
107
|
+
}
|
|
108
|
+
|
|
138
109
|
clearWhere(): QueryOptions {
|
|
139
|
-
return new QueryOptions([], this.sortOptions, this.dateRange, this.pagination);
|
|
110
|
+
return new QueryOptions([], [...this.sortOptions] as SortOptions[], this.dateRange, this.pagination);
|
|
140
111
|
}
|
|
141
112
|
|
|
142
|
-
/**
|
|
143
|
-
* Remove all sort options
|
|
144
|
-
*/
|
|
145
113
|
clearSort(): QueryOptions {
|
|
146
|
-
return new QueryOptions(this.whereClauses, [], this.dateRange, this.pagination);
|
|
114
|
+
return new QueryOptions([...this.whereClauses] as WhereClause[], [], this.dateRange, this.pagination);
|
|
147
115
|
}
|
|
148
116
|
|
|
149
|
-
/**
|
|
150
|
-
* Remove date range
|
|
151
|
-
*/
|
|
152
117
|
clearDateRange(): QueryOptions {
|
|
153
|
-
return new QueryOptions(this.whereClauses, this.sortOptions, null, this.pagination);
|
|
118
|
+
return new QueryOptions([...this.whereClauses] as WhereClause[], [...this.sortOptions] as SortOptions[], null, this.pagination);
|
|
154
119
|
}
|
|
155
120
|
|
|
156
|
-
/**
|
|
157
|
-
* Remove pagination
|
|
158
|
-
*/
|
|
159
121
|
clearPagination(): QueryOptions {
|
|
160
|
-
return new QueryOptions(this.whereClauses, this.sortOptions, this.dateRange, null);
|
|
122
|
+
return new QueryOptions([...this.whereClauses] as WhereClause[], [...this.sortOptions] as SortOptions[], this.dateRange, null);
|
|
161
123
|
}
|
|
162
124
|
|
|
163
|
-
/**
|
|
164
|
-
* Clone with modifications
|
|
165
|
-
*/
|
|
166
125
|
clone(modifications: {
|
|
167
126
|
where?: WhereClause[];
|
|
168
127
|
sort?: SortOptions[];
|
|
169
128
|
dateRange?: DateRangeOptions | null;
|
|
170
129
|
pagination?: PaginationOptions | null;
|
|
171
130
|
}): QueryOptions {
|
|
172
|
-
return
|
|
173
|
-
where: modifications.where ?? [...this.whereClauses] as WhereClause[],
|
|
174
|
-
sort: modifications.sort ?? [...this.sortOptions] as SortOptions[],
|
|
175
|
-
dateRange: modifications.dateRange ?? this.dateRange ?? null,
|
|
176
|
-
pagination: modifications.pagination ?? this.pagination ?? null,
|
|
177
|
-
});
|
|
131
|
+
return Factory.clone(this, modifications);
|
|
178
132
|
}
|
|
179
133
|
}
|
|
180
134
|
|
|
181
|
-
|
|
182
|
-
* Factory function to create query options
|
|
183
|
-
*/
|
|
135
|
+
// Factory function
|
|
184
136
|
export function createQueryOptions(options?: {
|
|
185
137
|
where?: WhereClause[];
|
|
186
138
|
sort?: SortOptions[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Options Factory
|
|
3
|
+
* Single Responsibility: Create query options
|
|
4
|
+
*
|
|
5
|
+
* Max lines: 150 (enforced for maintainability)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { WhereFilterOp, OrderByDirection } from 'firebase/firestore';
|
|
9
|
+
import type { SortOptions, DateRangeOptions, PaginationOptions } from './QueryOptions';
|
|
10
|
+
import { WhereClause } from './WhereClause';
|
|
11
|
+
import { QueryOptions } from './QueryOptions';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create empty query options
|
|
15
|
+
*/
|
|
16
|
+
export function empty(): QueryOptions {
|
|
17
|
+
return QueryOptions.empty();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create query options from partial configuration
|
|
22
|
+
*/
|
|
23
|
+
export function create(options: {
|
|
24
|
+
where?: WhereClause[];
|
|
25
|
+
sort?: SortOptions[];
|
|
26
|
+
dateRange?: DateRangeOptions;
|
|
27
|
+
pagination?: PaginationOptions;
|
|
28
|
+
}): QueryOptions {
|
|
29
|
+
return QueryOptions.create(options);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create query options with where clause
|
|
34
|
+
*/
|
|
35
|
+
export function withWhere(
|
|
36
|
+
baseOptions: QueryOptions,
|
|
37
|
+
field: string,
|
|
38
|
+
operator: WhereFilterOp,
|
|
39
|
+
value: unknown
|
|
40
|
+
): QueryOptions {
|
|
41
|
+
const clause = new WhereClause(field, operator, value);
|
|
42
|
+
return baseOptions.withWhere(clause);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create query options with sort
|
|
47
|
+
*/
|
|
48
|
+
export function withSort(
|
|
49
|
+
baseOptions: QueryOptions,
|
|
50
|
+
field: string,
|
|
51
|
+
direction: OrderByDirection
|
|
52
|
+
): QueryOptions {
|
|
53
|
+
return baseOptions.withSort({ field, direction });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Create query options with date range
|
|
58
|
+
*/
|
|
59
|
+
export function withDateRange(
|
|
60
|
+
baseOptions: QueryOptions,
|
|
61
|
+
field: string,
|
|
62
|
+
startDate?: Date,
|
|
63
|
+
endDate?: Date
|
|
64
|
+
): QueryOptions {
|
|
65
|
+
return baseOptions.withDateRange({ field, startDate, endDate });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create query options with pagination
|
|
70
|
+
*/
|
|
71
|
+
export function withPagination(
|
|
72
|
+
baseOptions: QueryOptions,
|
|
73
|
+
pagination: PaginationOptions
|
|
74
|
+
): QueryOptions {
|
|
75
|
+
return baseOptions.withPagination(pagination);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Create query options with limit
|
|
80
|
+
*/
|
|
81
|
+
export function withLimit(baseOptions: QueryOptions, limit: number): QueryOptions {
|
|
82
|
+
return baseOptions.withLimit(limit);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Clone query options with modifications
|
|
87
|
+
*/
|
|
88
|
+
export function clone(baseOptions: QueryOptions, modifications: {
|
|
89
|
+
where?: WhereClause[];
|
|
90
|
+
sort?: SortOptions[];
|
|
91
|
+
dateRange?: DateRangeOptions | null;
|
|
92
|
+
pagination?: PaginationOptions | null;
|
|
93
|
+
}): QueryOptions {
|
|
94
|
+
return baseOptions.clone(modifications);
|
|
95
|
+
}
|