@dooor-ai/cortexdb 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +170 -182
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,34 +1,33 @@
1
- # CortexDB TypeScript/JavaScript SDK
1
+ # CortexDB TypeScript SDK
2
2
 
3
- Official TypeScript/JavaScript client for **CortexDB** - A powerful multi-modal RAG (Retrieval Augmented Generation) platform with advanced document processing capabilities.
4
-
5
- [![npm version](https://badge.fury.io/js/%40dooor-ai%2Fcortexdb.svg)](https://badge.fury.io/js/%40dooor-ai%2Fcortexdb)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ Official TypeScript/JavaScript client for CortexDB - Multi-modal RAG Platform.
7
4
 
8
5
  ## Features
9
6
 
10
- - 🚀 **Simple & Intuitive API** - Easy to use, TypeScript-first design
11
- - 🔍 **Semantic Search** - Vector-based semantic search with embeddings
12
- - 📄 **Document Processing** - Advanced PDF, DOCX, XLSX processing with Docling
13
- - 🎯 **Type Safe** - Full TypeScript support with type definitions
14
- - **Async/Await** - Modern async/await API
15
- - 🛡️ **Error Handling** - Comprehensive error types for better debugging
16
- - 🔌 **Flexible** - Works with Node.js, Deno, and modern browsers
7
+ - Full TypeScript support with type definitions
8
+ - Async/await API using native fetch
9
+ - Semantic search with vector embeddings
10
+ - Collection and record management
11
+ - Custom error types for better debugging
12
+ - Works with Node.js 18+, Deno, and modern browsers
17
13
 
18
14
  ## Installation
19
15
 
20
16
  ```bash
21
17
  npm install @dooor-ai/cortexdb
22
- # or
18
+ ```
19
+
20
+ Or with yarn:
21
+
22
+ ```bash
23
23
  yarn add @dooor-ai/cortexdb
24
- # or
25
- pnpm add @dooor-ai/cortexdb
26
24
  ```
27
25
 
28
- ## Requirements
26
+ Or with pnpm:
29
27
 
30
- - Node.js >= 18.0.0 (uses native `fetch`)
31
- - CortexDB gateway running (default: `http://localhost:8000`)
28
+ ```bash
29
+ pnpm add @dooor-ai/cortexdb
30
+ ```
32
31
 
33
32
  ## Quick Start
34
33
 
@@ -36,242 +35,235 @@ pnpm add @dooor-ai/cortexdb
36
35
  import { CortexClient, FieldType } from '@dooor-ai/cortexdb';
37
36
 
38
37
  async function main() {
39
- // Initialize client
40
38
  const client = new CortexClient({
41
- baseUrl: 'http://localhost:8000',
42
- // apiKey: 'YOUR_API_KEY', // Optional: if authentication is enabled
39
+ baseUrl: 'http://localhost:8000'
43
40
  });
44
41
 
45
- // Check health
46
- const isHealthy = await client.healthcheck();
47
- console.log('CortexDB:', isHealthy ? 'Connected ✓' : 'Disconnected ✗');
48
-
49
42
  // Create a collection
50
- await client.collections.create('my_docs', [
43
+ await client.collections.create('documents', [
51
44
  { name: 'title', type: FieldType.STRING },
52
- { name: 'content', type: FieldType.STRING },
45
+ { name: 'content', type: FieldType.STRING, vectorize: true }
53
46
  ]);
54
47
 
55
48
  // Create a record
56
- const record = await client.records.create('my_docs', {
49
+ const record = await client.records.create('documents', {
57
50
  title: 'Hello World',
58
- content: 'This is my first document',
51
+ content: 'This is my first document'
59
52
  });
60
53
 
61
- console.log('Created:', record.id);
62
-
63
- // Get the record
64
- const fetched = await client.records.get('my_docs', record.id);
65
- console.log('Fetched:', fetched.data);
54
+ // Semantic search
55
+ const results = await client.records.search(
56
+ 'documents',
57
+ 'hello world',
58
+ undefined,
59
+ 10
60
+ );
66
61
 
67
- // List all records
68
- const results = await client.records.list('my_docs');
69
- console.log('Total:', results.total);
62
+ results.results.forEach(result => {
63
+ console.log(`Score: ${result.score.toFixed(4)} - ${result.record.data.title}`);
64
+ });
70
65
 
71
- // Clean up
72
- await client.collections.delete('my_docs');
73
66
  await client.close();
74
67
  }
75
68
 
76
69
  main();
77
70
  ```
78
71
 
79
- ## Semantic Search Example
72
+ ## Usage
80
73
 
81
- Enable semantic search by creating a collection with `vectorize: true` and an embedding provider:
74
+ ### Initialize Client
82
75
 
83
76
  ```typescript
84
- import { CortexClient, FieldType } from '@dooor-ai/cortexdb';
85
-
86
- async function semanticSearch() {
87
- const client = new CortexClient({ baseUrl: 'http://localhost:8000' });
88
-
89
- // Create collection with vectorization
90
- await client.collections.create(
91
- 'knowledge_base',
92
- [
93
- { name: 'title', type: FieldType.STRING },
94
- { name: 'content', type: FieldType.STRING, vectorize: true },
95
- ],
96
- 'your-embedding-provider-id' // Required for vectorization
97
- );
77
+ import { CortexClient } from '@dooor-ai/cortexdb';
98
78
 
99
- // Add documents
100
- await client.records.create('knowledge_base', {
101
- title: 'Machine Learning',
102
- content: 'ML is a branch of AI that focuses on learning from data.',
103
- });
104
-
105
- await client.records.create('knowledge_base', {
106
- title: 'Deep Learning',
107
- content: 'Deep learning uses neural networks with multiple layers.',
108
- });
109
-
110
- // Perform semantic search
111
- const results = await client.records.search(
112
- 'knowledge_base',
113
- 'What is artificial intelligence?',
114
- undefined, // filters
115
- 5 // limit
116
- );
117
-
118
- results.results.forEach((result) => {
119
- console.log(`${result.record.data.title} (score: ${result.score})`);
120
- });
121
-
122
- await client.close();
123
- }
124
- ```
125
-
126
- ## API Reference
79
+ // Local development
80
+ const client = new CortexClient({
81
+ baseUrl: 'http://localhost:8000'
82
+ });
127
83
 
128
- ### CortexClient
84
+ // With API key
85
+ const client = new CortexClient({
86
+ baseUrl: 'https://api.cortexdb.com',
87
+ apiKey: 'your-api-key'
88
+ });
129
89
 
130
- ```typescript
90
+ // Custom timeout
131
91
  const client = new CortexClient({
132
- baseUrl?: string; // Default: 'http://localhost:8000'
133
- apiKey?: string; // Optional API key
134
- timeout?: number; // Request timeout in ms (default: 30000)
92
+ baseUrl: 'http://localhost:8000',
93
+ timeout: 60000 // 60 seconds
135
94
  });
136
95
  ```
137
96
 
138
- #### Methods
139
-
140
- - `health()` - Get health status
141
- - `healthcheck()` - Returns boolean health status
142
- - `close()` - Close the client
143
-
144
- ### Collections API
97
+ ### Collections
145
98
 
146
99
  ```typescript
147
- // List all collections
148
- const collections = await client.collections.list();
100
+ import { FieldType, StoreLocation } from '@dooor-ai/cortexdb';
101
+
102
+ // Create collection
103
+ const collection = await client.collections.create('articles', [
104
+ {
105
+ name: 'title',
106
+ type: FieldType.STRING
107
+ },
108
+ {
109
+ name: 'content',
110
+ type: FieldType.STRING,
111
+ vectorize: true // Enable semantic search
112
+ },
113
+ {
114
+ name: 'year',
115
+ type: FieldType.NUMBER,
116
+ store_in: [StoreLocation.POSTGRES, StoreLocation.QDRANT_PAYLOAD]
117
+ }
118
+ ]);
149
119
 
150
- // Get a collection
151
- const collection = await client.collections.get('my_collection');
152
-
153
- // Create a collection
154
- await client.collections.create(
155
- 'my_collection',
156
- [
157
- { name: 'title', type: FieldType.STRING, required: true },
158
- { name: 'content', type: FieldType.STRING, vectorize: true },
159
- ],
160
- 'embedding-provider-id' // Optional: required if vectorize is true
161
- );
120
+ // List collections
121
+ const collections = await client.collections.list();
162
122
 
163
- // Update a collection
164
- await client.collections.update('my_collection', fields, embeddingProvider);
123
+ // Get collection
124
+ const schema = await client.collections.get('articles');
165
125
 
166
- // Delete a collection
167
- await client.collections.delete('my_collection');
126
+ // Delete collection
127
+ await client.collections.delete('articles');
168
128
  ```
169
129
 
170
- ### Records API
130
+ ### Records
171
131
 
172
132
  ```typescript
173
- // Create a record
174
- const record = await client.records.create('collection_name', {
175
- title: 'My Document',
176
- content: 'Document content...',
133
+ // Create record
134
+ const record = await client.records.create('articles', {
135
+ title: 'Machine Learning Basics',
136
+ content: 'Introduction to ML concepts...',
137
+ year: 2024
177
138
  });
178
139
 
179
- // Get a record
180
- const record = await client.records.get('collection_name', 'record-id');
140
+ // Get record by ID
141
+ const fetched = await client.records.get('articles', record.id);
181
142
 
182
- // List records with filters
183
- const results = await client.records.list('collection_name', {
184
- filters: { year: 2024 },
185
- limit: 10,
186
- offset: 0,
143
+ // Update record
144
+ const updated = await client.records.update('articles', record.id, {
145
+ year: 2025
187
146
  });
188
147
 
189
- // Update a record
190
- await client.records.update('collection_name', 'record-id', {
191
- title: 'Updated Title',
148
+ // Delete record
149
+ await client.records.delete('articles', record.id);
150
+
151
+ // List records
152
+ const results = await client.records.list('articles', {
153
+ limit: 10,
154
+ offset: 0
192
155
  });
156
+ ```
193
157
 
194
- // Delete a record
195
- await client.records.delete('collection_name', 'record-id');
158
+ ### Semantic Search
196
159
 
197
- // Semantic search
160
+ ```typescript
161
+ // Basic search
198
162
  const results = await client.records.search(
199
- 'collection_name',
200
- 'search query',
201
- { category: 'tech' }, // optional filters
202
- 10 // limit
163
+ 'articles',
164
+ 'machine learning fundamentals',
165
+ undefined,
166
+ 10
203
167
  );
168
+
169
+ // Search with filters
170
+ const filteredResults = await client.records.search(
171
+ 'articles',
172
+ 'neural networks',
173
+ {
174
+ year: 2024,
175
+ category: 'AI'
176
+ },
177
+ 5
178
+ );
179
+
180
+ // Process results
181
+ filteredResults.results.forEach(result => {
182
+ console.log(`Score: ${result.score.toFixed(4)}`);
183
+ console.log(`Title: ${result.record.data.title}`);
184
+ console.log(`Year: ${result.record.data.year}`);
185
+ });
204
186
  ```
205
187
 
206
- ## Field Types
188
+ ### Filter Operators
207
189
 
208
190
  ```typescript
209
- import { FieldType, StoreLocation } from '@cortexdb/sdk';
210
-
211
- const field = {
212
- name: 'my_field',
213
- type: FieldType.STRING, // STRING, NUMBER, BOOLEAN, FILE, ARRAY
214
- vectorize: true, // Enable semantic search
215
- required: false, // Make field required
216
- store_in: [ // Storage locations
217
- StoreLocation.POSTGRES,
218
- StoreLocation.QDRANT_PAYLOAD,
219
- ],
220
- };
191
+ // Exact match
192
+ const results = await client.records.list('articles', {
193
+ filters: {
194
+ category: 'technology',
195
+ published: true
196
+ }
197
+ });
198
+
199
+ // Combine filters
200
+ const filtered = await client.records.list('articles', {
201
+ filters: {
202
+ year: 2024,
203
+ category: 'AI'
204
+ },
205
+ limit: 20
206
+ });
221
207
  ```
222
208
 
223
209
  ## Error Handling
224
210
 
225
- The SDK provides specific error types for better error handling:
226
-
227
211
  ```typescript
228
212
  import {
229
213
  CortexDBError,
230
- CortexDBConnectionError,
231
- CortexDBTimeoutError,
232
214
  CortexDBNotFoundError,
233
215
  CortexDBValidationError,
234
- CortexDBAuthenticationError,
235
- CortexDBPermissionError,
236
- CortexDBServerError,
237
- } from '@cortexdb/sdk';
216
+ CortexDBConnectionError
217
+ } from '@dooor-ai/cortexdb';
238
218
 
239
219
  try {
240
- await client.records.get('collection', 'invalid-id');
220
+ const record = await client.records.get('articles', 'invalid-id');
241
221
  } catch (error) {
242
222
  if (error instanceof CortexDBNotFoundError) {
243
223
  console.log('Record not found');
224
+ } else if (error instanceof CortexDBValidationError) {
225
+ console.log('Validation error:', error.message);
244
226
  } else if (error instanceof CortexDBConnectionError) {
245
- console.log('Connection failed');
246
- } else if (error instanceof CortexDBTimeoutError) {
247
- console.log('Request timed out');
248
- } else {
249
- console.log('Unknown error:', error);
227
+ console.log('Connection failed:', error.message);
228
+ } else if (error instanceof CortexDBError) {
229
+ console.log('General error:', error.message);
250
230
  }
251
231
  }
252
232
  ```
253
233
 
254
234
  ## Examples
255
235
 
256
- Check out the [examples](./examples) directory for more:
236
+ Check the [`examples/`](./examples) directory for more usage examples:
257
237
 
258
- - [quickstart.ts](./examples/quickstart.ts) - Complete quickstart guide
259
- - [search.ts](./examples/search.ts) - Semantic search with filters
260
- - [basic.ts](./examples/basic.ts) - Basic operations
238
+ - [`quickstart.ts`](./examples/quickstart.ts) - Walkthrough of SDK features
239
+ - [`search.ts`](./examples/search.ts) - Semantic search with filters
240
+ - [`basic.ts`](./examples/basic.ts) - Basic operations
261
241
 
262
242
  Run examples:
263
243
 
264
244
  ```bash
265
- cd examples
266
- npx ts-node -O '{"module":"commonjs"}' quickstart.ts
245
+ npx ts-node -O '{"module":"commonjs"}' examples/quickstart.ts
267
246
  ```
268
247
 
269
248
  ## Development
270
249
 
250
+ ### Setup
251
+
271
252
  ```bash
253
+ # Clone repository
254
+ git clone https://github.com/yourusername/cortexdb
255
+ cd cortexdb/clients/typescript
256
+
272
257
  # Install dependencies
273
258
  npm install
274
259
 
260
+ # Build
261
+ npm run build
262
+ ```
263
+
264
+ ### Scripts
265
+
266
+ ```bash
275
267
  # Build
276
268
  npm run build
277
269
 
@@ -280,23 +272,19 @@ npm run build:watch
280
272
 
281
273
  # Clean
282
274
  npm run clean
283
- ```
284
-
285
- ## Contributing
286
-
287
- Contributions are welcome! Please feel free to submit a Pull Request.
288
275
 
289
- ## License
276
+ # Lint
277
+ npm run lint
290
278
 
291
- MIT License - see [LICENSE](./LICENSE) file for details.
279
+ # Format
280
+ npm run format
281
+ ```
292
282
 
293
- ## Support
283
+ ## Requirements
294
284
 
295
- - 📖 [Documentation](https://github.com/cortexdb/cortexdb)
296
- - 🐛 [Issue Tracker](https://github.com/cortexdb/cortexdb/issues)
297
- - 💬 [Discussions](https://github.com/cortexdb/cortexdb/discussions)
285
+ - Node.js >= 18.0.0
286
+ - CortexDB gateway running (local or remote)
298
287
 
299
- ## Related
288
+ ## License
300
289
 
301
- - [CortexDB Python SDK](../python) - Python client for CortexDB
302
- - [CortexDB Gateway](../../gateway) - CortexDB backend service
290
+ MIT License - see [LICENSE](./LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooor-ai/cortexdb",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Official TypeScript/JavaScript SDK for CortexDB - Multi-modal RAG Platform with advanced document processing",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",