Skip to content

Commit

Permalink
add support for dataType=pdf in CadenzaClient#downloadData and #fetch…
Browse files Browse the repository at this point in the history
…Data
  • Loading branch information
jkissel committed Jul 12, 2024
1 parent b475a04 commit fffbdcd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- Support for `dataType=pdf` in `CadenzaClient#downloadData` and `CadenzaClient#fetchData`

### Fixed
- Make Cadenza return an error instead of showing an error page.

Expand Down
1 change: 1 addition & 0 deletions sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
<option>csv</option>
<option>excel</option>
<option>json</option>
<option>pdf</option>
</select>
</div>
<div>
Expand Down
14 changes: 7 additions & 7 deletions src/cadenza.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,9 @@ export class CadenzaClient {
* Fetch data from a workbook view.
*
* @param {EmbeddingTargetId} source - The workbook view to fetch data from.
* Currently only table and indicator views are supported.
* @param {DataType} dataType - The data type you want to get back from the server.
* Currently, `"csv"`, `"excel"` and `"json"` are supported.
* Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views
* and `"pdf"` for views of type "JasperReports report".
* @param {object} [options] - Options
* @param {FilterVariables} [options.filter] - Filter variables
* @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
Expand All @@ -839,7 +839,7 @@ export class CadenzaClient {
*/
fetchData(source, dataType, { filter, parts, signal } = {}) {
this.#log('CadenzaClient#fetchData', ...arguments);
assertSupportedDataType(dataType, ['csv', 'excel', 'json']);
assertSupportedDataType(dataType, ['csv', 'excel', 'json', 'pdf']);
const params = createParams({ dataType, filter, parts });
return this.#fetch(resolvePath(source), params, signal);
}
Expand Down Expand Up @@ -875,10 +875,10 @@ export class CadenzaClient {
*
* _Note:_ The file name, if not provided, is generated from the name of the workbook view and the current date.
*
* @param {EmbeddingTargetId} source - The workbook view to download data from.
* Currently only table and indicator views are supported.
* @param {EmbeddingTargetId} source - The workbook view to fetch data from.
* @param {DataType} dataType - The data type you want to get back from the server.
* Currently, `"csv"`, `"excel"` and `"json"` are supported.
* Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views
* and `"pdf"` for views of type "JasperReports report".
* @param {object} [options] - Options
* @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
* @param {FilterVariables} [options.filter] - Filter variables
Expand All @@ -888,7 +888,7 @@ export class CadenzaClient {
*/
downloadData(source, dataType, { fileName, filter, parts } = {}) {
this.#log('CadenzaClient#downloadData', ...arguments);
assertSupportedDataType(dataType, ['csv', 'excel', 'json']);
assertSupportedDataType(dataType, ['csv', 'excel', 'json', 'pdf']);
const params = createParams({ dataType, fileName, filter, parts });
this.#download(resolvePath(source), params);
}
Expand Down

0 comments on commit fffbdcd

Please sign in to comment.