@anvailabs/proximadb-client 0.3.0 → 0.4.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.
package/src/graph.ts CHANGED
@@ -35,15 +35,18 @@ export interface GraphHttpClient {
35
35
  url(): string;
36
36
  // Typed transport seams (route through the generated client).
37
37
  createGraphRequest(body: Record<string, unknown>): Promise<unknown>;
38
- getGraphRequest(graphId: string): Promise<unknown>;
38
+ getGraphRequest(graphId: string): Promise<GraphInfo>;
39
39
  getGraphStatsRequest(graphId: string): Promise<unknown>;
40
40
  createNodeRequest(graphId: string, body: Record<string, unknown>): Promise<unknown>;
41
41
  batchCreateNodesRequest(graphId: string, body: Record<string, unknown>): Promise<unknown>;
42
- getNodeRequest(graphId: string, nodeId: string): Promise<unknown>;
42
+ getNodeRequest(graphId: string, nodeId: string): Promise<GraphNode>;
43
43
  deleteNodeRequest(graphId: string, nodeId: string): Promise<void>;
44
44
  createEdgeRequest(graphId: string, body: Record<string, unknown>): Promise<unknown>;
45
45
  batchCreateEdgesRequest(graphId: string, body: Record<string, unknown>): Promise<unknown>;
46
- traverseGraphRequest(graphId: string, body: Record<string, unknown>): Promise<unknown>;
46
+ traverseGraphRequest(
47
+ graphId: string,
48
+ body: Record<string, unknown>,
49
+ ): Promise<TraversalResult>;
47
50
  }
48
51
 
49
52
  // ============================================================================
@@ -471,11 +474,10 @@ export class TraversalBuilder {
471
474
  void this.traversalDirection;
472
475
  void this.filterExpr;
473
476
 
474
- const data = await this.handle.getClient().traverseGraphRequest(
477
+ return this.handle.getClient().traverseGraphRequest(
475
478
  this.handle.getName(),
476
479
  request,
477
480
  );
478
- return data as TraversalResult;
479
481
  }
480
482
  }
481
483
 
@@ -549,8 +551,20 @@ export class GraphHandle {
549
551
  const response = (await this.client.batchCreateNodesRequest(
550
552
  this.graphName,
551
553
  request as unknown as Record<string, unknown>,
552
- )) as { data?: { count?: number }; count?: number } | null;
553
- return response?.data?.count ?? response?.count ?? normalized.length;
554
+ )) as {
555
+ data?: { created_count?: number; count?: number };
556
+ created_count?: number;
557
+ count?: number;
558
+ added_count?: number;
559
+ } | null;
560
+ return (
561
+ response?.data?.created_count ??
562
+ response?.data?.count ??
563
+ response?.created_count ??
564
+ response?.count ??
565
+ response?.added_count ??
566
+ 0
567
+ );
554
568
  }
555
569
 
556
570
  /**
@@ -574,8 +588,20 @@ export class GraphHandle {
574
588
  const response = (await this.client.batchCreateEdgesRequest(
575
589
  this.graphName,
576
590
  request as unknown as Record<string, unknown>,
577
- )) as { data?: { count?: number }; count?: number } | null;
578
- return response?.data?.count ?? response?.count ?? normalized.length;
591
+ )) as {
592
+ data?: { created_count?: number; count?: number };
593
+ created_count?: number;
594
+ count?: number;
595
+ added_count?: number;
596
+ } | null;
597
+ return (
598
+ response?.data?.created_count ??
599
+ response?.data?.count ??
600
+ response?.created_count ??
601
+ response?.count ??
602
+ response?.added_count ??
603
+ 0
604
+ );
579
605
  }
580
606
 
581
607
  /**
@@ -583,8 +609,7 @@ export class GraphHandle {
583
609
  */
584
610
  async getNode(nodeId: string): Promise<GraphNode | null> {
585
611
  try {
586
- const data = await this.client.getNodeRequest(this.graphName, nodeId);
587
- return data as GraphNode;
612
+ return await this.client.getNodeRequest(this.graphName, nodeId);
588
613
  } catch (e: unknown) {
589
614
  // The facade maps a 404 to a ProximaDBError (statusCode 404, message =
590
615
  // server body). Treat "not found" as a null result, preserving the
@@ -630,8 +655,7 @@ export class GraphHandle {
630
655
  * Wire endpoint: GET /api/v2/graphs/{graph_id} (getGraph)
631
656
  */
632
657
  async info(): Promise<GraphInfo> {
633
- const data = await this.client.getGraphRequest(this.graphName);
634
- return data as GraphInfo;
658
+ return this.client.getGraphRequest(this.graphName);
635
659
  }
636
660
  }
637
661