@umituz/react-native-firebase 2.6.1 → 2.6.2

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 (87) hide show
  1. package/package.json +1 -1
  2. package/src/application/auth/ports/AuthPort_part_aa +150 -0
  3. package/src/application/auth/ports/AuthPort_part_ab +14 -0
  4. package/src/application/auth/use-cases/SignInUseCaseHelpers.ts +0 -0
  5. package/src/application/auth/use-cases/SignInUseCaseMain.ts +0 -0
  6. package/src/application/auth/use-cases/SignInUseCase_part_aa +150 -0
  7. package/src/application/auth/use-cases/SignInUseCase_part_ab +103 -0
  8. package/src/application/auth/use-cases/SignOutUseCaseCleanup.ts +0 -0
  9. package/src/application/auth/use-cases/SignOutUseCaseMain.ts +0 -0
  10. package/src/application/auth/use-cases/SignOutUseCase_part_aa +150 -0
  11. package/src/application/auth/use-cases/SignOutUseCase_part_ab +138 -0
  12. package/src/domains/account-deletion/domain/services/UserValidationHelpers.ts.bak +181 -0
  13. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_aa +150 -0
  14. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_ab +31 -0
  15. package/src/domains/account-deletion/domain/services/{UserValidationService.ts → UserValidationService.ts.bak} +1 -10
  16. package/src/domains/account-deletion/domain/services/UserValidationService_part_aa +150 -0
  17. package/src/domains/account-deletion/domain/services/UserValidationService_part_ab +136 -0
  18. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_aa +150 -0
  19. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_ab +80 -0
  20. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_aa +150 -0
  21. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_ab +24 -0
  22. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_aa +150 -0
  23. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_ab +116 -0
  24. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_aa +150 -0
  25. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_ab +10 -0
  26. package/src/domains/auth/infrastructure_part_aa +150 -0
  27. package/src/domains/auth/infrastructure_part_ab +6 -0
  28. package/src/domains/auth/presentation/hooks/GoogleOAuthHelpers.ts +0 -0
  29. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_aa +150 -0
  30. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_ab +97 -0
  31. package/src/domains/auth/presentation/hooks/GoogleOAuthService.ts +0 -0
  32. package/src/domains/firestore/domain/entities/Collection.ts +31 -191
  33. package/src/domains/firestore/domain/entities/Collection.ts.bak +288 -0
  34. package/src/domains/firestore/domain/entities/CollectionFactory.ts +55 -0
  35. package/src/domains/firestore/domain/entities/CollectionHelpers.ts +143 -0
  36. package/src/domains/firestore/domain/entities/CollectionUtils.ts +72 -0
  37. package/src/domains/firestore/domain/entities/CollectionValidation.ts +138 -0
  38. package/src/domains/firestore/domain/entities/Collection_part_aa +150 -0
  39. package/src/domains/firestore/domain/entities/Collection_part_ab +138 -0
  40. package/src/domains/firestore/domain/entities/DocumentHelpers.ts +0 -0
  41. package/src/domains/firestore/domain/entities/DocumentMain.ts +0 -0
  42. package/src/domains/firestore/domain/entities/Document_part_aa +150 -0
  43. package/src/domains/firestore/domain/entities/Document_part_ab +83 -0
  44. package/src/domains/firestore/domain/index.ts +44 -9
  45. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_aa +150 -0
  46. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_ab +19 -0
  47. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_aa +150 -0
  48. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_ab +1 -0
  49. package/src/domains/firestore/domain/services/QueryService_part_aa +150 -0
  50. package/src/domains/firestore/domain/services/QueryService_part_ab +32 -0
  51. package/src/domains/firestore/domain/value-objects/QueryOptions.ts.bak +6 -135
  52. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_aa +150 -0
  53. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_ab +57 -0
  54. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_aa +150 -0
  55. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_ab +32 -0
  56. package/src/domains/firestore/domain/value-objects/{QueryOptions.ts → QueryOptions_part_aa} +0 -41
  57. package/src/domains/firestore/domain/value-objects/QueryOptions_part_ab +41 -0
  58. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_aa +150 -0
  59. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_ab +57 -0
  60. package/src/domains/firestore/domain/value-objects/WhereClause_part_aa +150 -0
  61. package/src/domains/firestore/domain/value-objects/WhereClause_part_ab +149 -0
  62. package/src/shared/infrastructure/base/ErrorHandler_part_aa +150 -0
  63. package/src/shared/infrastructure/base/ErrorHandler_part_ab +39 -0
  64. package/src/shared/infrastructure/base/ServiceBase_part_aa +150 -0
  65. package/src/shared/infrastructure/base/ServiceBase_part_ab +70 -0
  66. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_aa +150 -0
  67. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_ab +5 -0
  68. /package/src/application/auth/ports/{AuthPort.ts → AuthPort.ts.bak} +0 -0
  69. /package/src/application/auth/use-cases/{SignInUseCase.ts → SignInUseCase.ts.bak} +0 -0
  70. /package/src/application/auth/use-cases/{SignOutUseCase.ts → SignOutUseCase.ts.bak} +0 -0
  71. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionExecutor.ts → AccountDeletionExecutor.ts.bak} +0 -0
  72. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionReauthHandler.ts → AccountDeletionReauthHandler.ts.bak} +0 -0
  73. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionRepository.ts → AccountDeletionRepository.ts.bak} +0 -0
  74. /package/src/domains/account-deletion/infrastructure/services/{reauthentication.service.ts → reauthentication.service.ts.bak} +0 -0
  75. /package/src/domains/auth/{infrastructure.ts → infrastructure.ts.bak} +0 -0
  76. /package/src/domains/auth/presentation/hooks/{GoogleOAuthHookService.ts → GoogleOAuthHookService.ts.bak} +0 -0
  77. /package/src/domains/firestore/domain/entities/{Document.ts → Document.ts.bak} +0 -0
  78. /package/src/domains/firestore/domain/services/{QueryService.ts → QueryService.ts.bak} +0 -0
  79. /package/src/domains/firestore/domain/services/{QueryServiceAnalysis.ts → QueryServiceAnalysis.ts.bak} +0 -0
  80. /package/src/domains/firestore/domain/services/{QueryServiceHelpers.ts → QueryServiceHelpers.ts.bak} +0 -0
  81. /package/src/domains/firestore/domain/value-objects/{QueryOptionsSerialization.ts → QueryOptionsSerialization.ts.bak} +0 -0
  82. /package/src/domains/firestore/domain/value-objects/{QueryOptionsValidation.ts → QueryOptionsValidation.ts.bak} +0 -0
  83. /package/src/domains/firestore/domain/value-objects/{WhereClause.ts → WhereClause.ts.bak} +0 -0
  84. /package/src/domains/firestore/domain/value-objects/{WhereClauseFactory.ts → WhereClauseFactory.ts.bak} +0 -0
  85. /package/src/shared/infrastructure/base/{ErrorHandler.ts → ErrorHandler.ts.bak} +0 -0
  86. /package/src/shared/infrastructure/base/{ServiceBase.ts → ServiceBase.ts.bak} +0 -0
  87. /package/src/shared/infrastructure/config/base/{ServiceClientSingleton.ts → ServiceClientSingleton.ts.bak} +0 -0
