Skip to content

Commit c97858d

Browse files
committed
Added JSDoc documentation for RC app endpoints
1 parent a6c9e95 commit c97858d

File tree

4 files changed

+62
-39
lines changed

4 files changed

+62
-39
lines changed

ai-assistant/src/endpoints/establishRelations.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ import {
1919
} from "./establishRelations.types";
2020

2121
namespace Helpers {
22+
/**
23+
* Establishes a relation between two nodes in the database.
24+
*
25+
* @param {IDB} db - The database instance.
26+
* @param {string} sourceID - The ID of the source node.
27+
* @param {string} targetID - The ID of the target node.
28+
* @param {string} relation - The type of relation to establish between the nodes.
29+
* @returns {Promise<void>} - A promise that resolves when the relation is successfully established.
30+
*/
2231
async function establishRelation(
2332
db: IDB,
2433
sourceID: string,
@@ -37,6 +46,13 @@ namespace Helpers {
3746
}
3847
}
3948

49+
/**
50+
* Establishes relations between entities in the database.
51+
*
52+
* @param {IDB} db - The database instance.
53+
* @param {EstablishRelationsEndpointRelations[]} relations - An array of objects representing the relations to be established.
54+
* @returns {Promise<void>} - A promise that resolves when all relations have been established.
55+
*/
4056
export async function establishRelations(
4157
db: IDB,
4258
relations: EstablishRelationsEndpointRelations[]
@@ -58,6 +74,12 @@ namespace Helpers {
5874
export class EstablishRelationsEndpoint extends ApiEndpoint {
5975
public path = "establishRelations";
6076

77+
/**
78+
* Generates the request and response bodies for the EstablishRelationsEndpoint.
79+
*
80+
* @param content - The content to be used for generating the request and response bodies.
81+
* @returns An array containing the generated request body and response body.
82+
*/
6183
makeBodies(
6284
content: any
6385
): [
@@ -72,6 +94,14 @@ export class EstablishRelationsEndpoint extends ApiEndpoint {
7294
return [requestBody, responseBody];
7395
}
7496

97+
/**
98+
* Commits the progress of the database transaction.
99+
*
100+
* @param {IDB} db - The database instance.
101+
* @returns {Promise<number>} - A promise that resolves to the status code indicating the success or failure of the commit operation.
102+
* - Returns 200 if the commit is successful.
103+
* - Returns 500 if an error occurs during the commit or rollback operation.
104+
*/
75105
async commitProgress(
76106
db: IDB
77107
): Promise<EstablishRelationsEndpointResponseBody["status"]> {

ai-assistant/src/endpoints/ingest.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,25 @@ import {
2020
} from "./ingest.types";
2121

2222
namespace Helpers {
23+
/**
24+
* Inserts a node into the database.
25+
*
26+
* @param {IDB} db - The database instance.
27+
* @param {DBNode} node - The node to be inserted.
28+
* @returns {Promise<void>} - A promise that resolves when the node is successfully inserted.
29+
*/
2330
async function insertNode(db: IDB, node: DBNode) {
2431
const query = new DBNode(node).getDBInsertQuery();
2532
await db.run(query, node);
2633
}
2734

35+
/**
36+
* Inserts an array of nodes into the database.
37+
*
38+
* @param {IDB} db - The database object.
39+
* @param {DBNode[]} nodes - The array of nodes to be inserted.
40+
* @returns {Promise<void>} - A promise that resolves when all nodes have been inserted.
41+
*/
2842
export async function insertNodes(db: IDB, nodes: DBNode[]) {
2943
await Promise.all(nodes.map((node) => insertNode(db, node)));
3044
}
@@ -33,6 +47,12 @@ namespace Helpers {
3347
export class IngestEndpoint extends ApiEndpoint {
3448
public path = "ingest";
3549

50+
/**
51+
* Generates the request and response bodies for the IngestEndpoint.
52+
*
53+
* @param content - The content to be used for generating the request body.
54+
* @returns An array containing the generated request body and response body.
55+
*/
3656
makeBodies(
3757
content: any
3858
): [IngestEndpointRequestBody, IngestEndpointResponseBody] {

ai-assistant/src/endpoints/llm.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

ai-assistant/src/endpoints/purgeDB.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ import { Neo4j } from "../core/services/db/neo4j";
1616
export class PurgeDBEndpoint extends ApiEndpoint {
1717
public path = "purgeDB";
1818

19+
/**
20+
* Empties the specified database by deleting all nodes and relationships.
21+
*
22+
* @param {IDB} db - The database to be emptied.
23+
* @returns {Promise<void>} - A promise that resolves when the database has been emptied.
24+
*/
1925
async emptyDB(db: IDB) {
2026
const query = `MATCH (n) DETACH DELETE n`;
2127
await db.run(query);
2228
}
2329

30+
/**
31+
* Sets up the indices for name embeddings and code embeddings in the specified database.
32+
*
33+
* @param {IDB} db - The database object.
34+
* @returns {Promise<void>} - A promise that resolves when the indices are set up.
35+
*/
2436
async setupIndices(db: IDB) {
2537
const query = [
2638
// Create indices for name embeddings

0 commit comments

Comments
 (0)