ultipa 6.0.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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/client.d.ts +194 -0
  4. package/dist/client.js +390 -0
  5. package/dist/config.d.ts +65 -0
  6. package/dist/config.js +135 -0
  7. package/dist/connection.d.ts +30 -0
  8. package/dist/connection.js +190 -0
  9. package/dist/errors.d.ts +99 -0
  10. package/dist/errors.js +237 -0
  11. package/dist/index.d.ts +14 -0
  12. package/dist/index.js +88 -0
  13. package/dist/printers.d.ts +33 -0
  14. package/dist/printers.js +312 -0
  15. package/dist/proto/gqldb.proto +632 -0
  16. package/dist/response.d.ts +256 -0
  17. package/dist/response.js +723 -0
  18. package/dist/services/admin-service.d.ts +40 -0
  19. package/dist/services/admin-service.js +115 -0
  20. package/dist/services/bulk-import-service.d.ts +35 -0
  21. package/dist/services/bulk-import-service.js +108 -0
  22. package/dist/services/converters.d.ts +57 -0
  23. package/dist/services/converters.js +254 -0
  24. package/dist/services/data-service.d.ts +44 -0
  25. package/dist/services/data-service.js +206 -0
  26. package/dist/services/graph-service.d.ts +32 -0
  27. package/dist/services/graph-service.js +127 -0
  28. package/dist/services/health-service.d.ts +50 -0
  29. package/dist/services/health-service.js +78 -0
  30. package/dist/services/index.d.ts +13 -0
  31. package/dist/services/index.js +30 -0
  32. package/dist/services/query-service.d.ts +39 -0
  33. package/dist/services/query-service.js +112 -0
  34. package/dist/services/service-context.d.ts +39 -0
  35. package/dist/services/service-context.js +73 -0
  36. package/dist/services/session-service.d.ts +24 -0
  37. package/dist/services/session-service.js +66 -0
  38. package/dist/services/transaction-service.d.ts +33 -0
  39. package/dist/services/transaction-service.js +100 -0
  40. package/dist/services.d.ts +28 -0
  41. package/dist/services.js +122 -0
  42. package/dist/session.d.ts +45 -0
  43. package/dist/session.js +75 -0
  44. package/dist/transaction.d.ts +42 -0
  45. package/dist/transaction.js +89 -0
  46. package/dist/types/bulk_import.d.ts +53 -0
  47. package/dist/types/bulk_import.js +6 -0
  48. package/dist/types/data_types.d.ts +116 -0
  49. package/dist/types/data_types.js +122 -0
  50. package/dist/types/enums.d.ts +59 -0
  51. package/dist/types/enums.js +67 -0
  52. package/dist/types/graph_models.d.ts +54 -0
  53. package/dist/types/graph_models.js +6 -0
  54. package/dist/types/index.d.ts +11 -0
  55. package/dist/types/index.js +36 -0
  56. package/dist/types/metadata.d.ts +60 -0
  57. package/dist/types/metadata.js +6 -0
  58. package/dist/types/schema.d.ts +31 -0
  59. package/dist/types/schema.js +6 -0
  60. package/dist/types/typed_value.d.ts +25 -0
  61. package/dist/types/typed_value.js +1176 -0
  62. package/dist/types/wrappers.d.ts +23 -0
  63. package/dist/types/wrappers.js +39 -0
  64. package/dist/types.d.ts +7 -0
  65. package/dist/types.js +24 -0
  66. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 GQLDB Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Ultipa Node.js Driver
