@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
829 lines (813 loc) • 39.4 kB
TypeScript
import { MeasurementService, IFetchResponse, IMeasurementFilter, IMeasurement, ISeriesFilter, IResult, ISeries } from '@c8y/client';
import { AggregationOption, AlertService, AggregationOptionStatus, AggregationService, GainsightService, ModalLabels } from '@c8y/ngx-components';
import { TranslateService } from '@ngx-translate/core';
import * as i0 from '@angular/core';
import { InjectionToken, OnInit, OnDestroy, EventEmitter } from '@angular/core';
import { SupportedIconsSuggestions } from '@c8y/ngx-components/icon-selector/icons';
import { ValidatorFn, FormBuilder } from '@angular/forms';
import * as packages_client_lib from 'packages/client/lib';
import { AggregationOptionStatus as AggregationOptionStatus$1, AggregationOption as AggregationOption$1 } from '@c8y/ngx-components/global-context';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
type Measurement = number | {
min: number;
max: number;
};
interface SeriesInfo {
unit: string | null | undefined;
name: string;
type: string | null | undefined;
}
interface SourceData {
series: SeriesInfo[];
values: {
[timestamp: string]: (Measurement | null)[] | undefined;
};
truncated: boolean;
}
interface SourceItem {
source: string | number;
data: SourceData;
}
interface TransformedSeries {
values: {
[timestamp: string]: Measurement;
} | null;
seriesDetails: SeriesInfo;
}
interface TransformedSource {
[seriesType: string]: TransformedSeries;
}
interface TransformedData {
[sourceId: string]: TransformedSource;
}
declare class UtilsService {
transformDataStructure(data: SourceItem[]): TransformedData;
/**
* Formats a date range into a specific string format, handling UTC dates correctly.
*
* @param fromDate - The start date in ISO format (e.g., "2023-12-04T12:40:00.000Z")
* @param toDate - The end date in ISO format (e.g., "2023-12-06T23:50:00.000Z")
* @returns A string representing the date range in the format "ddmmmyyhhmm-ddmmmyyhhmm"
* where d=day, m=month, y=year, h=hour, m=minute
*
* Example
* ```typescript
* const fromDate = "2023-12-04T12:40:00.000Z";
* const toDate = "2023-12-06T23:50:00.000Z";
* const formattedRange = getFormattedDateRange(fromDate, toDate);
* console.log(formattedRange); // Output: "04dec231240-06dec232350"
* ```
*/
getFormattedDateRange(fromDate: string, toDate: string): string;
static ɵfac: i0.ɵɵFactoryDeclaration<UtilsService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<UtilsService>;
}
declare const HAS_ERROR = "has-error";
declare const MEASUREMENTS_PREVIEW_ITEMS_LIMIT = 5;
declare const SERIES_DATA_MERGED_FILE_NAME = "seriesDataMergedFileName";
/**
* Represents counts of datapoints data categorized by their availability and delivery method.
*/
interface DatapointCounts {
/**
* The number of datapoints whose data can be directly downloaded
* through a web browser.
*/
browserDownloadableCount: number;
/**
* The number of datapoints whose data will be sent via email because its record count exceeded 50_000.
*/
emailDeliverableCount: number;
/**
* The number of datapoints whose data cannot be retrieved at all,
* neither through direct download nor via email because its record count exceeded 1_000_000 API limit.
*/
nonRetrievableCount: number;
}
/**
* Represents a datapoints which number of records exceed a threshold where data will be precessed by a backend.
*/
interface DatapointsExceedingLimit {
datapointDetail: DatapointDetails;
totalElements: number;
}
interface DateFetchConfig {
date: string;
shouldFetchData: boolean;
}
interface IDataTransformer {
transformToMergedFormat(data: ExportData[]): TimeSeriesColumnData;
}
interface FileGenerator {
generateMerged?: (exportData: ExportData[], mergedExportDetails: MergedExportDetails) => BlobPart;
getFileExtension(): string;
getMimeType(): string;
getLabel(): string;
getIcon(): string;
getType(): string;
getTitle(): string;
getZipName(): string;
getAcceptType(): string;
}
interface FileTypeMetadata {
extension: string;
icon: SupportedIconsSuggestions;
label: string;
title: string;
type: string;
zipName: string;
}
/**
* Represents the data structure, which is used to be transformed into a file (series) or used for a preview (series and measurements).
*/
interface ExportData {
time?: string | null;
source: string | number;
device_name: string;
fragment_series: string;
/**
* Represents the value of a measurement for /measurement data API.
*/
value?: number | null;
/**
* Represents the min value of a measurement for /series data API.
*/
value_min?: number | null;
/**
* Represents the value of a measurement for /series data API.
* Measurement API data does not contain max value.
*/
value_max?: number | null;
unit?: string | null;
}
interface DatapointDetails {
deviceName?: string;
source: string | number;
valueFragmentSeries: string;
valueFragmentType: string;
}
/**
* Represents the data structure, which is used to be
* transformed into an ExportData.
*/
interface DataToExport extends DatapointDetails {
unit: string | undefined;
timeValueMap: {
[timestamp: string]: Measurement;
} | undefined;
}
/**
* Represents the data to be exported along with the backend-created file.
* Only measurements API generates a file on the backend.
*/
interface DataToExportWithBackendCreatedFile {
source: string | number;
valueFragmentSeries: string;
valueFragmentType: string;
fetchedMeasurementsBlobFile: Blob;
}
/**
* Base configuration for the export process.
*/
interface ExportConfig {
aggregation?: AggregationOption;
datapointDetails: DatapointDetails[];
dateFrom: string;
dateTo: string;
}
/**
* Represents the configuration on the basis of which the zip file is created.
*/
interface FileExportConfig {
fileType: string;
zipName: string;
}
/**
* Represents a required config properties used in a process of generating a measurements based export file.
*/
interface MeasurementFileConfig {
exportConfig: ExportConfig;
acceptFileType: string;
}
/**
* Represents a required config properties along with transformed data structures,
* used in a process of generating a series based export file.
*/
interface SeriesExportParams {
flattenedAndSortedExportData: ExportData[];
fileType: string;
mergedExportDetails: MergedExportDetails;
}
interface TimeSeriesColumnData {
timeSeries: Map<TimeStamp, ColumnValueMap>;
uniqueColumnIdentifiers: string[];
}
/**
* Represents a mapping of datapoints series values.
* The key of the map is a source, and the value is the value data from requested series.
*/
type DatapointsValuesDataMap = Map<SourceId | number, string[]>;
type SourceId = string | number;
type FileCompressionTypes = 'STORE' | 'DEFLATE';
type TimeSeriesData = {
[timestamp: string]: Measurement;
};
interface FileTypeConfig {
extension: string;
mimeType: string;
acceptType: string;
}
/**
* Represents the details unique for a merged file.
*/
type MergedExportDetails = {
aggregation: AggregationOption;
dateFrom: string;
dateTo: string;
};
type ExportedFile = {
fileName: string;
fileData: Blob;
};
type TimeStamp = string;
type ReadingValue = number;
/**
* Represents the min and max values for a specific timestamp.
* Both min and max values are available only when using series API.
*/
type MinMaxValues = {
min: number;
max: number;
};
/**
* Represents a mapping of column headers and their corresponding values.
* e.g. 'Temperature - 5 -> c8y_Temperature.T [ºC] (max)': 25
*/
type ColumnValueMap = {
[key: ColumnHeader]: ReadingValue;
};
declare const EXPORT_MODE_LABELS: {
readonly FULL: "Full";
readonly COMPACT: "Compact";
};
/**
* Each export type is based on a different API:
* - COMPACT - series
* - FULL - measurements
* All differences between export modes:
* Compact:
* Processes up to 5,000 records per data point, or up to the data retention limit (API limit)
* Creates a single merged file containing all the data
* Provides minimum and maximum values (API feature)
* Preview is not available
* Supports optional data aggregation (API feature)
* Full:
* Processes up to 1,000,000 records per data point, or up to the data retention limit (API limit)
* For exports exceeding 50,000 records, data will be sent via email
* Creates a compressed ZIP file containing separate data files for each selected data point
* Preview is available
* Does not support data aggregation
*/
declare const EXPORT_MODE_VALUES: {
readonly full: "FULL";
readonly compact: "COMPACT";
};
declare const FILE_COMPRESSION_TYPES_VALUES: {
readonly store: "STORE";
readonly deflate: "DEFLATE";
};
declare const PRODUCT_EXPERIENCE_DATAPOINTS_EXPORT_SELECTOR: {
readonly EVENTS: {
readonly EXPORT_SELECTOR: "exportSelector";
};
readonly COMPONENTS: {
readonly DATAPOINTS_EXPORT_SELECTOR: "datapoints-export-selector";
readonly DATAPOINTS_EXPORT_SELECTOR_FILE_EXPORTER: "datapoints-export-selector-file-exporter";
};
readonly ACTIONS: {
readonly OPEN_MODAL: "openModal";
readonly DOWNLOAD_STARTED: "downloadStarted";
};
readonly EXPORT_CONFIG: {
readonly FULL_EXPORT_TYPE: "fullExportType";
readonly COMPACT_EXPORT_TYPE: "compactExportType";
};
};
declare class DataFetchingService {
private alertService;
private measurementService;
private translateService;
private utilsService;
constructor(alertService: AlertService, measurementService: MeasurementService, translateService: TranslateService, utilsService: UtilsService);
/**
* Checks if any of measurements requests may exceeded the limit,
* after which the export data is processed by the backend and the generated CSV/Excel file is sent by email.
*
* The threshold is set to 50_000 records in application's core properties (export.data.synchronous.limit).
*
* @param exportConfig - The export configuration.
* @returns A promise that returns an array of objects representing datapoints files that will be sent by email.
*/
getDatapointsExceedingLimit(exportConfig: ExportConfig): Promise<DatapointsExceedingLimit[]>;
/**
* Retrieves the message to be displayed when the limit of datapoints is exceeded during file export.
*
* @param hasNoExportableData - Indicates if there is no exportable data because the date range of all selected datapoints exceeds 1,000,000 records.
* @param emailDeliverableCount - The number of datapoint exports that exceed the limit, will be proceeded by the backend and sent by email.
* @param browserDownloadableCount - The number of datapoint exports that can be downloaded directly.
* @param skippedDatapointCount - The number of datapoint exports skipped due to exceeding the measurements API limit of 1,000,000 records.
* @param totalDatapointsSelectedForExportCount - Total number of datapoint selected for exports.
* @returns The message that can be injected.
*/
getLimitExceededMessage(hasNoExportableData: boolean, emailDeliverableCount?: number, browserDownloadableCount?: number, nonRetrievableCount?: number, totalDatapointsSelectedForExportCount?: number): string;
/**
* Trims the given HTML message by removing list items that correspond to zero counts.
*
* @param message - The HTML string containing the message with list items.
* @param counts - An array of number values corresponding to each list item.
* @param countToTrim - A count that will be trimmed with corresponding list item.
* @returns A trimmed HTML string with list items removed where the corresponding count is zero.
*
* Example:
* ```typescript
* const message = '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>';
* const counts = [1, 0, 2];
* const trimmedMessage = this.removeZeroCountListItems(message, counts);
* // Result: '<ul><li>Item 1</li><li>Item 3</li></ul>'
* ```
*/
removeZeroCountListItems(message: string, counts: number[], countToTrim?: number): string;
/**
* Displays an information alert about sending data via email.
*
* Only measurements API can send files via email.
*
* @param fileType - The type of file to be sent.
* @param datapointsExceedingLimit - The array of datapoints exceeding the limit.
*/
showSendViaEmailInfoAlert(fileType: string, datapointsExceedingLimit: DatapointsExceedingLimit[]): void;
fetchMeasurementDataFilesAndPairWithSourceDetails(acceptFileType: string, exportConfig: ExportConfig): Promise<DataToExportWithBackendCreatedFile[]>;
fetchAndProcessMeasurementFile(details: DatapointDetails, measurementFileConfig: MeasurementFileConfig, roundSeconds?: boolean): Promise<DataToExportWithBackendCreatedFile | undefined>;
mergeMeasurementsWithItsSourceDetails(details: DatapointDetails, measurementFile: IFetchResponse): Promise<DataToExportWithBackendCreatedFile>;
fetchAndPrepareDataToExport(exportConfig: ExportConfig, isMeasurement: boolean): Promise<DataToExport[]>;
prepareMeasurementsFilter(details: DatapointDetails, exportConfig: ExportConfig, roundSeconds: boolean, pageSize?: number): IMeasurementFilter;
processMeasurementDataForPreview(details: DatapointDetails, data: IMeasurement[]): DataToExport;
/**
* Returns a map of active data points device IDs with their corresponding series.
*
* Example output:
* ```typescript
* new Map([
* ['844657202', ['c8y_Temperature.T']],
* ['32666427', ['c8y_Battery.Battery']]
* ]);
* ```
* @param datapointDetails - An array of data points details.
* @returns A map where the key is the data point ID and the value is an array of data point series.
*/
groupSeriesByDeviceId(datapointDetails: DatapointDetails[]): DatapointsValuesDataMap;
/**
* Processes the fetched series data and prepares it for export.
*
* @param datapointDetails - An array of data point details.
* @param fetchedDataMap - A map of fetched series data grouped by source.
* @returns An array of DataToExport objects.
*/
processSeriesData(datapointDetails: DatapointDetails[], fetchedDataMap: SourceItem[]): DataToExport[];
getSourcesWithPermissionsToRead(datapointDetails: DatapointDetails[]): Promise<string[]>;
/**
* Adjusts the given date by adding the specified number of minutes and setting seconds to 0.
*
* @param date - The date to be adjusted in string format.
* @param minutes - The number of minutes to add to the date.
* @param roundSeconds - Whether to round the seconds or not.
* If true, the seconds will be rounded to 0.
* If false, the seconds will be displayed as they are.
* @returns The adjusted date in ISO string format.
*/
adjustDate(date: string | Date, minutes: number, roundSeconds?: boolean): string;
/**
* Asynchronously loads series data based on the provided parameters.
*
* This method constructs a filter for retrieving series data within a specified date range,
* from a specific source, and optionally applying an aggregation type.
*
* @param rawFilter - The parameters for loading series data, including date range, source, series names, and aggregation type.
* @param roundSeconds - Indicates whether to round the seconds in the date range to the nearest whole number.
* @returns A promise that resolves to series data wrapped in result object.
*/
fetchSeriesData(rawFilter: ISeriesFilter, roundSeconds?: boolean): Promise<IResult<ISeries>> | undefined;
/**
* Fetches and prepares measurement data for preview.
*
* Empty DataToExport object can be returned, because unlike series data,
* measurement data is not further processed besides showing only in the preview.
* CSV/Excel files are generated by the backend for measurements.
*
* @param exportConfig - The export configuration.
* @param roundSeconds - Indicates whether to round the seconds in the date range to the nearest whole number.
* @returns A promise that resolves to an array of DataToExport objects or null when no data is fetched.
*/
private fetchAndPrepareMeasurementDataToExportForPreview;
private fetchMeasurementDataForPreview;
private fetchAndPrepareSeriesDataToExport;
private prepareSeriesFilter;
static ɵfac: i0.ɵɵFactoryDeclaration<DataFetchingService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DataFetchingService>;
}
declare class DataProcessingService {
private fileGenerators;
private utils;
mergeMapping: {};
fileTypesConfigs: {
[key: string]: {
extension: string;
mimeType: string;
acceptType: string;
};
};
constructor(fileGenerators: FileGenerator[], utils: UtilsService);
setGenerators(fileGenerators: FileGenerator[]): void;
/**
* Transforms the data into a structured format for an export.
*
* @param dataToExport - An array of processed measurement data combined with the respective properties of the datapoint.
* @returns Provides a two-dimensional array of ExportData,
* where each inner array contains ExportData entries representing the transformed measurements and metadata of each datapoint.
*/
transformToExportFileStructure(dataToExport: DataToExport[]): ExportData[][];
/**
* Transforms the input datapoints with values into a structured format for a preview.
*
* @param dataToExport - An array of processed measurement data combined with the respective properties of the datapoint.
* @returns Provides an array of up to 5 ExportData elements (no more is needed for a preview) or an empty array,
*/
transformToExportFileStructureForPreview(dataToExport: DataToExport[]): ExportData[];
/**
* Processes a single dataToExport and transforms it into an array of ExportData.
*
* Used further for creating series data based export and also for measurements and series data based preview.
* Series data provides min and max values for each timestamp.
*
* @param dataToExport - A processed measurement or series data combined with the respective properties of the datapoint to be precessed
* @returns An array of ExportData representing the processed datapoint,
* that can be used as a row data in the exported files or for preview.
*/
processDataToExport(dataToExport: DataToExport): ExportData[];
createExportData(dataToExport: DataToExport, time: string, isMeasurement: boolean, value: number, valueMax?: number): ExportData;
/**
* Exports the given data to merged CSV or Excel files.
*
* @param exportData - An array containing ExportData objects that will be used as parts of the merged file.
* @param fileType - Indicates the type of the file to be exported.
* @param mergedExportDetails - An object containing the date range from which the export was created and aggregation type.
* @returns An objects containing file name and its respective content as Blob.
*
* Example of exported merged file structure:
* date from date to
* 2024-04-15T12:14:00.000Z 2024-07-16T14:14:28+02:00
* time G6Fit -> c8y_Acceleration.accelerationX [G] G6Fit -> c8y_Acceleration.accelerationY [G]
* 2024-05-13T13:45:10.500+02:00 0.0109026359624273 0.789461628278069
*
* Example of exported file name format:
* 04dec231240-06dec232350.xlsx
*/
exportSeriesDataToMergedFiles(exportData: ExportData[], fileType: string, mergedExportDetails: MergedExportDetails): Promise<ExportedFile>;
/**
* Zips all created files.
*
* @param files - An array of objects containing file names and their respective content as Blobs.
* @returns A Promise that resolves to a Blob representing the generated zip file.
*/
zipFiles(files: ExportedFile[]): Promise<Blob>;
/**
* Exports the given data to CSV or Excel files.
*
* @param params - An object containing all the necessary parameters for the export and zip process.
* @returns A Promise that resolves to a Blob representing the exported file.
*/
exportSeriesData(params: SeriesExportParams): Promise<Blob>;
createFileName(source: string | number, fragmentSeries: string, fileExtension: string): string;
/**
* Generates a zip blob using the provided zip object.
*
* @param zip - The zip object used for generating the blob.
* @param compressionType - The compression type for the zip file. 'STORE' is no compression, 'DEFLATE' is compression.
* @param compressionLevel - The compression level for the zip file.
* Level 1 is quickest, 9 is best compressed.
* @returns A Promise that resolves to a Blob containing the generated zip file.
*/
private generateZipBlob;
static ɵfac: i0.ɵɵFactoryDeclaration<DataProcessingService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DataProcessingService>;
}
declare class DatapointsExportSelectorFileExporterService {
private alertService;
private datapointsExportSelectorDataProcessingService;
private translateService;
/**
* Cached data is reused when both CSV and Excel files were selected for export, used for merged file.
*/
private cachedFlatteredAndSortedSeriesExportData;
/**
* Cached data is reused when both CSV and Excel files were selected for export, used for raw files.
*/
private cachedRawExportSeriesData;
constructor(alertService: AlertService, datapointsExportSelectorDataProcessingService: DataProcessingService, translateService: TranslateService);
getMeasurementExportedDataBlob(extension: string, dataToExport: DataToExportWithBackendCreatedFile[]): Promise<Blob | null>;
getSeriesExportedDataBlob(fileType: string, dataToExport: DataToExport[], mergedExportDetails: MergedExportDetails): Promise<Blob | null>;
cleanupCachedData(): void;
private showZipCreationErrorAlert;
private getMeasurementDataZipBlob;
private createRawMeasurementExportedFiles;
/**
* Converts data to a specified file type and returns the generated blob.
*
* Unlike measurements, data must be transformed to an exportable file structure before exporting.
*
* @param fileType - The type of file to which the data points should be exported. This can be 'csv' or 'excel'.
* @param dataToExport - An array of processed measurement data combined with the respective properties of the datapoint.
* @param mergedExportDetails - The details for the merged export, contains date range and aggregation.
* @returns A promise that resolves to the generated ZIP blob or null if an error occurs.
*/
private getSeriesDataBlob;
private transformSeriesDataToExportableFileStructure;
static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsExportSelectorFileExporterService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DatapointsExportSelectorFileExporterService>;
}
declare const FILE_GENERATORS: InjectionToken<FileGenerator[]>;
declare const dateRangeValidator: ValidatorFn;
declare class DatapointsExportSelectorFileExporterComponent implements OnInit, OnDestroy {
private aggregationService;
private datapointsExportModalService;
private datapointsExportSelectorFileExporterService;
private dataFetchingService;
private formBuilder;
private generators;
private gainsightService;
exportConfig: ExportConfig;
onDownloadButtonStateChange: EventEmitter<boolean>;
/**
* Represents aggregation selector options that are disabled.
* This state is determined based on the current date range.
*/
disabledAggregationOptions: AggregationOptionStatus;
formGroup: ReturnType<DatapointsExportSelectorFileExporterComponent['createForm']>;
/**
* Contains all datapoints that number of records exceeds a threshold, where data for these datapoints will be processed by the backend.
* Applies only to measurement API which can return processed CSV, Excel or XML data.
*/
datapointsExceedingBrowserDownloadLimit: DatapointsExceedingLimit[];
/**
* Indicates whether any of DataToExport objects timeValueMap property is not undefined (series data)
* or dataPointToExport is not undefined at all (measurement data).
*/
hasFetchedDataAnyValuesToExport: boolean;
/**
* Indicates if there is no exportable data because the date range of all selected datapoints exceeds 1,000,000 records.
*/
hasNoExportableData: boolean;
hasPermissionToReadAnyMeasurements: boolean;
isPreviewLoading: boolean;
/**
* Indicates whether the full or compact type of export is selected.
* Full type of export is based on measurement API data.
* Compact type of export is based on series API data.
*/
isFullTypeOfExport: boolean;
previewTableData: ExportData[];
limitExceededMessage: string;
/**
* Contains processed data that is prepared to be exported if series data was fetched
* or shown in the preview table in case of measurements data.
*/
private dataToExport;
/**
* Contains a list of datapoints that selected date range exceeds API limit of 1_000_000 records.
*/
private dataPointsExceedingOneMillionLimit;
/**
* Represents the state of file type selection checkboxes.
*/
private fileTypeSelectionState;
/**
* Hold the initial state of the aggregation from the export config.
* Value will be loaded on component destroy.
*/
private initialAggregation;
/**
* Hold the initial state of the dateFrom from the export config.
* Value will be loaded on component destroy.
*/
private initialDateFrom;
/**
* Hold the initial state of the dateTo from the export config.
* Value will be loaded on component destroy.
*/
private initialDateTo;
/**
* Hold the initial state of the datapointDetails from the export config.
* Some logic may filter out datapoints in datapointDetails array, that exceeds 1_000_000 limit for measurements API,
* but full list is still needed when component is reopened.
* Value will be loaded on component destroy.
*/
private initialDatapointDetails;
/**
* Indicates whether the aggregation value was changed programmatically.
* It prevents a case where fetching may be triggered twice when export type is changed.
* Both options alone can trigger fetching data.
*/
private isAggregationChangedProgrammatically;
/**
* Indicates whether any of the export file types (CSV, Excel) are checked.
*/
private isAnyOfExportFileTypeChecked;
private dateFromSubject;
private dateToSubject;
private destroy$;
dynamicFilesTypeMetadata: {
[key: string]: FileTypeMetadata;
};
constructor(aggregationService: AggregationService, datapointsExportModalService: DataProcessingService, datapointsExportSelectorFileExporterService: DatapointsExportSelectorFileExporterService, dataFetchingService: DataFetchingService, formBuilder: FormBuilder, generators: FileGenerator[], gainsightService: GainsightService);
setFilesType(generators: FileGenerator[]): void;
ngOnInit(): Promise<void>;
ngOnDestroy(): void;
exportAndDownload(): Promise<void>;
getOnlySelectedFileExports(fileExports: FileExportConfig[]): FileExportConfig[];
exportFile(fileType: string): Promise<Blob | null>;
downloadFile(blob: Blob | null, fileType: string, measurementsZipFileName: string): Promise<void>;
/**
* Exports a measurement file of the specified type.
*
* Measurements API does provide a way to fetch a preprocessed CSV/Excel file.
*
* At this point a backed file needs to be fetched.
* Measurement data used for a preview contains just 5 first records
* and it's not fetched with CSV/Excel headers.
*
* @param fileType - The type of file to export.
* @returns A Promise that resolves to a Blob representing the exported file or null when no data to export or it's sent via email.
*/
exportMeasurementFile(fileType: string): Promise<Blob> | null;
excludeDatapointsThatExceedsApiLimit(exportConfig: ExportConfig): ExportConfig;
/**
* Exports the series data to a file of the specified type.
*
* Series API does not provide a way to fetch a preprocessed CSV/Excel file.
*
* Series data used for exporting a file is already fetched for a preview
* and can be reused for exporting.
*
* @param fileType - The type of file to export (e.g., CSV, Excel).
* @returns A Promise that resolves to a Blob representing the exported file.
*/
exportSeriesFile(fileType: string): Promise<Blob>;
onAggregationChange(newAggregation: AggregationOption): Promise<void>;
onDateFromChange(updatedDate: string): void;
onDateToChange(updatedDate: string): void;
updateDateAndFetchData(dateType: 'dateFrom' | 'dateTo', dateInfo: DateFetchConfig): Promise<void>;
onExportTypeChange(exportType: string): Promise<void>;
private updateDisabledAggregationOptions;
private createForm;
private preparePreview;
private handleDateSelectorChanges;
private handleExportModeChanges;
private handleFileTypeSelectionChanges;
private updateFileTypeSelectionState;
private handleFormValidationChanges;
private updateFileTypeControl;
private determineShowingPreviewOrEmptyState;
private determineIfMeasurementResponseWillBeProcessedByBackend;
private calculateDatapointCounts;
private storeInitialChangeableConfig;
private loadInitialChangeableConfig;
private loadExportData;
private updateDownloadButtonState;
private resetFullExportRelatedProperties;
private getInitialSelection;
/**
* Adjusts both "from" and "to" dates when either is updated:
* - Resets seconds to 00 even when only one date changes
* - Prevents persisting hidden seconds ≠ 00 from initial load
* - Triggers data fetch
*
* Example:
* When user changes "from" date:
* Input: startDate = "2024-03-26 13:30:45", endDate = "2024-03-27 15:20:45"
* Result: startDate -> "2024-03-26 14:30:00", endDate -> "2024-03-27 15:20:00"
*
* When user changes "to" date:
* Input: startDate = "2024-03-26 14:30:45", endDate = "2024-03-27 15:20:45"
* Result: startDate -> "2024-03-26 14:30:00", endDate -> "2024-03-27 16:20:00"
*
* @param startDate - The "start" date to be adjusted.
* @param endDate - The "end" date to be adjusted.
*/
private update;
private triggerGainsightDownloadEvent;
static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsExportSelectorFileExporterComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DatapointsExportSelectorFileExporterComponent, "c8y-datapoints-export-selector-file-exporter", never, { "exportConfig": { "alias": "exportConfig"; "required": false; }; }, { "onDownloadButtonStateChange": "onDownloadButtonStateChange"; }, never, never, true, never>;
}
declare class DataPointsExportSelectorPreviewComponent {
hasFetchedDataAnyValuesToExport: boolean;
isPreviewLoading: boolean;
previewTableData: ExportData[];
readonly MEASUREMENTS_PREVIEW_ITEMS_LIMIT = 5;
static ɵfac: i0.ɵɵFactoryDeclaration<DataPointsExportSelectorPreviewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DataPointsExportSelectorPreviewComponent, "c8y-datapoints-export-selector-preview", never, { "hasFetchedDataAnyValuesToExport": { "alias": "hasFetchedDataAnyValuesToExport"; "required": false; }; "isPreviewLoading": { "alias": "isPreviewLoading"; "required": false; }; "previewTableData": { "alias": "previewTableData"; "required": false; }; }, {}, never, never, true, never>;
}
declare class DataPointsExportSelectorDataScopeComponent {
disabledAggregationOptions: AggregationOptionStatus$1;
formGroup: ReturnType<DatapointsExportSelectorFileExporterComponent['createForm']>;
onAggregationChange: EventEmitter<AggregationOption$1>;
onExportTypeChange: EventEmitter<string>;
readonly AGGREGATION_LABELS: {
readonly NONE: string;
readonly MINUTELY: string;
readonly HOURLY: string;
readonly DAILY: string;
};
readonly AGGREGATION_VALUES_ARR: readonly ["NONE", packages_client_lib.aggregationType.MINUTELY, packages_client_lib.aggregationType.HOURLY, packages_client_lib.aggregationType.DAILY];
readonly EXPORT_MODE_LABELS: {
readonly FULL: "Full";
readonly COMPACT: "Compact";
};
readonly EXPORT_MODE_VALUES_ARR: readonly ["FULL", "COMPACT"];
emitAggregationChange(aggregation: AggregationOption$1): void;
emitExportTypeChange(exportType: string): void;
static ɵfac: i0.ɵɵFactoryDeclaration<DataPointsExportSelectorDataScopeComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DataPointsExportSelectorDataScopeComponent, "c8y-datapoints-export-selector-data-scope", never, { "disabledAggregationOptions": { "alias": "disabledAggregationOptions"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; }, { "onAggregationChange": "onAggregationChange"; "onExportTypeChange": "onExportTypeChange"; }, never, never, true, never>;
}
declare class DataPointsExportSelectorFileTypesComponent {
dynamicFilesTypeMetadata: {
[key: string]: FileTypeMetadata;
};
formGroup: ReturnType<DatapointsExportSelectorFileExporterComponent['createForm']>;
static ɵfac: i0.ɵɵFactoryDeclaration<DataPointsExportSelectorFileTypesComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DataPointsExportSelectorFileTypesComponent, "c8y-datapoints-export-selector-file-types", never, { "dynamicFilesTypeMetadata": { "alias": "dynamicFilesTypeMetadata"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; }, {}, never, never, true, never>;
}
declare class DataPointsExportSelectorTimeRangeComponent implements OnInit, OnDestroy {
formGroup: ReturnType<DatapointsExportSelectorFileExporterComponent['createForm']>;
onDateFromChange: EventEmitter<string>;
onDateToChange: EventEmitter<string>;
private destroy$;
readonly DATE_FROM = "dateFrom";
readonly DATE_TO = "dateTo";
readonly FROM_DATE: "From`date`";
readonly HAS_ERROR = "has-error";
readonly INVALID_DATE_TIME = "invalidDateTime";
readonly THIS_DATE_IS_INVALID: "This date is invalid.";
readonly THIS_DATE_IS_AFTER_THE_LAST_ALLOWED_DATE: "This date is after the latest allowed date.";
readonly THIS_DATE_IS_BEFORE_THE_EARLIEST_ALLOWED_DATE: "This date is before the earliest allowed date.";
readonly TO_DATE: "To`date`";
ngOnInit(): void;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<DataPointsExportSelectorTimeRangeComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DataPointsExportSelectorTimeRangeComponent, "c8y-datapoints-export-selector-time-range", never, { "formGroup": { "alias": "formGroup"; "required": false; }; }, { "onDateFromChange": "onDateFromChange"; "onDateToChange": "onDateToChange"; }, never, never, true, never>;
}
declare const CSVGeneratorAdapter: FileGenerator;
declare class ExcelDataTransformer implements IDataTransformer {
transformToMergedFormat(exportData: ExportData[]): TimeSeriesColumnData;
private createMeasurementIdentifier;
private formatMinKey;
private formatMaxKey;
}
declare const ExcelGeneratorAdapter: FileGenerator;
declare class DatapointsExportSelectorModalComponent {
private bsModalRef;
private datapointsExportSelectorFileExporterComponent;
exportConfig: ExportConfig;
isDownloadEnabled: boolean;
labels: ModalLabels;
result: Promise<boolean>;
private _close;
constructor(bsModalRef: BsModalRef);
handleKeyboardEvent(event: KeyboardEvent): void;
dismiss(): void;
exportAndDownload(): Promise<void>;
changeDownloadButtonState(isEnabled: boolean): void;
static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsExportSelectorModalComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DatapointsExportSelectorModalComponent, "c8y-datapoints-export-selector-modal", never, {}, {}, never, never, true, never>;
}
declare class DatapointsExportSelectorComponent {
private bsModalService;
private gainsightService;
/**
* CSS class for the container element.
* Defaults to 'd-flex p-t-4 p-b-4' if not provided.
*/
containerClass: string;
/**
* Configuration for the export selector modal.
*/
exportConfig: ExportConfig;
isOpen: EventEmitter<boolean>;
readonly DEFAULT_CSS_STYLE = "d-flex";
constructor(bsModalService: BsModalService, gainsightService: GainsightService);
openExportModal(): Promise<void>;
static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsExportSelectorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DatapointsExportSelectorComponent, "c8y-datapoints-export-selector", never, { "containerClass": { "alias": "containerClass"; "required": false; }; "exportConfig": { "alias": "exportConfig"; "required": false; }; }, { "isOpen": "isOpen"; }, never, never, true, never>;
}
export { CSVGeneratorAdapter, DataFetchingService, DataPointsExportSelectorDataScopeComponent, DataPointsExportSelectorFileTypesComponent, DataPointsExportSelectorPreviewComponent, DataPointsExportSelectorTimeRangeComponent, DataProcessingService, DatapointsExportSelectorComponent, DatapointsExportSelectorFileExporterComponent, DatapointsExportSelectorFileExporterService, DatapointsExportSelectorModalComponent, EXPORT_MODE_LABELS, EXPORT_MODE_VALUES, ExcelDataTransformer, ExcelGeneratorAdapter, FILE_COMPRESSION_TYPES_VALUES, FILE_GENERATORS, HAS_ERROR, MEASUREMENTS_PREVIEW_ITEMS_LIMIT, PRODUCT_EXPERIENCE_DATAPOINTS_EXPORT_SELECTOR, SERIES_DATA_MERGED_FILE_NAME, UtilsService, dateRangeValidator };
export type { ColumnValueMap, DataToExport, DataToExportWithBackendCreatedFile, DatapointCounts, DatapointDetails, DatapointsExceedingLimit, DatapointsValuesDataMap, DateFetchConfig, ExportConfig, ExportData, ExportedFile, FileCompressionTypes, FileExportConfig, FileGenerator, FileTypeConfig, FileTypeMetadata, IDataTransformer, Measurement, MeasurementFileConfig, MergedExportDetails, MinMaxValues, ReadingValue, SeriesExportParams, SeriesInfo, SourceData, SourceId, SourceItem, TimeSeriesColumnData, TimeSeriesData, TimeStamp, TransformedData, TransformedSeries, TransformedSource };
//# sourceMappingURL=index.d.ts.map