From 879b4af82b3da83739328c32c4ac1c75f7f3bc6e Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Tue, 3 Sep 2024 14:25:34 +0200 Subject: [PATCH] Continued move to dustAPIDataSourceId (#7082) * getDataSourceDocumentVersions * update document methods * dataSourceTokenize * deleteTable, upssertTable, upsertTableRows * getTable * getTable * updateTableParents * getTableRow * getTableRows * deleteTableRow --- front/admin/cli.ts | 2 +- .../server_side_props_helpers.ts | 2 +- front/lib/api/data_source_view.ts | 2 +- front/lib/api/tables.ts | 61 +++++++------ front/lib/document_tracker.ts | 4 +- .../hooks/data_source_helpers.ts | 2 +- .../[name]/documents/[documentId]/index.ts | 4 +- .../[name]/documents/[documentId]/parents.ts | 2 +- .../data_sources/[name]/tables/[tId]/index.ts | 2 +- .../[name]/tables/[tId]/parents.ts | 2 +- .../[name]/tables/[tId]/rows/[rId].ts | 4 +- .../[name]/tables/[tId]/rows/index.ts | 6 +- .../[wId]/data_sources/[name]/tables/index.ts | 6 +- .../w/[wId]/data_sources/[name]/tokenize.ts | 2 +- .../[name]/documents/[documentId]/index.ts | 4 +- .../data_sources/[name]/tables/[tId]/index.ts | 5 +- .../w/[wId]/data_sources/[name]/tables/csv.ts | 3 +- .../[wId]/data_sources/[name]/tables/index.ts | 2 +- front/temporal/upsert_queue/activities.ts | 5 +- types/src/front/lib/core_api.ts | 90 +++++++++---------- 20 files changed, 106 insertions(+), 104 deletions(-) diff --git a/front/admin/cli.ts b/front/admin/cli.ts index 90384f68f6ff..c79f39901977 100644 --- a/front/admin/cli.ts +++ b/front/admin/cli.ts @@ -423,7 +423,7 @@ const dataSource = async (command: string, args: parseArgs.ParsedArgs) => { } const delRes = await coreAPI.deleteDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: args.documentId, }); if (delRes.isErr()) { diff --git a/front/components/assistant_builder/server_side_props_helpers.ts b/front/components/assistant_builder/server_side_props_helpers.ts index cb776dc8b788..7c1845455ac4 100644 --- a/front/components/assistant_builder/server_side_props_helpers.ts +++ b/front/components/assistant_builder/server_side_props_helpers.ts @@ -200,7 +200,7 @@ export async function buildInitialActions({ const coreAPITable = await coreAPI.getTable({ projectId: dataSourceView.dataSource.dustAPIProjectId, - dataSourceName: dataSourceView.dataSource.name, + dataSourceId: dataSourceView.dataSource.dustAPIDataSourceId, tableId: t.tableId, }); diff --git a/front/lib/api/data_source_view.ts b/front/lib/api/data_source_view.ts index fef4ba2d90a3..95e5de846d35 100644 --- a/front/lib/api/data_source_view.ts +++ b/front/lib/api/data_source_view.ts @@ -160,7 +160,7 @@ export async function getContentNodesForStaticDataSourceView( return new Ok(documentsAsContentNodes); } else { const tablesRes = await coreAPI.getTables({ - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, projectId: dataSource.dustAPIProjectId, viewFilter: dataSourceView.toViewFilter(), }); diff --git a/front/lib/api/tables.ts b/front/lib/api/tables.ts index 3b1b20b6856c..ba6ad0324d71 100644 --- a/front/lib/api/tables.ts +++ b/front/lib/api/tables.ts @@ -3,6 +3,7 @@ import type { CoreAPIRow, CoreAPIRowValue, CoreAPITable, + DataSourceType, Result, WorkspaceType, } from "@dust-tt/types"; @@ -58,26 +59,26 @@ export type TableOperationError = export async function deleteTable({ owner, - projectId, - dataSourceName, + dataSource, tableId, }: { owner: WorkspaceType; - projectId: string; - dataSourceName: string; + dataSource: DataSourceType; tableId: string; }): Promise> { const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const deleteRes = await coreAPI.deleteTable({ - projectId, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, }); if (deleteRes.isErr()) { logger.error( { - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, workspaceId: owner.id, error: deleteRes.error, }, @@ -101,7 +102,8 @@ export async function deleteTable({ await AgentTablesQueryConfigurationTable.destroy({ where: { dataSourceWorkspaceId: owner.sId, - dataSourceId: dataSourceName, + // TODO(DATASOURCE_SID); state storing the datasource name + dataSourceId: dataSource.name, tableId, }, }); @@ -111,8 +113,7 @@ export async function deleteTable({ export async function upsertTableFromCsv({ auth, - projectId, - dataSourceName, + dataSource, tableName, tableDescription, tableId, @@ -123,8 +124,7 @@ export async function upsertTableFromCsv({ truncate, }: { auth: Authenticator; - projectId: string; - dataSourceName: string; + dataSource: DataSourceType; tableName: string; tableDescription: string; tableId: string; @@ -166,10 +166,11 @@ export async function upsertTableFromCsv({ logger.error( { ...errorDetails, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, tableName, tableId, - projectId, }, "CSV parsing error." ); @@ -190,10 +191,11 @@ export async function upsertTableFromCsv({ logger.error( { ...errorDetails, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, tableName, tableId, - projectId, }, "CSV input validation error: too many rows." ); @@ -202,8 +204,8 @@ export async function upsertTableFromCsv({ const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const tableRes = await coreAPI.upsertTable({ - projectId, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, name: tableName, description: tableDescription, @@ -221,11 +223,12 @@ export async function upsertTableFromCsv({ logger.error( { ...errorDetails, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, workspaceId: owner.id, tableId, tableName, - projectId, }, "Error upserting table in CoreAPI." ); @@ -234,8 +237,8 @@ export async function upsertTableFromCsv({ if (csvRows) { const rowsRes = await coreAPI.upsertTableRows({ - projectId, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, rows: csvRows, truncate, @@ -250,18 +253,19 @@ export async function upsertTableFromCsv({ logger.error( { ...errorDetails, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, workspaceId: owner.id, tableId, tableName, - projectId, }, "Error upserting rows in CoreAPI." ); const delRes = await coreAPI.deleteTable({ - projectId, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, }); @@ -270,11 +274,12 @@ export async function upsertTableFromCsv({ { type: "internal_server_error", coreAPIError: delRes.error, - dataSourceName, + projectId: dataSource.dustAPIProjectId, + dataSourceId: dataSource.dustAPIDataSourceId, + dataSourceName: dataSource.name, workspaceId: owner.id, tableId, tableName, - projectId, }, "Failed to delete table after failed row upsert." ); diff --git a/front/lib/document_tracker.ts b/front/lib/document_tracker.ts index b734e70f8fb8..f5abd078857a 100644 --- a/front/lib/document_tracker.ts +++ b/front/lib/document_tracker.ts @@ -176,14 +176,14 @@ export async function updateTrackedDocuments( if (hasExistingTrackedDocs && !hasRemainingTrackedDocs) { await coreAPI.updateDataSourceDocumentTags({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, removeTags: ["__DUST_TRACKED"], documentId, }); } else if (!hasExistingTrackedDocs && hasRemainingTrackedDocs) { await coreAPI.updateDataSourceDocumentTags({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, addTags: ["__DUST_TRACKED"], documentId, }); diff --git a/front/lib/documents_post_process_hooks/hooks/data_source_helpers.ts b/front/lib/documents_post_process_hooks/hooks/data_source_helpers.ts index 59ea3e3ec950..d045907ee934 100644 --- a/front/lib/documents_post_process_hooks/hooks/data_source_helpers.ts +++ b/front/lib/documents_post_process_hooks/hooks/data_source_helpers.ts @@ -26,7 +26,7 @@ export async function getPreviousDocumentVersion({ const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const versions = await coreAPI.getDataSourceDocumentVersions({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: documentId, limit: 1, offset: 1, diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts index 5009674cd077..07d114d50448 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts @@ -452,7 +452,7 @@ async function handler( // Create document with the Dust internal API. const upsertRes = await coreAPI.upsertDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: req.query.documentId as string, tags: bodyValidation.right.tags || [], parents: bodyValidation.right.parents || [], @@ -516,7 +516,7 @@ async function handler( const delRes = await coreAPI.deleteDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: req.query.documentId as string, }); diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/parents.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/parents.ts index 065b755a89f1..4520cacf7256 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/parents.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/documents/[documentId]/parents.ts @@ -125,7 +125,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const updateRes = await coreAPI.updateDataSourceDocumentParents({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: req.query.documentId as string, parents: req.body.parents, }); diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/index.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/index.ts index d72889ed9282..940a353c2f37 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/index.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/index.ts @@ -152,7 +152,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const tableRes = await coreAPI.getTable({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, }); if (tableRes.isErr()) { diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/parents.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/parents.ts index 4067f1a1091a..07a80cc2633d 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/parents.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/parents.ts @@ -82,7 +82,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const updateRes = await coreAPI.updateTableParents({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId: req.query.tId as string, parents, }); diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/[rId].ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/[rId].ts index ed993fa1b363..492eb9b88dae 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/[rId].ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/[rId].ts @@ -169,7 +169,7 @@ async function handler( case "GET": const rowRes = await coreAPI.getTableRow({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, rowId, }); @@ -201,7 +201,7 @@ async function handler( case "DELETE": const deleteRes = await coreAPI.deleteTableRow({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, rowId, }); diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/index.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/index.ts index affd5324d603..ccae64d56b38 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/index.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/[tId]/rows/index.ts @@ -249,7 +249,7 @@ async function handler( const listRes = await coreAPI.getTableRows({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, offset, limit, @@ -317,7 +317,7 @@ async function handler( }); const upsertRes = await coreAPI.upsertTableRows({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId: tableId, rows: rowsToUpsert, truncate, @@ -346,7 +346,7 @@ async function handler( // Upsert is succesful, retrieve the updated table. const tableRes = await coreAPI.getTable({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, }); if (tableRes.isErr()) { diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/index.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/index.ts index 35857ad3ff39..02ba61c0b1d9 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/index.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tables/index.ts @@ -168,7 +168,7 @@ async function handler( case "GET": const tablesRes = await coreAPI.getTables({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, }); if (tablesRes.isErr()) { @@ -230,7 +230,7 @@ async function handler( const tRes = await coreAPI.getTables({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, }); if (tRes.isErr()) { @@ -265,7 +265,7 @@ async function handler( const upsertRes = await coreAPI.upsertTable({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, name, description, diff --git a/front/pages/api/v1/w/[wId]/data_sources/[name]/tokenize.ts b/front/pages/api/v1/w/[wId]/data_sources/[name]/tokenize.ts index 98c79fd59db6..26dd22f987ef 100644 --- a/front/pages/api/v1/w/[wId]/data_sources/[name]/tokenize.ts +++ b/front/pages/api/v1/w/[wId]/data_sources/[name]/tokenize.ts @@ -84,7 +84,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const coreTokenizeRes = await coreAPI.dataSourceTokenize({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, text, }); if (coreTokenizeRes.isErr()) { diff --git a/front/pages/api/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts b/front/pages/api/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts index 585ab2918682..b9a782217cad 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/documents/[documentId]/index.ts @@ -207,7 +207,7 @@ async function handler( // Create document with the Dust internal API. const upsertRes = await coreAPI.upsertDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: req.query.documentId as string, tags, parents: bodyValidation.right.parents || [], @@ -283,7 +283,7 @@ async function handler( const deleteRes = await coreAPI.deleteDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: req.query.documentId as string, }); diff --git a/front/pages/api/w/[wId]/data_sources/[name]/tables/[tId]/index.ts b/front/pages/api/w/[wId]/data_sources/[name]/tables/[tId]/index.ts index c5d52382a3e3..194fcc3c9e11 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/tables/[tId]/index.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/tables/[tId]/index.ts @@ -63,7 +63,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const tableRes = await coreAPI.getTable({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, tableId, }); if (tableRes.isErr()) { @@ -134,8 +134,7 @@ export async function handleDeleteTableByIdRequest( ) { const delRes = await deleteTable({ owner, - projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSource, tableId, }); diff --git a/front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts b/front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts index 424b019593f5..c2f22ecf8dbd 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts @@ -215,8 +215,7 @@ export async function handlePostTableCsvUpsertRequest( const tableRes = await upsertTableFromCsv({ auth, - projectId: dataSource.dustAPIProjectId, - dataSourceName, + dataSource, tableId, tableName: name, tableDescription: description, diff --git a/front/pages/api/w/[wId]/data_sources/[name]/tables/index.ts b/front/pages/api/w/[wId]/data_sources/[name]/tables/index.ts index e777ad8b482b..590ccecd814f 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/tables/index.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/tables/index.ts @@ -56,7 +56,7 @@ async function handler( const coreAPI = new CoreAPI(config.getCoreAPIConfig(), logger); const tablesRes = await coreAPI.getTables({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, }); if (tablesRes.isErr()) { logger.error( diff --git a/front/temporal/upsert_queue/activities.ts b/front/temporal/upsert_queue/activities.ts index de8201d72b22..dad7b6070c7b 100644 --- a/front/temporal/upsert_queue/activities.ts +++ b/front/temporal/upsert_queue/activities.ts @@ -86,7 +86,7 @@ export async function upsertDocumentActivity( // Create document with the Dust internal API. const upsertRes = await coreAPI.upsertDataSourceDocument({ projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSourceId: dataSource.dustAPIDataSourceId, documentId: upsertQueueItem.documentId, tags: upsertQueueItem.tags || [], parents: upsertQueueItem.parents || [], @@ -224,8 +224,7 @@ export async function upsertTableActivity( const tableRes = await upsertTableFromCsv({ auth, - projectId: dataSource.dustAPIProjectId, - dataSourceName: dataSource.name, + dataSource, tableName: upsertQueueItem.tableName, tableDescription: upsertQueueItem.tableDescription, tableId: upsertQueueItem.tableId, diff --git a/types/src/front/lib/core_api.ts b/types/src/front/lib/core_api.ts index 7ddc350ae2e1..94be4fcd94ec 100644 --- a/types/src/front/lib/core_api.ts +++ b/types/src/front/lib/core_api.ts @@ -758,14 +758,14 @@ export class CoreAPI { async getDataSourceDocumentVersions({ projectId, - dataSourceName, + dataSourceId, documentId, latest_hash, limit = 10, offset = 0, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; documentId: string; limit: number; offset: number; @@ -791,7 +791,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/documents/${encodeURIComponent( documentId )}/versions?${params.toString()}`, @@ -805,7 +805,7 @@ export class CoreAPI { async upsertDataSourceDocument({ projectId, - dataSourceName, + dataSourceId, documentId, timestamp, tags, @@ -816,7 +816,7 @@ export class CoreAPI { lightDocumentOutput = false, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; documentId: string; timestamp?: number | null; tags: string[]; @@ -837,7 +837,7 @@ export class CoreAPI { > { const response = await this._fetchWithError( `${this._url}/projects/${projectId}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/documents`, { method: "POST", @@ -862,13 +862,13 @@ export class CoreAPI { async updateDataSourceDocumentTags({ projectId, - dataSourceName, + dataSourceId, documentId, addTags, removeTags, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; documentId: string; addTags?: string[]; removeTags?: string[]; @@ -881,7 +881,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/documents/${encodeURIComponent(documentId)}/tags`, { method: "PATCH", @@ -900,12 +900,12 @@ export class CoreAPI { async updateDataSourceDocumentParents({ projectId, - dataSourceName, + dataSourceId, documentId, parents, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; documentId: string; parents: string[]; }): Promise< @@ -917,7 +917,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/documents/${encodeURIComponent(documentId)}/parents`, { method: "PATCH", @@ -935,18 +935,18 @@ export class CoreAPI { async deleteDataSourceDocument({ projectId, - dataSourceName, + dataSourceId, documentId, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; documentId: string; }): Promise> { const response = await this._fetchWithError( `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/documents/${encodeURIComponent(documentId)}`, { method: "DELETE", @@ -1011,16 +1011,16 @@ export class CoreAPI { async dataSourceTokenize({ text, projectId, - dataSourceName, + dataSourceId, }: { text: string; projectId: string; - dataSourceName: string; + dataSourceId: string; }): Promise> { const response = await this._fetchWithError( `${this._url}/projects/${encodeURIComponent( projectId - )}/data_sources/${encodeURIComponent(dataSourceName)}/tokenize`, + )}/data_sources/${encodeURIComponent(dataSourceId)}/tokenize`, { method: "POST", headers: { @@ -1034,7 +1034,7 @@ export class CoreAPI { async upsertTable({ projectId, - dataSourceName, + dataSourceId, tableId, name, description, @@ -1043,7 +1043,7 @@ export class CoreAPI { parents, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; name: string; description: string; @@ -1054,7 +1054,7 @@ export class CoreAPI { const response = await this._fetchWithError( `${this._url}/projects/${encodeURIComponent( projectId - )}/data_sources/${encodeURIComponent(dataSourceName)}/tables`, + )}/data_sources/${encodeURIComponent(dataSourceId)}/tables`, { method: "POST", headers: { @@ -1076,18 +1076,18 @@ export class CoreAPI { async getTable({ projectId, - dataSourceName, + dataSourceId, tableId, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; }): Promise> { const response = await this._fetchWithError( `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}`, { method: "GET", @@ -1098,11 +1098,11 @@ export class CoreAPI { } async getTables({ - dataSourceName, + dataSourceId, projectId, viewFilter, }: { - dataSourceName: string; + dataSourceId: string; projectId: string; viewFilter?: CoreAPISearchFilter | null; }): Promise< @@ -1120,7 +1120,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables?${queryParams.toString()}`, { method: "GET", @@ -1132,18 +1132,18 @@ export class CoreAPI { async deleteTable({ projectId, - dataSourceName, + dataSourceId, tableId, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; }): Promise> { const response = await this._fetchWithError( `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}`, { method: "DELETE", @@ -1155,12 +1155,12 @@ export class CoreAPI { async updateTableParents({ projectId, - dataSourceName, + dataSourceId, tableId, parents, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; parents: string[]; }): Promise> { @@ -1168,7 +1168,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}/parents`, { method: "PATCH", @@ -1186,13 +1186,13 @@ export class CoreAPI { async upsertTableRows({ projectId, - dataSourceName, + dataSourceId, tableId, rows, truncate, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; rows: CoreAPIRow[]; truncate?: boolean; @@ -1201,7 +1201,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}/rows`, { method: "POST", @@ -1220,13 +1220,13 @@ export class CoreAPI { async getTableRow({ projectId, - dataSourceName, + dataSourceId, tableId, rowId, filter, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; rowId: string; filter?: CoreAPISearchFilter | null; @@ -1238,7 +1238,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}/rows/${encodeURIComponent( rowId )}${qs}`, @@ -1252,14 +1252,14 @@ export class CoreAPI { async getTableRows({ projectId, - dataSourceName, + dataSourceId, tableId, limit, offset, filter, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; limit: number; offset: number; @@ -1279,7 +1279,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent( tableId )}/rows?limit=${limit}&offset=${offset}${qs}`, @@ -1293,12 +1293,12 @@ export class CoreAPI { async deleteTableRow({ projectId, - dataSourceName, + dataSourceId, tableId, rowId, }: { projectId: string; - dataSourceName: string; + dataSourceId: string; tableId: string; rowId: string; }): Promise> { @@ -1306,7 +1306,7 @@ export class CoreAPI { `${this._url}/projects/${encodeURIComponent( projectId )}/data_sources/${encodeURIComponent( - dataSourceName + dataSourceId )}/tables/${encodeURIComponent(tableId)}/rows/${encodeURIComponent( rowId )}`,