@ultipa-graph/ultipa-driver 6.0.5 → 6.0.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 CHANGED
@@ -58,8 +58,8 @@ main().catch(console.error);
58
58
 
59
59
  ## Documentation
60
60
 
61
- See [GUIDE.md](https://github.com/ultipa/gqldb-drivers/blob/main/nodejs/GUIDE.md) for detailed usage.
61
+ See [Quick Start](https://www.ultipa.com/docs/drivers/nodejs-quick-start) for detailed usage.
62
62
 
63
63
  ## License
64
64
 
65
- [MIT License](https://github.com/ultipa/gqldb-drivers/blob/main/nodejs/LICENSE)
65
+ MIT License
package/dist/client.d.ts CHANGED
@@ -6,7 +6,7 @@ import { GqldbConfig } from './config';
6
6
  import { Response, InsertNodesResult, InsertEdgesResult, DeleteResult, ExportNodesResult, ExportEdgesResult, ExportConfig, ExportChunk } from './response';
7
7
  import { Session } from './session';
8
8
  import { Transaction } from './transaction';
9
- import { GraphInfo, GraphType, HealthStatus, CacheStats, CacheType, Statistics, CompactResult, ComputeTopologyResult, SystemMetrics, NodeData, EdgeData, BulkCreateNodesOptions, BulkCreateEdgesOptions, BulkImportOptions, BulkImportSession, CheckpointResult, EndBulkImportResult, AbortBulkImportResult, BulkImportStatus, TransactionInfo } from './types';
9
+ import { GraphInfo, GraphType, HealthStatus, CacheStats, CacheType, Statistics, CompactResult, ComputeTopologyResult, SystemMetrics, NodeData, EdgeData, BulkCreateNodesOptions, BulkCreateEdgesOptions, BulkImportOptions, BulkImportSession, CheckpointResult, EndBulkImportResult, AbortBulkImportResult, BulkImportStatus, TransactionInfo, DBType, InsertType, LabelInfo, NodeTypeInfo, EdgeTypeInfo, ConvPropertyDef, IndexProperty, IndexInfo, FulltextInfo, TaskInfo, ProcessInfo, GraphStats, AlgoInfo } from './types';
10
10
  /** Configuration for a query */
11
11
  export interface QueryConfig {
12
12
  graphName?: string;
@@ -42,6 +42,9 @@ export declare class GqldbClient {
42
42
  private sessions;
43
43
  private txManager;
44
44
  private closed;
45
+ private storedUsername;
46
+ private storedPassword;
47
+ private storedGraph;
45
48
  private sessionService;
46
49
  private queryService;
47
50
  private graphService;
@@ -57,6 +60,12 @@ export declare class GqldbClient {
57
60
  close(): Promise<void>;
58
61
  /** Authenticate the user and create a session */
59
62
  login(username: string, password: string): Promise<Session>;
63
+ /**
64
+ * Execute fn and auto-reconnect on UNAUTHENTICATED error.
65
+ * If fn throws an UNAUTHENTICATED gRPC error and credentials are stored,
66
+ * re-login and retry fn once.
67
+ */
68
+ private withAutoReconnect;
60
69
  /** Terminate the current session */
61
70
  logout(): Promise<void>;
62
71
  /** Check the connection and return the latency in nanoseconds */
@@ -89,10 +98,10 @@ export declare class GqldbClient {
89
98
  listTransactions(): Promise<TransactionInfo[]>;
90
99
  /** Execute a function within a transaction */
91
100
  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>;
101
+ /** Insert multiple nodes into a graph using gRPC bulk insert */
102
+ insertNodesBatchAuto(graphName: string, nodes: NodeData[], config?: InsertNodesConfig): Promise<InsertNodesResult>;
103
+ /** Insert multiple edges into a graph using gRPC bulk insert */
104
+ insertEdgesBatchAuto(graphName: string, edges: EdgeData[], config?: InsertEdgesConfig): Promise<InsertEdgesResult>;
96
105
  /** Delete nodes from a graph */
97
106
  deleteNodes(graphName: string, nodeIds?: string[], labels?: string[], where?: string): Promise<DeleteResult>;
98
107
  /** Delete edges from a graph */
@@ -193,4 +202,157 @@ export declare class GqldbClient {
193
202
  get clusterId(): string;
194
203
  /** Get the partition count (0 if not a cluster) */
195
204
  get partitionCount(): number;
205
+ /** Wrap a name in backticks for safe use in GQL statements.
206
+ * Label names and property names should be quoted; graph names, index names,
207
+ * and fulltext names should NOT be wrapped in backticks. */
208
+ private static quoteLabel;
209
+ /** Wrap each label name in backticks and join with ", " */
210
+ private static quoteLabels;
211
+ /** Join names with ", " without backtick wrapping */
212
+ private static joinNames;
213
+ /** Create a new open (schema-less) graph */
214
+ createOpenGraph(name: string): Promise<Response>;
215
+ /** Create a new closed (schema-enforced) graph with node and edge label definitions */
216
+ createClosedGraph(name: string): Promise<Response>;
217
+ /**
218
+ * Create a graph if it does not already exist.
219
+ * Returns true if the graph was created, false if it already existed.
220
+ */
221
+ createGraphIfNotExist(name: string, graphType?: GraphType, description?: string): Promise<boolean>;
222
+ /** Check whether a graph with the given name exists */
223
+ hasGraph(name: string): Promise<boolean>;
224
+ /** Rename a graph */
225
+ alterGraph(graphName: string, newName: string): Promise<Response>;
226
+ /** Remove all data from a graph while keeping its structure */
227
+ truncate(graphName: string): Promise<Response>;
228
+ /** Return all labels (node and edge) in the current graph */
229
+ showLabels(): Promise<LabelInfo[]>;
230
+ /** Return all node labels in the current graph */
231
+ showNodeLabels(): Promise<LabelInfo[]>;
232
+ /** Return all edge labels in the current graph */
233
+ showEdgeLabels(): Promise<LabelInfo[]>;
234
+ /** Return all node types with their properties */
235
+ showNodeTypes(): Promise<NodeTypeInfo[]>;
236
+ /** Return all edge types with their properties */
237
+ showEdgeTypes(): Promise<EdgeTypeInfo[]>;
238
+ /** Return a specific label by name from the current graph, or null if not found */
239
+ getLabel(name: string): Promise<LabelInfo | null>;
240
+ /** Return a specific node type by name, or null if not found */
241
+ getNodeLabel(name: string): Promise<NodeTypeInfo | null>;
242
+ /** Return a specific edge type by name, or null if not found */
243
+ getEdgeLabel(name: string): Promise<EdgeTypeInfo | null>;
244
+ /** Create a node label in the current graph (closed graph) */
245
+ createNodeLabel(name: string, props?: ConvPropertyDef[]): Promise<Response>;
246
+ /** Create an edge label in the current graph (closed graph) */
247
+ createEdgeLabel(name: string, props?: ConvPropertyDef[]): Promise<Response>;
248
+ /** Drop a node label from the current graph (closed graph) */
249
+ dropNodeLabel(name: string): Promise<Response>;
250
+ /** Drop one or more edge labels from the current graph (closed graph) */
251
+ dropEdgeLabel(...names: string[]): Promise<Response>;
252
+ /**
253
+ * Create a label if it does not already exist.
254
+ * Returns true if created, false if it already existed.
255
+ */
256
+ createLabelIfNotExist(nodeOrEdge: DBType, name: string, props?: ConvPropertyDef[]): Promise<boolean>;
257
+ /** Rename a node label */
258
+ alterNodeLabel(oldName: string, newName: string): Promise<Response>;
259
+ /** Rename an edge label */
260
+ alterEdgeLabel(oldName: string, newName: string): Promise<Response>;
261
+ /** Return all available algorithms */
262
+ showAlgos(): Promise<AlgoInfo[]>;
263
+ /** Return properties for a label (node or edge) in the current graph */
264
+ showProperty(nodeOrEdge: DBType, labelName: string): Promise<ConvPropertyDef[]>;
265
+ /** Return properties for a node label */
266
+ showNodeProperty(labelName: string): Promise<ConvPropertyDef[]>;
267
+ /** Return properties for an edge label */
268
+ showEdgeProperty(labelName: string): Promise<ConvPropertyDef[]>;
269
+ /** Return a specific property definition for a label, or null if not found */
270
+ getProperty(nodeOrEdge: DBType, labelName: string, propName: string): Promise<ConvPropertyDef | null>;
271
+ /** Return a specific property definition for a node label, or null if not found */
272
+ getNodeProperty(labelName: string, propName: string): Promise<ConvPropertyDef | null>;
273
+ /** Return a specific property definition for an edge label, or null if not found */
274
+ getEdgeProperty(labelName: string, propName: string): Promise<ConvPropertyDef | null>;
275
+ /** Add properties to a label (node or edge) */
276
+ createProperty(nodeOrEdge: DBType, labelName: string, props: ConvPropertyDef[]): Promise<Response>;
277
+ /** Add properties to a node label */
278
+ createNodeProperty(labelName: string, props: ConvPropertyDef[]): Promise<Response>;
279
+ /** Add properties to an edge label */
280
+ createEdgeProperty(labelName: string, props: ConvPropertyDef[]): Promise<Response>;
281
+ /** Drop properties from a label (node or edge) */
282
+ dropProperty(nodeOrEdge: DBType, labelName: string, ...propNames: string[]): Promise<Response>;
283
+ /** Drop properties from a node label */
284
+ dropNodeProperty(labelName: string, ...propNames: string[]): Promise<Response>;
285
+ /** Drop properties from an edge label */
286
+ dropEdgeProperty(labelName: string, ...propNames: string[]): Promise<Response>;
287
+ /**
288
+ * Create properties on a label if they do not already exist.
289
+ * Returns true if any properties were created, false if all already existed.
290
+ */
291
+ createPropertyIfNotExist(nodeOrEdge: DBType, labelName: string, props: ConvPropertyDef[]): Promise<boolean>;
292
+ /** Create a NOT NULL constraint on a property */
293
+ createNotNullConstraint(nodeOrEdge: DBType, labelName: string, propName: string): Promise<Response>;
294
+ /** Create a UNIQUE constraint on one or more properties */
295
+ createUniqueConstraint(nodeOrEdge: DBType, labelName: string, ...propNames: string[]): Promise<Response>;
296
+ /** Remove a NOT NULL constraint from a property */
297
+ dropNotNullConstraint(nodeOrEdge: DBType, labelName: string, propName: string): Promise<Response>;
298
+ /** Remove a UNIQUE constraint from one or more properties */
299
+ dropUniqueConstraint(nodeOrEdge: DBType, labelName: string, ...propNames: string[]): Promise<Response>;
300
+ /** Return all indexes in the current graph */
301
+ showIndex(): Promise<IndexInfo[]>;
302
+ /** Return all node indexes in the current graph */
303
+ showNodeIndex(): Promise<IndexInfo[]>;
304
+ /** Return all edge indexes in the current graph */
305
+ showEdgeIndex(): Promise<IndexInfo[]>;
306
+ /** Create an index on a node label */
307
+ createNodeIndex(indexName: string, labelName: string, props: IndexProperty[]): Promise<Response>;
308
+ /** Create an index on an edge label */
309
+ createEdgeIndex(indexName: string, labelName: string, props: IndexProperty[]): Promise<Response>;
310
+ /** Drop a node index by name */
311
+ dropNodeIndex(indexName: string): Promise<Response>;
312
+ /** Drop an edge index by name */
313
+ dropEdgeIndex(indexName: string): Promise<Response>;
314
+ /** Return all fulltext indexes in the current graph */
315
+ showFulltext(): Promise<FulltextInfo[]>;
316
+ /** Return all node fulltext indexes */
317
+ showNodeFulltext(): Promise<FulltextInfo[]>;
318
+ /** Return all edge fulltext indexes */
319
+ showEdgeFulltext(): Promise<FulltextInfo[]>;
320
+ /** Create a fulltext index on a node label */
321
+ createNodeFulltext(indexName: string, labelName: string, props: string[]): Promise<Response>;
322
+ /** Create a fulltext index on an edge label */
323
+ createEdgeFulltext(indexName: string, labelName: string, props: string[]): Promise<Response>;
324
+ /** Drop a node fulltext index by name */
325
+ dropNodeFulltext(indexName: string): Promise<Response>;
326
+ /** Drop an edge fulltext index by name */
327
+ dropEdgeFulltext(indexName: string): Promise<Response>;
328
+ /** Return all tasks in the current graph */
329
+ showTasks(): Promise<TaskInfo[]>;
330
+ /** Delete a task by ID */
331
+ deleteTask(taskId: string): Promise<Response>;
332
+ /** Stop a running task by ID */
333
+ stopTask(taskId: string): Promise<Response>;
334
+ /** Insert nodes using GQL INSERT syntax */
335
+ /**
336
+ * Insert nodes using GQL INSERT syntax with RETURN clause.
337
+ * GQL: INSERT (n0:Label {p1: v1}), (n1:Label {p2: v2}) RETURN n0, n1
338
+ * If NodeData.id is set (non-empty), includes it as _id property in the GQL.
339
+ * Returns the raw Response containing the inserted nodes in columns n0, n1, etc.
340
+ */
341
+ insertNodes(nodes: NodeData[], insertType?: InsertType): Promise<Response>;
342
+ /**
343
+ * Insert edges using GQL INSERT syntax with RETURN clause.
344
+ * Each edge is inserted individually using MATCH + INSERT to resolve node IDs.
345
+ * GQL: MATCH (src WHERE id(src) = 'from'), (dst WHERE id(dst) = 'to')
346
+ * INSERT (src)-[e0:Label {p1: v1}]->(dst) RETURN e0
347
+ * Returns a merged Response containing all inserted edges in columns e0, e1, etc.
348
+ */
349
+ insertEdges(edges: EdgeData[], insertType?: InsertType): Promise<Response>;
350
+ /** Return currently running processes (queries) */
351
+ top(): Promise<ProcessInfo[]>;
352
+ /** Terminate a running query by its query ID */
353
+ kill(queryId: string): Promise<Response>;
354
+ /** Return statistics for the current graph using db.stats() */
355
+ stats(): Promise<GraphStats>;
356
+ /** Send a ping to the server and return the latency in nanoseconds */
357
+ test(): Promise<number>;
196
358
  }