2
+
3
+ Official Node.js/TypeScript driver for Ultipa graph database (GQL).
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 18+
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install ultipa
13
+ ```
14
+
15
+ > **Note:** This is the v6.x driver for Ultipa GQL. If you are using Ultipa v4.x or v5.x, please install [ultipa@5.2.1](https://www.npmjs.com/package/ultipa/v/5.2.1) (`npm install ultipa@5.2.1`).
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { GqldbClient, ConfigBuilder } from 'ultipa';
21
+
22
+ async function main() {
23
+ const client = new GqldbClient(
24
+ new ConfigBuilder()
25
+ .hosts('localhost:60061')
26
+ .username('admin')
27
+ .password('password')
28
+ .defaultGraph('myGraph')
29
+ .build()
30
+ );
31
+
32
+ try {
33
+ await client.login('admin', 'password');
34
+
35
+ const response = await client.gql('MATCH (n) RETURN n LIMIT 10');
36
+
37
+ console.log('Rows:', response.rowCount);
38
+ console.log('Columns:', response.columns);
39
+ console.log('Data:', response.toObjects());
40
+ } finally {
41
+ await client.close();
42
+ }
43
+ }
44
+
45
+ main().catch(console.error);
46
+ ```
47
+
48
+ ## Features
49
+
50
+ - GQL query execution with parameters
51
+ - Streaming results for large datasets
52
+ - Transaction support (begin, commit, rollback)
53
+ - Graph management (create, drop, list)
54
+ - Bulk import for high-throughput loading
55
+ - Algorithm support (CALL algo.pagerank, algo.degree, etc.)
56
+ - TypeScript support
57
+ - Health checks
58
+
59
+ ## Documentation
60
+
61
+ See [GUIDE.md](GUIDE.md) for detailed usage.
62
+
63
+ ## License
64
+
65
+ [MIT License](LICENSE)
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Main client for GQLDB Node.js driver.
3
+ */
4
+ import { EventEmitter } from 'events';
5
+ import { GqldbConfig } from './config';
6
+ import { Response, InsertNodesResult, InsertEdgesResult, DeleteResult, ExportNodesResult, ExportEdgesResult, ExportConfig, ExportChunk } from './response';
7
+ import { Session } from './session';
8
+ import { Transaction } from './transaction';
9
+ import { GraphInfo, GraphType, HealthStatus, CacheStats, CacheType, Statistics, CompactResult, ComputeTopologyResult, NodeData, EdgeData, BulkCreateNodesOptions, BulkCreateEdgesOptions, BulkImportOptions, BulkImportSession, CheckpointResult, EndBulkImportResult, AbortBulkImportResult, BulkImportStatus, TransactionInfo } from './types';
10
+ /** Configuration for a query */
11
+ export interface QueryConfig {
12
+ graphName?: string;
13
+ parameters?: Record<string, any>;
14
+ transactionId?: number;
15
+ timeout?: number;
16
+ readOnly?: boolean;
17
+ /** Max paths to return from path queries (0 = unlimited) */
18
+ maxPathResults?: number;
19
+ }
20
+ /** Configuration for insert nodes */
21
+ export interface InsertNodesConfig {
22
+ options?: BulkCreateNodesOptions;
23
+ bulkImportSessionId?: string;
24
+ }
25
+ /** Configuration for insert edges */
26
+ export interface InsertEdgesConfig {
27
+ options?: BulkCreateEdgesOptions;
28
+ bulkImportSessionId?: string;
29
+ }
30
+ /**
31
+ * Health watcher interface for streaming health updates.
32
+ * Emits 'status' events with HealthStatus and 'error' events on failure.
33
+ */
34
+ export interface HealthWatcher extends EventEmitter {
35
+ /** Stop watching health updates */
36
+ stop(): void;
37
+ }
38
+ /** Main client for interacting with GQLDB */
39
+ export declare class GqldbClient {
40
+ private config;
41
+ private clients;
42
+ private sessions;
43
+ private txManager;
44
+ private closed;
45
+ private sessionService;
46
+ private queryService;
47
+ private graphService;
48
+ private transactionService;
49
+ private dataService;
50
+ private healthService;
51
+ private adminService;
52
+ private bulkImportService;
53
+ /** Get session metadata for authenticated requests */
54
+ private getSessionMetadata;
55
+ constructor(config: GqldbConfig);
56
+ /** Close the client and all connections */
57
+ close(): Promise<void>;
58
+ /** Authenticate the user and create a session */
59
+ login(username: string, password: string): Promise<Session>;
60
+ /** Terminate the current session */
61
+ logout(): Promise<void>;
62
+ /** Check the connection and return the latency in nanoseconds */
63
+ ping(): Promise<number>;
64
+ /** Execute a GQL query and return the result */
65
+ gql(query: string, config?: QueryConfig): Promise<Response>;
66
+ /** Execute a GQL query and stream the results */
67
+ gqlStream(query: string, config?: QueryConfig, callback?: (response: Response) => void): Promise<void>;
68
+ /** Return the execution plan for a query */
69
+ explain(query: string, config?: QueryConfig): Promise<string>;
70
+ /** Execute a query with profiling and return statistics */
71
+ profile(query: string, config?: QueryConfig): Promise<string>;
72
+ /** Create a new graph */
73
+ createGraph(name: string, graphType?: GraphType, description?: string): Promise<void>;
74
+ /** Delete a graph */
75
+ dropGraph(name: string, ifExists?: boolean): Promise<void>;
76
+ /** Set the current graph for the session */
77
+ useGraph(name: string): Promise<void>;
78
+ /** Return all available graphs */
79
+ listGraphs(): Promise<GraphInfo[]>;
80
+ /** Return information about a specific graph */
81
+ getGraphInfo(name: string): Promise<GraphInfo>;
82
+ /** Start a new transaction */
83
+ beginTransaction(graphName: string, readOnly?: boolean, timeout?: number): Promise<Transaction>;
84
+ /** Commit a transaction */
85
+ commit(transactionId: number): Promise<boolean>;
86
+ /** Rollback a transaction */
87
+ rollback(transactionId: number): Promise<boolean>;
88
+ /** Return active transactions */
89
+ listTransactions(): Promise<TransactionInfo[]>;
90
+ /** Execute a function within a transaction */
91
+ withTransaction<T>(graphName: string, fn: (txId: number) => Promise<T>, readOnly?: boolean): Promise<T>;
92
+ /** Insert multiple nodes into a graph */
93
+ insertNodes(graphName: string, nodes: NodeData[], config?: InsertNodesConfig): Promise<InsertNodesResult>;
94
+ /** Insert multiple edges into a graph */
95
+ insertEdges(graphName: string, edges: EdgeData[], config?: InsertEdgesConfig): Promise<InsertEdgesResult>;
96
+ /** Delete nodes from a graph */
97
+ deleteNodes(graphName: string, nodeIds?: string[], labels?: string[], where?: string): Promise<DeleteResult>;
98
+ /** Delete edges from a graph */
99
+ deleteEdges(graphName: string, edgeIds?: string[], label?: string, where?: string): Promise<DeleteResult>;
100
+ /**
101
+ * Export graph data in JSON Lines format (streaming).
102
+ * @param config Export configuration
103
+ * @param callback Callback for each exported chunk
104
+ */
105
+ export(config: ExportConfig, callback?: (chunk: ExportChunk) => void): Promise<void>;
106
+ /**
107
+ * Stream nodes from a graph
108
+ * @deprecated Use export() with ExportConfig instead
109
+ */
110
+ exportNodes(graphName: string, labels?: string[], limit?: number, callback?: (result: ExportNodesResult) => void): Promise<void>;
111
+ /**
112
+ * Stream edges from a graph
113
+ * @deprecated Use export() with ExportConfig instead
114
+ */
115
+ exportEdges(graphName: string, labels?: string[], limit?: number, callback?: (result: ExportEdgesResult) => void): Promise<void>;
116
+ /** Check the health of a service */
117
+ healthCheck(service?: string): Promise<HealthStatus>;
118
+ /**
119
+ * Watch health status changes via server-side streaming.
120
+ * Returns a HealthWatcher that emits 'status' events with HealthStatus values.
121
+ * Call stop() to cancel the stream.
122
+ *
123
+ * @param service - Optional service name to watch
124
+ * @returns HealthWatcher - EventEmitter with stop() method
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const watcher = client.watch();
129
+ * watcher.on('status', (status: HealthStatus) => {
130
+ * console.log('Health status:', status);
131
+ * });
132
+ * watcher.on('error', (err) => {
133
+ * console.error('Watch error:', err);
134
+ * });
135
+ * watcher.on('end', () => {
136
+ * console.log('Watch stream ended');
137
+ * });
138
+ * // Later, to stop watching:
139
+ * watcher.stop();
140
+ * ```
141
+ */
142
+ watch(service?: string): HealthWatcher;
143
+ /** Pre-allocate parser instances */
144
+ warmupParser(count: number): Promise<void>;
145
+ /** Return cache statistics */
146
+ getCacheStats(cacheType?: CacheType): Promise<CacheStats>;
147
+ /** Clear the specified cache */
148
+ clearCache(cacheType?: CacheType): Promise<void>;
149
+ /** Return database statistics */
150
+ getStatistics(graphName?: string): Promise<Statistics>;
151
+ /** Invalidate the RBAC permission cache */
152
+ invalidatePermissionCache(username?: string): Promise<void>;
153
+ /** Trigger manual compaction of the database storage */
154
+ compact(): Promise<CompactResult>;
155
+ /** Wait for the computing engine topology to be ready */
156
+ waitForComputeTopology(graphName: string, timeoutMs?: number): Promise<ComputeTopologyResult>;
157
+ /**
158
+ * Start a bulk import session for optimized high-throughput inserts.
159
+ * @param graphName Target graph name
160
+ * @param options Optional bulk import configuration
161
+ */
162
+ startBulkImport(graphName: string, options?: BulkImportOptions): Promise<BulkImportSession>;
163
+ /**
164
+ * @deprecated Checkpoint is no longer needed. Use endBulkImport() which performs a final flush.
165
+ */
166
+ checkpoint(sessionId: string): Promise<CheckpointResult>;
167
+ /**
168
+ * End the bulk import session with a final checkpoint.
169
+ * @param sessionId Bulk import session ID
170
+ */
171
+ endBulkImport(sessionId: string): Promise<EndBulkImportResult>;
172
+ /**
173
+ * Cancel the bulk import session without final sync.
174
+ * @param sessionId Bulk import session ID
175
+ */
176
+ abortBulkImport(sessionId: string): Promise<AbortBulkImportResult>;
177
+ /**
178
+ * Return the current status of a bulk import session.
179
+ * @param sessionId Bulk import session ID
180
+ */
181
+ getBulkImportStatus(sessionId: string): Promise<BulkImportStatus>;
182
+ /** Get the current session */
183
+ getSession(): Session | null;
184
+ /** Check if there is an active session */
185
+ isLoggedIn(): boolean;
186
+ /** Get the client configuration */
187
+ getConfig(): GqldbConfig;
188
+ /** Whether this client is connected to a cluster deployment */
189
+ get isCluster(): boolean;
190
+ /** Get the cluster ID (empty string if not a cluster) */
191
+ get clusterId(): string;
192
+ /** Get the partition count (0 if not a cluster) */
193
+ get partitionCount(): number;
194
+ }