diff --git a/clients/search-component/src/utils/trieve.ts b/clients/search-component/src/utils/trieve.ts index ec883dcdef..fc467bcf1e 100644 --- a/clients/search-component/src/utils/trieve.ts +++ b/clients/search-component/src/utils/trieve.ts @@ -290,7 +290,7 @@ export const getAllChunksForGroup = async ( "/api/chunk_group/{group_id}/{page}", "get", { - datasetId: trieve.datasetId, + datasetId: trieve.datasetId as string, groupId, page, } diff --git a/clients/ts-sdk/src/functions/analytics/index.ts b/clients/ts-sdk/src/functions/analytics/index.ts index 65d4e841a5..d9872cab76 100644 --- a/clients/ts-sdk/src/functions/analytics/index.ts +++ b/clients/ts-sdk/src/functions/analytics/index.ts @@ -41,8 +41,12 @@ export async function getCTRAnalytics( /** @hidden */ this: TrieveSDK, data: CTRAnalytics, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/analytics/events/ctr", "post", @@ -50,7 +54,7 @@ export async function getCTRAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -71,8 +75,12 @@ export async function sendCTRAnalytics( /** @hidden */ this: TrieveSDK, data: CTRDataRequestBody, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/analytics/ctr", "put", @@ -80,7 +88,7 @@ export async function sendCTRAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -110,8 +118,12 @@ export async function getRagAnalytics( /** @hidden */ this: TrieveSDK, data: RAGAnalytics, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/rag", "post", @@ -119,7 +131,7 @@ export async function getRagAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -148,8 +160,12 @@ export async function getRecommendationAnalytics( /** @hidden */ this: TrieveSDK, data: RecommendationAnalytics, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/recommendations", "post", @@ -157,7 +173,7 @@ export async function getRecommendationAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -186,8 +202,12 @@ export async function getSearchAnalytics( /** @hidden */ this: TrieveSDK, data: SearchAnalytics, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/search", "post", @@ -195,7 +215,7 @@ export async function getSearchAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -221,8 +241,12 @@ export async function getClusterAnalytics( /** @hidden */ this: TrieveSDK, data: ClusterAnalytics, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/search/cluster", "post", @@ -230,7 +254,7 @@ export async function getClusterAnalytics( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -249,8 +273,12 @@ export async function rateRagQuery( /** @hidden */ this: TrieveSDK, data: RateQueryRequest, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/rag", "put", @@ -258,7 +286,7 @@ export async function rateRagQuery( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -277,8 +305,12 @@ export async function rateSearchQuery( /** @hidden */ this: TrieveSDK, data: RateQueryRequest, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/analytics/search", "put", @@ -286,7 +318,7 @@ export async function rateSearchQuery( data, datasetId: this.datasetId, }, - signal, + signal ); } @@ -305,7 +337,7 @@ export async function getTopDatasets( /** @hidden */ this: TrieveSDK, data: GetTopDatasetsRequestBody & { organizationId: string }, - signal?: AbortSignal, + signal?: AbortSignal ) { return this.trieve.fetch( "/api/analytics/top", @@ -314,7 +346,7 @@ export async function getTopDatasets( data, organizationId: data.organizationId, }, - signal, + signal ); } @@ -341,7 +373,7 @@ export async function getAllAnalyticsEvents( /** @hidden */ this: TrieveSDK, data: GetEventsRequestBody, - signal?: AbortSignal, + signal?: AbortSignal ) { return await this.trieve.fetch( "/api/analytics/events/all", @@ -349,6 +381,6 @@ export async function getAllAnalyticsEvents( { data, }, - signal, + signal ); } diff --git a/clients/ts-sdk/src/functions/chunks/index.ts b/clients/ts-sdk/src/functions/chunks/index.ts index ab9f9f029a..76d86b5523 100644 --- a/clients/ts-sdk/src/functions/chunks/index.ts +++ b/clients/ts-sdk/src/functions/chunks/index.ts @@ -45,6 +45,9 @@ export async function search( props: SearchChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } return this.trieve.fetch( "/api/chunk/search", "post", @@ -77,6 +80,10 @@ export async function createChunk( props: CreateChunkReqPayloadEnum, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk", "post", @@ -107,6 +114,10 @@ export async function autocomplete( props: AutocompleteReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/autocomplete", "post", @@ -137,6 +148,10 @@ export async function getRecommendedChunks( props: RecommendChunksRequest, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/recommend", "post", @@ -173,6 +188,10 @@ export async function ragOnChunk( props: GenerateOffChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/generate", "post", @@ -211,6 +230,10 @@ export async function ragOnChunkReader( props: GenerateOffChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/chunk/generate", { method: "post", headers: { @@ -258,6 +281,10 @@ export async function ragOnChunkReaderWithQueryId( props: GenerateOffChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/chunk/generate", { method: "post", headers: { @@ -299,6 +326,10 @@ export async function suggestedQueries( props: SuggestedQueriesReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/suggestions", "post", @@ -328,6 +359,10 @@ export async function countChunksAboveThreshold( props: CountChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/count", "post", @@ -355,6 +390,10 @@ export async function scroll( props: ScrollChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunks/scroll", "post", @@ -383,6 +422,10 @@ export async function updateChunk( props: UpdateChunkReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk", "put", @@ -411,6 +454,10 @@ export async function updateChunkByTrackingId( props: UpdateChunkByTrackingIdData, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/tracking_id/update", "put", @@ -438,6 +485,10 @@ export async function getChunkByTrackingId( props: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/tracking_id/{tracking_id}", "get", @@ -466,6 +517,10 @@ export async function deleteChunkByTrackingId( props: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/tracking_id/{tracking_id}", "delete", @@ -493,6 +548,10 @@ export async function getChunkById( props: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/{chunk_id}", "get", @@ -521,6 +580,10 @@ export async function deleteChunkById( props: DeleteChunkData, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk/{chunk_id}", "delete", @@ -548,6 +611,10 @@ export async function getChunksByIds( props: GetChunksData, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunks", "post", @@ -575,6 +642,10 @@ export async function getChunksByTrackingIds( props: GetTrackingChunksData, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunks/tracking", "post", @@ -588,7 +659,7 @@ export async function getChunksByTrackingIds( /** * Function that splits an html string into chunks. - * The html string will be split into chunks based on the number of characters in the string and header tags. + * The html string will be split into chunks based on the number of characters in the string and header tags. * * Example: * ```js diff --git a/clients/ts-sdk/src/functions/events/index.ts b/clients/ts-sdk/src/functions/events/index.ts index 733de45550..5e80dbf359 100644 --- a/clients/ts-sdk/src/functions/events/index.ts +++ b/clients/ts-sdk/src/functions/events/index.ts @@ -23,8 +23,12 @@ export async function getEventsForDataset( /** @hidden */ this: TrieveSDK, data: GetEventsData, - signal?: AbortSignal, + signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/dataset/events", "post", @@ -32,6 +36,6 @@ export async function getEventsForDataset( data, datasetId: this.datasetId, }, - signal, + signal ); } diff --git a/clients/ts-sdk/src/functions/file/index.ts b/clients/ts-sdk/src/functions/file/index.ts index b0877f4ef7..4e687daa49 100644 --- a/clients/ts-sdk/src/functions/file/index.ts +++ b/clients/ts-sdk/src/functions/file/index.ts @@ -38,6 +38,10 @@ export async function uploadFile( data: UploadFileReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/file", "post", @@ -55,6 +59,10 @@ export async function createPresignedUrlForCsvJsonl( data: CreatePresignedUrlForCsvJsonlReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/file/csv_or_jsonl", "post", @@ -82,6 +90,10 @@ export async function getFilesForDataset( data: Omit, "trDataset">, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/dataset/files/{dataset_id}/{page}", "get", @@ -109,6 +121,10 @@ export async function getFile( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/file/{file_id}", "get", @@ -136,6 +152,10 @@ export async function deleteFile( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/file/{file_id}", "delete", diff --git a/clients/ts-sdk/src/functions/groups/index.ts b/clients/ts-sdk/src/functions/groups/index.ts index b6710a92a9..3bee3d9d4a 100644 --- a/clients/ts-sdk/src/functions/groups/index.ts +++ b/clients/ts-sdk/src/functions/groups/index.ts @@ -49,6 +49,10 @@ export async function createChunkGroup( this: TrieveSDK, data: Omit ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch("/api/chunk_group", "post", { data, datasetId: this.datasetId, @@ -71,6 +75,10 @@ export async function searchOverGroups( data: SearchOverGroupsReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/group_oriented_search", "post", @@ -98,6 +106,10 @@ export async function searchInGroup( data: SearchWithinGroupReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/search", "post", @@ -125,6 +137,10 @@ export async function recommendedGroups( data: RecommendGroupsReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/recommend", "post", @@ -152,6 +168,10 @@ export async function updateGroup( data: UpdateChunkGroupReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group", "put", @@ -179,6 +199,10 @@ export async function addChunkToGroup( data: AddChunkToGroupReqPayload & { group_id: string }, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/chunk/{group_id}", "post", @@ -208,6 +232,10 @@ export async function removeChunkFromGroup( data: RemoveChunkFromGroupReqPayload & { group_id: string }, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/chunk/{group_id}", "delete", @@ -236,6 +264,10 @@ export async function getGroupsForChunks( data: GetGroupsForChunksReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/chunks", "post", @@ -264,6 +296,10 @@ export async function getChunksGroupByTrackingId( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/tracking_id/{group_tracking_id}/{page}", "get", @@ -293,6 +329,10 @@ export async function getGroupByTrackingId( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/tracking_id/{tracking_id}", "get", @@ -321,6 +361,10 @@ export async function addChunkToGroupByTrackingId( data: AddChunkToGroupReqPayload & { tracking_id: string }, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/tracking_id/{tracking_id}", "post", @@ -349,6 +393,10 @@ export async function deleteGroupByTrackingId( data: DeleteGroupByTrackingIdData & { tracking_id: string }, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/tracking_id/{tracking_id}", "delete", @@ -377,6 +425,10 @@ export async function getGroup( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/{group_id}", "get", @@ -404,6 +456,10 @@ export async function deleteGroup( data: DeleteChunkGroupData, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/{group_id}", "delete", @@ -432,6 +488,10 @@ export async function getChunksInGroup( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/chunk_group/{group_id}/{page}", "get", @@ -459,6 +519,10 @@ export async function getGroupsForDataset( data: Omit, "trDataset">, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return this.trieve.fetch( "/api/dataset/groups/{dataset_id}/{page}", "get", diff --git a/clients/ts-sdk/src/functions/message/index.ts b/clients/ts-sdk/src/functions/message/index.ts index 4fd3bb7911..afa9a50a93 100644 --- a/clients/ts-sdk/src/functions/message/index.ts +++ b/clients/ts-sdk/src/functions/message/index.ts @@ -29,6 +29,10 @@ export async function createMessage( data: CreateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/message", "post", @@ -57,6 +61,10 @@ export async function createMessageReader( data: CreateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "post", headers: { @@ -67,7 +75,7 @@ export async function createMessageReader( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -94,6 +102,10 @@ export async function createMessageReaderWithQueryId( data: CreateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "post", headers: { @@ -104,7 +116,7 @@ export async function createMessageReaderWithQueryId( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -115,7 +127,7 @@ export async function createMessageReaderWithQueryId( return { reader, - queryId + queryId, }; } @@ -137,6 +149,10 @@ export async function editMessage( data: EditMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/message", "put", @@ -166,6 +182,10 @@ export async function editMessageReader( data: EditMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "put", headers: { @@ -176,7 +196,7 @@ export async function editMessageReader( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -204,6 +224,10 @@ export async function editMessageReaderWithQueryId( data: EditMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "put", headers: { @@ -214,7 +238,7 @@ export async function editMessageReaderWithQueryId( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -225,7 +249,7 @@ export async function editMessageReaderWithQueryId( return { reader, - queryId + queryId, }; } @@ -245,6 +269,10 @@ export async function regenerateMessage( data: RegenerateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/message", "delete", @@ -272,6 +300,10 @@ export async function regenerateMessageReader( data: RegenerateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "delete", headers: { @@ -282,7 +314,7 @@ export async function regenerateMessageReader( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -308,6 +340,10 @@ export async function regenerateMessageReaderWithQueryId( data: RegenerateMessageReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + const response = await fetch(this.trieve.baseUrl + "/api/message", { method: "delete", headers: { @@ -318,7 +354,7 @@ export async function regenerateMessageReaderWithQueryId( body: JSON.stringify(data), signal, }); - + const reader = response.body?.getReader(); if (!reader) { @@ -327,9 +363,9 @@ export async function regenerateMessageReaderWithQueryId( const queryId = response.headers.get("TR-QueryID"); - return { + return { reader, - queryId + queryId, }; } @@ -349,6 +385,10 @@ export async function getAllMessagesForTopic( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/messages/{messages_topic_id}", "get", @@ -376,6 +416,10 @@ export async function getMessageById( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/message/{message_id}", "get", @@ -386,4 +430,3 @@ export async function getMessageById( signal ); } - diff --git a/clients/ts-sdk/src/functions/topic/index.ts b/clients/ts-sdk/src/functions/topic/index.ts index eb585fb365..e477049a35 100644 --- a/clients/ts-sdk/src/functions/topic/index.ts +++ b/clients/ts-sdk/src/functions/topic/index.ts @@ -8,7 +8,7 @@ import { DeleteTopicData2, GetAllTopicsForOwnerIdData, UpdateTopicReqPayload, - CloneTopicReqPayload + CloneTopicReqPayload, } from "../../fetch-client"; import { TrieveSDK } from "../../sdk"; @@ -30,6 +30,10 @@ export async function createTopic( data: CreateTopicReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/topic", "post", @@ -59,6 +63,10 @@ export async function cloneTopic( data: CloneTopicReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/topic/clone", "post", @@ -87,6 +95,10 @@ export async function updateTopic( data: UpdateTopicReqPayload, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/topic", "put", @@ -114,6 +126,10 @@ export async function getAllTopics( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/topic/owner/{owner_id}", "get", @@ -141,6 +157,10 @@ export async function deleteTopic( data: Omit, signal?: AbortSignal ) { + if (!this.datasetId) { + throw new Error("datasetId is required"); + } + return await this.trieve.fetch( "/api/topic/{topic_id}", "delete", diff --git a/clients/ts-sdk/src/sdk.ts b/clients/ts-sdk/src/sdk.ts index fff3f796ee..a251b0f7ac 100644 --- a/clients/ts-sdk/src/sdk.ts +++ b/clients/ts-sdk/src/sdk.ts @@ -3,7 +3,7 @@ import { TrieveFetchClient } from "./fetch-client"; export class TrieveSDK { trieve: TrieveFetchClient; - datasetId: string; + datasetId?: string; organizationId?: string; constructor({ apiKey, @@ -11,18 +11,21 @@ export class TrieveSDK { debug = false, datasetId, organizationId, + omitCredentials, }: { apiKey: string; baseUrl?: string; debug?: boolean; - datasetId: string; + datasetId?: string; organizationId?: string; + omitCredentials?: boolean; }) { this.trieve = new TrieveFetchClient({ apiKey, baseUrl, debug, organizationId, + omitCredentials, }); this.datasetId = datasetId; this.organizationId = organizationId;