@onchaindb/sdk 2.0.1 → 2.1.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 +5 -1
- package/.gitignore +1 -0
- package/README.md +0 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -5
- package/dist/client.js.map +1 -1
- package/dist/database.d.ts +46 -8
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +32 -9
- package/dist/database.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/query-sdk/NestedBuilders.d.ts +3 -2
- package/dist/query-sdk/NestedBuilders.d.ts.map +1 -1
- package/dist/query-sdk/NestedBuilders.js +7 -4
- package/dist/query-sdk/NestedBuilders.js.map +1 -1
- package/dist/query-sdk/QueryBuilder.d.ts +17 -15
- package/dist/query-sdk/QueryBuilder.d.ts.map +1 -1
- package/dist/query-sdk/QueryBuilder.js +126 -190
- package/dist/query-sdk/QueryBuilder.js.map +1 -1
- package/dist/query-sdk/index.d.ts +24 -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 +3 -2
- package/dist/query-sdk/operators.d.ts.map +1 -1
- package/dist/query-sdk/operators.js +7 -4
- package/dist/query-sdk/operators.js.map +1 -1
- package/dist/types.d.ts +17 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/skills.md +5 -5
- package/src/client.ts +0 -6
- package/src/database.ts +159 -26
- package/src/index.ts +16 -10
- package/src/query-sdk/NestedBuilders.ts +14 -4
- package/src/query-sdk/QueryBuilder.ts +212 -235
- package/src/query-sdk/index.ts +19 -1
- package/src/query-sdk/operators.ts +15 -4
- package/src/query-sdk/tests/FieldConditionBuilder.test.ts +4 -2
- package/src/query-sdk/tests/NestedBuilders.test.ts +4 -3
- package/src/types.ts +26 -17
- package/.DS_Store +0 -0
|
@@ -202,16 +202,27 @@ export class FieldConditionBuilder {
|
|
|
202
202
|
return this.cond('b64', value);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
/** Case-sensitive membership check — use this when exact casing matters. For case-insensitive use .in() */
|
|
206
|
+
inDataset(values: string[]): LogicalOperator {
|
|
207
|
+
return this.cond('inDataset', values as any);
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
inCountry(countryCode: string): LogicalOperator {
|
|
210
211
|
return this.cond('inCountry', countryCode);
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Checks whether the data IP falls within any of the given CIDR ranges.
|
|
216
|
+
* IMPORTANT: always sends the "$cidr" alias — never the canonical "CIDR" key,
|
|
217
|
+
* which triggers a stack overflow in Scepter's recursive Operator enum.
|
|
218
|
+
*/
|
|
219
|
+
cidr(ranges: string | string[]): LogicalOperator {
|
|
220
|
+
return this.cond('$cidr', (Array.isArray(ranges) ? ranges : [ranges]) as any);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Matches if the field value contains ANY of the given keywords (case-insensitive substring). */
|
|
224
|
+
keywords(keywords: string[]): LogicalOperator {
|
|
225
|
+
return this.cond('keywords', keywords as any);
|
|
215
226
|
}
|
|
216
227
|
|
|
217
228
|
// ===== CONVENIENCE =====
|
|
@@ -48,9 +48,11 @@ describe('FieldConditionBuilder', () => {
|
|
|
48
48
|
test('isLocalIp', () => expect(builder.isLocalIp().toComposable()).toEqual({ field: { isLocalIp: true } }));
|
|
49
49
|
test('isExternalIp', () => expect(builder.isExternalIp().toComposable()).toEqual({ field: { isExternalIp: true } }));
|
|
50
50
|
test('b64', () => expect(builder.b64('dGVzdA==').toComposable()).toEqual({ field: { b64: 'dGVzdA==' } }));
|
|
51
|
-
test('inDataset', () => expect(builder.inDataset('
|
|
51
|
+
test('inDataset', () => expect(builder.inDataset(['admin', 'moderator']).toComposable()).toEqual({ field: { inDataset: ['admin', 'moderator'] } }));
|
|
52
52
|
test('inCountry', () => expect(builder.inCountry('US').toComposable()).toEqual({ field: { inCountry: 'US' } }));
|
|
53
|
-
test('cidr', () => expect(builder.cidr('192.168.1.0/24').toComposable()).toEqual({ field: {
|
|
53
|
+
test('cidr single', () => expect(builder.cidr('192.168.1.0/24').toComposable()).toEqual({ field: { '$cidr': ['192.168.1.0/24'] } }));
|
|
54
|
+
test('cidr array', () => expect(builder.cidr(['192.168.0.0/16', '10.0.0.0/8']).toComposable()).toEqual({ field: { '$cidr': ['192.168.0.0/16', '10.0.0.0/8'] } }));
|
|
55
|
+
test('keywords', () => expect(builder.keywords(['rust', 'async']).toComposable()).toEqual({ field: { keywords: ['rust', 'async'] } }));
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
describe('Dot-notation fields', () => {
|
|
@@ -171,11 +171,12 @@ describe('NestedFieldConditionBuilder', () => {
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
describe('Misc operators', () => {
|
|
174
|
-
test('b64, inCountry, inDataset, cidr', () => {
|
|
174
|
+
test('b64, inCountry, inDataset, cidr, keywords', () => {
|
|
175
175
|
expect(fieldBuilder.b64('dGVzdA==').condition?.operator).toBe('b64');
|
|
176
176
|
expect(fieldBuilder.inCountry('US').condition?.operator).toBe('inCountry');
|
|
177
|
-
expect(fieldBuilder.inDataset('
|
|
178
|
-
expect(fieldBuilder.cidr('192.168.1.0/24').condition?.operator).toBe('
|
|
177
|
+
expect(fieldBuilder.inDataset(['admin', 'moderator']).condition?.operator).toBe('inDataset');
|
|
178
|
+
expect(fieldBuilder.cidr('192.168.1.0/24').condition?.operator).toBe('$cidr');
|
|
179
|
+
expect(fieldBuilder.keywords(['rust', 'async']).condition?.operator).toBe('keywords');
|
|
179
180
|
});
|
|
180
181
|
|
|
181
182
|
test('IP operators', () => {
|
package/src/types.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface OnDBConfig {
|
|
|
6
6
|
endpoint: string;
|
|
7
7
|
apiKey?: string; // Deprecated: use appKey instead
|
|
8
8
|
appKey?: string; // App API key for write operations (X-App-Key header)
|
|
9
|
-
userKey?: string; // User API key for Auto-Pay (X-User-Key header)
|
|
10
9
|
agentKey?: string; // Agent Key with Pay permission (X-Agent-Key header)
|
|
11
10
|
appId?: string; // Application ID for automatic root building
|
|
12
11
|
timeout?: number;
|
|
@@ -118,11 +117,6 @@ export interface TaskInfo {
|
|
|
118
117
|
progress_log: string[];
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
export interface UserTasksResponse {
|
|
122
|
-
user_address: string;
|
|
123
|
-
tasks: TaskInfo[];
|
|
124
|
-
total_tasks: number;
|
|
125
|
-
}
|
|
126
120
|
|
|
127
121
|
export interface TransactionStatus {
|
|
128
122
|
id: string;
|
|
@@ -140,9 +134,12 @@ export interface QueryRequest {
|
|
|
140
134
|
limit?: number;
|
|
141
135
|
offset?: number;
|
|
142
136
|
sortBy?: string;
|
|
143
|
-
sortDirection?: string
|
|
144
|
-
find?: QueryValue["find"]
|
|
145
|
-
select?: QueryValue["select"]
|
|
137
|
+
sortDirection?: string;
|
|
138
|
+
find?: QueryValue["find"];
|
|
139
|
+
select?: QueryValue["select"];
|
|
140
|
+
field_map?: QueryValue["field_map"];
|
|
141
|
+
group_by?: QueryValue["group_by"];
|
|
142
|
+
aggregate?: QueryValue["aggregate"];
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
// Enhanced query support for advanced query builder
|
|
@@ -252,18 +249,28 @@ export class PaymentVerificationError extends OnDBError {
|
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
|
|
255
|
-
// Index Management
|
|
252
|
+
// Index Management — mirrors CreateIndexRequest from broker (handlers/indexes.rs)
|
|
256
253
|
export interface IndexRequest {
|
|
254
|
+
name: string;
|
|
257
255
|
collection: string;
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
field_name: string;
|
|
257
|
+
index_type: 'btree' | 'hash' | 'fulltext' | 'composite' | 'price';
|
|
258
|
+
store_values?: boolean;
|
|
259
|
+
unique_constraint?: boolean;
|
|
260
|
+
sort_enabled?: boolean;
|
|
261
|
+
/** Write-time payment config — only for index_type: 'price'. */
|
|
262
|
+
price_config?: import('./database').WriteIndexConfig;
|
|
263
|
+
/** Read-time payment config. */
|
|
264
|
+
read_price_config?: import('./database').ReadIndexConfig;
|
|
265
|
+
/** Creator revenue sharing config. */
|
|
266
|
+
creator_premium_config?: import('./database').CreatorPremiumConfig;
|
|
260
267
|
}
|
|
261
268
|
|
|
262
269
|
export interface IndexResponse {
|
|
263
270
|
id: string;
|
|
264
271
|
collection: string;
|
|
265
|
-
|
|
266
|
-
|
|
272
|
+
field_name: string;
|
|
273
|
+
index_type: string;
|
|
267
274
|
status: 'active' | 'building' | 'failed';
|
|
268
275
|
}
|
|
269
276
|
|
|
@@ -337,7 +344,9 @@ export interface PricingQuoteRequest {
|
|
|
337
344
|
export type {
|
|
338
345
|
Index,
|
|
339
346
|
IndexOptions,
|
|
340
|
-
|
|
347
|
+
WriteIndexConfig,
|
|
348
|
+
ReadIndexConfig,
|
|
349
|
+
CreatorPremiumConfig,
|
|
341
350
|
} from './database';
|
|
342
351
|
|
|
343
352
|
/**
|
|
@@ -691,8 +700,8 @@ export interface ViewDataResponse<T = any> {
|
|
|
691
700
|
}
|
|
692
701
|
|
|
693
702
|
export interface ViewQueryRequest {
|
|
694
|
-
find?: any
|
|
695
|
-
select?: string
|
|
703
|
+
find?: Record<string, any>;
|
|
704
|
+
select?: Record<string, boolean>;
|
|
696
705
|
sort_by?: string[];
|
|
697
706
|
limit?: number;
|
|
698
707
|
offset?: number;
|
package/.DS_Store
DELETED
|
Binary file
|