@umituz/react-native-firebase 2.6.3 → 2.6.5
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/config/FirebaseAuthClient.ts +48 -60
- package/src/domains/auth/infrastructure/config/index.ts +2 -0
- package/src/domains/auth/infrastructure/config/initializers/index.ts +1 -0
- package/src/domains/auth/infrastructure/services/index.ts +16 -0
- package/src/domains/auth/infrastructure/services/utils/index.ts +1 -0
- package/src/domains/auth/infrastructure/stores/index.ts +1 -0
- package/src/domains/auth/infrastructure/utils/index.ts +1 -0
- package/src/domains/auth/infrastructure.ts +11 -0
- package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +18 -59
- package/src/domains/firestore/domain/entities/Collection.ts +0 -2
- package/src/domains/firestore/domain/index.ts +6 -2
- package/src/domains/firestore/domain/value-objects/WhereClause.ts +0 -14
- package/src/domains/firestore/index.ts +0 -1
- package/src/domains/firestore/infrastructure/config/FirestoreClient.ts +42 -60
- package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
- package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
- package/src/shared/infrastructure/base/ErrorHandler.ts +81 -0
- package/src/shared/infrastructure/base/ServiceBase.ts +62 -0
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +39 -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/QueryOptions.ts.bak +0 -191
- 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,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query Options Serialization
|
|
3
|
-
* Single Responsibility: Handle serialization and conversion
|
|
4
|
-
*
|
|
5
|
-
* Serialization and conversion utilities for QueryOptions.
|
|
6
|
-
* Separated for better maintainability.
|
|
7
|
-
*
|
|
8
|
-
* Max lines: 150 (enforced for maintainability)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { QueryOptions, createQueryOptions } from './QueryOptions';
|
|
12
|
-
import { WhereClause } from './WhereClause';
|
|
13
|
-
import type { SortOptions, DateRangeOptions, PaginationOptions } from './QueryOptions';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert to plain object (for serialization)
|
|
17
|
-
*/
|
|
18
|
-
export function toObject(options: QueryOptions): {
|
|
19
|
-
where: WhereClause[];
|
|
20
|
-
sort: SortOptions[];
|
|
21
|
-
dateRange: DateRangeOptions | null;
|
|
22
|
-
pagination: PaginationOptions | null;
|
|
23
|
-
} {
|
|
24
|
-
return {
|
|
25
|
-
where: [...options.whereClauses],
|
|
26
|
-
sort: [...options.sortOptions],
|
|
27
|
-
dateRange: options.dateRange,
|
|
28
|
-
pagination: options.pagination,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create from plain object
|
|
34
|
-
*/
|
|
35
|
-
export function fromObject(obj: {
|
|
36
|
-
where?: Array<{ field: string; operator: string; value: unknown }>;
|
|
37
|
-
sort?: SortOptions[];
|
|
38
|
-
dateRange?: DateRangeOptions;
|
|
39
|
-
pagination?: PaginationOptions;
|
|
40
|
-
}): QueryOptions {
|
|
41
|
-
return QueryOptions.create({
|
|
42
|
-
where: obj.where?.map(w => WhereClause.create(w.field, w.operator as any, w.value)) || [],
|
|
43
|
-
sort: obj.sort || [],
|
|
44
|
-
dateRange: obj.dateRange || null,
|
|
45
|
-
pagination: obj.pagination || null,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create from filters object (simplified)
|
|
51
|
-
*/
|
|
52
|
-
export function fromFilters(filters: Record<string, unknown>): QueryOptions {
|
|
53
|
-
const whereClauses = Object.entries(filters).map(([field, value]) =>
|
|
54
|
-
WhereClause.equals(field, value)
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return QueryOptions.create({ where: whereClauses });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Merge multiple query options
|
|
62
|
-
*/
|
|
63
|
-
export function mergeOptions(...options: QueryOptions[]): QueryOptions {
|
|
64
|
-
if (options.length === 0) {
|
|
65
|
-
return createQueryOptions();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (options.length === 1) {
|
|
69
|
-
return options[0];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const merged = options.reduce((acc, opt) => {
|
|
73
|
-
return QueryOptions.create({
|
|
74
|
-
where: [...acc.whereClauses, ...opt.whereClauses] as WhereClause[],
|
|
75
|
-
sort: opt.sortOptions.length > 0 ? [...opt.sortOptions] as any[] : [...acc.sortOptions] as any[],
|
|
76
|
-
dateRange: opt.dateRange ?? acc.dateRange,
|
|
77
|
-
pagination: opt.pagination ?? acc.pagination,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return merged ?? createQueryOptions();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Create paginated query options
|
|
86
|
-
*/
|
|
87
|
-
export function createPaginatedOptions(limit: number, cursor?: number): QueryOptions {
|
|
88
|
-
return createQueryOptions({
|
|
89
|
-
pagination: { limit, cursor },
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Create sorted query options
|
|
95
|
-
*/
|
|
96
|
-
export function createSortedOptions(
|
|
97
|
-
field: string,
|
|
98
|
-
direction: 'asc' | 'desc' = 'asc'
|
|
99
|
-
): QueryOptions {
|
|
100
|
-
return createQueryOptions({
|
|
101
|
-
sort: [{ field, direction }],
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Create date range query options
|
|
107
|
-
*/
|
|
108
|
-
export function createDateRangeOptions(
|
|
109
|
-
field: string,
|
|
110
|
-
startDate?: Date,
|
|
111
|
-
endDate?: Date
|
|
112
|
-
): QueryOptions {
|
|
113
|
-
return createQueryOptions({
|
|
114
|
-
dateRange: { field, startDate, endDate },
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Clone query options with safety checks
|
|
120
|
-
*/
|
|
121
|
-
export function cloneSafe(options: QueryOptions, defaults?: Partial<{
|
|
122
|
-
where: WhereClause[];
|
|
123
|
-
sort: SortOptions[];
|
|
124
|
-
dateRange: DateRangeOptions;
|
|
125
|
-
pagination: PaginationOptions;
|
|
126
|
-
}>): QueryOptions {
|
|
127
|
-
return QueryOptions.create({
|
|
128
|
-
where: options.whereClauses.length > 0 ? [...options.whereClauses] as WhereClause[] : defaults?.where || [],
|
|
129
|
-
sort: options.sortOptions.length > 0 ? [...options.sortOptions] as SortOptions[] : defaults?.sort || [],
|
|
130
|
-
dateRange: options.dateRange ?? defaults?.dateRange ?? null,
|
|
131
|
-
pagination: options.pagination ?? defaults?.pagination ?? null,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Strip pagination from options
|
|
137
|
-
*/
|
|
138
|
-
export function withoutPagination(options: QueryOptions): QueryOptions {
|
|
139
|
-
return QueryOptions.create({
|
|
140
|
-
where: [...options.whereClauses] as WhereClause[],
|
|
141
|
-
sort: [...options.sortOptions] as SortOptions[],
|
|
142
|
-
dateRange: options.dateRange,
|
|
143
|
-
pagination: null,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Strip sort from options
|
|
149
|
-
*/
|
|
150
|
-
export function withoutSort(options: QueryOptions): QueryOptions {
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
return QueryOptions.create({
|
|
2
|
-
where: [...options.whereClauses] as WhereClause[],
|
|
3
|
-
sort: [],
|
|
4
|
-
dateRange: options.dateRange,
|
|
5
|
-
pagination: options.pagination,
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Strip date range from options
|
|
11
|
-
*/
|
|
12
|
-
export function withoutDateRange(options: QueryOptions): QueryOptions {
|
|
13
|
-
return QueryOptions.create({
|
|
14
|
-
where: [...options.whereClauses] as WhereClause[],
|
|
15
|
-
sort: [...options.sortOptions] as SortOptions[],
|
|
16
|
-
dateRange: null,
|
|
17
|
-
pagination: options.pagination,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Strip where clauses from options
|
|
23
|
-
*/
|
|
24
|
-
export function withoutWhere(options: QueryOptions): QueryOptions {
|
|
25
|
-
return QueryOptions.create({
|
|
26
|
-
where: [],
|
|
27
|
-
sort: [...options.sortOptions] as SortOptions[],
|
|
28
|
-
dateRange: options.dateRange,
|
|
29
|
-
pagination: options.pagination,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Add limit to existing options
|
|
35
|
-
*/
|
|
36
|
-
export function withLimit(options: QueryOptions, limit: number): QueryOptions {
|
|
37
|
-
const currentPagination = options.pagination || {};
|
|
38
|
-
return QueryOptions.create({
|
|
39
|
-
where: [...options.whereClauses] as WhereClause[],
|
|
40
|
-
sort: [...options.sortOptions] as SortOptions[],
|
|
41
|
-
dateRange: options.dateRange,
|
|
42
|
-
pagination: { ...currentPagination, limit },
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Add cursor to existing options
|
|
48
|
-
*/
|
|
49
|
-
export function withCursor(options: QueryOptions, cursor: number): QueryOptions {
|
|
50
|
-
const currentPagination = options.pagination || {};
|
|
51
|
-
return QueryOptions.create({
|
|
52
|
-
where: [...options.whereClauses] as WhereClause[],
|
|
53
|
-
sort: [...options.sortOptions] as SortOptions[],
|
|
54
|
-
dateRange: options.dateRange,
|
|
55
|
-
pagination: { ...currentPagination, cursor },
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -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
|
-
}
|