Skip to content

Commit

Permalink
cleanup remove Union types caused by V2 response type upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed Oct 6, 2024
1 parent 3c2187d commit d944862
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
7 changes: 3 additions & 4 deletions clients/ts-sdk/src/functions/chunks/chunk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { TrieveSDK } from "../../sdk";
import {
ChunkReturnTypes,
CountChunkQueryResponseBody,
RecommendResponseTypes,
RecommendChunksResponseBody,
ReturnQueuedChunk,
ScrollChunksResponseBody,
SearchResponseBody,
SearchResponseTypes,
} from "../../types.gen";
import {
CHUNK_EXAMPLE_ID,
Expand Down Expand Up @@ -44,15 +43,15 @@ describe("Chunk Methods Test", async () => {
search_type: "fulltext",
});

expectTypeOf(data).toEqualTypeOf<SearchResponseTypes>();
expectTypeOf(data).toEqualTypeOf<SearchResponseBody>();
});

test("getRecommendedChunks", async () => {
const data = await trieve.getRecommendedChunks({
positive_chunk_ids: [CHUNK_EXAMPLE_ID],
});

expectTypeOf(data).toEqualTypeOf<RecommendResponseTypes>();
expectTypeOf(data).toEqualTypeOf<RecommendChunksResponseBody>();
});

test("ragOnChunk", async () => {
Expand Down
5 changes: 3 additions & 2 deletions clients/ts-sdk/src/functions/chunks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
GetChunksData,
GetTrackingChunksData,
RecommendChunksRequest,
RecommendChunksResponseBody,
ScrollChunksReqPayload,
SearchChunksReqPayload,
SearchResponseBody,
Expand Down Expand Up @@ -114,7 +115,7 @@ export async function autocomplete(
xApiVersion: "V2",
},
signal
);
) as Promise<SearchResponseBody>;
}

/**
Expand Down Expand Up @@ -143,7 +144,7 @@ export async function getRecommendedChunks(
datasetId: this.datasetId,
},
signal
);
) as Promise<RecommendChunksResponseBody>;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions clients/ts-sdk/src/functions/groups/chunkGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
GetChunksInGroupResponse,
GroupData,
GroupsForChunk,
RecommendGroupsResponse,
SearchGroupResponseTypes,
SearchOverGroupsResponseTypes,
RecommendGroupsResponseBody,
SearchOverGroupsResponseBody,
SearchWithinGroupResponseBody,
} from "../../types.gen";
import { test } from "../../__tests__/utils";

Expand All @@ -37,7 +37,7 @@ describe("Chunk Groups Methods Test", async () => {
search_type: "fulltext",
});

expectTypeOf(data).toEqualTypeOf<SearchOverGroupsResponseTypes>();
expectTypeOf(data).toEqualTypeOf<SearchOverGroupsResponseBody>();
});
test("searchInGroup", async () => {
const data = await trieve.searchInGroup({
Expand All @@ -46,14 +46,14 @@ describe("Chunk Groups Methods Test", async () => {
group_id: GROUP_EXAMPLE_ID,
});

expectTypeOf(data).toEqualTypeOf<SearchGroupResponseTypes>();
expectTypeOf(data).toEqualTypeOf<SearchWithinGroupResponseBody>();
});
test("recommendedGroups", async () => {
const data = await trieve.recommendedGroups({
positive_group_ids: [GROUP_EXAMPLE_ID],
});

expectTypeOf(data).toEqualTypeOf<RecommendGroupsResponse>();
expectTypeOf(data).toEqualTypeOf<RecommendGroupsResponseBody>();
});
test("updateGroup", async () => {
const data = await trieve.updateGroup({
Expand Down
9 changes: 6 additions & 3 deletions clients/ts-sdk/src/functions/groups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import {
GetGroupsForChunksReqPayload,
GetGroupsForDatasetData,
RecommendGroupsReqPayload,
RecommendGroupsResponseBody,
RemoveChunkFromGroupReqPayload,
SearchOverGroupsReqPayload,
SearchOverGroupsResponseBody,
SearchWithinGroupReqPayload,
SearchWithinGroupResponseBody,
UpdateChunkGroupReqPayload,
UpdateGroupByTrackingIDReqPayload,
} from "../../fetch-client";
Expand Down Expand Up @@ -77,7 +80,7 @@ export async function searchOverGroups(
datasetId: this.datasetId,
},
signal
);
) as Promise<SearchOverGroupsResponseBody>;
}

/**
Expand All @@ -104,7 +107,7 @@ export async function searchInGroup(
datasetId: this.datasetId,
},
signal
);
) as Promise<SearchWithinGroupResponseBody>;
}

/**
Expand All @@ -131,7 +134,7 @@ export async function recommendedGroups(
datasetId: this.datasetId,
},
signal
);
) as Promise<RecommendGroupsResponseBody>;
}

/**
Expand Down

0 comments on commit d944862

Please sign in to comment.