@onchaindb/sdk 0.4.5 → 2.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.
Files changed (117) hide show
  1. package/.claude/settings.local.json +10 -2
  2. package/README.md +422 -355
  3. package/dist/batch.d.ts +1 -10
  4. package/dist/batch.d.ts.map +1 -1
  5. package/dist/batch.js +4 -26
  6. package/dist/batch.js.map +1 -1
  7. package/dist/client.d.ts +31 -46
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +222 -357
  10. package/dist/client.js.map +1 -1
  11. package/dist/database.d.ts +14 -131
  12. package/dist/database.d.ts.map +1 -1
  13. package/dist/database.js +35 -131
  14. package/dist/database.js.map +1 -1
  15. package/dist/index.d.ts +10 -13
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +4 -18
  18. package/dist/index.js.map +1 -1
  19. package/dist/query-sdk/ConditionBuilder.d.ts +3 -11
  20. package/dist/query-sdk/ConditionBuilder.d.ts.map +1 -1
  21. package/dist/query-sdk/ConditionBuilder.js +10 -48
  22. package/dist/query-sdk/ConditionBuilder.js.map +1 -1
  23. package/dist/query-sdk/NestedBuilders.d.ts +33 -30
  24. package/dist/query-sdk/NestedBuilders.d.ts.map +1 -1
  25. package/dist/query-sdk/NestedBuilders.js +46 -43
  26. package/dist/query-sdk/NestedBuilders.js.map +1 -1
  27. package/{src/query-sdk/dist/OnChainDB.d.ts → dist/query-sdk/OnDB.d.ts} +10 -2
  28. package/dist/query-sdk/OnDB.d.ts.map +1 -0
  29. package/{src/query-sdk/dist/OnChainDB.js → dist/query-sdk/OnDB.js} +86 -18
  30. package/dist/query-sdk/OnDB.js.map +1 -0
  31. package/dist/query-sdk/QueryBuilder.d.ts +4 -2
  32. package/dist/query-sdk/QueryBuilder.d.ts.map +1 -1
  33. package/dist/query-sdk/QueryBuilder.js +47 -169
  34. package/dist/query-sdk/QueryBuilder.js.map +1 -1
  35. package/dist/query-sdk/QueryResult.d.ts +0 -38
  36. package/dist/query-sdk/QueryResult.d.ts.map +1 -1
  37. package/dist/query-sdk/QueryResult.js +1 -227
  38. package/dist/query-sdk/QueryResult.js.map +1 -1
  39. package/dist/query-sdk/index.d.ts +2 -2
  40. package/dist/query-sdk/index.d.ts.map +1 -1
  41. package/dist/query-sdk/index.js +3 -3
  42. package/dist/query-sdk/index.js.map +1 -1
  43. package/dist/query-sdk/operators.d.ts +32 -28
  44. package/dist/query-sdk/operators.d.ts.map +1 -1
  45. package/dist/query-sdk/operators.js +45 -155
  46. package/dist/query-sdk/operators.js.map +1 -1
  47. package/dist/types.d.ts +159 -36
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/types.js +8 -8
  50. package/dist/types.js.map +1 -1
  51. package/dist/x402/types.d.ts +1 -1
  52. package/dist/x402/types.d.ts.map +1 -1
  53. package/dist/x402/utils.js +2 -2
  54. package/dist/x402/utils.js.map +1 -1
  55. package/jest.config.js +4 -0
  56. package/package.json +1 -1
  57. package/skills.md +0 -1
  58. package/src/batch.d.ts +3 -3
  59. package/src/batch.js +1 -1
  60. package/src/client.ts +287 -823
  61. package/src/database.d.ts +1 -1
  62. package/src/database.js +4 -4
  63. package/src/database.ts +71 -494
  64. package/src/index.d.ts +18 -18
  65. package/src/index.js +16 -16
  66. package/src/index.ts +44 -198
  67. package/src/query-sdk/ConditionBuilder.ts +37 -89
  68. package/src/query-sdk/NestedBuilders.ts +90 -92
  69. package/src/query-sdk/{OnChainDB.ts → OnDB.ts} +1 -1
  70. package/src/query-sdk/QueryBuilder.ts +59 -218
  71. package/src/query-sdk/QueryResult.ts +4 -330
  72. package/src/query-sdk/README.md +218 -587
  73. package/src/query-sdk/index.ts +2 -2
  74. package/src/query-sdk/operators.ts +91 -200
  75. package/src/query-sdk/tests/FieldConditionBuilder.test.ts +70 -71
  76. package/src/query-sdk/tests/LogicalOperator.test.ts +43 -82
  77. package/src/query-sdk/tests/NestedBuilders.test.ts +229 -309
  78. package/src/query-sdk/tests/QueryBuilder.test.ts +5 -5
  79. package/src/query-sdk/tests/QueryResult.test.ts +41 -435
  80. package/src/query-sdk/tests/comprehensive.test.ts +4 -185
  81. package/src/tests/client-requests.test.ts +280 -0
  82. package/src/tests/client-validation.test.ts +80 -0
  83. package/src/types.d.ts +6 -6
  84. package/src/types.js +8 -8
  85. package/src/types.ts +239 -54
  86. package/src/x402/types.ts +3 -3
  87. package/src/x402/utils.ts +3 -3
  88. package/examples/blob-upload-example.ts +0 -140
  89. package/src/batch.ts +0 -257
  90. package/src/query-sdk/dist/ConditionBuilder.d.ts +0 -22
  91. package/src/query-sdk/dist/ConditionBuilder.js +0 -90
  92. package/src/query-sdk/dist/FieldConditionBuilder.d.ts +0 -1
  93. package/src/query-sdk/dist/FieldConditionBuilder.js +0 -6
  94. package/src/query-sdk/dist/NestedBuilders.d.ts +0 -43
  95. package/src/query-sdk/dist/NestedBuilders.js +0 -144
  96. package/src/query-sdk/dist/QueryBuilder.d.ts +0 -70
  97. package/src/query-sdk/dist/QueryBuilder.js +0 -295
  98. package/src/query-sdk/dist/QueryResult.d.ts +0 -52
  99. package/src/query-sdk/dist/QueryResult.js +0 -293
  100. package/src/query-sdk/dist/SelectionBuilder.d.ts +0 -20
  101. package/src/query-sdk/dist/SelectionBuilder.js +0 -80
  102. package/src/query-sdk/dist/adapters/HttpClientAdapter.d.ts +0 -27
  103. package/src/query-sdk/dist/adapters/HttpClientAdapter.js +0 -170
  104. package/src/query-sdk/dist/index.d.ts +0 -36
  105. package/src/query-sdk/dist/index.js +0 -27
  106. package/src/query-sdk/dist/operators.d.ts +0 -56
  107. package/src/query-sdk/dist/operators.js +0 -289
  108. package/src/query-sdk/dist/tests/setup.d.ts +0 -15
  109. package/src/query-sdk/dist/tests/setup.js +0 -46
  110. package/src/query-sdk/jest.config.js +0 -25
  111. package/src/query-sdk/package.json +0 -46
  112. package/src/query-sdk/tests/aggregations.test.ts +0 -653
  113. package/src/query-sdk/tests/integration.test.ts +0 -608
  114. package/src/query-sdk/tests/operators.test.ts +0 -327
  115. package/src/query-sdk/tests/unit.test.ts +0 -794
  116. package/src/query-sdk/tsconfig.json +0 -26
  117. package/src/query-sdk/yarn.lock +0 -3092
