diff --git a/src/client.ts b/src/client.ts index d64710c78..cb9567add 100644 --- a/src/client.ts +++ b/src/client.ts @@ -127,6 +127,10 @@ import { FlagReportsPaginationOptions, ExportUsersRequest, ExportUsersResponse, + CreateImportResponse, + GetImportResponse, + ListImportsResponse, + ListImportsPaginationOptions, } from './types'; import { InsightMetrics, postInsights } from './insights'; @@ -3073,4 +3077,54 @@ export class StreamChat< ...options, }); } + + /** + * _createImport - Create an Import Task. + * + * Note: Do not use this. + * It is present for internal usage only. + * This function can, and will, break and/or be removed at any point in time. + * + * @private + * @param {string} filename filename of uploaded data + * + * @return {APIResponse & CreateImportResponse} An ImportTask + */ + async _createImport(filename: string) { + return await this.post(this.baseURL + `/imports`, { + filename, + }); + } + + /** + * _getImport - Get an Import Task. + * + * Note: Do not use this. + * It is present for internal usage only. + * This function can, and will, break and/or be removed at any point in time. + * + * @private + * @param {string} id id of Import Task + * + * @return {APIResponse & GetImportResponse} An ImportTask + */ + async _getImport(id: string) { + return await this.get(this.baseURL + `/imports/${id}`); + } + + /** + * _listImports - Lists Import Tasks. + * + * Note: Do not use this. + * It is present for internal usage only. + * This function can, and will, break and/or be removed at any point in time. + * + * @private + * @param {ListImportsPaginationOptions} options pagination options + * + * @return {APIResponse & ListImportsResponse} An ImportTask + */ + async _listImports(options: ListImportsPaginationOptions) { + return await this.get(this.baseURL + `/imports`, options); + } } diff --git a/src/types.ts b/src/types.ts index bf2b7ddd4..a47d967f9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2137,3 +2137,38 @@ export type TruncateOptions = { skip_push?: boolean; truncated_at?: Date; }; + +export type CreateImportResponse = { + import_task: ImportTask; + upload_url: string; +}; + +export type GetImportResponse = { + import_task: ImportTask; +}; + +export type ListImportsPaginationOptions = { + limit?: number; + offset?: number; +}; + +export type ListImportsResponse = { + import_tasks: ImportTask[]; +}; + +export type ImportTaskHistory = { + created_at: string; + next_state: string; + prev_state: string; +}; + +export type ImportTask = { + created_at: string; + filename: string; + history: ImportTaskHistory[]; + id: string; + state: string; + updated_at: string; + result?: UR; + size?: number; +};