Skip to content

Commit

Permalink
Move JS SDK to camel case (#1724)
Browse files Browse the repository at this point in the history
  • Loading branch information
NolanTrem authored Dec 24, 2024
1 parent a1953d9 commit 4e3c608
Show file tree
Hide file tree
Showing 17 changed files with 647 additions and 178 deletions.
22 changes: 11 additions & 11 deletions js/sdk/__tests__/ChunksIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const baseUrl = "http://localhost:7272";

describe("r2rClient V3 Collections Integration Tests", () => {
let client: r2rClient;
let document_id: string;
let documentId: string;
let chunkId: string;

beforeAll(async () => {
Expand All @@ -22,28 +22,28 @@ describe("r2rClient V3 Collections Integration Tests", () => {
runWithOrchestration: false,
});

document_id = response.results.document_id;
documentId = response.results.documentId;

expect(response.results).toEqual({
document_id: expect.any(String),
documentId: expect.any(String),
message: "Document created and ingested successfully.",
task_id: null,
taskId: null,
});
});

test("Retrieve document's chunks", async () => {
const response = await client.documents.listChunks({
id: document_id,
id: documentId,
});

chunkId = response.results[0]?.id;

expect(chunkId).toBeDefined();
expect(response.results[0]).toMatchObject({
id: expect.any(String),
document_id: expect.any(String),
documentId: expect.any(String),
text: expect.any(String),
collection_ids: expect.any(Array),
collectionIds: expect.any(Array),
metadata: expect.any(Object),
});
});
Expand All @@ -55,9 +55,9 @@ describe("r2rClient V3 Collections Integration Tests", () => {

expect(response.results).toMatchObject({
id: expect.any(String),
document_id: expect.any(String),
documentId: expect.any(String),
text: expect.any(String),
collection_ids: expect.any(Array),
collectionIds: expect.any(Array),
metadata: expect.any(Object),
});
});
Expand All @@ -70,9 +70,9 @@ describe("r2rClient V3 Collections Integration Tests", () => {

expect(response.results).toMatchObject({
id: expect.any(String),
document_id: expect.any(String),
documentId: expect.any(String),
text: "Hello, world! How are you?",
collection_ids: expect.any(Array),
collectionIds: expect.any(Array),
metadata: expect.any(Object),
});
});
Expand Down
4 changes: 2 additions & 2 deletions js/sdk/__tests__/CollectionsIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe("r2rClient V3 Collections Integration Tests", () => {
metadata: { title: "zametov.txt" },
});

expect(ingestResponse.results.document_id).toBeDefined();
documentId = ingestResponse.results.document_id;
expect(ingestResponse.results.documentId).toBeDefined();
documentId = ingestResponse.results.documentId;

const response = await client.collections.addDocument({
id: collectionId,
Expand Down
10 changes: 5 additions & 5 deletions js/sdk/__tests__/ConversationsIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("r2rClient V3 Collections Integration Tests", () => {

user1Id = response.results.id;
expect(response.results).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.isSuperuser).toBe(false);
expect(response.results.name).toBe(null);
});

Expand All @@ -52,7 +52,7 @@ describe("r2rClient V3 Collections Integration Tests", () => {

user2Id = response.results.id;
expect(response.results).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.isSuperuser).toBe(false);
expect(response.results.name).toBe(null);
});

Expand Down Expand Up @@ -84,23 +84,23 @@ describe("r2rClient V3 Collections Integration Tests", () => {

expect(response.results).toBeDefined();
expect(response.results).toEqual([]);
expect(response.total_entries).toBe(0);
expect(response.totalEntries).toBe(0);
});

test("List all conversations as user 1", async () => {
const response = await user1Client.conversations.list();

expect(response.results).toBeDefined();
expect(response.results).toEqual([]);
expect(response.total_entries).toBe(0);
expect(response.totalEntries).toBe(0);
});

test("List all conversations as user 2", async () => {
const response = await user2Client.conversations.list();

expect(response.results).toBeDefined();
expect(response.results).toEqual([]);
expect(response.total_entries).toBe(0);
expect(response.totalEntries).toBe(0);
});

test("Create a conversation with a name", async () => {
Expand Down
24 changes: 12 additions & 12 deletions js/sdk/__tests__/DocumentsAndCollectionsIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

user1Id = response.results.id;
expect(response.results).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.isSuperuser).toBe(false);
expect(response.results.name).toBe(null);
});

Expand All @@ -61,7 +61,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

user2Id = response.results.id;
expect(response.results).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.isSuperuser).toBe(false);
expect(response.results.name).toBe(null);
});

Expand Down Expand Up @@ -93,7 +93,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

expect(response.results).toBeDefined();
expect(response.results.length).toBe(1);
expect(response.total_entries).toBe(1);
expect(response.totalEntries).toBe(1);
user1CollectionId = response.results[0].id;
});

Expand All @@ -102,7 +102,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