@@ -0,0 +1,32 @@
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
+ }
@@ -148,44 +148,3 @@ export class QueryOptions {
148
148
 
149
149
  /**
150
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
- * Clone with modifications
165
- */
166
- clone(modifications: {
167
- where?: WhereClause[];
168
- sort?: SortOptions[];
169
- dateRange?: DateRangeOptions | null;
170
- pagination?: PaginationOptions | null;
171
- }): QueryOptions {
172
- return QueryOptions.create({
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
- });
178
- }
179
- }
180
-
181
- /**
182
- * Factory function to create query options
183
- */
184
- export function createQueryOptions(options?: {
185
- where?: WhereClause[];
186
- sort?: SortOptions[];
187
- dateRange?: DateRangeOptions;
188
- pagination?: PaginationOptions;
189
- }): QueryOptions {
190
- return options ? QueryOptions.create(options) : QueryOptions.empty();
191
- }
@@ -0,0 +1,41 @@
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
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Where Clause Factory
3
+ * Single Responsibility: Provide factory methods for common where clauses
4
+ *
5
+ * Factory functions for creating commonly used where clauses.
6
+ * Separated from WhereClause for better maintainability.
7
+ *
8
+ * Max lines: 150 (enforced for maintainability)
9
+ */
10
+
11
+ import type { WhereFilterOp } from 'firebase/firestore';
12
+ import { WhereClause } from './WhereClause';
13
+ import type { WhereOperator } from './WhereClause';
14
+
15
+ /**
16
+ * Factory function to create where clause
17
+ */
18
+ export function createWhereClause(
19
+ field: string,
20
+ operator: WhereFilterOp,
21
+ value: unknown
22
+ ): WhereClause {
23
+ return WhereClause.create(field, operator, value);
24
+ }
25
+
26
+ /**
27
+ * Factory functions for common where clauses
28
+ */
29
+ export const where = {
30
+ equals: WhereClause.equals,
31
+ notEquals: WhereClause.notEquals,
32
+ lessThan: WhereClause.lessThan,
33
+ lessThanOrEqual: WhereClause.lessThanOrEqual,
34
+ greaterThan: WhereClause.greaterThan,
35
+ greaterThanOrEqual: WhereClause.greaterThanOrEqual,
36
+ arrayContains: WhereClause.arrayContains,
37
+ arrayContainsAny: WhereClause.arrayContainsAny,
38
+ in: WhereClause.in,
39
+ notIn: WhereClause.notIn,
40
+ };
41
+
42
+ /**
43
+ * Create batch of where clauses
44
+ */
45
+ export function createWhereBatch(
46
+ clauses: Array<{ field: string; operator: WhereFilterOp; value: unknown }>
47
+ ): WhereClause[] {
48
+ return clauses.map(c => WhereClause.create(c.field, c.operator, c.value));
49
+ }
50
+
51
+ /**
52
+ * Create equality clauses from object
53
+ */
54
+ export function createEqualityFilters(obj: Record<string, unknown>): WhereClause[] {
55
+ return Object.entries(obj).map(([field, value]) =>
56
+ WhereClause.equals(field, value)
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Create in clause from values
62
+ */
63
+ export function createInClause(field: string, values: unknown[]): WhereClause {
64
+ return WhereClause.in(field, values);
65
+ }
66
+
67
+ /**
68
+ * Create not-in clause from values
69
+ */
70
+ export function createNotInClause(field: string, values: unknown[]): WhereClause {
71
+ return WhereClause.notIn(field, values);
72
+ }
73
+
74
+ /**
75
+ * Create range clause (>= start and <= end)
76
+ */
77
+ export function createRangeClause(
78
+ field: string,
79
+ startValue: unknown,
80
+ endValue: unknown
81
+ ): WhereClause[] {
82
+ return [
83
+ WhereClause.greaterThanOrEqual(field, startValue),
84
+ WhereClause.lessThanOrEqual(field, endValue),
85
+ ];
86
+ }
87
+
88
+ /**
89
+ * Create date range clause
90
+ */
91
+ export function createDateRangeClause(
92
+ field: string,
93
+ startDate: Date,
94
+ endDate: Date
95
+ ): WhereClause[] {
96
+ return createRangeClause(field, startDate, endDate);
97
+ }
98
+
99
+ /**
100
+ * Create text search clause (case-insensitive contains)
101
+ * Note: Firestore doesn't support native contains, this is for consistency
102
+ */
103
+ export function createTextSearchClause(field: string, searchText: string): WhereClause {
104
+ return WhereClause.equals(field, searchText);
105
+ }
106
+
107
+ /**
108
+ * Create multiple equality clauses combined
109
+ */
110
+ export function createMultiFieldFilter(filters: Record<string, unknown>): WhereClause[] {
111
+ return createEqualityFilters(filters);
112
+ }
113
+
114
+ /**
115
+ * Create not-null clause
116
+ */
117
+ export function createNotNullClause(field: string): WhereClause {
118
+ return WhereClause.notEquals(field, null);
119
+ }
120
+
121
+ /**
122
+ * Create null clause
123
+ */
124
+ export function createNullClause(field: string): WhereClause {
125
+ return WhereClause.equals(field, null);
126
+ }
127
+
128
+ /**
129
+ * Create boolean clause
130
+ */
131
+ export function createBooleanClause(field: string, value: boolean): WhereClause {
132
+ return WhereClause.equals(field, value);
133
+ }
134
+
135
+ /**
136
+ * Create number range clause
137
+ */
138
+ export function createNumberRangeClause(
139
+ field: string,
140
+ min: number,
141
+ max: number
142
+ ): WhereClause[] {
143
+ return [
144
+ WhereClause.greaterThanOrEqual(field, min),
145
+ WhereClause.lessThanOrEqual(field, max),
146
+ ];
147
+ }
148
+
149
+ /**
150
+ * Validate where clauses compatibility
@@ -0,0 +1,57 @@
1
+ */
2
+ export function validateWhereClauses(clauses: WhereClause[]): {
3
+ valid: boolean;
4
+ errors: string[];
5
+ } {
6
+ const errors: string[] = [];
7
+
8
+ // Validate each clause individually
9
+ for (let i = 0; i < clauses.length; i++) {
10
+ const validation = clauses[i].validate();
11
+ if (!validation.valid) {
12
+ errors.push(`Clause ${i}: ${validation.errors.join(', ')}`);
13
+ }
14
+ }
15
+
16
+ // Validate compatibility
17
+ for (let i = 0; i < clauses.length; i++) {
18
+ for (let j = i + 1; j < clauses.length; j++) {
19
+ if (!clauses[i].isCompatibleWith(clauses[j])) {
20
+ errors.push(`Clauses ${i} and ${j} are incompatible`);
21
+ }
22
+ }
23
+ }
24
+
25
+ return {
26
+ valid: errors.length === 0,
27
+ errors,
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Optimize where clauses
33
+ * Removes duplicates and incompatible clauses
34
+ */
35
+ export function optimizeWhereClauses(clauses: WhereClause[]): WhereClause[] {
36
+ // Remove duplicates
37
+ const unique = clauses.filter((clause, index, self) =>
38
+ index === self.findIndex(c => clause.equals(c))
39
+ );
40
+
41
+ // Remove incompatible (keep first occurrences)
42
+ const compatible: WhereClause[] = [];
43
+ for (const clause of unique) {
44
+ let canAdd = true;
45
+ for (const existing of compatible) {
46
+ if (!clause.isCompatibleWith(existing)) {
47
+ canAdd = false;
48
+ break;
49
+ }
50
+ }
51
+ if (canAdd) {
52
+ compatible.push(clause);
53
+ }
54
+ }
55
+
56
+ return compatible;
57
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Where Clause Value Object
3
+ * Single Responsibility: Encapsulate where clause conditions
4
+ *
5
+ * Value object that represents a single where clause condition.
6
+ * Provides validation and business logic for query filtering.
7
+ *
8
+ * Max lines: 150 (enforced for maintainability)
9
+ */
10
+
11
+ import type { WhereFilterOp } from 'firebase/firestore';
12
+
13
+ /**
14
+ * Valid where operators for Firestore queries
15
+ */
16
+ export type WhereOperator =
17
+ | '=='
18
+ | '!='
19
+ | '<'
20
+ | '<='
21
+ | '>'
22
+ | '>='
23
+ | 'array-contains'
24
+ | 'array-contains-any'
25
+ | 'in'
26
+ | 'not-in';
27
+
28
+ /**
29
+ * Where clause value object
30
+ * Immutable representation of a single query condition
31
+ */
32
+ export class WhereClause {
33
+ readonly field: string;
34
+ readonly operator: WhereFilterOp;
35
+ readonly value: unknown;
36
+
37
+ private constructor(field: string, operator: WhereFilterOp, value: unknown) {
38
+ this.field = field;
39
+ this.operator = operator;
40
+ this.value = Object.freeze(value);
41
+ }
42
+
43
+ /**
44
+ * Create a where clause
45
+ */
46
+ static create(field: string, operator: WhereFilterOp, value: unknown): WhereClause {
47
+ return new WhereClause(field, operator, value);
48
+ }
49
+
50
+ /**
51
+ * Create equality clause (==)
52
+ */
53
+ static equals(field: string, value: unknown): WhereClause {
54
+ return new WhereClause(field, '==', value);
55
+ }
56
+
57
+ /**
58
+ * Create inequality clause (!=)
59
+ */
60
+ static notEquals(field: string, value: unknown): WhereClause {
61
+ return new WhereClause(field, '!=', value);
62
+ }
63
+
64
+ /**
65
+ * Create less than clause (<)
66
+ */
67
+ static lessThan(field: string, value: unknown): WhereClause {
68
+ return new WhereClause(field, '<', value);
69
+ }
70
+
71
+ /**
72
+ * Create less than or equal clause (<=)
73
+ */
74
+ static lessThanOrEqual(field: string, value: unknown): WhereClause {
75
+ return new WhereClause(field, '<=', value);
76
+ }
77
+
78
+ /**
79
+ * Create greater than clause (>)
80
+ */
81
+ static greaterThan(field: string, value: unknown): WhereClause {
82
+ return new WhereClause(field, '>', value);
83
+ }
84
+
85
+ /**
86
+ * Create greater than or equal clause (>=)
87
+ */
88
+ static greaterThanOrEqual(field: string, value: unknown): WhereClause {
89
+ return new WhereClause(field, '>=', value);
90
+ }
91
+
92
+ /**
93
+ * Create array contains clause
94
+ */
95
+ static arrayContains(field: string, value: unknown): WhereClause {
96
+ return new WhereClause(field, 'array-contains', value);
97
+ }
98
+
99
+ /**
100
+ * Create array contains any clause
101
+ */
102
+ static arrayContainsAny(field: string, values: unknown[]): WhereClause {
103
+ return new WhereClause(field, 'array-contains-any', values);
104
+ }
105
+
106
+ /**
107
+ * Create in clause
108
+ */
109
+ static in(field: string, values: unknown[]): WhereClause {
110
+ return new WhereClause(field, 'in', values);
111
+ }
112
+
113
+ /**
114
+ * Create not-in clause
115
+ */
116
+ static notIn(field: string, values: unknown[]): WhereClause {
117
+ return new WhereClause(field, 'not-in', values);
118
+ }
119
+
120
+ /**
121
+ * Validate where clause
122
+ */
123
+ validate(): { valid: boolean; errors: string[] } {
124
+ const errors: string[] = [];
125
+
126
+ // Validate field name
127
+ if (!this.field || typeof this.field !== 'string' || this.field.trim() === '') {
128
+ errors.push('Field name must be a non-empty string');
129
+ }
130
+
131
+ // Validate operator
132
+ const validOperators: WhereFilterOp[] = [
133
+ '==', '!=', '<', '<=', '>', '>=',
134
+ 'array-contains', 'array-contains-any', 'in', 'not-in'
135
+ ];
136
+ if (!validOperators.includes(this.operator)) {
137
+ errors.push(`Invalid operator: ${this.operator}`);
138
+ }
139
+
140
+ // Validate value based on operator
141
+ if (this.operator === 'array-contains-any' || this.operator === 'in' || this.operator === 'not-in') {
142
+ if (!Array.isArray(this.value)) {
143
+ errors.push(`Operator ${this.operator} requires an array value`);
144
+ } else if (this.value.length === 0) {
145
+ errors.push(`Operator ${this.operator} requires a non-empty array`);
146
+ } else if (this.value.length > 10) {
147
+ errors.push(`Operator ${this.operator} supports maximum 10 elements`);
148
+ }
149
+ }
150
+
@@ -0,0 +1,149 @@
1
+ return {
2
+ valid: errors.length === 0,
3
+ errors,
4
+ };
5
+ }
6
+
7
+ /**
8
+ * Check if equals another where clause
9
+ */
10
+ equals(other: WhereClause): boolean {
11
+ return (
12
+ this.field === other.field &&
13
+ this.operator === other.operator &&
14
+ JSON.stringify(this.value) === JSON.stringify(other.value)
15
+ );
16
+ }
17
+
18
+ /**
19
+ * Check if compatible for compound queries
20
+ * Some operator combinations are not allowed in Firestore
21
+ */
22
+ isCompatibleWith(other: WhereClause): boolean {
23
+ // Equality and inequality operators can be combined
24
+ // Array operators and membership operators have restrictions
25
+ if (
26
+ (this.isArrayOperator() || this.isMembership()) &&
27
+ (other.isArrayOperator() || other.isMembership())
28
+ ) {
29
+ // Only one array/membership clause per query
30
+ return false;
31
+ }
32
+
33
+ return true;
34
+ }
35
+
36
+ /**
37
+ * Get field path components
38
+ * Returns array of field path segments (for nested fields)
39
+ */
40
+ getFieldPath(): string[] {
41
+ return this.field.split('.');
42
+ }
43
+
44
+ /**
45
+ * Check if field is nested (contains dots)
46
+ */
47
+ isNestedField(): boolean {
48
+ return this.field.includes('.');
49
+ }
50
+
51
+ /**
52
+ * Get top-level field name
53
+ */
54
+ getTopLevelField(): string {
55
+ return this.getFieldPath()[0];
56
+ }
57
+
58
+ /**
59
+ * Get human-readable description
60
+ */
61
+ getDescription(): string {
62
+ const valueStr = Array.isArray(this.value)
63
+ ? `[${this.value.map(v => JSON.stringify(v)).join(', ')}]`
64
+ : JSON.stringify(this.value);
65
+
66
+ return `${this.field} ${this.operator} ${valueStr}`;
67
+ }
68
+
69
+ /**
70
+ * Convert to plain object (for serialization)
71
+ */
72
+ toObject(): { field: string; operator: WhereFilterOp; value: unknown } {
73
+ return {
74
+ field: this.field,
75
+ operator: this.operator,
76
+ value: this.value,
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Create from plain object
82
+ */
83
+ static fromObject(obj: { field: string; operator: WhereFilterOp; value: unknown }): WhereClause {
84
+ return WhereClause.create(obj.field, obj.operator, obj.value);
85
+ }
86
+
87
+ /**
88
+ * Clone with new value
89
+ */
90
+ withValue(newValue: unknown): WhereClause {
91
+ return new WhereClause(this.field, this.operator, newValue);
92
+ }
93
+
94
+ /**
95
+ * Clone with new field
96
+ */
97
+ withField(newField: string): WhereClause {
98
+ return new WhereClause(newField, this.operator, this.value);
99
+ }
100
+
101
+ /**
102
+ * Clone with new operator
103
+ */
104
+ withOperator(newOperator: WhereFilterOp): WhereClause {
105
+ return new WhereClause(this.field, newOperator, this.value);
106
+ }
107
+
108
+ /**
109
+ * Check if is equality operator
110
+ */
111
+ isEquality(): boolean {
112
+ return this.operator === '==';
113
+ }
114
+
115
+ /**
116
+ * Check if is inequality operator
117
+ */
118
+ isInequality(): boolean {
119
+ return this.operator === '!=';
120
+ }
121
+
122
+ /**
123
+ * Check if is comparison operator (<, <=, >, >=)
124
+ */
125
+ isComparison(): boolean {
126
+ return ['<', '<=', '>', '>='].includes(this.operator);
127
+ }
128
+
129
+ /**
130
+ * Check if is array operator
131
+ */
132
+ isArrayOperator(): boolean {
133
+ return ['array-contains', 'array-contains-any'].includes(this.operator);
134
+ }
135
+
136
+ /**
137
+ * Check if is membership operator (in, not-in)
138
+ */
139
+ isMembership(): boolean {
140
+ return ['in', 'not-in'].includes(this.operator);
141
+ }
142
+
143
+ /**
144
+ * Check if operator requires array value
145
+ */
146
+ requiresArrayValue(): boolean {
147
+ return ['array-contains-any', 'in', 'not-in'].includes(this.operator);
148
+ }
149
+ }