@ekodb/ekodb-client 0.6.0 → 0.7.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/dist/client.d.ts +55 -2
- package/dist/client.js +77 -4
- package/dist/functions.d.ts +25 -0
- package/dist/functions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -1
- package/dist/utils.d.ts +174 -0
- package/dist/utils.js +325 -0
- package/package.json +1 -1
- package/src/client.ts +124 -4
- package/src/functions.ts +59 -0
- package/src/index.ts +17 -0
- package/src/utils.ts +355 -0
package/dist/client.d.ts
CHANGED
|
@@ -206,6 +206,9 @@ export declare class EkoDBClient {
|
|
|
206
206
|
private makeRequest;
|
|
207
207
|
/**
|
|
208
208
|
* Insert a document into a collection
|
|
209
|
+
* @param collection - Collection name
|
|
210
|
+
* @param record - Document to insert
|
|
211
|
+
* @param ttl - Optional TTL: duration string ("1h", "30m"), seconds ("3600"), or ISO8601 timestamp
|
|
209
212
|
*/
|
|
210
213
|
insert(collection: string, record: Record, ttl?: string): Promise<Record>;
|
|
211
214
|
/**
|
|
@@ -260,9 +263,12 @@ export declare class EkoDBClient {
|
|
|
260
263
|
*/
|
|
261
264
|
batchDelete(collection: string, ids: string[], bypassRipple?: boolean): Promise<BatchOperationResult>;
|
|
262
265
|
/**
|
|
263
|
-
* Set a key-value pair
|
|
266
|
+
* Set a key-value pair with optional TTL
|
|
267
|
+
* @param key - The key to set
|
|
268
|
+
* @param value - The value to store
|
|
269
|
+
* @param ttl - Optional TTL in seconds
|
|
264
270
|
*/
|
|
265
|
-
kvSet(key: string, value: any): Promise<void>;
|
|
271
|
+
kvSet(key: string, value: any, ttl?: number): Promise<void>;
|
|
266
272
|
/**
|
|
267
273
|
* Get a value by key
|
|
268
274
|
*/
|
|
@@ -271,6 +277,53 @@ export declare class EkoDBClient {
|
|
|
271
277
|
* Delete a key
|
|
272
278
|
*/
|
|
273
279
|
kvDelete(key: string): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Check if a key exists
|
|
282
|
+
* @param key - The key to check
|
|
283
|
+
* @returns true if the key exists, false otherwise
|
|
284
|
+
*/
|
|
285
|
+
kvExists(key: string): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Query/find KV entries with pattern matching
|
|
288
|
+
* @param options - Query options including pattern and include_expired
|
|
289
|
+
* @returns Array of matching records
|
|
290
|
+
*/
|
|
291
|
+
kvFind(options?: {
|
|
292
|
+
pattern?: string;
|
|
293
|
+
include_expired?: boolean;
|
|
294
|
+
}): Promise<any[]>;
|
|
295
|
+
/**
|
|
296
|
+
* Alias for kvFind - query KV store with pattern
|
|
297
|
+
*/
|
|
298
|
+
kvQuery(options?: {
|
|
299
|
+
pattern?: string;
|
|
300
|
+
include_expired?: boolean;
|
|
301
|
+
}): Promise<any[]>;
|
|
302
|
+
/**
|
|
303
|
+
* Begin a new transaction
|
|
304
|
+
* @param isolationLevel - Transaction isolation level (default: "ReadCommitted")
|
|
305
|
+
* @returns Transaction ID
|
|
306
|
+
*/
|
|
307
|
+
beginTransaction(isolationLevel?: string): Promise<string>;
|
|
308
|
+
/**
|
|
309
|
+
* Get transaction status
|
|
310
|
+
* @param transactionId - The transaction ID
|
|
311
|
+
* @returns Transaction status object
|
|
312
|
+
*/
|
|
313
|
+
getTransactionStatus(transactionId: string): Promise<{
|
|
314
|
+
state: string;
|
|
315
|
+
operations_count: number;
|
|
316
|
+
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Commit a transaction
|
|
319
|
+
* @param transactionId - The transaction ID to commit
|
|
320
|
+
*/
|
|
321
|
+
commitTransaction(transactionId: string): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* Rollback a transaction
|
|
324
|
+
* @param transactionId - The transaction ID to rollback
|
|
325
|
+
*/
|
|
326
|
+
rollbackTransaction(transactionId: string): Promise<void>;
|
|
274
327
|
/**
|
|
275
328
|
* List all collections
|
|
276
329
|
*/
|
package/dist/client.js
CHANGED
|
@@ -263,11 +263,14 @@ class EkoDBClient {
|
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* Insert a document into a collection
|
|
266
|
+
* @param collection - Collection name
|
|
267
|
+
* @param record - Document to insert
|
|
268
|
+
* @param ttl - Optional TTL: duration string ("1h", "30m"), seconds ("3600"), or ISO8601 timestamp
|
|
266
269
|
*/
|
|
267
270
|
async insert(collection, record, ttl) {
|
|
268
271
|
const data = { ...record };
|
|
269
272
|
if (ttl) {
|
|
270
|
-
data.
|
|
273
|
+
data.ttl = ttl;
|
|
271
274
|
}
|
|
272
275
|
return this.makeRequest("POST", `/api/insert/${collection}`, data);
|
|
273
276
|
}
|
|
@@ -347,10 +350,17 @@ class EkoDBClient {
|
|
|
347
350
|
return this.makeRequest("DELETE", `/api/batch/delete/${collection}`, { deletes });
|
|
348
351
|
}
|
|
349
352
|
/**
|
|
350
|
-
* Set a key-value pair
|
|
353
|
+
* Set a key-value pair with optional TTL
|
|
354
|
+
* @param key - The key to set
|
|
355
|
+
* @param value - The value to store
|
|
356
|
+
* @param ttl - Optional TTL in seconds
|
|
351
357
|
*/
|
|
352
|
-
async kvSet(key, value) {
|
|
353
|
-
|
|
358
|
+
async kvSet(key, value, ttl) {
|
|
359
|
+
const body = { value };
|
|
360
|
+
if (ttl !== undefined) {
|
|
361
|
+
body.ttl = ttl;
|
|
362
|
+
}
|
|
363
|
+
await this.makeRequest("POST", `/api/kv/set/${encodeURIComponent(key)}`, body, 0, true);
|
|
354
364
|
}
|
|
355
365
|
/**
|
|
356
366
|
* Get a value by key
|
|
@@ -365,6 +375,69 @@ class EkoDBClient {
|
|
|
365
375
|
async kvDelete(key) {
|
|
366
376
|
await this.makeRequest("DELETE", `/api/kv/delete/${encodeURIComponent(key)}`, undefined, 0, true);
|
|
367
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Check if a key exists
|
|
380
|
+
* @param key - The key to check
|
|
381
|
+
* @returns true if the key exists, false otherwise
|
|
382
|
+
*/
|
|
383
|
+
async kvExists(key) {
|
|
384
|
+
try {
|
|
385
|
+
const result = await this.kvGet(key);
|
|
386
|
+
return result !== null && result !== undefined;
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Query/find KV entries with pattern matching
|
|
394
|
+
* @param options - Query options including pattern and include_expired
|
|
395
|
+
* @returns Array of matching records
|
|
396
|
+
*/
|
|
397
|
+
async kvFind(options) {
|
|
398
|
+
const result = await this.makeRequest("POST", "/api/kv/find", options || {}, 0, true);
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Alias for kvFind - query KV store with pattern
|
|
403
|
+
*/
|
|
404
|
+
async kvQuery(options) {
|
|
405
|
+
return this.kvFind(options);
|
|
406
|
+
}
|
|
407
|
+
// ============================================================================
|
|
408
|
+
// Transaction Operations
|
|
409
|
+
// ============================================================================
|
|
410
|
+
/**
|
|
411
|
+
* Begin a new transaction
|
|
412
|
+
* @param isolationLevel - Transaction isolation level (default: "ReadCommitted")
|
|
413
|
+
* @returns Transaction ID
|
|
414
|
+
*/
|
|
415
|
+
async beginTransaction(isolationLevel = "ReadCommitted") {
|
|
416
|
+
const result = await this.makeRequest("POST", "/api/transactions", { isolation_level: isolationLevel }, 0, true);
|
|
417
|
+
return result.transaction_id;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Get transaction status
|
|
421
|
+
* @param transactionId - The transaction ID
|
|
422
|
+
* @returns Transaction status object
|
|
423
|
+
*/
|
|
424
|
+
async getTransactionStatus(transactionId) {
|
|
425
|
+
return this.makeRequest("GET", `/api/transactions/${encodeURIComponent(transactionId)}`, undefined, 0, true);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Commit a transaction
|
|
429
|
+
* @param transactionId - The transaction ID to commit
|
|
430
|
+
*/
|
|
431
|
+
async commitTransaction(transactionId) {
|
|
432
|
+
await this.makeRequest("POST", `/api/transactions/${encodeURIComponent(transactionId)}/commit`, undefined, 0, true);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Rollback a transaction
|
|
436
|
+
* @param transactionId - The transaction ID to rollback
|
|
437
|
+
*/
|
|
438
|
+
async rollbackTransaction(transactionId) {
|
|
439
|
+
await this.makeRequest("POST", `/api/transactions/${encodeURIComponent(transactionId)}/rollback`, undefined, 0, true);
|
|
440
|
+
}
|
|
368
441
|
/**
|
|
369
442
|
* List all collections
|
|
370
443
|
*/
|
package/dist/functions.d.ts
CHANGED
|
@@ -174,6 +174,26 @@ export type FunctionStageConfig = {
|
|
|
174
174
|
} | {
|
|
175
175
|
type: "ReleaseSavepoint";
|
|
176
176
|
name: string;
|
|
177
|
+
} | {
|
|
178
|
+
type: "KvGet";
|
|
179
|
+
key: string;
|
|
180
|
+
output_field?: string;
|
|
181
|
+
} | {
|
|
182
|
+
type: "KvSet";
|
|
183
|
+
key: string;
|
|
184
|
+
value: any;
|
|
185
|
+
ttl?: number;
|
|
186
|
+
} | {
|
|
187
|
+
type: "KvDelete";
|
|
188
|
+
key: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: "KvExists";
|
|
191
|
+
key: string;
|
|
192
|
+
output_field?: string;
|
|
193
|
+
} | {
|
|
194
|
+
type: "KvQuery";
|
|
195
|
+
pattern?: string;
|
|
196
|
+
include_expired?: boolean;
|
|
177
197
|
};
|
|
178
198
|
export interface ChatMessage {
|
|
179
199
|
role: string;
|
|
@@ -275,4 +295,9 @@ export declare const Stage: {
|
|
|
275
295
|
createSavepoint: (name: string) => FunctionStageConfig;
|
|
276
296
|
rollbackToSavepoint: (name: string) => FunctionStageConfig;
|
|
277
297
|
releaseSavepoint: (name: string) => FunctionStageConfig;
|
|
298
|
+
kvGet: (key: string, output_field?: string) => FunctionStageConfig;
|
|
299
|
+
kvSet: (key: string, value: any, ttl?: number) => FunctionStageConfig;
|
|
300
|
+
kvDelete: (key: string) => FunctionStageConfig;
|
|
301
|
+
kvExists: (key: string, output_field?: string) => FunctionStageConfig;
|
|
302
|
+
kvQuery: (pattern?: string, include_expired?: boolean) => FunctionStageConfig;
|
|
278
303
|
};
|
package/dist/functions.js
CHANGED
|
@@ -206,4 +206,30 @@ exports.Stage = {
|
|
|
206
206
|
type: "ReleaseSavepoint",
|
|
207
207
|
name,
|
|
208
208
|
}),
|
|
209
|
+
// KV Store operations - faster than collection lookups for simple key-value data
|
|
210
|
+
kvGet: (key, output_field) => ({
|
|
211
|
+
type: "KvGet",
|
|
212
|
+
key,
|
|
213
|
+
output_field,
|
|
214
|
+
}),
|
|
215
|
+
kvSet: (key, value, ttl) => ({
|
|
216
|
+
type: "KvSet",
|
|
217
|
+
key,
|
|
218
|
+
value,
|
|
219
|
+
ttl,
|
|
220
|
+
}),
|
|
221
|
+
kvDelete: (key) => ({
|
|
222
|
+
type: "KvDelete",
|
|
223
|
+
key,
|
|
224
|
+
}),
|
|
225
|
+
kvExists: (key, output_field) => ({
|
|
226
|
+
type: "KvExists",
|
|
227
|
+
key,
|
|
228
|
+
output_field,
|
|
229
|
+
}),
|
|
230
|
+
kvQuery: (pattern, include_expired) => ({
|
|
231
|
+
type: "KvQuery",
|
|
232
|
+
pattern,
|
|
233
|
+
include_expired,
|
|
234
|
+
}),
|
|
209
235
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { SearchQueryBuilder } from "./search";
|
|
|
4
4
|
export { SchemaBuilder, FieldTypeSchemaBuilder, VectorIndexAlgorithm, DistanceMetric, } from "./schema";
|
|
5
5
|
export { JoinBuilder } from "./join";
|
|
6
6
|
export { Stage, ChatMessage } from "./functions";
|
|
7
|
+
export { getValue, getValues, extractRecord, getDateTimeValue, getUUIDValue, getDecimalValue, getDurationValue, getBytesValue, getBinaryValue, getArrayValue, getSetValue, getVectorValue, getObjectValue, Field, } from "./utils";
|
|
8
|
+
export type { WrappedFieldValue } from "./utils";
|
|
7
9
|
export type { SearchQuery, SearchResult, SearchResponse } from "./search";
|
|
8
10
|
export type { Schema, FieldTypeSchema, IndexConfig, CollectionMetadata, } from "./schema";
|
|
9
11
|
export type { JoinConfig } from "./join";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatMessage = exports.Stage = exports.JoinBuilder = exports.DistanceMetric = exports.VectorIndexAlgorithm = exports.FieldTypeSchemaBuilder = exports.SchemaBuilder = exports.SearchQueryBuilder = exports.SortOrder = exports.QueryBuilder = exports.RateLimitError = exports.MergeStrategy = exports.SerializationFormat = exports.WebSocketClient = exports.EkoDBClient = void 0;
|
|
3
|
+
exports.Field = exports.getObjectValue = exports.getVectorValue = exports.getSetValue = exports.getArrayValue = exports.getBinaryValue = exports.getBytesValue = exports.getDurationValue = exports.getDecimalValue = exports.getUUIDValue = exports.getDateTimeValue = exports.extractRecord = exports.getValues = exports.getValue = exports.ChatMessage = exports.Stage = exports.JoinBuilder = exports.DistanceMetric = exports.VectorIndexAlgorithm = exports.FieldTypeSchemaBuilder = exports.SchemaBuilder = exports.SearchQueryBuilder = exports.SortOrder = exports.QueryBuilder = exports.RateLimitError = exports.MergeStrategy = exports.SerializationFormat = exports.WebSocketClient = exports.EkoDBClient = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
5
|
Object.defineProperty(exports, "EkoDBClient", { enumerable: true, get: function () { return client_1.EkoDBClient; } });
|
|
6
6
|
Object.defineProperty(exports, "WebSocketClient", { enumerable: true, get: function () { return client_1.WebSocketClient; } });
|
|
@@ -22,3 +22,18 @@ Object.defineProperty(exports, "JoinBuilder", { enumerable: true, get: function
|
|
|
22
22
|
var functions_1 = require("./functions");
|
|
23
23
|
Object.defineProperty(exports, "Stage", { enumerable: true, get: function () { return functions_1.Stage; } });
|
|
24
24
|
Object.defineProperty(exports, "ChatMessage", { enumerable: true, get: function () { return functions_1.ChatMessage; } });
|
|
25
|
+
var utils_1 = require("./utils");
|
|
26
|
+
Object.defineProperty(exports, "getValue", { enumerable: true, get: function () { return utils_1.getValue; } });
|
|
27
|
+
Object.defineProperty(exports, "getValues", { enumerable: true, get: function () { return utils_1.getValues; } });
|
|
28
|
+
Object.defineProperty(exports, "extractRecord", { enumerable: true, get: function () { return utils_1.extractRecord; } });
|
|
29
|
+
Object.defineProperty(exports, "getDateTimeValue", { enumerable: true, get: function () { return utils_1.getDateTimeValue; } });
|
|
30
|
+
Object.defineProperty(exports, "getUUIDValue", { enumerable: true, get: function () { return utils_1.getUUIDValue; } });
|
|
31
|
+
Object.defineProperty(exports, "getDecimalValue", { enumerable: true, get: function () { return utils_1.getDecimalValue; } });
|
|
32
|
+
Object.defineProperty(exports, "getDurationValue", { enumerable: true, get: function () { return utils_1.getDurationValue; } });
|
|
33
|
+
Object.defineProperty(exports, "getBytesValue", { enumerable: true, get: function () { return utils_1.getBytesValue; } });
|
|
34
|
+
Object.defineProperty(exports, "getBinaryValue", { enumerable: true, get: function () { return utils_1.getBinaryValue; } });
|
|
35
|
+
Object.defineProperty(exports, "getArrayValue", { enumerable: true, get: function () { return utils_1.getArrayValue; } });
|
|
36
|
+
Object.defineProperty(exports, "getSetValue", { enumerable: true, get: function () { return utils_1.getSetValue; } });
|
|
37
|
+
Object.defineProperty(exports, "getVectorValue", { enumerable: true, get: function () { return utils_1.getVectorValue; } });
|
|
38
|
+
Object.defineProperty(exports, "getObjectValue", { enumerable: true, get: function () { return utils_1.getObjectValue; } });
|
|
39
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return utils_1.Field; } });
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with ekoDB records
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract the value from an ekoDB field object.
|
|
6
|
+
* ekoDB returns fields as { type: string, value: any } objects.
|
|
7
|
+
* This helper safely extracts the value or returns the input if it's not a field object.
|
|
8
|
+
*
|
|
9
|
+
* @param field - The field value from ekoDB (may be { type, value } or a plain value)
|
|
10
|
+
* @returns The extracted value
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const user = await client.findByID('users', userId);
|
|
15
|
+
* const email = getValue(user.email); // Extracts string from { type: 'String', value: 'user@example.com' }
|
|
16
|
+
* const age = getValue(user.age); // Extracts number from { type: 'Integer', value: 25 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getValue<T = any>(field: any): T;
|
|
20
|
+
/**
|
|
21
|
+
* Extract values from multiple fields in a record.
|
|
22
|
+
* Useful for processing entire records returned from ekoDB.
|
|
23
|
+
*
|
|
24
|
+
* @param record - The record object from ekoDB
|
|
25
|
+
* @param fields - Array of field names to extract values from
|
|
26
|
+
* @returns Object with extracted values
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const user = await client.findByID('users', userId);
|
|
31
|
+
* const { email, first_name, status } = getValues(user, ['email', 'first_name', 'status']);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function getValues<T extends Record<string, any>>(record: any, fields: (keyof T)[]): Partial<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Extract a Date value from an ekoDB DateTime field
|
|
37
|
+
*/
|
|
38
|
+
export declare function getDateTimeValue(field: any): Date | null;
|
|
39
|
+
/**
|
|
40
|
+
* Extract a UUID string from an ekoDB UUID field
|
|
41
|
+
*/
|
|
42
|
+
export declare function getUUIDValue(field: any): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Extract a number from an ekoDB Decimal field
|
|
45
|
+
*/
|
|
46
|
+
export declare function getDecimalValue(field: any): number | null;
|
|
47
|
+
/**
|
|
48
|
+
* Extract a number (milliseconds) from an ekoDB Duration field
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDurationValue(field: any): number | null;
|
|
51
|
+
/**
|
|
52
|
+
* Extract a Uint8Array from an ekoDB Bytes field
|
|
53
|
+
*/
|
|
54
|
+
export declare function getBytesValue(field: any): Uint8Array | null;
|
|
55
|
+
/**
|
|
56
|
+
* Extract a Uint8Array from an ekoDB Binary field
|
|
57
|
+
*/
|
|
58
|
+
export declare function getBinaryValue(field: any): Uint8Array | null;
|
|
59
|
+
/**
|
|
60
|
+
* Extract an array from an ekoDB Array field
|
|
61
|
+
*/
|
|
62
|
+
export declare function getArrayValue<T = any>(field: any): T[] | null;
|
|
63
|
+
/**
|
|
64
|
+
* Extract an array from an ekoDB Set field
|
|
65
|
+
*/
|
|
66
|
+
export declare function getSetValue<T = any>(field: any): T[] | null;
|
|
67
|
+
/**
|
|
68
|
+
* Extract an array from an ekoDB Vector field
|
|
69
|
+
*/
|
|
70
|
+
export declare function getVectorValue(field: any): number[] | null;
|
|
71
|
+
/**
|
|
72
|
+
* Extract an object from an ekoDB Object field
|
|
73
|
+
*/
|
|
74
|
+
export declare function getObjectValue<T = any>(field: any): T | null;
|
|
75
|
+
/**
|
|
76
|
+
* Transform an entire record by extracting all field values.
|
|
77
|
+
* Preserves the 'id' field and extracts values from all other fields.
|
|
78
|
+
*
|
|
79
|
+
* @param record - The record object from ekoDB
|
|
80
|
+
* @returns Object with all field values extracted
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const user = await client.findByID('users', userId);
|
|
85
|
+
* const plainUser = extractRecord(user);
|
|
86
|
+
* // { id: '123', email: 'user@example.com', first_name: 'John', ... }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function extractRecord<T extends Record<string, any>>(record: any): T;
|
|
90
|
+
export interface WrappedFieldValue {
|
|
91
|
+
type: string;
|
|
92
|
+
value: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Field builders for creating wrapped type values to send to ekoDB.
|
|
96
|
+
* These are the inverse of the getValue* extraction functions.
|
|
97
|
+
*/
|
|
98
|
+
export declare const Field: {
|
|
99
|
+
/**
|
|
100
|
+
* Create a UUID field value
|
|
101
|
+
* @param value - UUID string (e.g., "550e8400-e29b-41d4-a716-446655440000")
|
|
102
|
+
*/
|
|
103
|
+
uuid: (value: string) => WrappedFieldValue;
|
|
104
|
+
/**
|
|
105
|
+
* Create a Decimal field value for precise numeric values
|
|
106
|
+
* @param value - Decimal as string (e.g., "99.99") to preserve precision
|
|
107
|
+
*/
|
|
108
|
+
decimal: (value: string) => WrappedFieldValue;
|
|
109
|
+
/**
|
|
110
|
+
* Create a DateTime field value
|
|
111
|
+
* @param value - Date object or RFC3339 string
|
|
112
|
+
*/
|
|
113
|
+
dateTime: (value: Date | string) => WrappedFieldValue;
|
|
114
|
+
/**
|
|
115
|
+
* Create a Duration field value
|
|
116
|
+
* @param milliseconds - Duration in milliseconds
|
|
117
|
+
*/
|
|
118
|
+
duration: (milliseconds: number) => WrappedFieldValue;
|
|
119
|
+
/**
|
|
120
|
+
* Create a Number field value (flexible numeric type)
|
|
121
|
+
* @param value - Integer or float
|
|
122
|
+
*/
|
|
123
|
+
number: (value: number) => WrappedFieldValue;
|
|
124
|
+
/**
|
|
125
|
+
* Create a Set field value (unique elements)
|
|
126
|
+
* @param values - Array of values (duplicates will be removed by server)
|
|
127
|
+
*/
|
|
128
|
+
set: <T>(values: T[]) => WrappedFieldValue;
|
|
129
|
+
/**
|
|
130
|
+
* Create a Vector field value (for embeddings/similarity search)
|
|
131
|
+
* @param values - Array of numbers representing the vector
|
|
132
|
+
*/
|
|
133
|
+
vector: (values: number[]) => WrappedFieldValue;
|
|
134
|
+
/**
|
|
135
|
+
* Create a Binary field value
|
|
136
|
+
* @param value - Base64 encoded string or Uint8Array
|
|
137
|
+
*/
|
|
138
|
+
binary: (value: string | Uint8Array) => WrappedFieldValue;
|
|
139
|
+
/**
|
|
140
|
+
* Create a Bytes field value
|
|
141
|
+
* @param value - Base64 encoded string or Uint8Array
|
|
142
|
+
*/
|
|
143
|
+
bytes: (value: string | Uint8Array) => WrappedFieldValue;
|
|
144
|
+
/**
|
|
145
|
+
* Create an Array field value
|
|
146
|
+
* @param values - Array of values
|
|
147
|
+
*/
|
|
148
|
+
array: <T>(values: T[]) => WrappedFieldValue;
|
|
149
|
+
/**
|
|
150
|
+
* Create an Object field value
|
|
151
|
+
* @param value - Object/map of key-value pairs
|
|
152
|
+
*/
|
|
153
|
+
object: (value: Record<string, unknown>) => WrappedFieldValue;
|
|
154
|
+
/**
|
|
155
|
+
* Create a String field value (explicit wrapping)
|
|
156
|
+
* @param value - String value
|
|
157
|
+
*/
|
|
158
|
+
string: (value: string) => WrappedFieldValue;
|
|
159
|
+
/**
|
|
160
|
+
* Create an Integer field value (explicit wrapping)
|
|
161
|
+
* @param value - Integer value
|
|
162
|
+
*/
|
|
163
|
+
integer: (value: number) => WrappedFieldValue;
|
|
164
|
+
/**
|
|
165
|
+
* Create a Float field value (explicit wrapping)
|
|
166
|
+
* @param value - Float value
|
|
167
|
+
*/
|
|
168
|
+
float: (value: number) => WrappedFieldValue;
|
|
169
|
+
/**
|
|
170
|
+
* Create a Boolean field value (explicit wrapping)
|
|
171
|
+
* @param value - Boolean value
|
|
172
|
+
*/
|
|
173
|
+
boolean: (value: boolean) => WrappedFieldValue;
|
|
174
|
+
};
|