@dooor-ai/cortexdb 0.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.
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /** Custom exceptions for CortexDB SDK */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CortexDBServerError = exports.CortexDBPermissionError = exports.CortexDBAuthenticationError = exports.CortexDBValidationError = exports.CortexDBNotFoundError = exports.CortexDBTimeoutError = exports.CortexDBConnectionError = exports.CortexDBError = void 0;
5
+ /**
6
+ * Base exception for all CortexDB errors
7
+ */
8
+ class CortexDBError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = "CortexDBError";
12
+ Object.setPrototypeOf(this, CortexDBError.prototype);
13
+ }
14
+ }
15
+ exports.CortexDBError = CortexDBError;
16
+ /**
17
+ * Exception raised for connection errors
18
+ */
19
+ class CortexDBConnectionError extends CortexDBError {
20
+ constructor(message = "Failed to connect to CortexDB") {
21
+ super(message);
22
+ this.name = "CortexDBConnectionError";
23
+ Object.setPrototypeOf(this, CortexDBConnectionError.prototype);
24
+ }
25
+ }
26
+ exports.CortexDBConnectionError = CortexDBConnectionError;
27
+ /**
28
+ * Exception raised for timeout errors
29
+ */
30
+ class CortexDBTimeoutError extends CortexDBError {
31
+ constructor(message = "Request timed out") {
32
+ super(message);
33
+ this.name = "CortexDBTimeoutError";
34
+ Object.setPrototypeOf(this, CortexDBTimeoutError.prototype);
35
+ }
36
+ }
37
+ exports.CortexDBTimeoutError = CortexDBTimeoutError;
38
+ /**
39
+ * Exception raised for 404 Not Found errors
40
+ */
41
+ class CortexDBNotFoundError extends CortexDBError {
42
+ constructor(message = "Resource not found") {
43
+ super(message);
44
+ this.name = "CortexDBNotFoundError";
45
+ Object.setPrototypeOf(this, CortexDBNotFoundError.prototype);
46
+ }
47
+ }
48
+ exports.CortexDBNotFoundError = CortexDBNotFoundError;
49
+ /**
50
+ * Exception raised for validation errors (400)
51
+ */
52
+ class CortexDBValidationError extends CortexDBError {
53
+ constructor(message = "Validation error") {
54
+ super(message);
55
+ this.name = "CortexDBValidationError";
56
+ Object.setPrototypeOf(this, CortexDBValidationError.prototype);
57
+ }
58
+ }
59
+ exports.CortexDBValidationError = CortexDBValidationError;
60
+ /**
61
+ * Exception raised for authentication errors (401)
62
+ */
63
+ class CortexDBAuthenticationError extends CortexDBError {
64
+ constructor(message = "Authentication failed") {
65
+ super(message);
66
+ this.name = "CortexDBAuthenticationError";
67
+ Object.setPrototypeOf(this, CortexDBAuthenticationError.prototype);
68
+ }
69
+ }
70
+ exports.CortexDBAuthenticationError = CortexDBAuthenticationError;
71
+ /**
72
+ * Exception raised for permission errors (403)
73
+ */
74
+ class CortexDBPermissionError extends CortexDBError {
75
+ constructor(message = "Permission denied") {
76
+ super(message);
77
+ this.name = "CortexDBPermissionError";
78
+ Object.setPrototypeOf(this, CortexDBPermissionError.prototype);
79
+ }
80
+ }
81
+ exports.CortexDBPermissionError = CortexDBPermissionError;
82
+ /**
83
+ * Exception raised for server errors (5xx)
84
+ */
85
+ class CortexDBServerError extends CortexDBError {
86
+ constructor(message = "Server error") {
87
+ super(message);
88
+ this.name = "CortexDBServerError";
89
+ Object.setPrototypeOf(this, CortexDBServerError.prototype);
90
+ }
91
+ }
92
+ exports.CortexDBServerError = CortexDBServerError;
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";AAAA,yCAAyC;;;AAEzC;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAND,sCAMC;AAED;;GAEG;AACH,MAAa,uBA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E,CAAC;CACF;AAND,kEAMC;AAED;;GAEG;AACH,MAAa,uBAAwB,SAAQ,aAAa;IACxD,YAAY,UAAkB,mBAAmB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;CACF;AAND,0DAMC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,aAAa;IACpD,YAAY,UAAkB,cAAc;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;CACF;AAND,kDAMC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * HTTP client for CortexDB API
3
+ *
4
+ * Handles all HTTP requests with automatic error handling,
5
+ * timeout management, and status code mapping to specific exceptions.
6
+ */
7
+ /**
8
+ * HTTP client for making requests to CortexDB API
9
+ */
10
+ export declare class HTTPClient {
11
+ private baseUrl;
12
+ private apiKey?;
13
+ private timeout;
14
+ /**
15
+ * Create a new HTTP client
16
+ *
17
+ * @param baseUrl - Base URL of the CortexDB gateway
18
+ * @param apiKey - Optional API key for authentication
19
+ * @param timeout - Request timeout in milliseconds (default: 30000)
20
+ */
21
+ constructor(baseUrl: string, apiKey?: string, timeout?: number);
22
+ /**
23
+ * Make a GET request
24
+ *
25
+ * @param path - API endpoint path
26
+ * @returns Response data
27
+ */
28
+ get<T>(path: string): Promise<T>;
29
+ /**
30
+ * Make a POST request
31
+ *
32
+ * @param path - API endpoint path
33
+ * @param body - Request body
34
+ * @returns Response data
35
+ */
36
+ post<T>(path: string, body?: any): Promise<T>;
37
+ /**
38
+ * Make a PUT request
39
+ *
40
+ * @param path - API endpoint path
41
+ * @param body - Request body
42
+ * @returns Response data
43
+ */
44
+ put<T>(path: string, body?: any): Promise<T>;
45
+ /**
46
+ * Make a PATCH request
47
+ *
48
+ * @param path - API endpoint path
49
+ * @param body - Request body
50
+ * @returns Response data
51
+ */
52
+ patch<T>(path: string, body?: any): Promise<T>;
53
+ /**
54
+ * Make a DELETE request
55
+ *
56
+ * @param path - API endpoint path
57
+ * @returns Response data
58
+ */
59
+ delete<T>(path: string): Promise<T>;
60
+ /**
61
+ * Internal method to make HTTP requests
62
+ *
63
+ * @param method - HTTP method
64
+ * @param path - API endpoint path
65
+ * @param body - Optional request body
66
+ * @returns Response data
67
+ * @throws {CortexDBError} Various error types based on HTTP status codes
68
+ */
69
+ private request;
70
+ }
71
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc;IAMrE;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAItC;;;;;;OAMG;IACG,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAInD;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD;;;;;;OAMG;IACG,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAIpD;;;;;OAKG;IACG,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzC;;;;;;;;OAQG;YACW,OAAO;CA4EtB"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP client for CortexDB API
4
+ *
5
+ * Handles all HTTP requests with automatic error handling,
6
+ * timeout management, and status code mapping to specific exceptions.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HTTPClient = void 0;
10
+ const exceptions_1 = require("../exceptions");
11
+ /**
12
+ * HTTP client for making requests to CortexDB API
13
+ */
14
+ class HTTPClient {
15
+ /**
16
+ * Create a new HTTP client
17
+ *
18
+ * @param baseUrl - Base URL of the CortexDB gateway
19
+ * @param apiKey - Optional API key for authentication
20
+ * @param timeout - Request timeout in milliseconds (default: 30000)
21
+ */
22
+ constructor(baseUrl, apiKey, timeout = 30000) {
23
+ this.baseUrl = baseUrl.replace(/\/$/, "");
24
+ this.apiKey = apiKey;
25
+ this.timeout = timeout;
26
+ }
27
+ /**
28
+ * Make a GET request
29
+ *
30
+ * @param path - API endpoint path
31
+ * @returns Response data
32
+ */
33
+ async get(path) {
34
+ return this.request("GET", path);
35
+ }
36
+ /**
37
+ * Make a POST request
38
+ *
39
+ * @param path - API endpoint path
40
+ * @param body - Request body
41
+ * @returns Response data
42
+ */
43
+ async post(path, body) {
44
+ return this.request("POST", path, body);
45
+ }
46
+ /**
47
+ * Make a PUT request
48
+ *
49
+ * @param path - API endpoint path
50
+ * @param body - Request body
51
+ * @returns Response data
52
+ */
53
+ async put(path, body) {
54
+ return this.request("PUT", path, body);
55
+ }
56
+ /**
57
+ * Make a PATCH request
58
+ *
59
+ * @param path - API endpoint path
60
+ * @param body - Request body
61
+ * @returns Response data
62
+ */
63
+ async patch(path, body) {
64
+ return this.request("PATCH", path, body);
65
+ }
66
+ /**
67
+ * Make a DELETE request
68
+ *
69
+ * @param path - API endpoint path
70
+ * @returns Response data
71
+ */
72
+ async delete(path) {
73
+ return this.request("DELETE", path);
74
+ }
75
+ /**
76
+ * Internal method to make HTTP requests
77
+ *
78
+ * @param method - HTTP method
79
+ * @param path - API endpoint path
80
+ * @param body - Optional request body
81
+ * @returns Response data
82
+ * @throws {CortexDBError} Various error types based on HTTP status codes
83
+ */
84
+ async request(method, path, body) {
85
+ const url = `${this.baseUrl}${path}`;
86
+ const headers = {
87
+ "Content-Type": "application/json",
88
+ };
89
+ if (this.apiKey) {
90
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
91
+ }
92
+ const options = {
93
+ method,
94
+ headers,
95
+ };
96
+ if (body && method !== "GET" && method !== "DELETE") {
97
+ options.body = JSON.stringify(body);
98
+ }
99
+ try {
100
+ const controller = new AbortController();
101
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
102
+ const response = await fetch(url, { ...options, signal: controller.signal });
103
+ clearTimeout(timeoutId);
104
+ const contentType = response.headers.get("content-type");
105
+ let data;
106
+ if (contentType && contentType.includes("application/json")) {
107
+ data = await response.json();
108
+ }
109
+ else {
110
+ const text = await response.text();
111
+ data = text ? { detail: text } : {};
112
+ }
113
+ if (!response.ok) {
114
+ const errorMessage = data.detail || response.statusText;
115
+ // Map HTTP status codes to specific exceptions
116
+ switch (response.status) {
117
+ case 400:
118
+ throw new exceptions_1.CortexDBValidationError(errorMessage);
119
+ case 401:
120
+ throw new exceptions_1.CortexDBAuthenticationError(errorMessage);
121
+ case 403:
122
+ throw new exceptions_1.CortexDBPermissionError(errorMessage);
123
+ case 404:
124
+ throw new exceptions_1.CortexDBNotFoundError(errorMessage);
125
+ case 408:
126
+ throw new exceptions_1.CortexDBTimeoutError(errorMessage);
127
+ case 500:
128
+ case 502:
129
+ case 503:
130
+ case 504:
131
+ throw new exceptions_1.CortexDBServerError(errorMessage);
132
+ default:
133
+ throw new exceptions_1.CortexDBConnectionError(errorMessage);
134
+ }
135
+ }
136
+ return data;
137
+ }
138
+ catch (error) {
139
+ if (error.name === "AbortError") {
140
+ throw new exceptions_1.CortexDBTimeoutError(`Request timed out after ${this.timeout}ms`);
141
+ }
142
+ if (error.name === "TypeError" && error.message.includes("fetch")) {
143
+ throw new exceptions_1.CortexDBConnectionError(`Failed to connect to ${url}`);
144
+ }
145
+ throw error;
146
+ }
147
+ }
148
+ }
149
+ exports.HTTPClient = HTTPClient;
150
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,8CAQuB;AAEvB;;GAEG;AACH,MAAa,UAAU;IAKrB;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,MAAe,EAAE,UAAkB,KAAK;QACnE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAI,IAAY;QACvB,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,IAAU;QACpC,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAI,IAAY,EAAE,IAAU;QACnC,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAI,IAAY,EAAE,IAAU;QACrC,OAAO,IAAI,CAAC,OAAO,CAAI,OAAO,EAAE,IAAI,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AC,CAAC;YAC9E,CAAC;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,oCAAuB,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA5JD,gCA4JC"}
@@ -0,0 +1,8 @@
1
+ /** CortexDB TypeScript SDK */
2
+ export * from "./client";
3
+ export * from "./collections/api";
4
+ export * from "./records/api";
5
+ export * from "./types";
6
+ export * from "./exceptions";
7
+ export * from "./http/client";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAG9B,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /** CortexDB TypeScript SDK */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ // Main client
19
+ __exportStar(require("./client"), exports);
20
+ // API classes
21
+ __exportStar(require("./collections/api"), exports);
22
+ __exportStar(require("./records/api"), exports);
23
+ // Types
24
+ __exportStar(require("./types"), exports);
25
+ // Exceptions
26
+ __exportStar(require("./exceptions"), exports);
27
+ // HTTP Client (for advanced usage)
28
+ __exportStar(require("./http/client"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,8BAA8B;;;;;;;;;;;;;;;;AAE9B,cAAc;AACd,2CAAyB;AAEzB,cAAc;AACd,oDAAkC;AAClC,gDAA8B;AAE9B,QAAQ;AACR,0CAAwB;AAExB,aAAa;AACb,+CAA6B;AAE7B,mCAAmC;AACnC,gDAA8B"}
@@ -0,0 +1,47 @@
1
+ /** Records API for CortexDB */
2
+ import { CortexRecord, SearchResponse, QueryParams } from "../types";
3
+ import { HTTPClient } from "../http/client";
4
+ export declare class RecordsAPI {
5
+ private http;
6
+ constructor(http: HTTPClient);
7
+ /**
8
+ * Create a new record
9
+ */
10
+ create(collection: string, data: {
11
+ [key: string]: any;
12
+ }, files?: {
13
+ [key: string]: File | Buffer;
14
+ }): Promise<CortexRecord>;
15
+ /**
16
+ * Get a record by ID
17
+ */
18
+ get(collection: string, id: string): Promise<CortexRecord>;
19
+ /**
20
+ * List records in a collection
21
+ */
22
+ list(collection: string, params?: QueryParams): Promise<{
23
+ records: CortexRecord[];
24
+ total: number;
25
+ }>;
26
+ /**
27
+ * Update a record
28
+ */
29
+ update(collection: string, id: string, data: {
30
+ [key: string]: any;
31
+ }): Promise<CortexRecord>;
32
+ /**
33
+ * Delete a record
34
+ */
35
+ delete(collection: string, id: string): Promise<void>;
36
+ /**
37
+ * Semantic search
38
+ */
39
+ search(collection: string, query: string, filters?: {
40
+ [key: string]: any;
41
+ }, limit?: number): Promise<SearchResponse>;
42
+ /**
43
+ * Create record with files
44
+ */
45
+ private createWithFiles;
46
+ }
47
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/records/api.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EAAE,YAAY,EAAiB,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,UAAU;IACT,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;OAEG;IACG,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAC5B,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAA;KAAE,GACvC,OAAO,CAAC,YAAY,CAAC;IAQxB;;OAEG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIhE;;OAEG;IACG,IAAI,CACR,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAStD;;OAEG;IACG,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAC3B,OAAO,CAAC,YAAY,CAAC;IAOxB;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D;;OAEG;IACG,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAChC,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC,cAAc,CAAC;IAQ1B;;OAEG;YACW,eAAe;CAS9B"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /** Records API for CortexDB */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RecordsAPI = void 0;
5
+ class RecordsAPI {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /**
10
+ * Create a new record
11
+ */
12
+ async create(collection, data, files) {
13
+ if (files && Object.keys(files).length > 0) {
14
+ // Handle multipart/form-data for file uploads
15
+ return this.createWithFiles(collection, data, files);
16
+ }
17
+ return this.http.post(`/collections/${collection}/records`, data);
18
+ }
19
+ /**
20
+ * Get a record by ID
21
+ */
22
+ async get(collection, id) {
23
+ return this.http.get(`/collections/${collection}/records/${id}`);
24
+ }
25
+ /**
26
+ * List records in a collection
27
+ */
28
+ async list(collection, params) {
29
+ // Use POST to query endpoint with filters
30
+ const response = await this.http.post(`/collections/${collection}/query`, params || {});
31
+ return response;
32
+ }
33
+ /**
34
+ * Update a record
35
+ */
36
+ async update(collection, id, data) {
37
+ return this.http.put(`/collections/${collection}/records/${id}`, data);
38
+ }
39
+ /**
40
+ * Delete a record
41
+ */
42
+ async delete(collection, id) {
43
+ await this.http.delete(`/collections/${collection}/records/${id}`);
44
+ }
45
+ /**
46
+ * Semantic search
47
+ */
48
+ async search(collection, query, filters, limit = 10) {
49
+ const request = { query, filters, limit };
50
+ return this.http.post(`/collections/${collection}/search`, request);
51
+ }
52
+ /**
53
+ * Create record with files
54
+ */
55
+ async createWithFiles(collection, data, files) {
56
+ // For file uploads, we need to use FormData
57
+ // This is a simplified version - in production you'd use form-data library
58
+ throw new Error("File uploads not yet implemented in TypeScript SDK");
59
+ }
60
+ }
61
+ exports.RecordsAPI = RecordsAPI;
62
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+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MAAM,CAAC,gBAAgB,UAAU,YAAY,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,UAAkB,EAClB,KAAa,EACb,OAAgC,EAChC,QAAgB,EAAE;QAElB,MAAM,OAAO,GAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,gBAAgB,UAAU,SAAS,EACnC,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,eAAe,CAC3B,UAAkB,EAClB,IAA4B,EAC5B,KAAuC;QAEvC,4CAA4C;QAC5C,2EAA2E;QAC3E,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;CACF;AAzFD,gCAyFC"}
@@ -0,0 +1,113 @@
1
+ /** Core types for CortexDB TypeScript SDK */
2
+ export type FieldType = "string" | "number" | "boolean" | "file" | "array";
3
+ /**
4
+ * Storage location options for fields
5
+ */
6
+ export declare enum StoreLocation {
7
+ POSTGRES = "postgres",
8
+ QDRANT_PAYLOAD = "qdrant_payload",
9
+ MINIO = "minio"
10
+ }
11
+ export interface FieldDefinition {
12
+ name: string;
13
+ type: FieldType;
14
+ vectorize?: boolean;
15
+ required?: boolean;
16
+ store_in?: StoreLocation[];
17
+ }
18
+ export interface CollectionConfig {
19
+ embedding_provider_id?: string;
20
+ }
21
+ export interface Collection {
22
+ name: string;
23
+ fields: FieldDefinition[];
24
+ config?: CollectionConfig;
25
+ }
26
+ export interface CortexRecord {
27
+ id: string;
28
+ data: {
29
+ [key: string]: any;
30
+ };
31
+ created_at?: string;
32
+ updated_at?: string;
33
+ }
34
+ export interface SearchResult {
35
+ record: CortexRecord;
36
+ score: number;
37
+ highlights?: string[];
38
+ }
39
+ export interface SearchResponse {
40
+ results: SearchResult[];
41
+ total: number;
42
+ took_ms: number;
43
+ }
44
+ export interface PaginationParams {
45
+ page?: number;
46
+ per_page?: number;
47
+ }
48
+ export interface QueryParams {
49
+ filters?: {
50
+ [key: string]: any;
51
+ };
52
+ limit?: number;
53
+ offset?: number;
54
+ }
55
+ export interface SearchRequest {
56
+ query: string;
57
+ filters?: {
58
+ [key: string]: any;
59
+ };
60
+ limit?: number;
61
+ }
62
+ export interface EmbeddingProvider {
63
+ id: string;
64
+ name: string;
65
+ provider: string;
66
+ enabled: boolean;
67
+ }
68
+ export interface Database {
69
+ name: string;
70
+ }
71
+ export interface CortexError {
72
+ detail: string;
73
+ }
74
+ /**
75
+ * Configuration for text extraction from files
76
+ */
77
+ export interface ExtractConfig {
78
+ chunk_size?: number;
79
+ chunk_overlap?: number;
80
+ ocr_if_needed?: boolean;
81
+ }
82
+ /**
83
+ * Vector chunk representing a portion of text and its embedding
84
+ */
85
+ export interface VectorChunk {
86
+ id: string;
87
+ text: string;
88
+ metadata?: {
89
+ [key: string]: any;
90
+ };
91
+ }
92
+ /**
93
+ * Request for querying records with filters
94
+ */
95
+ export interface QueryRequest {
96
+ filters?: {
97
+ [key: string]: any;
98
+ };
99
+ limit?: number;
100
+ offset?: number;
101
+ }
102
+ /**
103
+ * Complete collection schema
104
+ */
105
+ export interface CollectionSchema {
106
+ name: string;
107
+ database?: string;
108
+ fields: FieldDefinition[];
109
+ config?: CollectionConfig;
110
+ created_at?: string;
111
+ updated_at?: string;
112
+ }
113
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3E;;GAEG;AACH,oBAAY,aAAa;IACvB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CA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GAAG,CAAA;KAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /** Core types for CortexDB TypeScript SDK */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.StoreLocation = void 0;
5
+ /**
6
+ * Storage location options for fields
7
+ */
8
+ var StoreLocation;
9
+ (function (StoreLocation) {
10
+ StoreLocation["POSTGRES"] = "postgres";
11
+ StoreLocation["QDRANT_PAYLOAD"] = "qdrant_payload";
12
+ StoreLocation["MINIO"] = "minio";
13
+ })(StoreLocation || (exports.StoreLocation = StoreLocation = {}));
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,6CAA6C;;;AAI7C;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,kDAAiC,CAAA;IACjC,gCAAe,CAAA;AACjB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}