Skip to content

Commit

Permalink
feat: added private _createImportURL method (#918)
Browse files Browse the repository at this point in the history
Co-authored-by: ferhat elmas <[email protected]>
  • Loading branch information
gumuz and ferhatelmas authored Mar 10, 2022
1 parent 1523889 commit a820666
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 22 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import {
ExportUsersRequest,
ExportUsersResponse,
CreateImportResponse,
CreateImportURLResponse,
GetImportResponse,
ListImportsResponse,
ListImportsPaginationOptions,
Expand Down Expand Up @@ -2833,7 +2834,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
}

/**
* _createImport - Create an Import Task.
* _createImportURL - Create an Import upload url.
*
* Note: Do not use this.
* It is present for internal usage only.
Expand All @@ -2844,12 +2845,30 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
*
* @return {APIResponse & CreateImportResponse} An ImportTask
*/
async _createImport(filename: string) {
return await this.post<APIResponse & CreateImportResponse>(this.baseURL + `/imports`, {
async _createImportURL(filename: string) {
return await this.post<APIResponse & CreateImportURLResponse>(this.baseURL + `/import_urls`, {
filename,
});
}

/**
* _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} path path of uploaded data
*
* @return {APIResponse & CreateImportResponse} An ImportTask
*/
async _createImport(path: string) {
return await this.post<APIResponse & CreateImportResponse>(this.baseURL + `/imports`, {
path,
});
}

/**
* _getImport - Get an Import Task.
*
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2157,9 +2157,13 @@ export type TruncateOptions<StreamChatGenerics extends ExtendableGenerics = Defa
truncated_at?: Date;
};

export type CreateImportURLResponse = {
path: string;
upload_url: string;
};

export type CreateImportResponse = {
import_task: ImportTask;
upload_url: string;
};

export type GetImportResponse = {
Expand All @@ -2183,9 +2187,9 @@ export type ImportTaskHistory = {

export type ImportTask = {
created_at: string;
filename: string;
history: ImportTaskHistory[];
id: string;
path: string;
state: string;
updated_at: string;
result?: UR;
Expand Down

0 comments on commit a820666

Please sign in to comment.