import { type DataValue, type DimensionGenerator, type GeoCollectionKind, type IAttributeOrMeasure, type IBucket, type IDimension, type IDimensionDescriptor, type IExecutionConfig, type IExecutionDefinition, type IExecutionResultLimitBreak, type IFilter, type IGeoJsonFeature, type IInsight, type IInsightDefinition, type IMeasureDescriptor, type INullableFilter, type IResultHeader, type IResultWarning, type ISortItem } from "@gooddata/sdk-model"; import { type ICancelable } from "../../cancelation/index.js"; /** * @beta */ export interface IForecastConfig { /** * Forecast period in number of periods - e.g. 3 */ forecastPeriod: number; /** * Confidence level of the forecast in percents - e.g. 0.95 */ confidenceLevel: number; /** * Defines, whether the forecast should be seasonal. */ seasonal: boolean; } /** * @beta */ export interface IForecastResult { attribute: string[]; origin: Array; prediction: Array; lowerBound: Array; upperBound: Array; } /** * @beta */ export interface IOutliersConfig { /** * Sensitivity of the outliers detection - e.g. "low" */ sensitivity: "low" | "medium" | "high"; /** * Granularity of the outlier detection, can be omitted, will be * determined automatically */ granularity?: "hour" | "day" | "week" | "month" | "quarter" | "year"; } /** * @beta */ export interface IOutliersResult { attributes: string[]; metrics: { localIdentifier: string; values: Array; }[]; } /** * @alpha */ export interface IAnomalyDetectionConfig { /** * Sensitivity of the anomaly detection - e.g. 1.5 */ sensitivity: number; } /** * @alpha */ export interface IAnomalyDetectionResult { attribute: string[]; values: Array; anomalyFlag: Array; } /** * @alpha */ export interface IClusteringConfig { /** * Number of clusters - e.g. 3 */ numberOfClusters: number; /** * Threshold for clustering - e.g. 0.03 */ threshold?: number; } /** * @alpha */ export interface IClusteringResult { attribute: string[]; clusters: Array; xcoord: Array; ycoord: Array; } /** * Configuration for retrieving collection items (geospatial features). * @alpha */ export interface ICollectionItemsConfig { /** * Collection identifier. */ collectionId: string; /** * Kind of geo collection - STATIC (default) or CUSTOM. * STATIC collections use /api/v1/location/collections/\{collectionId\}/items * CUSTOM collections use /api/v1/location/custom/collections/\{collectionId\}/items */ kind?: GeoCollectionKind; /** * List of values to filter features by. */ values?: string[]; /** * Maximum number of features to return. */ limit?: number; /** * Bounding box filter (minx,miny,maxx,maxy). */ bbox?: string; } /** * Result from collection items retrieval containing GeoJSON features. * @alpha */ export interface ICollectionItemsResult { /** * Collection type (typically "FeatureCollection"). */ type: string; /** * List of GeoJSON features. */ features: IGeoJsonFeature[]; /** * Optional bounding box for all features. */ bbox?: number[]; } /** * A piece of extra information related to the results (e.g. debug information, warnings, etc.). * @alpha */ export interface IExecutionResultDataSourceMessage { /** * Id correlating different pieces of supplementary info together. */ correlationId: string; /** * Information about what part of the system created this piece of supplementary info. */ source: string; /** * Type of the supplementary info instance. * There are currently no well-known values for this, but there might be some in the future. */ type: string; /** * Data of this particular supplementary info item: * a free-form JSON specific to the particular supplementary info item type. */ data?: object; } /** * Additional metadata for the particular execution result. * @alpha */ export interface IExecutionResultMetadata { /** * Additional information sent by the underlying data source. */ readonly dataSourceMessages: ReadonlyArray; /** * Limits broken during result computation, causing partial data to be returned. */ readonly limitBreaks?: ReadonlyArray; } /** * Format in which the result data are streamed. * * - "arrow-stream" for Apache Arrow IPC Stream format (application/vnd.apache.arrow.stream MIME type) * * @alpha */ export type ExecutionResultBinaryStreamFormat = "arrow-stream"; /** * Additional configuration of the execution result retrieval as binary stream. * @alpha */ export interface IExecutionResultBinaryStreamConfig { /** * Which format to retrieve the data in. */ format?: ExecutionResultBinaryStreamFormat; } /** * Additional options for the prepared execution. * * @public */ /** * Arbitrary metadata attached to a prepared execution. * * @remarks * Use this bag to correlate executions with higher-level constructs (for example, * geo layer identifiers). The context travels with the execution through immutable * operations and can be retrieved once the data is resolved. * * @public */ export type IExecutionContext = unknown; /** * @public */ export interface IPreparedExecutionOptions { /** * Signal to abort the execution or its result. */ signal?: AbortSignal; /** * Additional metadata to carry with the execution. */ context?: IExecutionContext; } /** * Execution factory provides several methods to create a prepared execution from different types * of inputs. * * @remarks * Note: the execution factory WILL perform extensive input validation to ensure that the created * instance of prepared execution is semantically correct. * * @public */ export interface IExecutionFactory { /** * Prepares a new execution for the provided execution definition. * * @remarks * The contract is that the definition is taken and used in the prepared execution AS IS. Compared * to the other convenience methods, this method MUST NOT create prepared executions with automatically * generated dimensions. * * @param def - execution definition * @param options - additional options for the prepared execution * @returns new prepared execution */ forDefinition(def: IExecutionDefinition, options?: IPreparedExecutionOptions): IPreparedExecution; /** * Prepares a new execution for a list of attributes and measures, filtered using the * provided filters. * * @remarks * The contract is that prepared executions created by this method MUST be executable and MUST come with * pre-filled dimensions created using the {@link @gooddata/sdk-model#defaultDimensionsGenerator}. * * @param items - list of attributes and measures, must not be empty * @param options - additional options for the prepared execution * @param filters - list of filters, may not be provided */ forItems(items: IAttributeOrMeasure[], filters?: INullableFilter[], options?: IPreparedExecutionOptions): IPreparedExecution; /** * Prepares a new execution for a list of buckets. * * @remarks * Attributes and measures WILL be transferred to the * execution in natural order: * * - Order of items within a bucket is retained in the execution * - Items from first bucket appear before items from second bucket * * Or more specifically, given two buckets with items as [A1, A2, M1] and [A3, M2, M3], the resulting * prepared execution WILL have definition with attributes = [A1, A2, A3] and measures = [M1, M2, M3] * * The contract is that prepared executions created by this method MUST be executable and MUST come with * pre-filled dimensions created using the {@link @gooddata/sdk-model#defaultDimensionsGenerator}. * * @param buckets - list of buckets with attributes and measures, must be non empty, must have at least one attr or measure * @param filters - optional, may not be provided, may contain null or undefined values which must be ignored * @param options - additional options for the prepared execution */ forBuckets(buckets: IBucket[], filters?: INullableFilter[], options?: IPreparedExecutionOptions): IPreparedExecution; /** * Prepares a new execution for the provided insight. * * @remarks * Buckets with attributes and measures WILL be used * to obtain attributes and measures - the behavior WILL be same as in forBuckets() function. Filters, sort by * and totals in the insight WILL be included in the prepared execution. * * Additionally, an optional list of additional filters WILL be merged with the filters already defined in * the insight. * * The contract is that prepared executions created by this method MUST be executable and MUST come with * pre-filled dimensions greated using the {@link @gooddata/sdk-model#defaultDimensionsGenerator}. * * @param insightDefinition - insight definition to create execution for, must have buckets which must have some attributes or measures in them * @param filters - optional, may not be provided, may contain null or undefined values which must be ignored * @param options - additional options for the prepared execution */ forInsight(insightDefinition: IInsightDefinition, filters?: INullableFilter[], options?: IPreparedExecutionOptions): IPreparedExecution; /** * Prepares new, by-reference execution for an existing insight. * * @remarks * Execution prepared using this method MAY be realized using different backend API than the executions where * attributes and measures are provided 'freeform'. In return, this different backend API may provide additional * authorization guarantees - for instance the backend MAY only allow end user to execute these stored insights * and not do any 'freeform' execution. * * If the backend does not support execution by reference, then it MUST fall back to freeform execution. * * The contract is that prepared executions created by this method MUST be executable and MUST come with * pre-filled dimensions created using the {@link @gooddata/sdk-model#defaultDimensionsGenerator}. * * @param insight - saved insight * @param filters - optional list of filters to merge with filters already defined in the insight, may contain null or undefined values which must be ignored * @param options - additional options for the prepared execution */ forInsightByRef(insight: IInsight, filters?: INullableFilter[], options?: IPreparedExecutionOptions): IPreparedExecution; } /** * All supported explain types * @internal */ export type ExplainType = "MAQL" | "GRPC_MODEL" | "WDF" | "QT" | "QT_SVG" | "OPT_QT" | "OPT_QT_SVG" | "SQL"; /** * Config for execution in explain mode * @internal */ export type ExplainConfig = { explainType?: T; }; /** * Represents results of explain done with particular definition for provided exaplain type. * @see ExplainType * * @internal */ export type IExplainResult = { ["MAQL"]: unknown; ["GRPC_MODEL"]: unknown; ["WDF"]: unknown; ["QT"]: unknown; ["OPT_QT"]: unknown; ["QT_SVG"]: string; ["OPT_QT_SVG"]: string; ["SQL"]: string; }; /** * Explain provider for download or get data from explain api * @internal */ export interface IExplainProvider { download(): Promise; data(): Promise]>; } /** * Prepared execution already knows what data to calculate and allows to specify how the data should be * sorted and shaped into dimensions. * * @remarks * To this end, it provides several functions to customize sort items and dimensions. The prepared execution * is immutable and so all the customization functions WILL result in a new instance of prepared execution. * * The contract for creating these new instances is that the new prepared execution MUST be created using the * execution factory that created current execution. * * Note that even though the prepared executions are immutable, the abort signal itself is stateful * and is always propagated through the whole immutable chain. * If you don't want to cancel multiple executions simultaneously via single abort signal, * you need to set it on the outermost execution only, just before calling the execute method. * * @public */ export interface IPreparedExecution extends ICancelable { /** * Definition of the execution accumulated to so far. */ readonly definition: IExecutionDefinition; /** * Abort signal to cancel the execution or its result. */ readonly signal?: AbortSignal; /** * Arbitrary execution metadata provided by the caller. */ readonly context?: IExecutionContext; /** * Changes sorting of the resulting data. Any sorting settings accumulated so far WILL be wiped out. * * @param items - items to sort by * @returns new execution with the updated sorts */ withSorting(...items: ISortItem[]): IPreparedExecution; /** * Configures dimensions of the resulting data. Any dimension settings accumulated so far WILL be wiped out. * * @remarks * The realizations of analytical backend MAY impose constraints on the minimum and maximum number of dimensions. * This call WILL fail if the input dimensions do not match constraints imposed by the backend. * * @param dim - dimensions to set * @returns new execution with the updated dimensions */ withDimensions(...dim: Array): IPreparedExecution; /** * Configures buckets of the resulting data. Any dimension settings accumulated so far WILL be wiped out. * * @param buckets - buckets to set * @returns new execution with the updated buckets * @internal */ withBuckets(...buckets: IBucket[]): IPreparedExecution; /** * Adds the desired date format to the postProcessing of an IPreparedExecution. * * @param dateFormat - Format to be applied to the dates in an AFM execution response. * @returns new execution with the updated postProcessing */ withDateFormat(dateFormat: string): IPreparedExecution; /** * Starts the execution. */ execute(): Promise; /** * Starts the execution in explain mode. * @internal */ explain(config: ExplainConfig): IExplainProvider<(typeof config)["explainType"]>; /** * Tests whether this execution and the other execution are the same. * * @remarks * This effectively means that their definitions are deeply equal. * * If you are only concerned with the equality from the result calculation point of view, * consider comparing fingerprints instead. * * @param other - another execution */ equals(other: IPreparedExecution): boolean; /** * Fingerprint of this prepared execution. * * @remarks * This is effectively the fingerprint of the execution * definition underlying this instance of Prepared Execution. */ fingerprint(): string; /** * Additional execution configuration */ withExecConfig(config: IExecutionConfig): IPreparedExecution; /** * Attaches custom execution context metadata. * * @param context - metadata to associate with this execution * @returns new execution containing the provided context */ withContext(context: IExecutionContext): IPreparedExecution; } /** * Configuration for exports of results into tabular formats. * * @public */ export interface IExportConfig { /** * Format of the export file. Defaults to CSV if not specified. */ format?: "xlsx" | "csv" | "raw" | "pdf"; /** * Applicable for XLSX format; specifies title of the workbook. */ title?: string; /** * Applicable for CSV format; specifies the delimiter to use between values. */ delimiter?: string; /** * Applicable for XLSX format; indicates whether headers and cells in the sheet * should be merged. */ mergeHeaders?: boolean; /** * Applicable for XLSX, and PDF format; specifies filters to include as comments / metadata in * the Excel sheet. * * @remarks * Filters provided here are purely to paint a better context for the * person looking at the exported file. They serve no other purpose and are merely serialized * in the export in a human-readable form. * The visualizationObjectId has to be provided to make this work for PDF format. */ showFilters?: boolean; /** * Applicable for PDF format; specifies configuration for PDF export. */ pdfConfiguration?: IExportPdfConfig; /** * Visualization object identifier. Used to ensure the export result is generated based on * existing visualization in the PDF document. (PDF only) */ visualizationObjectId?: string; /** * Optional custom filters (as array of IFilter objects defined in UI SDK) to be applied * when visualizationObject is given. (PDF only) */ visualizationObjectCustomFilters?: Array; /** * Position of grand totals in the exported document. * * @remarks * Takes precedence over the position specified in the visualization object. * Applicable to all tabular export formats (XLSX, CSV, PDF). */ grandTotalsPosition?: "pinnedBottom" | "pinnedTop" | "bottom" | "top"; /** * Concrete IANA timezone ID used to resolve relative date filters and render date/time values * in the export. Overrides the workspace/user timezone settings. * * @alpha */ timezoneId?: string; /** * Override the default export result polling timeout (in milliseconds). * * @remarks * If not specified, there is still a default timeout applied. * You can use this to make the timeout more aggressive or more relaxed than the default. * We recommend not setting this lower than 5 seconds as it would mean only one attempt would be made. */ timeout?: number; /** * Pre-executed additional layers for multi-layer geo visualizations. * * @remarks * When set, the export includes one sheet (XLSX) or file (CSV zip) per layer. The result * that {@link IExecutionResult.export} is called on is the main layer (index 0); these are * the additional layers, in their original order. Each layer carries its own execution result * so the backend can build per-layer overrides. * * @alpha */ additionalExecutions?: ReadonlyArray; } /** * A single pre-executed additional layer in a multi-layer tabular export. * * @alpha */ export interface IExportAdditionalExecution { /** Already-executed result for this layer. */ executionResult: IExecutionResult; /** Layer title used for the exported sheet or file name. */ title?: string; } /** * Configuration for PDF export. * * @public */ export interface IExportPdfConfig { /** Page size and orientation (e.g. 'a4 landscape'). @deprecated Use pageSize and pageOrientation instead. */ pdfPageSize?: string; /** PDF top left header content. @deprecated This property is no longer supported. */ pdfTopLeftContent?: string; /** PDF top right header content. @deprecated This property is no longer supported. */ pdfTopRightContent?: string; /** Page size */ pageSize?: "A3" | "A4" | "LETTER"; /** Page orientation */ pageOrientation?: "PORTRAIT" | "LANDSCAPE"; /** Show info page with export information. */ showInfoPage?: boolean; } /** * Result of export is an object URL pointing to a Blob of downloaded data attached to the current * window instance. The result also contains name of the downloaded file provided by the backend export * service. * * {@link URL#revokeObjectURL} method must be used when object URL is no longer needed to release * the blob memory. * * @public */ export interface IExportResult { /** URI from which can the export be fetched again */ uri: string; /** Object URL pointing to the downloaded blob of exported data */ objectUrl: string; /** Name of the exported file provided by the export service */ fileName?: string; } /** * Represents results of execution done with particular definition. * * @remarks * Within the result is the description of the shape of the data and methods to to obtain views on the data. * * @public */ export interface IExecutionResult extends ICancelable { /** * Full definition of execution that yielded this result. */ readonly definition: IExecutionDefinition; /** * Arbitrary metadata carried over from the originating prepared execution. */ readonly context?: IExecutionContext; /** * Description of shape of the data. */ readonly dimensions: IDimensionDescriptor[]; /** * Abort signal to cancel the result retrieval. * * Note that the abort signal is shared with the prepared execution that created this result, * so if you cancel the result and want to retrieve it later again, * you should always create also a new execution for it. */ readonly signal?: AbortSignal; /** * Asynchronously reads all data for this result into a single data view. * * @returns Promise of data view */ readAll(): Promise; /** * Asynchronously reads a window of data for this result. * * @remarks * The window is specified using * offset array and size array. The offsets specify coordinates where the view starts and * are zero-based. The sizes specify size of the window in each of the results dimension. * * * @param offset - coordinates where the window starts * @param size - size of the window in each of the dimensions * @returns Promise of data view */ readWindow(offset: number[], size: number[]): Promise; /** * Reads forecast for the execution result. * @beta */ readForecastAll(config: IForecastConfig): Promise; /** * Reads outliers for the execution result. * @alpha */ readOutliersAll(config: IOutliersConfig): Promise; /** * Reads anomaly detection for the execution result. * @alpha */ readAnomalyDetectionAll(config: IAnomalyDetectionConfig): Promise; /** * Reads anomaly detection for the execution result. * @alpha */ readClusteringAll(config: IClusteringConfig): Promise; /** * Reads all the execution result data as a binary stream. * @alpha */ readBinaryStreamAll(config: IExecutionResultBinaryStreamConfig): Promise; /** * Transforms this execution result - changing the result sorting, dimensionality and available * totals is possible through transformation. * * @remarks * It is strongly encouraged to use this function every time when data SHOULD remain the same and just * its sorting or dimensionality or totals MUST change. That is because since this intent of the caller * is known, the function can apply additional optimizations and obtain the updated result faster * compared to fully running the execution. * * Whether the reuse of the computed result actually happens depends on couple of factors: * * - Transformation is eligible: adding new native totals (roll-ups) necessitates full re-execution; * all other types of changes (including adding other types of totals) are eligible for execution result reuse. * * - Backend capabilities: backend MAY NOT be able to natively reuse existing execution result. This is * communicated by the canTransformExistingResult indicator. * * If the transformation is not eligible for result reuse or the backend is not capable of this optimization, then * a new execution WILL be done completely transparently for the caller. * * @returns new prepared execution with no sorts, dimensions or totals */ transform(): IPreparedExecution; /** * Asynchronously exports all data in this result to a blob. * * Exported file is downloaded and attached as Blob data to the current window instance. * * @param options - customize how the result looks like (format etc.) * @returns promise with object URL pointing to a Blob data of downloaded exported insight */ export(options: IExportConfig): Promise; /** * Tests if this execution result is same as the other result. * * @param other - other result * @returns true if equal, false if not */ equals(other: IExecutionResult): boolean; /** * Unique fingerprint of the execution result. * * @remarks * The fingerprint is influenced by both data included in * the result and its dimensionality, sorting and totals. * * Thus, two results with the same data and same execution definition will have the same fingerprint. */ fingerprint(): string; /** * Server-assigned identifier of this execution result. * * @remarks * This is the signed result ID that can be used to reference the cached execution result * when communicating with backend services (e.g. GenAI context). * * @returns the result ID string, or undefined if not available * @internal */ resultId(): string | undefined; } /** * A view on the calculated data. * * @remarks * * See also the `{@link @gooddata/sdk-ui#DataViewFacade}`. This wrapper on top of this raw IDataView can be used to work * with the data in a way more convenient fashion. * * @public */ export interface IDataView { /** * Coordinates of where this data view starts. One coordinate per result dimension. */ readonly offset: number[]; /** * Count of data in each dimension. */ readonly count: number[]; /** * Total size of data in each dimension. */ readonly totalCount: number[]; /** * Headers are metadata for the data in this view. * * @remarks * There are headers for each dimension and in * each dimension headers are further sliced by the attribute or measure or total to which the data * belongs. * * Thus: * * - Top array contains 0 to N per-dimension arrays, one for each requested dimension (if any) * - The per-dimension arrays then contain per-slice array, one for each attribute or measure in the dimension * - The per-slice-array then contains the actual result header which includes information such as attribute element * or measure name */ readonly headerItems: IResultHeader[][][]; /** * The calculated data. Dimensionality of the data matches the dimensions requested at execution time. */ readonly data: DataValue[][] | DataValue[]; /** * Grand totals included in this data view. * * @remarks * Grand totals are included for each dimension; within each * dimension there is one entry per requested total and for each requested total there are list of values. * * Thus: * * - Top array contains 0 to N per-dimension arrays * - Each per-dimension array contains one per-total entry for each requested total * - Each per-total entry contains array of calculated values, cardinality of this matches the cardinality * of the data in the respective dimension. */ readonly totals?: DataValue[][][]; /** * Totals of grand totals included in this data view. */ readonly totalTotals?: DataValue[][][]; /** * Full definition of execution that computed data included in this DataView. */ readonly definition: IExecutionDefinition; /** * Result of the execution that calculated data for this view. */ readonly result: IExecutionResult; /** * Execution context metadata available on this data view. */ readonly context?: IExecutionContext; /** * Additional metadata for the particular execution result. * @alpha */ readonly metadata: IExecutionResultMetadata; /** * Configuration for the forecasting, if available. * @beta */ readonly forecastConfig?: IForecastConfig; /** * Forecasting result, if available. * @beta */ readonly forecastResult?: IForecastResult; /** * Configuration for the outliers, if available. * @alpha */ readonly outliersConfig?: IOutliersConfig; /** * Outliers result, if available. * @alpha */ readonly outliersResult?: IOutliersResult; /** * Configuration for the clustering, if available. * @beta */ readonly clusteringConfig?: IClusteringConfig; /** * Clustering result, if available. * @beta */ readonly clusteringResult?: IClusteringResult; /** * Result warnings. * * @remarks * Backend MAY return warnings to indicate that the result is different compared to what the caller can expect. * For example, the caller executes a definition with particular filter, * but the backend determines that the filter has no effect on the computation. * Backend runs the execution and communicates by warning that the filter was useless. */ readonly warnings?: IResultWarning[]; /** * Tests if this data view is same as the other data view. * * @param other - other data view * @returns true if equal, false if not */ equals(other: IDataView): boolean; /** * Unique fingerprint of this data view. * * @remarks * The fingerprint is influenced by the execution result and the * offset and limit of the data view. * * Thus, two data views on the same result, with same offset and limit will have the same fingerprint. */ fingerprint(): string; /** * Return forecast data view. This object is empty if not `withForecast` was called * @see IDataView.withForecast * @beta */ forecast(): IForecastView; /** * Return clustering data view. This object is empty if `withClustering` was not called * @see IDataView.withClustering * @beta */ clustering(): IClusteringResult; /** * Return outliers data view. This object is empty if not `withOutliers` was called * @see IDataView.withOutliers * @alpha */ outliers(): IOutliersView; /** * Adds forecast for this data view. * * @beta * @param config - forecast configuration * @param result - forecast result * @returns new data view with forecasting enabled */ withForecast(config?: IForecastConfig, result?: IForecastResult): IDataView; /** * Adds clustering for this data view. * @beta * @param config - clustering configuration * @param result - clustering result * @returns new data view with clustering enabled */ withClustering(config?: IClusteringConfig, result?: IClusteringResult): IDataView; /** * Adds outliers for this data view. * @alpha * @param config - outliers configuration * @param result - outliers result * @returns new data view with outliers enabled */ withOutliers(config?: IOutliersConfig, result?: IOutliersResult): IDataView; /** * Retrieves collection items (geospatial features) using provided configuration. * * * @param config - configuration including collection identifier and optional filters * @returns promise of collection items result with GeoJSON features * @alpha */ readCollectionItems(config: ICollectionItemsConfig): Promise; } /** * Represents a prediction, lower bound and upper bound for a forecast. * @beta */ export interface IForecastView { headerItems: IResultHeader[][][]; prediction: DataValue[][]; low: DataValue[][]; high: DataValue[][]; loading: boolean; } /** * Represents a outliers detection on current graph * @beta */ export interface IOutliersView { headerItems: (IResultHeader & IMeasureDescriptor)[]; anomalies: DataValue[][]; loading: boolean; } //# sourceMappingURL=index.d.ts.map