package/src/batch.ts DELETED
@@ -1,257 +0,0 @@
1
- import { OnChainDBClient } from './client';
2
- import { StoreRequest, StoreResponse, TransactionStatus } from './types';
3
- import { EventEmitter } from 'eventemitter3';
4
-
5
- /**
6
- * Batch operations for OnChainDB
7
- *
8
- * Allows efficient batch insertion with transaction management
9
- * and progress tracking for large datasets.
10
- */
11
- export class BatchOperations extends EventEmitter {
12
- constructor(private client: OnChainDBClient) {
13
- super();
14
- }
15
-
16
- /**
17
- * Batch store multiple records
18
- *
19
- * @param requests - Array of store requests
20
- * @param options - Batch options including payment configuration
21
- * @returns Promise resolving to array of store responses
22
- *
23
- * @example
24
- * ```typescript
25
- * const batch = new BatchOperations(db);
26
- *
27
- * const results = await batch.store([
28
- * { data: { message: 'Tweet 1' }, collection: 'tweets' },
29
- * { data: { message: 'Tweet 2' }, collection: 'tweets' },
30
- * { data: { message: 'Tweet 3' }, collection: 'tweets' }
31
- * ], {
32
- * concurrency: 5,
33
- * waitForConfirmation: true,
34
- * paymentOptions: {
35
- * userWallet: keplrWallet,
36
- * brokerAddress: 'celestia1xyz...'
37
- * }
38
- * });
39
- * ```
40
- */
41
- async store(
42
- requests: StoreRequest[],
43
- options: {
44
- concurrency?: number;
45
- waitForConfirmation?: boolean;
46
- onProgress?: (completed: number, total: number) => void;
47
- paymentOptions?: {
48
- userWallet?: any;
49
- brokerAddress?: string;
50
- };
51
- } = {}
52
- ): Promise<StoreResponse[]> {
53
- const {
54
- concurrency = 10,
55
- waitForConfirmation = false,
56
- onProgress,
57
- paymentOptions
58
- } = options;
59
-
60
- const results: StoreResponse[] = [];
61
- const errors: Array<{ index: number; error: Error }> = [];
62
- let completed = 0;
63
-
64
- // Process requests in batches with concurrency limit
65
- for (let i = 0; i < requests.length; i += concurrency) {
66
- const batch = requests.slice(i, i + concurrency);
67
- const batchPromises = batch.map(async (request, batchIndex) => {
68
- const globalIndex = i + batchIndex;
69
- try {
70
- const result = await this.client.store(request, undefined, waitForConfirmation);
71
- results[globalIndex] = result;
72
- completed++;
73
- onProgress?.(completed, requests.length);
74
- this.emit('progress', { completed, total: requests.length, success: true });
75
- return result;
76
- } catch (error) {
77
- errors.push({ index: globalIndex, error: error as Error });
78
- completed++;
79
- onProgress?.(completed, requests.length);
80
- this.emit('progress', { completed, total: requests.length, success: false, error });
81
- throw error;
82
- }
83
- });
84
-
85
- // Wait for current batch to complete before starting next
86
- await Promise.allSettled(batchPromises);
87
- }
88
-
89
- if (errors.length > 0) {
90
- this.emit('batchComplete', { results, errors });
91
- throw new Error(`Batch operation failed: ${errors.length}/${requests.length} requests failed`);
92
- }
93
-
94
- this.emit('batchComplete', { results, errors: [] });
95
- return results;
96
- }
97
-
98
- /**
99
- * Batch store with retry logic
100
- *
101
- * @param requests - Store requests
102
- * @param options - Batch options with retry configuration and payment support
103
- * @returns Store responses
104
- */
105
- async storeWithRetry(
106
- requests: StoreRequest[],
107
- options: {
108
- concurrency?: number;
109
- waitForConfirmation?: boolean;
110
- maxRetries?: number;
111
- retryDelay?: number;
112
- onProgress?: (completed: number, total: number) => void;
113
- paymentOptions?: {
114
- userWallet?: any;
115
- brokerAddress?: string;
116
- };
117
- } = {}
118
- ): Promise<StoreResponse[]> {
119
- const {
120
- maxRetries = 3,
121
- retryDelay = 1000,
122
- ...batchOptions
123
- } = options;
124
-
125
- let attempt = 0;
126
- let lastError: Error;
127
-
128
- while (attempt <= maxRetries) {
129
- try {
130
- return await this.store(requests, batchOptions);
131
- } catch (error) {
132
- lastError = error as Error;
133
- attempt++;
134
-
135
- if (attempt <= maxRetries) {
136
- this.emit('retryAttempt', { attempt, maxRetries, error });
137
- await this.sleep(retryDelay * attempt); // Exponential backoff
138
- }
139
- }
140
- }
141
-
142
- throw lastError!;
143
- }
144
-
145
- /**
146
- * Monitor multiple transactions for confirmation
147
- *
148
- * @param transactionIds - Array of transaction IDs to monitor
149
- * @param maxWaitTime - Maximum wait time per transaction
150
- * @returns Promise resolving when all transactions are confirmed
151
- */
152
- async waitForBatchConfirmation(
153
- transactionIds: string[],
154
- maxWaitTime: number = 300000
155
- ): Promise<TransactionStatus[]> {
156
- const confirmationPromises = transactionIds.map(async (id, index) => {
157
- try {
158
- const result = await this.client.waitForConfirmation(id, maxWaitTime);
159
- this.emit('transactionConfirmed', { id, index, result });
160
- return {
161
- id,
162
- status: 'confirmed' as const,
163
- block_height: result.block_height,
164
- transaction_hash: result.transaction_hash,
165
- celestia_height: result.celestia_height
166
- };
167
- } catch (error) {
168
- this.emit('transactionFailed', { id, index, error });
169
- return {
170
- id,
171
- status: 'failed' as const,
172
- error: (error as Error).message
173
- };
174
- }
175
- });
176
-
177
- return Promise.all(confirmationPromises);
178
- }
179
-
180
- private sleep(ms: number): Promise<void> {
181
- return new Promise(resolve => setTimeout(resolve, ms));
182
- }
183
- }
184
-
185
- /**
186
- * Utility class for building bulk operations
187
- *
188
- * @example
189
- * ```typescript
190
- * const builder = new BulkBuilder()
191
- * .collection('tweets')
192
- * .add({ message: 'Tweet 1', author: 'alice' })
193
- * .add({ message: 'Tweet 2', author: 'bob' })
194
- * .add({ message: 'Tweet 3', author: 'charlie' });
195
- *
196
- * const results = await db.batch().store(builder.build());
197
- * ```
198
- */
199
- export class BulkBuilder {
200
- private requests: StoreRequest[] = [];
201
- private defaultCollection?: string;
202
- private defaultApp?: string;
203
-
204
- /**
205
- * Set default collection for all subsequent operations
206
- */
207
- collection(name: string): this {
208
- this.defaultCollection = name;
209
- return this;
210
- }
211
-
212
- /**
213
- * Set default app for all subsequent operations
214
- */
215
- app(name: string): this {
216
- this.defaultApp = name;
217
- return this;
218
- }
219
-
220
- /**
221
- * Add a data record to the bulk operation
222
- */
223
- add(data: Record<string, any>, collection?: string, app?: string): this {
224
- this.requests.push({data: [data], root: `${app}::${collection}`});
225
- return this;
226
- }
227
-
228
- /**
229
- * Add multiple data records
230
- */
231
- addMany(records: Record<string, any>[], collection?: string, app?: string): this {
232
- records.forEach(data => this.add(data, collection, app));
233
- return this;
234
- }
235
-
236
- /**
237
- * Build the final array of store requests
238
- */
239
- build(): StoreRequest[] {
240
- return [...this.requests];
241
- }
242
-
243
- /**
244
- * Get the number of operations in the builder
245
- */
246
- count(): number {
247
- return this.requests.length;
248
- }
249
-
250
- /**
251
- * Clear all operations
252
- */
253
- clear(): this {
254
- this.requests = [];
255
- return this;
256
- }
257
- }
@@ -1,22 +0,0 @@
1
- import { LogicalOperator, FieldConditionBuilder } from './operators';
2
- import { NestedConditionBuilder } from './NestedBuilders';
3
- export declare class ConditionBuilder {
4
- private conditions;
5
- private currentOperator?;
6
- constructor();
7
- static new(): ConditionBuilder;
8
- field(fieldName: string): FieldConditionBuilder;
9
- nested(fieldName: string, builderFn: (builder: NestedConditionBuilder) => LogicalOperator): LogicalOperator;
10
- and(): ConditionBuilder;
11
- or(): ConditionBuilder;
12
- not(): ConditionBuilder;
13
- andGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator;
14
- orGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator;
15
- notGroup(builderFn: (builder: ConditionBuilder) => LogicalOperator[]): LogicalOperator;
16
- addCondition(condition: LogicalOperator): ConditionBuilder;
17
- build(): LogicalOperator[];
18
- buildSingle(): LogicalOperator;
19
- clear(): ConditionBuilder;
20
- isEmpty(): boolean;
21
- getConditionCount(): number;
22
- }
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConditionBuilder = void 0;
4
- const operators_1 = require("./operators");
5
- const NestedBuilders_1 = require("./NestedBuilders");
6
- // Builder for creating complex conditions with logical operators
7
- class ConditionBuilder {
8
- constructor() {
9
- this.conditions = [];
10
- }
11
- static new() {
12
- return new ConditionBuilder();
13
- }
14
- // Create a field condition builder
15
- field(fieldName) {
16
- return new operators_1.FieldConditionBuilder(fieldName);
17
- }
18
- // Create a nested field condition with fluent API (like Rust SDK)
19
- nested(fieldName, builderFn) {
20
- const nestedBuilder = new NestedBuilders_1.NestedConditionBuilder(fieldName);
21
- return builderFn(nestedBuilder);
22
- }
23
- // Add an AND operator context
24
- and() {
25
- this.currentOperator = 'and';
26
- return this;
27
- }
28
- // Add an OR operator context
29
- or() {
30
- this.currentOperator = 'or';
31
- return this;
32
- }
33
- // Add a NOT operator context
34
- not() {
35
- this.currentOperator = 'not';
36
- return this;
37
- }
38
- // Group conditions with AND logic
39
- andGroup(builderFn) {
40
- const nestedBuilder = new ConditionBuilder();
41
- const conditions = builderFn(nestedBuilder);
42
- return operators_1.LogicalOperator.And(conditions);
43
- }
44
- // Group conditions with OR logic
45
- orGroup(builderFn) {
46
- const nestedBuilder = new ConditionBuilder();
47
- const conditions = builderFn(nestedBuilder);
48
- return operators_1.LogicalOperator.Or(conditions);
49
- }
50
- // Group conditions with NOT logic
51
- notGroup(builderFn) {
52
- const nestedBuilder = new ConditionBuilder();
53
- const conditions = builderFn(nestedBuilder);
54
- return operators_1.LogicalOperator.Not(conditions);
55
- }
56
- // Add a condition to the current builder
57
- addCondition(condition) {
58
- this.conditions.push(condition);
59
- return this;
60
- }
61
- // Build and return all conditions
62
- build() {
63
- return [...this.conditions];
64
- }
65
- // Build as a single logical operator (combines all conditions with AND by default)
66
- buildSingle() {
67
- if (this.conditions.length === 0) {
68
- throw new Error('No conditions to build');
69
- }
70
- if (this.conditions.length === 1) {
71
- return this.conditions[0];
72
- }
73
- return operators_1.LogicalOperator.And(this.conditions);
74
- }
75
- // Clear all conditions
76
- clear() {
77
- this.conditions = [];
78
- this.currentOperator = undefined;
79
- return this;
80
- }
81
- // Check if any conditions have been added
82
- isEmpty() {
83
- return this.conditions.length === 0;
84
- }
85
- // Get the number of conditions
86
- getConditionCount() {
87
- return this.conditions.length;
88
- }
89
- }
90
- exports.ConditionBuilder = ConditionBuilder;
@@ -1 +0,0 @@
1
- export { FieldConditionBuilder } from './operators';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FieldConditionBuilder = void 0;
4
- // Re-export from operators for convenience
5
- var operators_1 = require("./operators");
6
- Object.defineProperty(exports, "FieldConditionBuilder", { enumerable: true, get: function () { return operators_1.FieldConditionBuilder; } });
@@ -1,43 +0,0 @@
1
- import { LogicalOperator, Condition } from './operators';
2
- export declare class NestedConditionBuilder {
3
- private path;
4
- constructor(rootField: string);
5
- field(fieldName: string): NestedFieldConditionBuilder;
6
- nested(fieldName: string, builderFn: (builder: NestedConditionBuilder) => LogicalOperator): LogicalOperator;
7
- andGroup(builderFn: (builder: NestedConditionBuilder) => LogicalOperator[]): LogicalOperator;
8
- orGroup(builderFn: (builder: NestedConditionBuilder) => LogicalOperator[]): LogicalOperator;
9
- notGroup(builderFn: (builder: NestedConditionBuilder) => LogicalOperator[]): LogicalOperator;
10
- }
11
- export declare class NestedFieldConditionBuilder {
12
- private fieldPath;
13
- constructor(fieldPath: string[]);
14
- private createCondition;
15
- equals(value: any): Condition;
16
- notEquals(value: any): Condition;
17
- in(values: any[]): Condition;
18
- notIn(values: any[]): Condition;
19
- isNull(): Condition;
20
- isNotNull(): Condition;
21
- exists(): Condition;
22
- notExists(): Condition;
23
- startsWith(value: string): Condition;
24
- endsWith(value: string): Condition;
25
- contains(value: string): Condition;
26
- regExpMatches(pattern: string): Condition;
27
- includesCaseInsensitive(value: string): Condition;
28
- startsWithCaseInsensitive(value: string): Condition;
29
- endsWithCaseInsensitive(value: string): Condition;
30
- greaterThan(value: any): Condition;
31
- lessThan(value: any): Condition;
32
- greaterThanOrEqual(value: any): Condition;
33
- lessThanOrEqual(value: any): Condition;
34
- isLocalIp(): Condition;
35
- isExternalIp(): Condition;
36
- b64(value: string): Condition;
37
- inDataset(dataset: string): Condition;
38
- inCountry(countryCode: string): Condition;
39
- cidr(cidr: string): Condition;
40
- between(min: any, max: any): Condition;
41
- isTrue(): Condition;
42
- isFalse(): Condition;
43
- }
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NestedFieldConditionBuilder = exports.NestedConditionBuilder = void 0;
4
- const operators_1 = require("./operators");
5
- // Builder for creating nested field conditions with ORM-like syntax
6
- class NestedConditionBuilder {
7
- constructor(rootField) {
8
- this.path = [rootField];
9
- }
10
- // Add another level to the path and create field conditions
11
- field(fieldName) {
12
- const newPath = [...this.path, fieldName];
13
- return new NestedFieldConditionBuilder(newPath);
14
- }
15
- // Create nested structure with callback
16
- nested(fieldName, builderFn) {
17
- const nestedPath = [...this.path, fieldName];
18
- const nestedBuilder = new NestedConditionBuilder('');
19
- nestedBuilder.path = nestedPath;
20
- return builderFn(nestedBuilder);
21
- }
22
- // Create logical groups
23
- andGroup(builderFn) {
24
- const conditions = builderFn(this);
25
- return operators_1.LogicalOperator.And(conditions);
26
- }
27
- orGroup(builderFn) {
28
- const conditions = builderFn(this);
29
- return operators_1.LogicalOperator.Or(conditions);
30
- }
31
- notGroup(builderFn) {
32
- const conditions = builderFn(this);
33
- return operators_1.LogicalOperator.Not(conditions);
34
- }
35
- }
36
- exports.NestedConditionBuilder = NestedConditionBuilder;
37
- // Builder for field conditions within nested structures
38
- // Only includes operators that actually exist in the Rust implementation
39
- class NestedFieldConditionBuilder {
40
- constructor(fieldPath) {
41
- this.fieldPath = fieldPath;
42
- }
43
- createCondition(operator, value) {
44
- const path = this.fieldPath.join('.');
45
- return {
46
- field: path,
47
- operator,
48
- value
49
- };
50
- }
51
- // ===== BASE OPERATORS (BaseOperator) =====
52
- equals(value) {
53
- return this.createCondition('is', value);
54
- }
55
- notEquals(value) {
56
- return this.createCondition('isNot', value);
57
- }
58
- in(values) {
59
- return this.createCondition('in', values);
60
- }
61
- notIn(values) {
62
- return this.createCondition('notIn', values);
63
- }
64
- isNull() {
65
- return this.createCondition('isNull', true);
66
- }
67
- isNotNull() {
68
- return this.createCondition('isNull', false);
69
- }
70
- exists() {
71
- return this.createCondition('exists', true);
72
- }
73
- notExists() {
74
- return this.createCondition('exists', false);
75
- }
76
- // ===== STRING OPERATORS (StringOperator) =====
77
- startsWith(value) {
78
- return this.createCondition('startsWith', value);
79
- }
80
- endsWith(value) {
81
- return this.createCondition('endsWith', value);
82
- }
83
- contains(value) {
84
- return this.createCondition('includes', value);
85
- }
86
- regExpMatches(pattern) {
87
- return this.createCondition('regExpMatches', pattern);
88
- }
89
- includesCaseInsensitive(value) {
90
- return this.createCondition('includesCaseInsensitive', value);
91
- }
92
- startsWithCaseInsensitive(value) {
93
- return this.createCondition('startsWithCaseInsensitive', value);
94
- }
95
- endsWithCaseInsensitive(value) {
96
- return this.createCondition('endsWithCaseInsensitive', value);
97
- }
98
- // ===== NUMBER OPERATORS (NumberOperator) =====
99
- greaterThan(value) {
100
- return this.createCondition('greaterThan', value);
101
- }
102
- lessThan(value) {
103
- return this.createCondition('lessThan', value);
104
- }
105
- greaterThanOrEqual(value) {
106
- return this.createCondition('greaterThanOrEqual', value);
107
- }
108
- lessThanOrEqual(value) {
109
- return this.createCondition('lessThanOrEqual', value);
110
- }
111
- // ===== IP OPERATORS (IpOperator) =====
112
- isLocalIp() {
113
- return this.createCondition('isLocalIp', true);
114
- }
115
- isExternalIp() {
116
- return this.createCondition('isExternalIp', true);
117
- }
118
- // ===== MISC OPERATORS (MiscOperator) =====
119
- b64(value) {
120
- return this.createCondition('b64', value);
121
- }
122
- inDataset(dataset) {
123
- return this.createCondition('inDataset', dataset);
124
- }
125
- inCountry(countryCode) {
126
- return this.createCondition('inCountry', countryCode);
127
- }
128
- cidr(cidr) {
129
- return this.createCondition('CIDR', cidr);
130
- }
131
- // ===== BETWEEN OPERATOR =====
132
- between(min, max) {
133
- return this.createCondition('betweenOp', { from: min, to: max });
134
- }
135
- // ===== CONVENIENCE METHODS =====
136
- // Boolean checks (using base operators)
137
- isTrue() {
138
- return this.equals(true);
139
- }
140
- isFalse() {
141
- return this.equals(false);
142
- }
143
- }
144
- exports.NestedFieldConditionBuilder = NestedFieldConditionBuilder;
@@ -1,70 +0,0 @@
1
- import { QueryRequest, QueryResponse, Val } from '../index';
2
- import { LogicalOperator } from './operators';
3
- import { SelectionBuilder } from './SelectionBuilder';
4
- import { ConditionBuilder } from './ConditionBuilder';
5
- import { FieldMap, HttpClient } from "./index";
6
- export declare class QueryBuilder {
7
- private findConditions?;
8
- private selections?;
9
- private fieldMap?;
10
- private limitValue?;
11
- private offsetValue?;
12
- private sortBy?;
13
- private sortDirection?;
14
- private httpClient?;
15
- private serverUrl?;
16
- private collectionName;
17
- private app;
18
- constructor(httpClient?: HttpClient, serverUrl?: string, app?: string);
19
- static new(httpClient?: HttpClient, serverUrl?: string, app?: string): QueryBuilder;
20
- withHttpClient(httpClient: HttpClient): QueryBuilder;
21
- withServerUrl(serverUrl: string): QueryBuilder;
22
- find(builderFn: (builder: ConditionBuilder) => LogicalOperator): QueryBuilder;
23
- collection(s: string): QueryBuilder;
24
- whereField(fieldName: string): WhereClause;
25
- select(builderFn: (builder: SelectionBuilder) => SelectionBuilder): QueryBuilder;
26
- selectFields(fields: string[]): QueryBuilder;
27
- selectAll(): QueryBuilder;
28
- withFieldMap(fieldMap: FieldMap): QueryBuilder;
29
- limit(limit: number): QueryBuilder;
30
- offset(offset: number): QueryBuilder;
31
- orderBy(fields: string): QueryBuilder;
32
- execute<T extends Record<string, any>>(): Promise<QueryResponse<T>>;
33
- isValid(): boolean;
34
- buildRawQuery(): QueryRequest;
35
- clone(): QueryBuilder;
36
- private buildQueryValue;
37
- }
38
- export declare class WhereClause {
39
- private queryBuilder;
40
- private fieldName;
41
- constructor(queryBuilder: QueryBuilder, fieldName: string);
42
- equals(value: Val): QueryBuilder;
43
- notEquals(value: Val): QueryBuilder;
44
- greaterThan(value: Val): QueryBuilder;
45
- greaterThanOrEqual(value: Val): QueryBuilder;
46
- lessThan(value: Val): QueryBuilder;
47
- lessThanOrEqual(value: Val): QueryBuilder;
48
- contains(value: string): QueryBuilder;
49
- startsWith(value: string): QueryBuilder;
50
- endsWith(value: string): QueryBuilder;
51
- in(values: Val[]): QueryBuilder;
52
- notIn(values: Val[]): QueryBuilder;
53
- exists(): QueryBuilder;
54
- notExists(): QueryBuilder;
55
- isNull(): QueryBuilder;
56
- isNotNull(): QueryBuilder;
57
- regExpMatches(pattern: string): QueryBuilder;
58
- includesCaseInsensitive(value: string): QueryBuilder;
59
- startsWithCaseInsensitive(value: string): QueryBuilder;
60
- endsWithCaseInsensitive(value: string): QueryBuilder;
61
- isLocalIp(): QueryBuilder;
62
- isExternalIp(): QueryBuilder;
63
- b64(value: string): QueryBuilder;
64
- inDataset(dataset: string): QueryBuilder;
65
- inCountry(countryCode: string): QueryBuilder;
66
- cidr(cidr: string): QueryBuilder;
67
- between(min: any, max: any): QueryBuilder;
68
- isTrue(): QueryBuilder;
69
- isFalse(): QueryBuilder;
70
- }