@umituz/react-native-firebase 2.5.1 → 2.6.1

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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/src/application/auth/index.ts +42 -0
  3. package/src/application/auth/ports/AuthPort.ts +164 -0
  4. package/src/application/auth/use-cases/SignInUseCase.ts +253 -0
  5. package/src/application/auth/use-cases/SignOutUseCase.ts +288 -0
  6. package/src/application/auth/use-cases/index.ts +26 -0
  7. package/src/domains/account-deletion/domain/index.ts +15 -0
  8. package/src/domains/account-deletion/domain/services/UserValidationService.ts +295 -0
  9. package/src/domains/account-deletion/index.ts +43 -6
  10. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +230 -0
  11. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler.ts +174 -0
  12. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository.ts +266 -0
  13. package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +33 -0
  14. package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +39 -227
  15. package/src/domains/auth/domain.ts +16 -0
  16. package/src/domains/auth/index.ts +7 -148
  17. package/src/domains/auth/infrastructure.ts +156 -0
  18. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService.ts +247 -0
  19. package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +49 -103
  20. package/src/domains/auth/presentation.ts +25 -0
  21. package/src/domains/firestore/domain/entities/Collection.ts +288 -0
  22. package/src/domains/firestore/domain/entities/Document.ts +233 -0
  23. package/src/domains/firestore/domain/index.ts +30 -0
  24. package/src/domains/firestore/domain/services/QueryService.ts +182 -0
  25. package/src/domains/firestore/domain/services/QueryServiceAnalysis.ts +169 -0
  26. package/src/domains/firestore/domain/services/QueryServiceHelpers.ts +151 -0
  27. package/src/domains/firestore/domain/value-objects/QueryOptions.ts +191 -0
  28. package/src/domains/firestore/domain/value-objects/QueryOptions.ts.bak +320 -0
  29. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization.ts +207 -0
  30. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation.ts +182 -0
  31. package/src/domains/firestore/domain/value-objects/WhereClause.ts +299 -0
  32. package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts +207 -0
  33. package/src/domains/firestore/index.ts +20 -6
  34. package/src/index.ts +25 -0
  35. package/src/shared/domain/utils/calculation.util.ts +17 -305
  36. package/src/shared/domain/utils/error-handlers/error-messages.ts +11 -0
  37. package/src/shared/domain/utils/index.ts +0 -5
  38. package/src/shared/infrastructure/base/ErrorHandler.ts +189 -0
  39. package/src/shared/infrastructure/base/ServiceBase.ts +220 -0
  40. package/src/shared/infrastructure/base/TypedGuard.ts +131 -0
  41. package/src/shared/infrastructure/base/index.ts +34 -0
  42. package/src/shared/infrastructure/config/state/FirebaseClientState.ts +34 -12
  43. package/src/shared/infrastructure/config/base/ClientStateManager.ts +0 -82
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Query Options Value Object
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[] 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
151
+ */
152
+ clearDateRange(): QueryOptions {
153
+ return new QueryOptions(this.whereClauses, this.sortOptions, null, this.pagination);
154
+ }
155
+
156
+ /**
157
+ * Remove pagination
158
+ */
159
+ clearPagination(): QueryOptions {
160
+ return new QueryOptions(this.whereClauses, this.sortOptions, this.dateRange, null);
161
+ }
162
+
163
+ /**
164
+ * Check if has any where clauses
165
+ */
166
+ hasWhereClauses(): boolean {
167
+ return this.whereClauses.length > 0;
168
+ }
169
+
170
+ /**
171
+ * Check if has any sort options
172
+ */
173
+ hasSort(): boolean {
174
+ return this.sortOptions.length > 0;
175
+ }
176
+
177
+ /**
178
+ * Check if has date range
179
+ */
180
+ hasDateRange(): boolean {
181
+ return this.dateRange !== null;
182
+ }
183
+
184
+ /**
185
+ * Check if has pagination
186
+ */
187
+ hasPagination(): boolean {
188
+ return this.pagination !== null;
189
+ }
190
+
191
+ /**
192
+ * Check if is empty (no options set)
193
+ */
194
+ isEmpty(): boolean {
195
+ return !this.hasWhereClauses() &&
196
+ !this.hasSort() &&
197
+ !this.hasDateRange() &&
198
+ !this.hasPagination();
199
+ }
200
+
201
+ /**
202
+ * Validate query options
203
+ */
204
+ validate(): { valid: boolean; errors: string[] } {
205
+ const errors: string[] = [];
206
+
207
+ // Validate where clauses
208
+ for (const clause of this.whereClauses) {
209
+ const clauseValidation = clause.validate();
210
+ if (!clauseValidation.valid) {
211
+ errors.push(...clauseValidation.errors);
212
+ }
213
+ }
214
+
215
+ // Validate sort options
216
+ for (const sort of this.sortOptions) {
217
+ if (!sort.field || typeof sort.field !== 'string') {
218
+ errors.push('Sort field must be a non-empty string');
219
+ }
220
+ if (sort.direction !== 'asc' && sort.direction !== 'desc') {
221
+ errors.push('Sort direction must be "asc" or "desc"');
222
+ }
223
+ }
224
+
225
+ // Validate date range
226
+ if (this.dateRange) {
227
+ if (!this.dateRange.field || typeof this.dateRange.field !== 'string') {
228
+ errors.push('Date range field must be a non-empty string');
229
+ }
230
+ if (this.dateRange.startDate && !(this.dateRange.startDate instanceof Date)) {
231
+ errors.push('Start date must be a Date instance');
232
+ }
233
+ if (this.dateRange.endDate && !(this.dateRange.endDate instanceof Date)) {
234
+ errors.push('End date must be a Date instance');
235
+ }
236
+ if (
237
+ this.dateRange.startDate &&
238
+ this.dateRange.endDate &&
239
+ this.dateRange.startDate > this.dateRange.endDate
240
+ ) {
241
+ errors.push('Start date must be before end date');
242
+ }
243
+ }
244
+
245
+ // Validate pagination
246
+ if (this.pagination) {
247
+ if (this.pagination.limit !== undefined && (typeof this.pagination.limit !== 'number' || this.pagination.limit <= 0)) {
248
+ errors.push('Pagination limit must be a positive number');
249
+ }
250
+ }
251
+
252
+ return {
253
+ valid: errors.length === 0,
254
+ errors,
255
+ };
256
+ }
257
+
258
+ /**
259
+ * Convert to plain object (for serialization)
260
+ */
261
+ toObject(): {
262
+ where: WhereClause[];
263
+ sort: SortOptions[];
264
+ dateRange: DateRangeOptions | null;
265
+ pagination: PaginationOptions | null;
266
+ } {
267
+ return {
268
+ where: [...this.whereClauses] as WhereClause[],
269
+ sort: [...this.sortOptions] as SortOptions[],
270
+ dateRange: this.dateRange,
271
+ pagination: this.pagination,
272
+ };
273
+ }
274
+
275
+ /**
276
+ * Create from plain object
277
+ */
278
+ static fromObject(obj: {
279
+ where?: Array<{ field: string; operator: WhereFilterOp; value: unknown }>;
280
+ sort?: SortOptions[];
281
+ dateRange?: DateRangeOptions;
282
+ pagination?: PaginationOptions;
283
+ }): QueryOptions {
284
+ return QueryOptions.create({
285
+ where: obj.where?.map(w => WhereClause.create(w.field, w.operator, w.value)) || [],
286
+ sort: obj.sort || [],
287
+ dateRange: obj.dateRange || null,
288
+ pagination: obj.pagination || null,
289
+ });
290
+ }
291
+
292
+ /**
293
+ * Clone with modifications
294
+ */
295
+ clone(modifications: {
296
+ where?: WhereClause[];
297
+ sort?: SortOptions[];
298
+ dateRange?: DateRangeOptions | null;
299
+ pagination?: PaginationOptions | null;
300
+ }): QueryOptions {
301
+ return QueryOptions.create({
302
+ where: modifications.where ?? this.whereClauses,
303
+ sort: modifications.sort ?? this.sortOptions,
304
+ dateRange: modifications.dateRange ?? this.dateRange,
305
+ pagination: modifications.pagination ?? this.pagination,
306
+ });
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Factory function to create query options
312
+ */
313
+ export function createQueryOptions(options?: {
314
+ where?: WhereClause[];
315
+ sort?: SortOptions[];
316
+ dateRange?: DateRangeOptions;
317
+ pagination?: PaginationOptions;
318
+ }): QueryOptions {
319
+ return options ? QueryOptions.create(options) : QueryOptions.empty();
320
+ }
@@ -0,0 +1,207 @@
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 {
151
+ return QueryOptions.create({
152
+ where: [...options.whereClauses] as WhereClause[],
153
+ sort: [],
154
+ dateRange: options.dateRange,
155
+ pagination: options.pagination,
156
+ });
157
+ }
158
+
159
+ /**
160
+ * Strip date range from options
161
+ */
162
+ export function withoutDateRange(options: QueryOptions): QueryOptions {
163
+ return QueryOptions.create({
164
+ where: [...options.whereClauses] as WhereClause[],
165
+ sort: [...options.sortOptions] as SortOptions[],
166
+ dateRange: null,
167
+ pagination: options.pagination,
168
+ });
169
+ }
170
+
171
+ /**
172
+ * Strip where clauses from options
173
+ */
174
+ export function withoutWhere(options: QueryOptions): QueryOptions {
175
+ return QueryOptions.create({
176
+ where: [],
177
+ sort: [...options.sortOptions] as SortOptions[],
178
+ dateRange: options.dateRange,
179
+ pagination: options.pagination,
180
+ });
181
+ }
182
+
183
+ /**
184
+ * Add limit to existing options
185
+ */
186
+ export function withLimit(options: QueryOptions, limit: number): QueryOptions {
187
+ const currentPagination = options.pagination || {};
188
+ return QueryOptions.create({
189
+ where: [...options.whereClauses] as WhereClause[],
190
+ sort: [...options.sortOptions] as SortOptions[],
191
+ dateRange: options.dateRange,
192
+ pagination: { ...currentPagination, limit },
193
+ });
194
+ }
195
+
196
+ /**
197
+ * Add cursor to existing options
198
+ */
199
+ export function withCursor(options: QueryOptions, cursor: number): QueryOptions {
200
+ const currentPagination = options.pagination || {};
201
+ return QueryOptions.create({
202
+ where: [...options.whereClauses] as WhereClause[],
203
+ sort: [...options.sortOptions] as SortOptions[],
204
+ dateRange: options.dateRange,
205
+ pagination: { ...currentPagination, cursor },
206
+ });
207
+ }
@@ -0,0 +1,182 @@
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
+ }