(core) Relocate export urls to /download/

Summary:
Moves CSV and XLSX export urls under /download/, and
removes the document title query parameter which is now
retrieved from the backend.

Test Plan: No new tests. Existing tests that verify endpoints still function.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3010
This commit is contained in:
George Gevoian
2021-09-01 14:07:53 -07:00
parent cecebded1f
commit 0717ee627e
9 changed files with 153 additions and 101 deletions

View File

@@ -11,6 +11,7 @@ import {FullUser} from 'app/common/LoginSessionAPI';
import {OrgPrefs, UserOrgPrefs, UserPrefs} from 'app/common/Prefs';
import * as roles from 'app/common/roles';
import {addCurrentOrgToPath} from 'app/common/urlUtils';
import {encodeQueryParams} from 'app/common/gutil';
export {FullUser} from 'app/common/LoginSessionAPI';
@@ -320,6 +321,16 @@ export interface UserAPI {
forRemoved(): UserAPI; // Get a version of the API that works on removed resources.
}
/**
* Parameters for the download CSV endpoint (/download/csv).
*/
export interface DownloadCsvParams {
tableId: string;
viewSection?: number;
activeSortSpec?: string;
filters?: string;
}
/**
* Collect endpoints related to the content of a single document that we've been thinking
* of as the (restful) "Doc API". A few endpoints that could be here are not, for historical
@@ -347,8 +358,8 @@ export interface DocAPI {
// is HEAD, the result will contain a copy of any rows added or updated.
compareVersion(leftHash: string, rightHash: string): Promise<DocStateComparison>;
getDownloadUrl(template?: boolean): string;
getGenerateXlsxUrl(): string;
getGenerateCsvUrl(): string;
getDownloadXlsxUrl(): string;
getDownloadCsvUrl(params: DownloadCsvParams): string;
/**
* Exports current document to the Google Drive as a spreadsheet file. To invoke this method, first
* acquire "code" via Google Auth Endpoint (see ShareMenu.ts for an example).
@@ -792,12 +803,13 @@ export class DocAPIImpl extends BaseAPI implements DocAPI {
return this._url + `/download?template=${Number(template)}`;
}
public getGenerateXlsxUrl() {
return this._url + '/gen-xlsx';
public getDownloadXlsxUrl() {
return this._url + '/download/xlsx';
}
public getGenerateCsvUrl() {
return this._url + '/gen-csv';
public getDownloadCsvUrl(params: DownloadCsvParams) {
// We spread `params` to work around TypeScript being overly cautious.
return this._url + '/download/csv?' + encodeQueryParams({...params});
}
public async sendToDrive(code: string, title: string): Promise<{url: string}> {