@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
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query Options Validation
|
|
3
|
-
* Single Responsibility: Validate and check query options
|
|
4
|
-
*
|
|
5
|
-
* Validation and type checking functionality for QueryOptions.
|
|
6
|
-
* Separated for better maintainability.
|
|
7
|
-
*
|
|
8
|
-
* Max lines: 150 (enforced for maintainability)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { QueryOptions } from './QueryOptions';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Validate query options
|
|
15
|
-
*/
|
|
16
|
-
export function validateOptions(options: QueryOptions): { valid: boolean; errors: string[] } {
|
|
17
|
-
const errors: string[] = [];
|
|
18
|
-
|
|
19
|
-
// Validate where clauses
|
|
20
|
-
for (const clause of options.whereClauses) {
|
|
21
|
-
const clauseValidation = clause.validate();
|
|
22
|
-
if (!clauseValidation.valid) {
|
|
23
|
-
errors.push(...clauseValidation.errors);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Validate sort options
|
|
28
|
-
for (const sort of options.sortOptions) {
|
|
29
|
-
if (!sort.field || typeof sort.field !== 'string') {
|
|
30
|
-
errors.push('Sort field must be a non-empty string');
|
|
31
|
-
}
|
|
32
|
-
if (sort.direction !== 'asc' && sort.direction !== 'desc') {
|
|
33
|
-
errors.push('Sort direction must be "asc" or "desc"');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Validate date range
|
|
38
|
-
if (options.dateRange) {
|
|
39
|
-
if (!options.dateRange.field || typeof options.dateRange.field !== 'string') {
|
|
40
|
-
errors.push('Date range field must be a non-empty string');
|
|
41
|
-
}
|
|
42
|
-
if (options.dateRange.startDate && !(options.dateRange.startDate instanceof Date)) {
|
|
43
|
-
errors.push('Start date must be a Date instance');
|
|
44
|
-
}
|
|
45
|
-
if (options.dateRange.endDate && !(options.dateRange.endDate instanceof Date)) {
|
|
46
|
-
errors.push('End date must be a Date instance');
|
|
47
|
-
}
|
|
48
|
-
if (
|
|
49
|
-
options.dateRange.startDate &&
|
|
50
|
-
options.dateRange.endDate &&
|
|
51
|
-
options.dateRange.startDate > options.dateRange.endDate
|
|
52
|
-
) {
|
|
53
|
-
errors.push('Start date must be before end date');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Validate pagination
|
|
58
|
-
if (options.pagination) {
|
|
59
|
-
if (options.pagination.limit !== undefined && (typeof options.pagination.limit !== 'number' || options.pagination.limit <= 0)) {
|
|
60
|
-
errors.push('Pagination limit must be a positive number');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
valid: errors.length === 0,
|
|
66
|
-
errors,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Check if has any where clauses
|
|
72
|
-
*/
|
|
73
|
-
export function hasWhereClauses(options: QueryOptions): boolean {
|
|
74
|
-
return options.whereClauses.length > 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Check if has any sort options
|
|
79
|
-
*/
|
|
80
|
-
export function hasSort(options: QueryOptions): boolean {
|
|
81
|
-
return options.sortOptions.length > 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Check if has date range
|
|
86
|
-
*/
|
|
87
|
-
export function hasDateRange(options: QueryOptions): boolean {
|
|
88
|
-
return options.dateRange !== null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Check if has pagination
|
|
93
|
-
*/
|
|
94
|
-
export function hasPagination(options: QueryOptions): boolean {
|
|
95
|
-
return options.pagination !== null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Check if is empty (no options set)
|
|
100
|
-
*/
|
|
101
|
-
export function isEmpty(options: QueryOptions): boolean {
|
|
102
|
-
return !hasWhereClauses(options) &&
|
|
103
|
-
!hasSort(options) &&
|
|
104
|
-
!hasDateRange(options) &&
|
|
105
|
-
!hasPagination(options);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Check if options have date range filter
|
|
110
|
-
*/
|
|
111
|
-
export function hasDateFilter(options: QueryOptions): boolean {
|
|
112
|
-
return hasDateRange(options);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Check if options have limit set
|
|
117
|
-
*/
|
|
118
|
-
export function hasLimit(options: QueryOptions): boolean {
|
|
119
|
-
return options.pagination?.limit !== undefined;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Check if options have cursor set
|
|
124
|
-
*/
|
|
125
|
-
export function hasCursor(options: QueryOptions): boolean {
|
|
126
|
-
return options.pagination?.cursor !== undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Check if options are valid for compound queries
|
|
131
|
-
*/
|
|
132
|
-
export function isValidForCompoundQuery(options: QueryOptions): boolean {
|
|
133
|
-
// Check for array/membership operator conflicts
|
|
134
|
-
const arrayCount = options.whereClauses.filter(c => c.isArrayOperator() || c.isMembership()).length;
|
|
135
|
-
|
|
136
|
-
if (arrayCount > 1) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return validateOptions(options).valid;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Check if options are ready for execution
|
|
145
|
-
*/
|
|
146
|
-
export function isReadyToExecute(options: QueryOptions): boolean {
|
|
147
|
-
if (!validateOptions(options).valid) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Must have at least one filter
|
|
152
|
-
if (isEmpty(options)) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Get query options type
|
|
161
|
-
*/
|
|
162
|
-
export function getQueryType(options: QueryOptions): 'empty' | 'simple' | 'complex' {
|
|
163
|
-
if (isEmpty(options)) {
|
|
164
|
-
return 'empty';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const complexity = options.whereClauses.length + options.sortOptions.length;
|
|
168
|
-
|
|
169
|
-
if (complexity <= 2) {
|
|
170
|
-
return 'simple';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return 'complex';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Check if query is read-only (no modifications needed)
|
|
178
|
-
*/
|
|
179
|
-
export function isReadOnly(options: QueryOptions): boolean {
|
|
180
|
-
// Query options are always read-only
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query Options Validation
|
|
3
|
-
* Single Responsibility: Validate and check query options
|
|
4
|
-
*
|
|
5
|
-
* Validation and type checking functionality for QueryOptions.
|
|
6
|
-
* Separated for better maintainability.
|
|
7
|
-
*
|
|
8
|
-
* Max lines: 150 (enforced for maintainability)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { QueryOptions } from './QueryOptions';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Validate query options
|
|
15
|
-
*/
|
|
16
|
-
export function validateOptions(options: QueryOptions): { valid: boolean; errors: string[] } {
|
|
17
|
-
const errors: string[] = [];
|
|
18
|
-
|
|
19
|
-
// Validate where clauses
|
|
20
|
-
for (const clause of options.whereClauses) {
|
|
21
|
-
const clauseValidation = clause.validate();
|
|
22
|
-
if (!clauseValidation.valid) {
|
|
23
|
-
errors.push(...clauseValidation.errors);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Validate sort options
|
|
28
|
-
for (const sort of options.sortOptions) {
|
|
29
|
-
if (!sort.field || typeof sort.field !== 'string') {
|
|
30
|
-
errors.push('Sort field must be a non-empty string');
|
|
31
|
-
}
|
|
32
|
-
if (sort.direction !== 'asc' && sort.direction !== 'desc') {
|
|
33
|
-
errors.push('Sort direction must be "asc" or "desc"');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Validate date range
|
|
38
|
-
if (options.dateRange) {
|
|
39
|
-
if (!options.dateRange.field || typeof options.dateRange.field !== 'string') {
|
|
40
|
-
errors.push('Date range field must be a non-empty string');
|
|
41
|
-
}
|
|
42
|
-
if (options.dateRange.startDate && !(options.dateRange.startDate instanceof Date)) {
|
|
43
|
-
errors.push('Start date must be a Date instance');
|
|
44
|
-
}
|
|
45
|
-
if (options.dateRange.endDate && !(options.dateRange.endDate instanceof Date)) {
|
|
46
|
-
errors.push('End date must be a Date instance');
|
|
47
|
-
}
|
|
48
|
-
if (
|
|
49
|
-
options.dateRange.startDate &&
|
|
50
|
-
options.dateRange.endDate &&
|
|
51
|
-
options.dateRange.startDate > options.dateRange.endDate
|
|
52
|
-
) {
|
|
53
|
-
errors.push('Start date must be before end date');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Validate pagination
|
|
58
|
-
if (options.pagination) {
|
|
59
|
-
if (options.pagination.limit !== undefined && (typeof options.pagination.limit !== 'number' || options.pagination.limit <= 0)) {
|
|
60
|
-
errors.push('Pagination limit must be a positive number');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
valid: errors.length === 0,
|
|
66
|
-
errors,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Check if has any where clauses
|
|
72
|
-
*/
|
|
73
|
-
export function hasWhereClauses(options: QueryOptions): boolean {
|
|
74
|
-
return options.whereClauses.length > 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Check if has any sort options
|
|
79
|
-
*/
|
|
80
|
-
export function hasSort(options: QueryOptions): boolean {
|
|
81
|
-
return options.sortOptions.length > 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Check if has date range
|
|
86
|
-
*/
|
|
87
|
-
export function hasDateRange(options: QueryOptions): boolean {
|
|
88
|
-
return options.dateRange !== null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Check if has pagination
|
|
93
|
-
*/
|
|
94
|
-
export function hasPagination(options: QueryOptions): boolean {
|
|
95
|
-
return options.pagination !== null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Check if is empty (no options set)
|
|
100
|
-
*/
|
|
101
|
-
export function isEmpty(options: QueryOptions): boolean {
|
|
102
|
-
return !hasWhereClauses(options) &&
|
|
103
|
-
!hasSort(options) &&
|
|
104
|
-
!hasDateRange(options) &&
|
|
105
|
-
!hasPagination(options);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Check if options have date range filter
|
|
110
|
-
*/
|
|
111
|
-
export function hasDateFilter(options: QueryOptions): boolean {
|
|
112
|
-
return hasDateRange(options);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Check if options have limit set
|
|
117
|
-
*/
|
|
118
|
-
export function hasLimit(options: QueryOptions): boolean {
|
|
119
|
-
return options.pagination?.limit !== undefined;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Check if options have cursor set
|
|
124
|
-
*/
|
|
125
|
-
export function hasCursor(options: QueryOptions): boolean {
|
|
126
|
-
return options.pagination?.cursor !== undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Check if options are valid for compound queries
|
|
131
|
-
*/
|
|
132
|
-
export function isValidForCompoundQuery(options: QueryOptions): boolean {
|
|
133
|
-
// Check for array/membership operator conflicts
|
|
134
|
-
const arrayCount = options.whereClauses.filter(c => c.isArrayOperator() || c.isMembership()).length;
|
|
135
|
-
|
|
136
|
-
if (arrayCount > 1) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return validateOptions(options).valid;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Check if options are ready for execution
|
|
145
|
-
*/
|
|
146
|
-
export function isReadyToExecute(options: QueryOptions): boolean {
|
|
147
|
-
if (!validateOptions(options).valid) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Must have at least one filter
|
|
2
|
-
if (isEmpty(options)) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get query options type
|
|
11
|
-
*/
|
|
12
|
-
export function getQueryType(options: QueryOptions): 'empty' | 'simple' | 'complex' {
|
|
13
|
-
if (isEmpty(options)) {
|
|
14
|
-
return 'empty';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const complexity = options.whereClauses.length + options.sortOptions.length;
|
|
18
|
-
|
|
19
|
-
if (complexity <= 2) {
|
|
20
|
-
return 'simple';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return 'complex';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Check if query is read-only (no modifications needed)
|
|
28
|
-
*/
|
|
29
|
-
export function isReadOnly(options: QueryOptions): boolean {
|
|
30
|
-
// Query options are always read-only
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query Options Value Object (Main)
|
|
3
|
-
* Single Responsibility: Encapsulate query configuration options
|
|
4
|
-
*
|
|
5
|
-
* Value object that represents query options in a type-safe way.
|
|
6
|
-
* Provides validation and business logic for query configuration.
|
|
7
|
-
*
|
|
8
|
-
* Max lines: 150 (enforced for maintainability)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { WhereFilterOp, OrderByDirection } from 'firebase/firestore';
|
|
12
|
-
import { WhereClause } from './WhereClause';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Sort options
|
|
16
|
-
*/
|
|
17
|
-
export interface SortOptions {
|
|
18
|
-
readonly field: string;
|
|
19
|
-
readonly direction: OrderByDirection;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Date range options
|
|
24
|
-
*/
|
|
25
|
-
export interface DateRangeOptions {
|
|
26
|
-
readonly field: string;
|
|
27
|
-
readonly startDate?: Date;
|
|
28
|
-
readonly endDate?: Date;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Pagination options
|
|
33
|
-
*/
|
|
34
|
-
export interface PaginationOptions {
|
|
35
|
-
readonly cursor?: number;
|
|
36
|
-
readonly limit?: number;
|
|
37
|
-
readonly startAfter?: number;
|
|
38
|
-
readonly startAt?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Query options value object
|
|
43
|
-
* Immutable configuration for Firestore queries
|
|
44
|
-
*/
|
|
45
|
-
export class QueryOptions {
|
|
46
|
-
readonly whereClauses: readonly WhereClause[];
|
|
47
|
-
readonly sortOptions: readonly SortOptions[];
|
|
48
|
-
readonly dateRange: DateRangeOptions | null;
|
|
49
|
-
readonly pagination: PaginationOptions | null;
|
|
50
|
-
|
|
51
|
-
private constructor(
|
|
52
|
-
whereClauses: WhereClause[],
|
|
53
|
-
sortOptions: SortOptions[],
|
|
54
|
-
dateRange: DateRangeOptions | null,
|
|
55
|
-
pagination: PaginationOptions | null
|
|
56
|
-
) {
|
|
57
|
-
this.whereClauses = Object.freeze(whereClauses);
|
|
58
|
-
this.sortOptions = Object.freeze(sortOptions);
|
|
59
|
-
this.dateRange = dateRange ? Object.freeze(dateRange) : null;
|
|
60
|
-
this.pagination = pagination ? Object.freeze(pagination) : null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Create empty query options
|
|
65
|
-
*/
|
|
66
|
-
static empty(): QueryOptions {
|
|
67
|
-
return new QueryOptions([], [], null, null);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Create query options from partial configuration
|
|
72
|
-
*/
|
|
73
|
-
static create(options: {
|
|
74
|
-
where?: WhereClause[];
|
|
75
|
-
sort?: SortOptions[];
|
|
76
|
-
dateRange?: DateRangeOptions;
|
|
77
|
-
pagination?: PaginationOptions;
|
|
78
|
-
}): QueryOptions {
|
|
79
|
-
return new QueryOptions(
|
|
80
|
-
options.where || [],
|
|
81
|
-
options.sort || [],
|
|
82
|
-
options.dateRange || null,
|
|
83
|
-
options.pagination || null
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Add where clause
|
|
89
|
-
*/
|
|
90
|
-
withWhere(clause: WhereClause): QueryOptions {
|
|
91
|
-
return new QueryOptions(
|
|
92
|
-
[...this.whereClauses, clause] as WhereClause[],
|
|
93
|
-
this.sortOptions,
|
|
94
|
-
this.dateRange,
|
|
95
|
-
this.pagination
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Add sort option
|
|
101
|
-
*/
|
|
102
|
-
withSort(sort: SortOptions): QueryOptions {
|
|
103
|
-
return new QueryOptions(
|
|
104
|
-
this.whereClauses,
|
|
105
|
-
[...this.sortOptions, sort] as SortOptions[],
|
|
106
|
-
this.dateRange,
|
|
107
|
-
this.pagination
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Set date range
|
|
113
|
-
*/
|
|
114
|
-
withDateRange(dateRange: DateRangeOptions): QueryOptions {
|
|
115
|
-
return new QueryOptions(
|
|
116
|
-
this.whereClauses,
|
|
117
|
-
this.sortOptions,
|
|
118
|
-
dateRange,
|
|
119
|
-
this.pagination
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Set pagination
|
|
125
|
-
*/
|
|
126
|
-
withPagination(pagination: PaginationOptions): QueryOptions {
|
|
127
|
-
return new QueryOptions(
|
|
128
|
-
this.whereClauses,
|
|
129
|
-
this.sortOptions,
|
|
130
|
-
this.dateRange,
|
|
131
|
-
pagination
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Remove all where clauses
|
|
137
|
-
*/
|
|
138
|
-
clearWhere(): QueryOptions {
|
|
139
|
-
return new QueryOptions([], this.sortOptions, this.dateRange, this.pagination);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Remove all sort options
|
|
144
|
-
*/
|
|
145
|
-
clearSort(): QueryOptions {
|
|
146
|
-
return new QueryOptions(this.whereClauses, [], this.dateRange, this.pagination);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Remove date range
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
*/
|
|
2
|
-
clearDateRange(): QueryOptions {
|
|
3
|
-
return new QueryOptions(this.whereClauses, this.sortOptions, null, this.pagination);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Remove pagination
|
|
8
|
-
*/
|
|
9
|
-
clearPagination(): QueryOptions {
|
|
10
|
-
return new QueryOptions(this.whereClauses, this.sortOptions, this.dateRange, null);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Clone with modifications
|
|
15
|
-
*/
|
|
16
|
-
clone(modifications: {
|
|
17
|
-
where?: WhereClause[];
|
|
18
|
-
sort?: SortOptions[];
|
|
19
|
-
dateRange?: DateRangeOptions | null;
|
|
20
|
-
pagination?: PaginationOptions | null;
|
|
21
|
-
}): QueryOptions {
|
|
22
|
-
return QueryOptions.create({
|
|
23
|
-
where: modifications.where ?? [...this.whereClauses] as WhereClause[],
|
|
24
|
-
sort: modifications.sort ?? [...this.sortOptions] as SortOptions[],
|
|
25
|
-
dateRange: modifications.dateRange ?? this.dateRange ?? null,
|
|
26
|
-
pagination: modifications.pagination ?? this.pagination ?? null,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Factory function to create query options
|
|
33
|
-
*/
|
|
34
|
-
export function createQueryOptions(options?: {
|
|
35
|
-
where?: WhereClause[];
|
|
36
|
-
sort?: SortOptions[];
|
|
37
|
-
dateRange?: DateRangeOptions;
|
|
38
|
-
pagination?: PaginationOptions;
|
|
39
|
-
}): QueryOptions {
|
|
40
|
-
return options ? QueryOptions.create(options) : QueryOptions.empty();
|
|
41
|
-
}
|