expect(response.results).toBeDefined();
expect(response.results.length).toBe(1);
expect(response.total_entries).toBe(1);
expect(response.totalEntries).toBe(1);
user2CollectionId = response.results[0].id;
});

Expand All @@ -114,8 +114,8 @@ describe("r2rClient V3 System Integration Tests User", () => {

await new Promise((resolve) => setTimeout(resolve, 5000));

expect(response.results.document_id).toBeDefined();
user1DocumentId = response.results.document_id;
expect(response.results.documentId).toBeDefined();
user1DocumentId = response.results.documentId;
}, 15000);

test("Create document as user 2 with file path", async () => {
Expand All @@ -126,8 +126,8 @@ describe("r2rClient V3 System Integration Tests User", () => {

await new Promise((resolve) => setTimeout(resolve, 5000));

expect(response.results.document_id).toBeDefined();
user2DocumentId = response.results.document_id;
expect(response.results.documentId).toBeDefined();
user2DocumentId = response.results.documentId;
}, 15000);

test("Retrieve document as user 1", async () => {
Expand Down Expand Up @@ -156,8 +156,8 @@ describe("r2rClient V3 System Integration Tests User", () => {

await new Promise((resolve) => setTimeout(resolve, 5000));

expect(response.results.document_id).toBeDefined();
user1Document2Id = response.results.document_id;
expect(response.results.documentId).toBeDefined();
user1Document2Id = response.results.documentId;
}, 15000);

test("Create document as user 2 from raw text", async () => {
Expand All @@ -168,8 +168,8 @@ describe("r2rClient V3 System Integration Tests User", () => {

await new Promise((resolve) => setTimeout(resolve, 5000));

expect(response.results.document_id).toBeDefined();
user2Document2Id = response.results.document_id;
expect(response.results.documentId).toBeDefined();
user2Document2Id = response.results.documentId;
}, 15000);

test("List documents with no parameters as user 1", async () => {
Expand Down
18 changes: 9 additions & 9 deletions js/sdk/__tests__/DocumentsIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe("r2rClient V3 Documents Integration Tests", () => {
metadata: { title: "marmeladov.txt" },
});

expect(response.results.document_id).toBeDefined();
documentId = response.results.document_id;
expect(response.results.documentId).toBeDefined();
documentId = response.results.documentId;
}, 10000);

test("Create document with content", async () => {
Expand All @@ -35,7 +35,7 @@ describe("r2rClient V3 Documents Integration Tests", () => {
metadata: { title: "Test Document" },
});

expect(response.results.document_id).toBeDefined();
expect(response.results.documentId).toBeDefined();
}, 30000);

test("Retrieve document", async () => {
Expand All @@ -45,15 +45,15 @@ describe("r2rClient V3 Documents Integration Tests", () => {

expect(response.results).toBeDefined();
expect(response.results.id).toBe(documentId);
expect(response.results.collection_ids).toContain(
expect(response.results.collectionIds).toContain(
"122fdf6a-e116-546b-a8f6-e4cb2e2c0a09",
);
expect(response.results.metadata.title).toBe("marmeladov.txt");
expect(response.results.size_in_bytes).toBeDefined();
expect(response.results.ingestion_status).toBe("success");
expect(response.results.extraction_status).toBe("pending");
expect(response.results.created_at).toBeDefined();
expect(response.results.updated_at).toBeDefined();
expect(response.results.sizeInBytes).toBeDefined();
expect(response.results.ingestionStatus).toBe("success");
expect(response.results.extractionStatus).toBe("pending");
expect(response.results.createdAt).toBeDefined();
expect(response.results.updatedAt).toBeDefined();
expect(response.results.summary).toBeDefined();
});

Expand Down
12 changes: 6 additions & 6 deletions js/sdk/__tests__/GraphsIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe("r2rClient V3 Graphs Integration Tests", () => {
metadata: { title: "raskolnikov_2.txt" },
});

expect(response.results.document_id).toBeDefined();
documentId = response.results.document_id;
expect(response.results.documentId).toBeDefined();
documentId = response.results.documentId;
}, 10000);

test("Create new collection", async () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("r2rClient V3 Graphs Integration Tests", () => {

expect(response.results).toBeDefined();
expect(response.results.name).toBe("Raskolnikov Graph");
expect(response.results.updated_at).not.toBe(response.results.created_at);
expect(response.results.updatedAt).not.toBe(response.results.createdAt);
});

test("List graphs", async () => {
Expand Down Expand Up @@ -123,15 +123,15 @@ describe("r2rClient V3 Graphs Integration Tests", () => {
collectionId: collectionId,
});
expect(response.results).toBeDefined();
expect(response.total_entries).toBeGreaterThanOrEqual(1);
expect(response.totalEntries).toBeGreaterThanOrEqual(1);
}, 60000);

test("Check that there are relationships in the graph", async () => {
const response = await client.graphs.listRelationships({
collectionId: collectionId,
});
expect(response.results).toBeDefined();
expect(response.total_entries).toBeGreaterThanOrEqual(1);
expect(response.totalEntries).toBeGreaterThanOrEqual(1);
});

test("Check that there are no communities in the graph prior to building", async () => {
Expand Down Expand Up @@ -159,7 +159,7 @@ describe("r2rClient V3 Graphs Integration Tests", () => {
});

expect(response.results).toBeDefined();
expect(response.total_entries).toBeGreaterThanOrEqual(1);
expect(response.totalEntries).toBeGreaterThanOrEqual(1);
});

test("Create a new entity", async () => {
Expand Down
4 changes: 2 additions & 2 deletions js/sdk/__tests__/RetrievalIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe("r2rClient V3 Documents Integration Tests", () => {
metadata: { title: "sonia.txt" },
});

expect(response.results.document_id).toBeDefined();
documentId = response.results.document_id;
expect(response.results.documentId).toBeDefined();
documentId = response.results.documentId;
}, 10000);

test("Search documents with no parameters", async () => {
Expand Down
2 changes: 1 addition & 1 deletion js/sdk/__tests__/SystemIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("r2rClient V3 System Integration Tests User", () => {
userId = response.results.id;
name = response.results.name;
expect(response.results).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.isSuperuser).toBe(false);
expect(response.results.name).toBe("Test User");
expect(response.results.bio).toBe("This is the bio of the test user.");
});
Expand Down
36 changes: 18 additions & 18 deletions js/sdk/__tests__/UsersIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ describe("r2rClient V3 Users Integration Tests", () => {
expect(response.results).toBeDefined();
expect(response.results.id).toBeDefined();
expect(response.results.email).toBe("[email protected]");
expect(response.results.is_active).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.created_at).toBeDefined();
expect(response.results.updated_at).toBeDefined();
expect(response.results.isActive).toBeDefined();
expect(response.results.isSuperuser).toBe(false);
expect(response.results.createdAt).toBeDefined();
expect(response.results.updatedAt).toBeDefined();
// expect(response.results.is_verified).toBe(false);
expect(response.results.collection_ids).toBeDefined();
expect(response.results.collectionIds).toBeDefined();
// expect(response.results.hashed_password).toBeUndefined();
// expect(response.results.verification_code_expiry).toBeUndefined();
expect(response.results.name).toBe(null);
expect(response.results.bio).toBe(null);
expect(response.results.profile_picture).toBe(null);
expect(response.results.profilePicture).toBe(null);
});

test("Login as a user", async () => {
Expand Down Expand Up @@ -95,17 +95,17 @@ describe("r2rClient V3 Users Integration Tests", () => {
expect(response.results).toBeDefined();
expect(response.results.id).toBeDefined();
expect(response.results.email).toBe("[email protected]");
expect(response.results.is_active).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.created_at).toBeDefined();
expect(response.results.updated_at).toBeDefined();
expect(response.results.isActive).toBeDefined();
expect(response.results.isSuperuser).toBe(false);
expect(response.results.createdAt).toBeDefined();
expect(response.results.updatedAt).toBeDefined();
// expect(response.results.is_verified).toBe(false);
expect(response.results.collection_ids).toBeDefined();
expect(response.results.collectionIds).toBeDefined();
// expect(response.results.hashed_password).toBeUndefined();
// expect(response.results.verification_code_expiry).toBeUndefined();
expect(response.results.name).toBe("New Name");
expect(response.results.bio).toBe("New Bio");
expect(response.results.profile_picture).toBe(null);
expect(response.results.profilePicture).toBe(null);
});

test("Retrieve a user after update", async () => {
Expand All @@ -114,17 +114,17 @@ describe("r2rClient V3 Users Integration Tests", () => {
expect(response.results).toBeDefined();
expect(response.results.id).toBeDefined();
expect(response.results.email).toBe("[email protected]");
expect(response.results.is_active).toBeDefined();
expect(response.results.is_superuser).toBe(false);
expect(response.results.created_at).toBeDefined();
expect(response.results.updated_at).toBeDefined();
expect(response.results.isActive).toBeDefined();
expect(response.results.isSuperuser).toBe(false);
expect(response.results.createdAt).toBeDefined();
expect(response.results.updatedAt).toBeDefined();
// expect(response.results.is_verified).toBe(false);
expect(response.results.collection_ids).toBeDefined();
expect(response.results.collectionIds).toBeDefined();
// expect(response.results.hashed_password).toBeUndefined();
// expect(response.results.verification_code_expiry).toBeUndefined();
expect(response.results.name).toBe("New Name");
expect(response.results.bio).toBe("New Bio");
expect(response.results.profile_picture).toBe(null);
expect(response.results.profilePicture).toBe(null);
});

test("List user's collections", async () => {
Expand Down
Loading

0 comments on commit 4e3c608

Please sign in to comment.