@onchaindb/sdk 0.4.4 → 1.0.0
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/.claude/settings.local.json +10 -2
- package/README.md +422 -355
- package/dist/batch.d.ts +1 -10
- package/dist/batch.d.ts.map +1 -1
- package/dist/batch.js +4 -26
- package/dist/batch.js.map +1 -1
- package/dist/client.d.ts +29 -43
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +199 -323
- package/dist/client.js.map +1 -1
- package/dist/database.d.ts +14 -131
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +35 -131
- package/dist/database.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -15
- package/dist/index.js.map +1 -1
- package/dist/query-sdk/ConditionBuilder.d.ts +3 -11
- package/dist/query-sdk/ConditionBuilder.d.ts.map +1 -1
- package/dist/query-sdk/ConditionBuilder.js +10 -48
- package/dist/query-sdk/ConditionBuilder.js.map +1 -1
- package/dist/query-sdk/NestedBuilders.d.ts +33 -30
- package/dist/query-sdk/NestedBuilders.d.ts.map +1 -1
- package/dist/query-sdk/NestedBuilders.js +46 -43
- package/dist/query-sdk/NestedBuilders.js.map +1 -1
- package/dist/query-sdk/QueryBuilder.d.ts +4 -2
- package/dist/query-sdk/QueryBuilder.d.ts.map +1 -1
- package/dist/query-sdk/QueryBuilder.js +47 -169
- package/dist/query-sdk/QueryBuilder.js.map +1 -1
- package/dist/query-sdk/QueryResult.d.ts +0 -38
- package/dist/query-sdk/QueryResult.d.ts.map +1 -1
- package/dist/query-sdk/QueryResult.js +1 -227
- package/dist/query-sdk/QueryResult.js.map +1 -1
- package/dist/query-sdk/index.d.ts +1 -1
- package/dist/query-sdk/index.d.ts.map +1 -1
- package/dist/query-sdk/index.js.map +1 -1
- package/dist/query-sdk/operators.d.ts +32 -28
- package/dist/query-sdk/operators.d.ts.map +1 -1
- package/dist/query-sdk/operators.js +45 -155
- package/dist/query-sdk/operators.js.map +1 -1
- package/dist/types.d.ts +153 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/jest.config.js +4 -0
- package/package.json +1 -1
- package/skills.md +0 -1
- package/src/client.ts +243 -745
- package/src/database.ts +70 -493
- package/src/index.ts +40 -193
- package/src/query-sdk/ConditionBuilder.ts +37 -89
- package/src/query-sdk/NestedBuilders.ts +90 -92
- package/src/query-sdk/QueryBuilder.ts +59 -218
- package/src/query-sdk/QueryResult.ts +4 -330
- package/src/query-sdk/README.md +214 -583
- package/src/query-sdk/index.ts +1 -1
- package/src/query-sdk/operators.ts +91 -200
- package/src/query-sdk/tests/FieldConditionBuilder.test.ts +70 -71
- package/src/query-sdk/tests/LogicalOperator.test.ts +43 -82
- package/src/query-sdk/tests/NestedBuilders.test.ts +229 -309
- package/src/query-sdk/tests/QueryBuilder.test.ts +5 -5
- package/src/query-sdk/tests/QueryResult.test.ts +41 -435
- package/src/query-sdk/tests/comprehensive.test.ts +4 -185
- package/src/tests/client-requests.test.ts +280 -0
- package/src/tests/client-validation.test.ts +80 -0
- package/src/types.ts +229 -8
- package/src/batch.ts +0 -257
- package/src/query-sdk/dist/ConditionBuilder.d.ts +0 -22
- package/src/query-sdk/dist/ConditionBuilder.js +0 -90
- package/src/query-sdk/dist/FieldConditionBuilder.d.ts +0 -1
- package/src/query-sdk/dist/FieldConditionBuilder.js +0 -6
- package/src/query-sdk/dist/NestedBuilders.d.ts +0 -43
- package/src/query-sdk/dist/NestedBuilders.js +0 -144
- package/src/query-sdk/dist/OnChainDB.d.ts +0 -19
- package/src/query-sdk/dist/OnChainDB.js +0 -123
- package/src/query-sdk/dist/QueryBuilder.d.ts +0 -70
- package/src/query-sdk/dist/QueryBuilder.js +0 -295
- package/src/query-sdk/dist/QueryResult.d.ts +0 -52
- package/src/query-sdk/dist/QueryResult.js +0 -293
- package/src/query-sdk/dist/SelectionBuilder.d.ts +0 -20
- package/src/query-sdk/dist/SelectionBuilder.js +0 -80
- package/src/query-sdk/dist/adapters/HttpClientAdapter.d.ts +0 -27
- package/src/query-sdk/dist/adapters/HttpClientAdapter.js +0 -170
- package/src/query-sdk/dist/index.d.ts +0 -36
- package/src/query-sdk/dist/index.js +0 -27
- package/src/query-sdk/dist/operators.d.ts +0 -56
- package/src/query-sdk/dist/operators.js +0 -289
- package/src/query-sdk/dist/tests/setup.d.ts +0 -15
- package/src/query-sdk/dist/tests/setup.js +0 -46
- package/src/query-sdk/jest.config.js +0 -25
- package/src/query-sdk/package.json +0 -46
- package/src/query-sdk/tests/aggregations.test.ts +0 -653
- package/src/query-sdk/tests/integration.test.ts +0 -608
- package/src/query-sdk/tests/operators.test.ts +0 -327
- package/src/query-sdk/tests/unit.test.ts +0 -794
- package/src/query-sdk/tsconfig.json +0 -26
- package/src/query-sdk/yarn.lock +0 -3092
package/src/index.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// Main SDK exports
|
|
2
|
-
export {OnChainDBClient} from './client';
|
|
3
|
-
export {
|
|
2
|
+
export { OnChainDBClient } from './client';
|
|
3
|
+
export { QueryBuilder } from './query-sdk';
|
|
4
|
+
export { DatabaseManager, createDatabaseManager } from './database';
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
-
export {QueryBuilder, SelectionBuilder, FieldConditionBuilder, LogicalOperator, ConditionBuilder, JoinBuilder, OnChainDB} from './query-sdk';
|
|
7
|
-
|
|
8
|
-
// Database management exports
|
|
9
|
-
export {DatabaseManager, createDatabaseManager} from './database';
|
|
10
|
-
|
|
11
|
-
// Type exports
|
|
6
|
+
// Core type exports
|
|
12
7
|
export type {
|
|
13
8
|
OnChainDBConfig,
|
|
14
9
|
StoreRequest,
|
|
@@ -30,55 +25,58 @@ export type {
|
|
|
30
25
|
PricingQuoteResponse,
|
|
31
26
|
SimpleCollectionSchema,
|
|
32
27
|
SimpleFieldDefinition,
|
|
28
|
+
SimpleCollectionSchemaWithSharding,
|
|
29
|
+
ShardingStrategy,
|
|
30
|
+
ShardKey,
|
|
33
31
|
CreateCollectionResult,
|
|
34
32
|
SyncCollectionResult,
|
|
33
|
+
UpdateCollectionRequest,
|
|
34
|
+
SetRetentionRequest,
|
|
35
|
+
ApiConfig,
|
|
36
|
+
SqlQueryRequest,
|
|
37
|
+
SqlQueryResponse,
|
|
38
|
+
SqlInsertRequest,
|
|
39
|
+
SqlCreateViewRequest,
|
|
40
|
+
ViewDataResponse,
|
|
41
|
+
ViewQueryRequest,
|
|
42
|
+
QueryParameter,
|
|
43
|
+
QueryDefinition,
|
|
44
|
+
CreateQueryRequest,
|
|
45
|
+
CreateQueryResponse,
|
|
46
|
+
QueryDataResponse,
|
|
47
|
+
RetentionConfig,
|
|
48
|
+
CollectionRetentionCost,
|
|
49
|
+
RetentionCostResponse,
|
|
50
|
+
CollectionResponse,
|
|
51
|
+
CreateApiCollectionRequest,
|
|
35
52
|
BaseDocument,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
AppKeyPermission,
|
|
54
|
+
PayLimits,
|
|
55
|
+
CreateKeyRequest,
|
|
56
|
+
AppKeyInfo,
|
|
39
57
|
} from './types';
|
|
40
58
|
|
|
41
|
-
// Query type exports
|
|
42
|
-
export type {
|
|
43
|
-
SelectionMap,
|
|
44
|
-
QueryRequest as RawQuery,
|
|
45
|
-
QueryResponse as OnChainQueryResponse,
|
|
46
|
-
QueryValue,
|
|
47
|
-
Val
|
|
48
|
-
} from './query-sdk';
|
|
49
|
-
|
|
50
|
-
// Re-export operator types from ./query-sdk
|
|
51
|
-
export type {Condition} from './query-sdk';
|
|
59
|
+
// Query type exports (useful for advanced typing)
|
|
60
|
+
export type { QueryResponse as RawQueryResponse, SelectionMap, Val } from './query-sdk';
|
|
52
61
|
|
|
53
|
-
// x402 payment types
|
|
62
|
+
// x402 payment types (needed for payment callbacks)
|
|
54
63
|
export type {
|
|
55
64
|
X402Quote,
|
|
56
65
|
X402PaymentRequirement,
|
|
57
66
|
X402PaymentResult,
|
|
67
|
+
X402PaymentCallbackResult,
|
|
58
68
|
ChainType,
|
|
59
|
-
PaymentMethod
|
|
69
|
+
PaymentMethod,
|
|
60
70
|
} from './x402';
|
|
61
71
|
|
|
62
72
|
// Database management type exports
|
|
63
73
|
export type {
|
|
64
|
-
Collection,
|
|
65
|
-
CollectionSchema,
|
|
66
|
-
FieldDefinition,
|
|
67
|
-
FieldValidation,
|
|
68
|
-
Relationship,
|
|
69
74
|
Index,
|
|
70
75
|
IndexOptions,
|
|
71
|
-
IndexStatus,
|
|
72
|
-
IndexStatistics,
|
|
73
76
|
PriceConfig,
|
|
74
|
-
CollectionMetadata,
|
|
75
|
-
DatabaseStats,
|
|
76
|
-
QueryPlan,
|
|
77
|
-
BatchOperation,
|
|
78
|
-
BatchResult,
|
|
79
77
|
MaterializedView,
|
|
80
78
|
ViewInfo,
|
|
81
|
-
ListViewsResponse
|
|
79
|
+
ListViewsResponse,
|
|
82
80
|
} from './database';
|
|
83
81
|
|
|
84
82
|
// Error exports
|
|
@@ -87,167 +85,16 @@ export {
|
|
|
87
85
|
TransactionError,
|
|
88
86
|
ValidationError,
|
|
89
87
|
PaymentRequiredError,
|
|
90
|
-
PaymentVerificationError
|
|
88
|
+
PaymentVerificationError,
|
|
91
89
|
} from './types';
|
|
92
90
|
|
|
93
|
-
// Import types for factory function
|
|
94
|
-
import {OnChainDBConfig} from './types';
|
|
95
|
-
import {OnChainDBClient} from './client';
|
|
96
|
-
|
|
97
91
|
// Convenience factory function
|
|
92
|
+
import { OnChainDBConfig } from './types';
|
|
93
|
+
import { OnChainDBClient } from './client';
|
|
94
|
+
|
|
98
95
|
export function createClient(config: OnChainDBConfig): OnChainDBClient {
|
|
99
96
|
return new OnChainDBClient(config);
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
// Re-export HTTP client utilities from ./query-sdk for advanced usage
|
|
103
|
-
export {AxiosHttpClient, FetchHttpClient, NodeHttpClient, createHttpClient} from './query-sdk';
|
|
104
|
-
|
|
105
99
|
// SDK version
|
|
106
100
|
export const VERSION = '1.0.0';
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* OnChainDB TypeScript SDK
|
|
110
|
-
*
|
|
111
|
-
* A complete TypeScript SDK for OnChainDB - the decentralized database
|
|
112
|
-
* built on Celestia blockchain.
|
|
113
|
-
*
|
|
114
|
-
* Features:
|
|
115
|
-
* - ✅ Full type safety with TypeScript
|
|
116
|
-
* - ✅ Automatic transaction management
|
|
117
|
-
* - ✅ Real-time confirmation tracking
|
|
118
|
-
* - ✅ Batch operations with progress tracking
|
|
119
|
-
* - ✅ Built-in error handling and retries
|
|
120
|
-
* - ✅ Event-driven architecture
|
|
121
|
-
* - ✅ Query building and filtering
|
|
122
|
-
* - ✅ Complete database management (collections, indexes, schemas)
|
|
123
|
-
* - ✅ Performance monitoring and optimization
|
|
124
|
-
* - ✅ Schema validation and migration
|
|
125
|
-
*
|
|
126
|
-
* @example Basic Usage
|
|
127
|
-
* ```typescript
|
|
128
|
-
* import { createClient } from '@onchaindb/sdk';
|
|
129
|
-
*
|
|
130
|
-
* const db = createClient({
|
|
131
|
-
* endpoint: 'http://localhost:9092',
|
|
132
|
-
* apiKey: 'your-api-key'
|
|
133
|
-
* });
|
|
134
|
-
*
|
|
135
|
-
* // Store data
|
|
136
|
-
* const result = await db.store({
|
|
137
|
-
* data: { message: 'Hello OnChainDB!', user: 'alice' },
|
|
138
|
-
* collection: 'messages'
|
|
139
|
-
* });
|
|
140
|
-
*
|
|
141
|
-
* console.log('Stored with ID:', result.id);
|
|
142
|
-
* console.log('Transaction:', result.transaction_hash);
|
|
143
|
-
*
|
|
144
|
-
* // Query data
|
|
145
|
-
* const messages = await db.query({
|
|
146
|
-
* collection: 'messages',
|
|
147
|
-
* limit: 10
|
|
148
|
-
* });
|
|
149
|
-
*
|
|
150
|
-
* console.log(`Found ${messages.total} messages`);
|
|
151
|
-
* ```
|
|
152
|
-
*
|
|
153
|
-
* @example Advanced Usage with Events
|
|
154
|
-
* ```typescript
|
|
155
|
-
* import { OnChainDBClient } from '@onchaindb/sdk';
|
|
156
|
-
*
|
|
157
|
-
* const db = new OnChainDBClient({
|
|
158
|
-
* endpoint: 'http://localhost:9092'
|
|
159
|
-
* });
|
|
160
|
-
*
|
|
161
|
-
* // Listen for transaction events
|
|
162
|
-
* db.on('transaction:pending', (tx) => {
|
|
163
|
-
* console.log('Transaction pending:', tx.id);
|
|
164
|
-
* });
|
|
165
|
-
*
|
|
166
|
-
* db.on('transaction:confirmed', (tx) => {
|
|
167
|
-
* console.log('Transaction confirmed:', tx.id);
|
|
168
|
-
* });
|
|
169
|
-
*
|
|
170
|
-
* // Store and wait for confirmation
|
|
171
|
-
* const confirmed = await db.storeAndConfirm({
|
|
172
|
-
* data: { important: 'data that needs confirmation' },
|
|
173
|
-
* collection: 'critical'
|
|
174
|
-
* });
|
|
175
|
-
* ```
|
|
176
|
-
*
|
|
177
|
-
* @example Batch Operations
|
|
178
|
-
* ```typescript
|
|
179
|
-
* import { OnChainDBClient, BulkBuilder } from '@onchaindb/sdk';
|
|
180
|
-
*
|
|
181
|
-
* const db = new OnChainDBClient({ endpoint: 'http://localhost:9092' });
|
|
182
|
-
* const batch = db.batch();
|
|
183
|
-
*
|
|
184
|
-
* // Build bulk operation
|
|
185
|
-
* const builder = new BulkBuilder()
|
|
186
|
-
* .collection('tweets')
|
|
187
|
-
* .add({ message: 'Tweet 1', author: 'alice' })
|
|
188
|
-
* .add({ message: 'Tweet 2', author: 'bob' })
|
|
189
|
-
* .add({ message: 'Tweet 3', author: 'charlie' });
|
|
190
|
-
*
|
|
191
|
-
* // Execute with progress tracking
|
|
192
|
-
* const results = await batch.store(builder.build(), {
|
|
193
|
-
* concurrency: 5,
|
|
194
|
-
* waitForConfirmation: true,
|
|
195
|
-
* onProgress: (completed, total) => {
|
|
196
|
-
* console.log(`Progress: ${completed}/${total}`);
|
|
197
|
-
* }
|
|
198
|
-
* });
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* @example Database Management
|
|
202
|
-
* ```typescript
|
|
203
|
-
* import { createClient } from '@onchaindb/sdk';
|
|
204
|
-
*
|
|
205
|
-
* const client = createClient({
|
|
206
|
-
* endpoint: 'http://localhost:9092',
|
|
207
|
-
* apiKey: 'your-api-key'
|
|
208
|
-
* });
|
|
209
|
-
*
|
|
210
|
-
* // Get database manager for an app
|
|
211
|
-
* const db = client.database('app_12345');
|
|
212
|
-
*
|
|
213
|
-
* // Create collections with schemas
|
|
214
|
-
* await db.createCollection('users', {
|
|
215
|
-
* fields: {
|
|
216
|
-
* id: { type: 'string', unique: true, required: true },
|
|
217
|
-
* name: { type: 'string', required: true },
|
|
218
|
-
* email: { type: 'string', unique: true, required: true },
|
|
219
|
-
* created_at: { type: 'date', default: () => new Date() }
|
|
220
|
-
* }
|
|
221
|
-
* });
|
|
222
|
-
*
|
|
223
|
-
* // Create optimized indexes
|
|
224
|
-
* await db.createIndex({
|
|
225
|
-
* name: 'users_email_index',
|
|
226
|
-
* collection: 'users',
|
|
227
|
-
* field_name: 'email',
|
|
228
|
-
* index_type: 'btree',
|
|
229
|
-
* options: { unique: true }
|
|
230
|
-
* });
|
|
231
|
-
*
|
|
232
|
-
* // Monitor performance
|
|
233
|
-
* const stats = await db.getDatabaseStats();
|
|
234
|
-
* console.log(`Collections: ${stats.total_collections}, Indexes: ${stats.total_indexes}`);
|
|
235
|
-
* ```
|
|
236
|
-
*
|
|
237
|
-
* @example Error Handling
|
|
238
|
-
* ```typescript
|
|
239
|
-
* import { OnChainDBError, TransactionError, ValidationError } from '@onchaindb/sdk';
|
|
240
|
-
*
|
|
241
|
-
* try {
|
|
242
|
-
* await db.store({ data: { test: 'data' } });
|
|
243
|
-
* } catch (error) {
|
|
244
|
-
* if (error instanceof ValidationError) {
|
|
245
|
-
* console.log('Validation failed:', error.message);
|
|
246
|
-
* } else if (error instanceof TransactionError) {
|
|
247
|
-
* console.log('Transaction failed:', error.transactionId);
|
|
248
|
-
* } else if (error instanceof OnChainDBError) {
|
|
249
|
-
* console.log('OnChainDB error:', error.code);
|
|
250
|
-
* }
|
|
251
|
-
* }
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
@@ -1,103 +1,51 @@
|
|
|
1
1
|
import { LogicalOperator, FieldConditionBuilder } from './operators';
|
|
2
2
|
import { NestedConditionBuilder } from './NestedBuilders';
|
|
3
3
|
|
|
4
|
-
// Builder for creating complex conditions with logical operators
|
|
4
|
+
// Builder for creating complex conditions with logical operators.
|
|
5
|
+
// Received as the argument inside .find() and .on() callbacks.
|
|
5
6
|
export class ConditionBuilder {
|
|
6
|
-
|
|
7
|
-
private currentOperator?: 'and' | 'or' | 'not';
|
|
7
|
+
constructor() {}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return new ConditionBuilder();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Create a field condition builder
|
|
16
|
-
field(fieldName: string): FieldConditionBuilder {
|
|
17
|
-
return new FieldConditionBuilder(fieldName);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Create a nested field condition with fluent API (like Rust SDK)
|
|
21
|
-
nested(fieldName: string, builderFn: (builder: NestedConditionBuilder) => LogicalOperator): LogicalOperator {
|
|
22
|
-
const nestedBuilder = new NestedConditionBuilder(fieldName);
|
|
23
|
-
return builderFn(nestedBuilder);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Add an AND operator context
|
|
27
|
-
and(): ConditionBuilder {
|
|
28
|
-
this.currentOperator = 'and';
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Add an OR operator context
|
|
33
|
-
or(): ConditionBuilder {
|
|
34
|
-
this.currentOperator = 'or';
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Add a NOT operator context
|
|
39
|
-
not(): ConditionBuilder {
|
|
40
|
-
this.currentOperator = 'not';
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Group conditions with AND logic
|
|
45
|
-
andGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator {
|
|
46
|
-
const nestedBuilder = new ConditionBuilder();
|
|
47
|
-
const conditions = builderFn(nestedBuilder);
|
|
48
|
-
return LogicalOperator.And(conditions);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Group conditions with OR logic
|
|
52
|
-
orGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator {
|
|
53
|
-
const nestedBuilder = new ConditionBuilder();
|
|
54
|
-
const conditions = builderFn(nestedBuilder);
|
|
55
|
-
return LogicalOperator.Or(conditions);
|
|
56
|
-
}
|
|
9
|
+
static new(): ConditionBuilder {
|
|
10
|
+
return new ConditionBuilder();
|
|
11
|
+
}
|
|
57
12
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return LogicalOperator.Not(conditions);
|
|
63
|
-
}
|
|
13
|
+
// Create a field condition builder for a single field
|
|
14
|
+
field(fieldName: string): FieldConditionBuilder {
|
|
15
|
+
return new FieldConditionBuilder(fieldName);
|
|
16
|
+
}
|
|
64
17
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
18
|
+
// Create a nested field condition (dot-notation path)
|
|
19
|
+
nested(fieldName: string, builderFn: (builder: NestedConditionBuilder) => LogicalOperator): LogicalOperator {
|
|
20
|
+
const nestedBuilder = new NestedConditionBuilder(fieldName);
|
|
21
|
+
return builderFn(nestedBuilder);
|
|
22
|
+
}
|
|
70
23
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
24
|
+
// Combine conditions with AND — the default when no group is specified
|
|
25
|
+
and(...conditions: LogicalOperator[]): LogicalOperator {
|
|
26
|
+
return LogicalOperator.And(conditions);
|
|
27
|
+
}
|
|
75
28
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
throw new Error('No conditions to build');
|
|
29
|
+
// Combine conditions with OR
|
|
30
|
+
or(...conditions: LogicalOperator[]): LogicalOperator {
|
|
31
|
+
return LogicalOperator.Or(conditions);
|
|
80
32
|
}
|
|
81
|
-
|
|
82
|
-
|
|
33
|
+
|
|
34
|
+
// Negate conditions with NOT
|
|
35
|
+
not(...conditions: LogicalOperator[]): LogicalOperator {
|
|
36
|
+
return LogicalOperator.Not(conditions);
|
|
83
37
|
}
|
|
84
|
-
return LogicalOperator.And(this.conditions);
|
|
85
|
-
}
|
|
86
38
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
39
|
+
// Callback-style group helpers (kept for compatibility)
|
|
40
|
+
andGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator {
|
|
41
|
+
return LogicalOperator.And(builderFn(new ConditionBuilder()));
|
|
42
|
+
}
|
|
93
43
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
44
|
+
orGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator {
|
|
45
|
+
return LogicalOperator.Or(builderFn(new ConditionBuilder()));
|
|
46
|
+
}
|
|
98
47
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
48
|
+
notGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator {
|
|
49
|
+
return LogicalOperator.Not(builderFn(new ConditionBuilder()));
|
|
50
|
+
}
|
|
51
|
+
}
|