/** * Listing exports. * * The backend runs the listing query once and writes the rows straight to a file * in S3, so an export is not limited by what the browser can hold. Everything * that could be rendered more than one way — which half of a reference, which * part of a user, the value or its timestamp — is decided here and sent along. * * A reference shown by name is written as a link to the element in the app. */ export type ExportFormat = 'csv' | 'xlsx' /** Which part of the stored value wrapper the column reads. */ export type ExportField = 'value' | 'timestamp' | 'author' | 'timestampAt' /** Which part of a complex value ends up in the cell. */ export type ExportPick = // references | 'elementName' | 'hash' | 'both' // users | 'cnSn' | 'uid' | 'email' // files | 'filename' // reference projections: the projected attribute on its own | 'refValue' // dropdowns | 'label' | 'raw' // dates | 'date' | 'dateTime' | 'iso' // dates in ExportColumn.dateFormat | 'custom' // coordinates, stored as [lat, lng]: "lat, lng", or one of them as a number | 'latLng' | 'lat' | 'lng' /** * Whether reference and file cells carry their URL as text: * 'none' "Acme, Globex"; 'nameAndUrl' "Acme (https://…), Globex (https://…)"; * 'url' "https://…, https://…". A cell with a single value is also a real * hyperlink. */ export type ExportLinks = 'none' | 'nameAndUrl' | 'url' export interface ExportColumn { /** Projected attribute, or an element field such as hash, author, timestamp. */ key: string /** Column header. Defaults to the key. */ label?: string /** Defaults to 'value'. */ field?: ExportField pick?: ExportPick /** Overrides the export wide separator for this column only. */ separator?: string /** * For a reference (ATE) column: project this attribute out of every * referenced element, e.g. `room_code` on a `room_ate` column. Each * referenced element is then rendered as "identifier - value", or as the * value alone with pick 'refValue'. */ refAttribute?: string /** * For a file column: put its files into the export, which then downloads as * a ZIP of the table plus one folder per such column (up to 2 GB of files). * The cells link to the files in the ZIP. */ includeFiles?: boolean /** Reference and file columns. Files in the ZIP link to their path in it. */ links?: ExportLinks /** For pick 'custom': day.js style tokens, e.g. 'D.M.YYYY H:mm'. */ dateFormat?: string /** Numbers: add the column's total under the last row. */ sum?: boolean /** XLSX: add a sheet counting the rows per value of this column. */ summary?: boolean /** With summary: split the counts by the column at this index (pivot). */ splitBy?: number } /** * Folders of the files in the ZIP: 'attributeElement' `Drawings/Hall 1/a.pdf`, * 'elementAttribute' `Hall 1/Drawings/a.pdf`. Defaults to 'attributeElement'. */ export type ExportFilesLayout = 'attributeElement' | 'elementAttribute' export interface ExportRequest { /** The listing query, in the same shape the listing itself sends. */ query: Record format: ExportFormat columns: ExportColumn[] /** attribute -> stored value -> label, for dropdown columns. */ valueLabels?: Record> /** Joins multiple values in one cell. Defaults to ', '. */ separator?: string /** IANA name, e.g. 'Europe/Prague'. Dates are formatted in it. */ timezone?: string alsoPublic?: boolean filesLayout?: ExportFilesLayout /** Words written into the file, in the user's language. */ labels?: { total?: string; count?: string; empty?: string } } export interface ExportStarted { /** S3 key of the file being written; also the id of its notifications. */ key: string } export interface ExportFile { key: string name: string size: number lastModified: string /** Signed link, valid for an hour from the moment it was listed. */ url: string }