@ekodb/ekodb-client 0.1.0 → 0.1.7
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/README.md +7 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +74 -66
- package/dist/index.d.ts +9 -9
- package/dist/schema.js +2 -1
- package/package.json +1 -1
- package/src/client.ts +241 -115
- package/src/index.ts +28 -13
- package/src/join.ts +21 -11
- package/src/query-builder.ts +1 -1
- package/src/schema.ts +12 -8
- package/src/search.ts +5 -5
package/src/index.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export {
|
|
2
|
+
EkoDBClient,
|
|
3
|
+
WebSocketClient,
|
|
4
|
+
MergeStrategy,
|
|
5
|
+
RateLimitError,
|
|
6
|
+
} from "./client";
|
|
7
|
+
export { QueryBuilder, SortOrder } from "./query-builder";
|
|
8
|
+
export { SearchQueryBuilder } from "./search";
|
|
9
|
+
export {
|
|
10
|
+
SchemaBuilder,
|
|
11
|
+
FieldTypeSchemaBuilder,
|
|
12
|
+
VectorIndexAlgorithm,
|
|
13
|
+
DistanceMetric,
|
|
14
|
+
} from "./schema";
|
|
15
|
+
export { JoinBuilder } from "./join";
|
|
16
|
+
export type { SearchQuery, SearchResult, SearchResponse } from "./search";
|
|
17
|
+
export type {
|
|
18
|
+
Schema,
|
|
19
|
+
FieldTypeSchema,
|
|
20
|
+
IndexConfig,
|
|
21
|
+
CollectionMetadata,
|
|
22
|
+
} from "./schema";
|
|
23
|
+
export type { JoinConfig } from "./join";
|
|
24
|
+
export type {
|
|
25
|
+
Record,
|
|
26
|
+
Query,
|
|
12
27
|
BatchOperationResult,
|
|
13
28
|
ClientConfig,
|
|
14
29
|
RateLimitInfo,
|
|
@@ -25,5 +40,5 @@ export type {
|
|
|
25
40
|
GetMessagesQuery,
|
|
26
41
|
GetMessagesResponse,
|
|
27
42
|
UpdateSessionRequest,
|
|
28
|
-
MergeSessionsRequest
|
|
29
|
-
} from
|
|
43
|
+
MergeSessionsRequest,
|
|
44
|
+
} from "./client";
|
package/src/join.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Join support for multi-collection queries
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides support for joining data across multiple collections,
|
|
5
5
|
* similar to SQL joins but with document-oriented semantics.
|
|
6
6
|
*/
|
|
@@ -21,12 +21,12 @@ export interface JoinConfig {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Builder for constructing join configurations
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
27
|
* // Single collection join
|
|
28
28
|
* const join = JoinBuilder.single("users", "user_id", "id", "user");
|
|
29
|
-
*
|
|
29
|
+
*
|
|
30
30
|
* // Multi-collection join
|
|
31
31
|
* const join = JoinBuilder.multi(
|
|
32
32
|
* ["users", "profiles", "settings"],
|
|
@@ -34,7 +34,7 @@ export interface JoinConfig {
|
|
|
34
34
|
* "id",
|
|
35
35
|
* "user_info"
|
|
36
36
|
* );
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* // Use in query
|
|
39
39
|
* const query = new QueryBuilder()
|
|
40
40
|
* .eq("status", "active")
|
|
@@ -49,7 +49,7 @@ export class JoinBuilder {
|
|
|
49
49
|
collections: string[],
|
|
50
50
|
localField: string,
|
|
51
51
|
foreignField: string,
|
|
52
|
-
asField: string
|
|
52
|
+
asField: string,
|
|
53
53
|
) {
|
|
54
54
|
this.config = {
|
|
55
55
|
collections,
|
|
@@ -61,7 +61,7 @@ export class JoinBuilder {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Create a join with a single collection
|
|
64
|
-
*
|
|
64
|
+
*
|
|
65
65
|
* @param collection - Target collection name
|
|
66
66
|
* @param localField - Field in the current collection
|
|
67
67
|
* @param foreignField - Field in the target collection
|
|
@@ -71,14 +71,19 @@ export class JoinBuilder {
|
|
|
71
71
|
collection: string,
|
|
72
72
|
localField: string,
|
|
73
73
|
foreignField: string,
|
|
74
|
-
asField: string
|
|
74
|
+
asField: string,
|
|
75
75
|
): JoinConfig {
|
|
76
|
-
return new JoinBuilder(
|
|
76
|
+
return new JoinBuilder(
|
|
77
|
+
[collection],
|
|
78
|
+
localField,
|
|
79
|
+
foreignField,
|
|
80
|
+
asField,
|
|
81
|
+
).build();
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
/**
|
|
80
85
|
* Create a join with multiple collections
|
|
81
|
-
*
|
|
86
|
+
*
|
|
82
87
|
* @param collections - Array of target collection names
|
|
83
88
|
* @param localField - Field in the current collection
|
|
84
89
|
* @param foreignField - Field in the target collections
|
|
@@ -88,9 +93,14 @@ export class JoinBuilder {
|
|
|
88
93
|
collections: string[],
|
|
89
94
|
localField: string,
|
|
90
95
|
foreignField: string,
|
|
91
|
-
asField: string
|
|
96
|
+
asField: string,
|
|
92
97
|
): JoinConfig {
|
|
93
|
-
return new JoinBuilder(
|
|
98
|
+
return new JoinBuilder(
|
|
99
|
+
collections,
|
|
100
|
+
localField,
|
|
101
|
+
foreignField,
|
|
102
|
+
asField,
|
|
103
|
+
).build();
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
/**
|
package/src/query-builder.ts
CHANGED
package/src/schema.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Schema management for collections
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides types and utilities for defining and managing
|
|
5
5
|
* collection schemas with field types, constraints, and indexes.
|
|
6
6
|
*/
|
|
@@ -51,7 +51,7 @@ export type IndexConfig =
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Field type schema with constraints
|
|
54
|
-
*
|
|
54
|
+
*
|
|
55
55
|
* Valid field types (case-sensitive):
|
|
56
56
|
* - String, Integer, Float, Boolean, DateTime
|
|
57
57
|
* - Array, Object, Vector, Set
|
|
@@ -106,7 +106,7 @@ export interface CollectionMetadata {
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* Builder for constructing field type schemas
|
|
109
|
-
*
|
|
109
|
+
*
|
|
110
110
|
* @example
|
|
111
111
|
* ```typescript
|
|
112
112
|
* const field = new FieldTypeSchemaBuilder("string")
|
|
@@ -191,7 +191,7 @@ export class FieldTypeSchemaBuilder {
|
|
|
191
191
|
algorithm: VectorIndexAlgorithm = VectorIndexAlgorithm.Flat,
|
|
192
192
|
metric: DistanceMetric = DistanceMetric.Cosine,
|
|
193
193
|
m: number = 16,
|
|
194
|
-
efConstruction: number = 200
|
|
194
|
+
efConstruction: number = 200,
|
|
195
195
|
): this {
|
|
196
196
|
this.schema.index = {
|
|
197
197
|
type: "vector",
|
|
@@ -229,7 +229,7 @@ export class FieldTypeSchemaBuilder {
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* Builder for constructing collection schemas
|
|
232
|
-
*
|
|
232
|
+
*
|
|
233
233
|
* @example
|
|
234
234
|
* ```typescript
|
|
235
235
|
* const schema = new SchemaBuilder()
|
|
@@ -237,7 +237,7 @@ export class FieldTypeSchemaBuilder {
|
|
|
237
237
|
* .addField("email", new FieldTypeSchemaBuilder("string").unique())
|
|
238
238
|
* .addField("age", new FieldTypeSchemaBuilder("number").range(0, 150))
|
|
239
239
|
* .build();
|
|
240
|
-
*
|
|
240
|
+
*
|
|
241
241
|
* await client.createCollection("users", schema);
|
|
242
242
|
* ```
|
|
243
243
|
*/
|
|
@@ -255,8 +255,12 @@ export class SchemaBuilder {
|
|
|
255
255
|
/**
|
|
256
256
|
* Add a field to the schema
|
|
257
257
|
*/
|
|
258
|
-
addField(
|
|
259
|
-
|
|
258
|
+
addField(
|
|
259
|
+
name: string,
|
|
260
|
+
field: FieldTypeSchema | FieldTypeSchemaBuilder,
|
|
261
|
+
): this {
|
|
262
|
+
this.schema.fields[name] =
|
|
263
|
+
field instanceof FieldTypeSchemaBuilder ? field.build() : field;
|
|
260
264
|
return this;
|
|
261
265
|
}
|
|
262
266
|
|
package/src/search.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Full-text and vector search support for ekoDB
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides comprehensive search capabilities including:
|
|
5
5
|
* - Full-text search with fuzzy matching
|
|
6
6
|
* - Vector/semantic search
|
|
@@ -35,7 +35,7 @@ export interface SearchQuery {
|
|
|
35
35
|
bypass_cache?: boolean;
|
|
36
36
|
/** Maximum number of results to return */
|
|
37
37
|
limit?: number;
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
// Vector search parameters
|
|
40
40
|
/** Query vector for semantic search */
|
|
41
41
|
vector?: number[];
|
|
@@ -47,7 +47,7 @@ export interface SearchQuery {
|
|
|
47
47
|
vector_k?: number;
|
|
48
48
|
/** Minimum similarity threshold */
|
|
49
49
|
vector_threshold?: number;
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
// Hybrid search parameters
|
|
52
52
|
/** Weight for text search (0.0-1.0) */
|
|
53
53
|
text_weight?: number;
|
|
@@ -81,7 +81,7 @@ export interface SearchResponse {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Builder for constructing search queries with fluent API
|
|
84
|
-
*
|
|
84
|
+
*
|
|
85
85
|
* @example
|
|
86
86
|
* ```typescript
|
|
87
87
|
* const query = new SearchQueryBuilder("john")
|
|
@@ -90,7 +90,7 @@ export interface SearchResponse {
|
|
|
90
90
|
* .minScore(0.5)
|
|
91
91
|
* .limit(10)
|
|
92
92
|
* .build();
|
|
93
|
-
*
|
|
93
|
+
*
|
|
94
94
|
* const results = await client.search("users", query);
|
|
95
95
|
* ```
|
|
96
96
|
*/
|