@hajewski/latticedb 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,149 @@
1
+ /**
2
+ * Transaction class for Lattice TypeScript bindings.
3
+ */
4
+ import { Node, Edge, PropertyValue, CreateNodeOptions, CreateEdgeOptions } from './types';
5
+ import { LatticeFFI, TransactionHandle } from './ffi';
6
+ /**
7
+ * A database transaction.
8
+ *
9
+ * Transactions provide atomic, isolated access to the database.
10
+ * Use `Database.read()` or `Database.write()` to create transactions.
11
+ */
12
+ export declare class Transaction {
13
+ private ffi;
14
+ private txnHandle;
15
+ private readonly readOnly;
16
+ private committed;
17
+ private rolledBack;
18
+ /**
19
+ * Create a new transaction wrapper.
20
+ * @internal
21
+ */
22
+ constructor(ffi: LatticeFFI, txnHandle: TransactionHandle, readOnly: boolean);
23
+ /**
24
+ * Commit the transaction.
25
+ */
26
+ commit(): void;
27
+ /**
28
+ * Rollback the transaction.
29
+ */
30
+ rollback(): void;
31
+ /**
32
+ * Create a new node.
33
+ *
34
+ * @param options - Node creation options
35
+ * @returns The created node
36
+ */
37
+ createNode(options?: CreateNodeOptions): Promise<Node>;
38
+ /**
39
+ * Delete a node.
40
+ *
41
+ * @param nodeId - ID of the node to delete
42
+ */
43
+ deleteNode(nodeId: bigint): Promise<void>;
44
+ /**
45
+ * Check if a node exists.
46
+ *
47
+ * @param nodeId - The node ID
48
+ * @returns True if the node exists
49
+ */
50
+ nodeExists(nodeId: bigint): Promise<boolean>;
51
+ /**
52
+ * Get a node by ID.
53
+ *
54
+ * Note: The returned node's `properties` will be empty. Use
55
+ * `getProperty()` to fetch individual properties by key.
56
+ *
57
+ * @param nodeId - The node ID
58
+ * @returns The node, or null if not found
59
+ */
60
+ getNode(nodeId: bigint): Promise<Node | null>;
61
+ /**
62
+ * Set a property on a node.
63
+ *
64
+ * @param nodeId - The node ID
65
+ * @param key - Property key
66
+ * @param value - Property value
67
+ */
68
+ setProperty(nodeId: bigint, key: string, value: PropertyValue): Promise<void>;
69
+ /**
70
+ * Get a property from a node.
71
+ *
72
+ * @param nodeId - The node ID
73
+ * @param key - Property key
74
+ * @returns The property value, or null if not found
75
+ */
76
+ getProperty(nodeId: bigint, key: string): Promise<PropertyValue>;
77
+ /**
78
+ * Set a vector embedding on a node.
79
+ *
80
+ * @param nodeId - The node ID
81
+ * @param key - Vector property key
82
+ * @param vector - Vector data
83
+ */
84
+ setVector(nodeId: bigint, key: string, vector: Float32Array): Promise<void>;
85
+ /**
86
+ * Batch insert multiple nodes with vectors in a single call.
87
+ *
88
+ * @param label - Label for all nodes
89
+ * @param vectors - Array of vectors (one per node)
90
+ * @returns Array of created node IDs
91
+ */
92
+ batchInsert(label: string, vectors: Float32Array[]): Promise<bigint[]>;
93
+ /**
94
+ * Index text for full-text search.
95
+ *
96
+ * @param nodeId - The node ID
97
+ * @param text - Text to index
98
+ */
99
+ ftsIndex(nodeId: bigint, text: string): Promise<void>;
100
+ /**
101
+ * Create an edge between two nodes.
102
+ *
103
+ * @param sourceId - Source node ID
104
+ * @param targetId - Target node ID
105
+ * @param edgeType - Edge type/label
106
+ * @param options - Edge creation options
107
+ * @returns The created edge
108
+ */
109
+ createEdge(sourceId: bigint, targetId: bigint, edgeType: string, options?: CreateEdgeOptions): Promise<Edge>;
110
+ /**
111
+ * Delete an edge.
112
+ *
113
+ * @param sourceId - Source node ID
114
+ * @param targetId - Target node ID
115
+ * @param edgeType - Edge type
116
+ */
117
+ deleteEdge(sourceId: bigint, targetId: bigint, edgeType: string): Promise<void>;
118
+ /**
119
+ * Get outgoing edges from a node.
120
+ *
121
+ * @param nodeId - The node ID
122
+ * @returns Array of edges
123
+ */
124
+ getOutgoingEdges(nodeId: bigint): Promise<Edge[]>;
125
+ /**
126
+ * Get incoming edges to a node.
127
+ *
128
+ * @param nodeId - The node ID
129
+ * @returns Array of edges
130
+ */
131
+ getIncomingEdges(nodeId: bigint): Promise<Edge[]>;
132
+ /**
133
+ * Check if this is a read-only transaction.
134
+ */
135
+ isReadOnly(): boolean;
136
+ /**
137
+ * Check if the transaction is still active.
138
+ */
139
+ isActive(): boolean;
140
+ /**
141
+ * Ensure transaction is active.
142
+ */
143
+ private ensureActive;
144
+ /**
145
+ * Ensure transaction is writable.
146
+ */
147
+ private ensureWritable;
148
+ }
149
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,UAAU,EACV,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAEf;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAE3B;;;OAGG;gBACS,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO;IAM5E;;OAEG;IACH,MAAM,IAAI,IAAI;IAed;;OAEG;IACH,QAAQ,IAAI,IAAI;IAYhB;;;;;OAKG;IACG,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBhE;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;;;OAKG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlD;;;;;;;;OAQG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAgBnD;;;;;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 +1,298 @@
1
+ "use strict";
2
+ /**
3
+ * Transaction class for Lattice TypeScript bindings.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Transaction = void 0;
7
+ /**
8
+ * A database transaction.
9
+ *
10
+ * Transactions provide atomic, isolated access to the database.
11
+ * Use `Database.read()` or `Database.write()` to create transactions.
12
+ */
13
+ class Transaction {
14
+ ffi;
15
+ txnHandle;
16
+ readOnly;
17
+ committed = false;
18
+ rolledBack = false;
19
+ /**
20
+ * Create a new transaction wrapper.
21
+ * @internal
22
+ */
23
+ constructor(ffi, txnHandle, readOnly) {
24
+ this.ffi = ffi;
25
+ this.txnHandle = txnHandle;
26
+ this.readOnly = readOnly;
27
+ }
28
+ /**
29
+ * Commit the transaction.
30
+ */
31
+ commit() {
32
+ if (this.committed) {
33
+ throw new Error('Transaction already committed');
34
+ }
35
+ if (this.rolledBack) {
36
+ throw new Error('Transaction already rolled back');
37
+ }
38
+ if (this.txnHandle === null) {
39
+ throw new Error('Transaction closed');
40
+ }
41
+ this.ffi.commit(this.txnHandle);
42
+ this.txnHandle = null;
43
+ this.committed = true;
44
+ }
45
+ /**
46
+ * Rollback the transaction.
47
+ */
48
+ rollback() {
49
+ if (this.committed) {
50
+ throw new Error('Transaction already committed');
51
+ }
52
+ if (this.rolledBack || this.txnHandle === null) {
53
+ return;
54
+ }
55
+ this.ffi.rollback(this.txnHandle);
56
+ this.txnHandle = null;
57
+ this.rolledBack = true;
58
+ }
59
+ /**
60
+ * Create a new node.
61
+ *
62
+ * @param options - Node creation options
63
+ * @returns The created node
64
+ */
65
+ async createNode(options = {}) {
66
+ this.ensureWritable();
67
+ const labels = options.labels ?? [];
68
+ const properties = options.properties ?? {};
69
+ if (labels.length > 1) {
70
+ throw new Error('Multiple labels are not yet supported. Pass at most one label.');
71
+ }
72
+ const firstLabel = labels[0] ?? '';
73
+ const nodeId = this.ffi.createNode(this.txnHandle, firstLabel);
74
+ // Set properties
75
+ for (const [key, value] of Object.entries(properties)) {
76
+ this.ffi.setProperty(this.txnHandle, nodeId, key, value);
77
+ }
78
+ return {
79
+ id: nodeId,
80
+ labels,
81
+ properties,
82
+ };
83
+ }
84
+ /**
85
+ * Delete a node.
86
+ *
87
+ * @param nodeId - ID of the node to delete
88
+ */
89
+ async deleteNode(nodeId) {
90
+ this.ensureWritable();
91
+ this.ffi.deleteNode(this.txnHandle, nodeId);
92
+ }
93
+ /**
94
+ * Check if a node exists.
95
+ *
96
+ * @param nodeId - The node ID
97
+ * @returns True if the node exists
98
+ */
99
+ async nodeExists(nodeId) {
100
+ this.ensureActive();
101
+ return this.ffi.nodeExists(this.txnHandle, nodeId);
102
+ }
103
+ /**
104
+ * Get a node by ID.
105
+ *
106
+ * Note: The returned node's `properties` will be empty. Use
107
+ * `getProperty()` to fetch individual properties by key.
108
+ *
109
+ * @param nodeId - The node ID
110
+ * @returns The node, or null if not found
111
+ */
112
+ async getNode(nodeId) {
113
+ this.ensureActive();
114
+ if (!this.ffi.nodeExists(this.txnHandle, nodeId)) {
115
+ return null;
116
+ }
117
+ const labels = this.ffi.getNodeLabels(this.txnHandle, nodeId);
118
+ return {
119
+ id: nodeId,
120
+ labels,
121
+ properties: {},
122
+ };
123
+ }
124
+ /**
125
+ * Set a property on a node.
126
+ *
127
+ * @param nodeId - The node ID
128
+ * @param key - Property key
129
+ * @param value - Property value
130
+ */
131
+ async setProperty(nodeId, key, value) {
132
+ this.ensureWritable();
133
+ this.ffi.setProperty(this.txnHandle, nodeId, key, value);
134
+ }
135
+ /**
136
+ * Get a property from a node.
137
+ *
138
+ * @param nodeId - The node ID
139
+ * @param key - Property key
140
+ * @returns The property value, or null if not found
141
+ */
142
+ async getProperty(nodeId, key) {
143
+ this.ensureActive();
144
+ return this.ffi.getProperty(this.txnHandle, nodeId, key);
145
+ }
146
+ /**
147
+ * Set a vector embedding on a node.
148
+ *
149
+ * @param nodeId - The node ID
150
+ * @param key - Vector property key
151
+ * @param vector - Vector data
152
+ */
153
+ async setVector(nodeId, key, vector) {
154
+ this.ensureWritable();
155
+ this.ffi.setVector(this.txnHandle, nodeId, key, vector);
156
+ }
157
+ /**
158
+ * Batch insert multiple nodes with vectors in a single call.
159
+ *
160
+ * @param label - Label for all nodes
161
+ * @param vectors - Array of vectors (one per node)
162
+ * @returns Array of created node IDs
163
+ */
164
+ async batchInsert(label, vectors) {
165
+ this.ensureWritable();
166
+ const nodes = vectors.map((v) => ({ label, vector: v }));
167
+ return this.ffi.batchInsert(this.txnHandle, nodes);
168
+ }
169
+ /**
170
+ * Index text for full-text search.
171
+ *
172
+ * @param nodeId - The node ID
173
+ * @param text - Text to index
174
+ */
175
+ async ftsIndex(nodeId, text) {
176
+ this.ensureWritable();
177
+ this.ffi.ftsIndex(this.txnHandle, nodeId, text);
178
+ }
179
+ /**
180
+ * Create an edge between two nodes.
181
+ *
182
+ * @param sourceId - Source node ID
183
+ * @param targetId - Target node ID
184
+ * @param edgeType - Edge type/label
185
+ * @param options - Edge creation options
186
+ * @returns The created edge
187
+ */
188
+ async createEdge(sourceId, targetId, edgeType, options = {}) {
189
+ this.ensureWritable();
190
+ if (options.properties && Object.keys(options.properties).length > 0) {
191
+ throw new Error('Edge properties are not yet supported');
192
+ }
193
+ const edgeId = this.ffi.createEdge(this.txnHandle, sourceId, targetId, edgeType);
194
+ return {
195
+ id: edgeId,
196
+ sourceId,
197
+ targetId,
198
+ type: edgeType,
199
+ properties: {},
200
+ };
201
+ }
202
+ /**
203
+ * Delete an edge.
204
+ *
205
+ * @param sourceId - Source node ID
206
+ * @param targetId - Target node ID
207
+ * @param edgeType - Edge type
208
+ */
209
+ async deleteEdge(sourceId, targetId, edgeType) {
210
+ this.ensureWritable();
211
+ this.ffi.deleteEdge(this.txnHandle, sourceId, targetId, edgeType);
212
+ }
213
+ /**
214
+ * Get outgoing edges from a node.
215
+ *
216
+ * @param nodeId - The node ID
217
+ * @returns Array of edges
218
+ */
219
+ async getOutgoingEdges(nodeId) {
220
+ this.ensureActive();
221
+ const resultHandle = this.ffi.getOutgoingEdges(this.txnHandle, nodeId);
222
+ try {
223
+ const count = this.ffi.edgeResultCount(resultHandle);
224
+ const edges = [];
225
+ for (let i = 0; i < count; i++) {
226
+ const e = this.ffi.edgeResultGet(resultHandle, i);
227
+ edges.push({
228
+ sourceId: e.source,
229
+ targetId: e.target,
230
+ type: e.edgeType,
231
+ properties: {},
232
+ });
233
+ }
234
+ return edges;
235
+ }
236
+ finally {
237
+ this.ffi.edgeResultFree(resultHandle);
238
+ }
239
+ }
240
+ /**
241
+ * Get incoming edges to a node.
242
+ *
243
+ * @param nodeId - The node ID
244
+ * @returns Array of edges
245
+ */
246
+ async getIncomingEdges(nodeId) {
247
+ this.ensureActive();
248
+ const resultHandle = this.ffi.getIncomingEdges(this.txnHandle, nodeId);
249
+ try {
250
+ const count = this.ffi.edgeResultCount(resultHandle);
251
+ const edges = [];
252
+ for (let i = 0; i < count; i++) {
253
+ const e = this.ffi.edgeResultGet(resultHandle, i);
254
+ edges.push({
255
+ sourceId: e.source,
256
+ targetId: e.target,
257
+ type: e.edgeType,
258
+ properties: {},
259
+ });
260
+ }
261
+ return edges;
262
+ }
263
+ finally {
264
+ this.ffi.edgeResultFree(resultHandle);
265
+ }
266
+ }
267
+ /**
268
+ * Check if this is a read-only transaction.
269
+ */
270
+ isReadOnly() {
271
+ return this.readOnly;
272
+ }
273
+ /**
274
+ * Check if the transaction is still active.
275
+ */
276
+ isActive() {
277
+ return !this.committed && !this.rolledBack && this.txnHandle !== null;
278
+ }
279
+ /**
280
+ * Ensure transaction is active.
281
+ */
282
+ ensureActive() {
283
+ if (!this.isActive()) {
284
+ throw new Error('Transaction is not active');
285
+ }
286
+ }
287
+ /**
288
+ * Ensure transaction is writable.
289
+ */
290
+ ensureWritable() {
291
+ this.ensureActive();
292
+ if (this.readOnly) {
293
+ throw new Error('Cannot write in read-only transaction');
294
+ }
295
+ }
296
+ }
297
+ exports.Transaction = Transaction;
298
+ //# sourceMappingURL=transaction.js.map
@@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YACrD,MAAM,KAAK,GAAW,EAAE,CAAC;YACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBAClD,KAAK,CAAC,IAAI,CAAC;oBACT,QAAQ,EAAE,CAAC,CAAC,MAAM;oBAClB,QAAQ,EAAE,CAAC,CAAC,MAAM;oBAClB,IAAI,EAAE,CAAC,CAAC,QAAQ;oBAChB,UAAU,EAAE,EAAE;iBACf,CAAC,CAAC;YACL,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC;IACxE,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF;AA5UD,kCA4UC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Type definitions for Lattice TypeScript bindings.
3
+ */
4
+ /**
5
+ * Property value types supported by Lattice.
6
+ */
7
+ export type PropertyValue = null | boolean | number | string | Uint8Array | PropertyValue[] | {
8
+ [key: string]: PropertyValue;
9
+ };
10
+ /**
11
+ * A node in the graph.
12
+ */
13
+ export interface Node {
14
+ /** Unique node identifier */
15
+ id: bigint;
16
+ /** Node labels */
17
+ labels: string[];
18
+ /** Node properties */
19
+ properties: Record<string, PropertyValue>;
20
+ }
21
+ /**
22
+ * An edge in the graph.
23
+ */
24
+ export interface Edge {
25
+ /** Unique edge identifier (not available on traversal results) */
26
+ id?: bigint;
27
+ /** Source node ID */
28
+ sourceId: bigint;
29
+ /** Target node ID */
30
+ targetId: bigint;
31
+ /** Edge type/label */
32
+ type: string;
33
+ /** Edge properties */
34
+ properties: Record<string, PropertyValue>;
35
+ }
36
+ /**
37
+ * Wrapper for property values.
38
+ */
39
+ export declare class Value {
40
+ readonly value: PropertyValue;
41
+ constructor(value: PropertyValue);
42
+ static null(): Value;
43
+ static bool(v: boolean): Value;
44
+ static int(v: number): Value;
45
+ static float(v: number): Value;
46
+ static string(v: string): Value;
47
+ static bytes(v: Uint8Array): Value;
48
+ }
49
+ /**
50
+ * Result of a Cypher query.
51
+ */
52
+ export interface QueryResult {
53
+ /** Column names */
54
+ columns: string[];
55
+ /** Result rows */
56
+ rows: Record<string, PropertyValue>[];
57
+ }
58
+ /**
59
+ * Result of a vector similarity search.
60
+ */
61
+ export interface VectorSearchResult {
62
+ /** Node ID */
63
+ nodeId: bigint;
64
+ /** Distance to query vector */
65
+ distance: number;
66
+ /** Optional full node data */
67
+ node?: Node;
68
+ }
69
+ /**
70
+ * Options for creating a node.
71
+ */
72
+ export interface CreateNodeOptions {
73
+ /** Node labels */
74
+ labels?: string[];
75
+ /** Node properties */
76
+ properties?: Record<string, PropertyValue>;
77
+ }
78
+ /**
79
+ * Options for creating an edge.
80
+ */
81
+ export interface CreateEdgeOptions {
82
+ /** Edge properties */
83
+ properties?: Record<string, PropertyValue>;
84
+ }
85
+ /**
86
+ * Options for vector search.
87
+ */
88
+ export interface VectorSearchOptions {
89
+ /** Number of results */
90
+ k?: number;
91
+ /** HNSW ef parameter */
92
+ efSearch?: number;
93
+ }
94
+ /**
95
+ * Options for full-text search.
96
+ */
97
+ export interface FtsSearchOptions {
98
+ /** Maximum results */
99
+ limit?: number;
100
+ }
101
+ /**
102
+ * API format for HTTP embedding services.
103
+ */
104
+ export declare enum EmbeddingApiFormat {
105
+ Ollama = 0,
106
+ OpenAI = 1
107
+ }
108
+ /**
109
+ * Configuration for an HTTP embedding client.
110
+ */
111
+ export interface EmbeddingConfig {
112
+ /** HTTP endpoint URL */
113
+ endpoint: string;
114
+ /** Model name (default: "nomic-embed-text") */
115
+ model?: string;
116
+ /** API format (default: Ollama) */
117
+ apiFormat?: EmbeddingApiFormat;
118
+ /** API key for authentication (null for no auth) */
119
+ apiKey?: string;
120
+ /** Request timeout in milliseconds (0 = default 30s) */
121
+ timeoutMs?: number;
122
+ }
123
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,aAAa,EAAE,GACf;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,kEAAkE;IAClE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,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;AACH,MAAM,WAAW,mBAAmB;IAClC,wBAAwB;IACxB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,MAAM,IAAI;IACV,MAAM,IAAI;CACX;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for Lattice TypeScript bindings.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EmbeddingApiFormat = exports.Value = void 0;
7
+ /**
8
+ * Wrapper for property values.
9
+ */
10
+ class Value {
11
+ value;
12
+ constructor(value) {
13
+ this.value = value;
14
+ }
15
+ static null() {
16
+ return new Value(null);
17
+ }
18
+ static bool(v) {
19
+ return new Value(v);
20
+ }
21
+ static int(v) {
22
+ return new Value(v);
23
+ }
24
+ static float(v) {
25
+ return new Value(v);
26
+ }
27
+ static string(v) {
28
+ return new Value(v);
29
+ }
30
+ static bytes(v) {
31
+ return new Value(v);
32
+ }
33
+ }
34
+ exports.Value = Value;
35
+ /**
36
+ * API format for HTTP embedding services.
37
+ */
38
+ var EmbeddingApiFormat;
39
+ (function (EmbeddingApiFormat) {
40
+ EmbeddingApiFormat[EmbeddingApiFormat["Ollama"] = 0] = "Ollama";
41
+ EmbeddingApiFormat[EmbeddingApiFormat["OpenAI"] = 1] = "OpenAI";
42
+ })(EmbeddingApiFormat || (exports.EmbeddingApiFormat = EmbeddingApiFormat = {}));
43
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0CH;;GAEG;AACH,MAAa,KAAK;IACY;IAA5B,YAA4B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IAEpD,MAAM,CAAC,IAAI;QACT,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,CAAU;QACpB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,CAAS;QAClB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,CAAS;QACpB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,CAAS;QACrB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,CAAa;QACxB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;CACF;AA1BD,sBA0BC;AA4DD;;GAEG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+DAAU,CAAA;IACV,+DAAU,CAAA;AACZ,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B"}