autoql-fe-utils 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ declare function sayHello(): void;
2
+
3
+ export { sayHello };
@@ -0,0 +1,355 @@
1
+ import dayjs from 'dayjs';
2
+
3
+ declare const TABLE_TYPES: string[];
4
+ declare const CHART_TYPES: string[];
5
+ declare const DATE_ONLY_CHART_TYPES: string[];
6
+ declare const DOUBLE_AXIS_CHART_TYPES: string[];
7
+ declare const MONTH_NAMES: string[];
8
+ declare const DEFAULT_DATA_PAGE_SIZE = 500;
9
+ declare const MAX_DATA_PAGE_SIZE = 5000;
10
+ declare const WEEKDAY_NAMES_MON: string[];
11
+ declare const WEEKDAY_NAMES_SUN: string[];
12
+ declare const DOW_STYLES: string[];
13
+ declare const SEASON_NAMES: string[];
14
+ declare const DAYJS_PRECISION_FORMATS: {
15
+ DAY: string;
16
+ MONTH: string;
17
+ YEAR: string;
18
+ DATE_HOUR: string;
19
+ DATE_MINUTE: string;
20
+ };
21
+ declare const DEFAULT_AGG_TYPE = "sum";
22
+ declare const AGG_TYPES: {
23
+ displayName: string;
24
+ value: string;
25
+ unit: string;
26
+ tooltip: string;
27
+ }[];
28
+ declare const MAX_LEGEND_LABELS = 22;
29
+ declare const MIN_HISTOGRAM_SAMPLE = 20;
30
+
31
+ declare enum TimestampFormats {
32
+ epoch = "EPOCH",
33
+ iso8601 = "ISO8601"
34
+ }
35
+ declare enum PrecisionTypes {
36
+ DAY = "DAY",
37
+ MONTH = "MONTH",
38
+ YEAR = "YEAR",
39
+ WEEK = "WEEK",
40
+ QUARTER = "QUARTER",
41
+ DATE_HOUR = "DATE_HOUR",
42
+ DATE_MINUTE = "DATE_MINUTE",
43
+ HOUR = "HOUR",
44
+ MINUTE = "MINUTE"
45
+ }
46
+ declare enum NumberColumnTypes {
47
+ CURRENCY = "DOLLAR_AMT",
48
+ QUANTITY = "QUANTITY",
49
+ RATIO = "RATIO",
50
+ PERCENT = "PERCENT"
51
+ }
52
+ declare enum NumberColumnTypeDisplayNames {
53
+ DOLLAR_AMT = "Currency",
54
+ QUANTITY = "Quantity",
55
+ RATIO = "Ratio",
56
+ PERCENT = "Percent"
57
+ }
58
+
59
+ interface Column {
60
+ dow_style: string;
61
+ type: string;
62
+ groupable: boolean;
63
+ precision: string;
64
+ name: string;
65
+ display_name: string;
66
+ is_visible: boolean;
67
+ multi_series: boolean;
68
+ aggType?: string;
69
+ title?: string;
70
+ }
71
+ type Columns = Column[];
72
+ interface FilterLock {
73
+ filter_type: string;
74
+ key: string;
75
+ value: string;
76
+ show_message: string;
77
+ }
78
+ interface FrontendReq {
79
+ session_locked_conditions: Object;
80
+ page_size: number;
81
+ debug: false;
82
+ disambiguation: any[];
83
+ chart_images: string;
84
+ orders: any[];
85
+ filters: any[];
86
+ translation: string;
87
+ text: string;
88
+ date_format: string;
89
+ scope: string;
90
+ source: string;
91
+ test: boolean;
92
+ session_filter_locks: any[];
93
+ v2_dates: number;
94
+ persistent_filter_locks: FilterLock[];
95
+ }
96
+ type Rows = Array<Array<string | number>>;
97
+ interface QueryData {
98
+ session_locked_conditions: any[];
99
+ count_rows: number;
100
+ fe_req: FrontendReq;
101
+ query_id: string;
102
+ row_limit: number;
103
+ rows: Rows;
104
+ chart_images: null;
105
+ display_type: string;
106
+ columns: Columns;
107
+ interpretation: string;
108
+ text: string;
109
+ parsed_interpretation: Object[];
110
+ persistent_locked_conditions: any[];
111
+ condition_filter: any[];
112
+ sql: any[];
113
+ }
114
+ interface QueryResponse {
115
+ data: QueryData;
116
+ message: string;
117
+ reference_id: string;
118
+ }
119
+ interface AxiosResponse {
120
+ data: QueryResponse;
121
+ }
122
+ interface DataFormatting {
123
+ timestampFormat: TimestampFormats;
124
+ currencyCode: string;
125
+ languageCode: string;
126
+ currencyDecimals: number;
127
+ quantityDecimals: number;
128
+ ratioDecimals: number;
129
+ comparisonDisplay: string;
130
+ monthYearFormat: string;
131
+ dayMonthYearFormat: string;
132
+ }
133
+ interface Scale {
134
+ }
135
+
136
+ declare const authenticationDefault: {
137
+ token: any;
138
+ apiKey: any;
139
+ domain: any;
140
+ dprKey: any;
141
+ dprDomain: any;
142
+ };
143
+ declare const dataFormattingDefault: {
144
+ timestampFormat: TimestampFormats;
145
+ currencyCode: string;
146
+ languageCode: string;
147
+ currencyDecimals: number;
148
+ quantityDecimals: number;
149
+ ratioDecimals: number;
150
+ comparisonDisplay: string;
151
+ monthYearFormat: string;
152
+ dayMonthYearFormat: string;
153
+ };
154
+ declare const autoQLConfigDefault: {
155
+ debug: boolean;
156
+ test: boolean;
157
+ enableAutocomplete: boolean;
158
+ enableQueryInterpretation: boolean;
159
+ enableQueryValidation: boolean;
160
+ enableQuerySuggestions: boolean;
161
+ enableColumnVisibilityManager: boolean;
162
+ enableDrilldowns: boolean;
163
+ enableNotifications: boolean;
164
+ enableCSVDownload: boolean;
165
+ enableReportProblem: boolean;
166
+ };
167
+ declare const dataConfigDefault: {
168
+ stringColumnIndices: any[];
169
+ numberColumnIndices: any[];
170
+ stringColumnIndex: number;
171
+ legendColumnIndex: any;
172
+ numberColumnIndex: number;
173
+ };
174
+ declare const getAuthentication: (prop?: {}) => {
175
+ token: any;
176
+ apiKey: any;
177
+ domain: any;
178
+ dprKey: any;
179
+ dprDomain: any;
180
+ };
181
+ declare const getDataFormatting: (prop?: {}) => DataFormatting;
182
+ declare const getAutoQLConfig: (prop?: {}) => {
183
+ debug: boolean;
184
+ test: boolean;
185
+ enableAutocomplete: boolean;
186
+ enableQueryInterpretation: boolean;
187
+ enableQueryValidation: boolean;
188
+ enableQuerySuggestions: boolean;
189
+ enableColumnVisibilityManager: boolean;
190
+ enableDrilldowns: boolean;
191
+ enableNotifications: boolean;
192
+ enableCSVDownload: boolean;
193
+ enableReportProblem: boolean;
194
+ };
195
+ declare const getDataConfig: (prop?: {}) => {
196
+ stringColumnIndices: any[];
197
+ numberColumnIndices: any[];
198
+ stringColumnIndex: number;
199
+ legendColumnIndex: any;
200
+ numberColumnIndex: number;
201
+ };
202
+
203
+ declare const isColumnNumberType: (col: any) => boolean;
204
+ declare const isColumnStringType: (col: any) => boolean;
205
+ declare const isColumnDateType: (col: any) => boolean;
206
+ declare const hasNumberColumn: (columns: any) => boolean;
207
+ declare const hasStringColumn: (columns: any) => boolean;
208
+ declare const hasDateColumn: (columns: any) => boolean;
209
+ declare const getVisibleColumns: (columns: any) => Columns;
210
+ declare const getGroupableColumns: (columns: any) => any[];
211
+ declare const getGroupBys: (row: any, columns: any) => {
212
+ groupBys: any[];
213
+ supportedByAPI: boolean;
214
+ };
215
+ declare const getGroupBysFromTable: (cell: any, tableColumns: any) => any[];
216
+ declare const getGroupBysFromPivotTable: ({ cell, rowHeaders, columnHeaders, rowHeaderDefinition, columnHeaderDefinition, }: {
217
+ cell: any;
218
+ rowHeaders: any;
219
+ columnHeaders: any;
220
+ rowHeaderDefinition: any;
221
+ columnHeaderDefinition: any;
222
+ }) => {
223
+ name: any;
224
+ value: string;
225
+ }[];
226
+ declare const isAggregation: (columns: any) => boolean;
227
+ declare const getColumnTypeAmounts: (columns: any) => {
228
+ amountOfNumberColumns: number;
229
+ amountOfStringColumns: number;
230
+ };
231
+ declare const getDateColumnIndex: (columns: any) => any;
232
+ declare const getNumberOfGroupables: (columns: any) => number;
233
+ declare const isListQuery: (columns: any) => boolean;
234
+
235
+ declare const formatStringDateWithPrecision: (value: any, col: any) => any;
236
+ declare const formatStringDate: (value: any, config?: DataFormatting) => any;
237
+ declare const formatDateType: (element: any, column: Column, config?: DataFormatting) => any;
238
+ declare const formatDateStringType: (element: any, column: Column, config?: DataFormatting) => any;
239
+ declare const formatISODateWithPrecision: (value: any, col: Column, config?: DataFormatting) => any;
240
+ declare const formatEpochDate: (value: any, col: Column, config?: DataFormatting) => any;
241
+ declare const dateStringSortFn: (a: any, b: any, col: Column) => number;
242
+ declare const dateSortFn: (a: any, b: any, col: Column, isTable: any) => number;
243
+ declare const sortDataByDate: (data: any, tableColumns: any, sortDirection: string, isTable: any) => any;
244
+ interface formatElementParams {
245
+ element: string | number;
246
+ column: Column;
247
+ config: DataFormatting;
248
+ htmlElement?: HTMLElement;
249
+ isChart?: boolean;
250
+ }
251
+ declare const formatElement: ({ element, column, config, htmlElement, isChart, }: formatElementParams) => string | number;
252
+ declare const getNumberFormatConfig: (d: any, scale: any) => {
253
+ minimumFractionDigits: number;
254
+ maximumFractionDigits: number;
255
+ notation: any;
256
+ };
257
+ declare const formatChartLabel: ({ d, scale, column, dataFormatting, maxLabelWidth }: {
258
+ d: any;
259
+ scale: any;
260
+ column: any;
261
+ dataFormatting: any;
262
+ maxLabelWidth: any;
263
+ }) => {
264
+ fullWidthLabel: any;
265
+ formattedLabel: any;
266
+ };
267
+ declare const getCurrencySymbol: (dataFormatting?: {
268
+ timestampFormat: TimestampFormats;
269
+ currencyCode: string;
270
+ languageCode: string;
271
+ currencyDecimals: number;
272
+ quantityDecimals: number;
273
+ ratioDecimals: number;
274
+ comparisonDisplay: string;
275
+ monthYearFormat: string;
276
+ dayMonthYearFormat: string;
277
+ }) => string;
278
+ declare const getDayjsObjForStringType: (value: any, col: any) => dayjs.Dayjs;
279
+ declare const getDayJSObj: ({ value, column }: {
280
+ value: any;
281
+ column: any;
282
+ }) => dayjs.Dayjs;
283
+ declare const getEpochFromDate: (date: any, precision?: any, precisionFrame?: any) => any;
284
+
285
+ interface getSupportedDisplayTypesParams {
286
+ response?: AxiosResponse;
287
+ columns?: Columns;
288
+ dataLength?: number;
289
+ pivotDataLength?: number;
290
+ isDataLimited?: boolean;
291
+ }
292
+ declare const isChartType: (type: any) => boolean;
293
+ declare const isTableType: (type: any) => boolean;
294
+ declare const isDisplayTypeValid: (response: AxiosResponse, displayType: string, dataLength: number, pivotDataLength: number, columns: Columns, isDataLimited: boolean) => boolean;
295
+ declare const shouldPlotMultiSeries: (columns: any) => boolean;
296
+ declare const supportsPieChart: (columns: any, chartData: any) => boolean;
297
+ declare const supports2DCharts: (columns: any, dataLength: any) => boolean;
298
+ declare const supportsRegularPivotTable: (columns: any, dataLength: any, data: any) => boolean;
299
+ declare const supportsDatePivotTable: (columns: any) => boolean;
300
+ declare const isSingleValueResponse: (response: any) => boolean;
301
+ declare const getSupportedDisplayTypes: ({ response, columns, dataLength, pivotDataLength, isDataLimited, }?: getSupportedDisplayTypesParams) => string[];
302
+ declare const getFirstChartDisplayType: (supportedDisplayTypes: any, fallback: any) => any;
303
+ declare const getDefaultDisplayType: (response?: AxiosResponse, defaultToChart?: boolean, columns?: Columns, dataLength?: number, pivotDataLength?: number, preferredDisplayType?: string, isDataLimited?: boolean) => string;
304
+ declare const hasData: (response: any) => any;
305
+
306
+ declare const currentEventLoopEnd: () => Promise<unknown>;
307
+ declare const animateInputText: ({ text, inputRef, callback, totalAnimationTime }: {
308
+ text?: string;
309
+ inputRef: any;
310
+ callback?: () => void;
311
+ totalAnimationTime?: number;
312
+ }) => Promise<void>;
313
+ declare const handleTooltipBoundaryCollision: (e: any, self: any) => void;
314
+ declare const removeFromDOM: (elem: any) => void;
315
+ declare const setCaretPosition: (elem: any, caretPos: any) => void;
316
+ declare const getPadding: (element: any) => {
317
+ left: number;
318
+ right: number;
319
+ top: number;
320
+ bottom: number;
321
+ };
322
+ declare const getQueryParams: (url: any) => {};
323
+ /**
324
+ * converts an svg string to base64 png using the domUrl
325
+ * @param {string} svgElement the svgElement
326
+ * @param {number} [margin=0] the width of the border - the image size will be height+margin by width+margin
327
+ * @param {string} [fill] optionally backgrund canvas fill
328
+ * @return {Promise} a promise to the bas64 png image
329
+ */
330
+ declare const svgToPng: (svgElement: any, scale?: number) => Promise<unknown>;
331
+ declare const getBBoxFromRef: (ref: any) => any;
332
+ declare const getSVGBase64: (svgElement: any) => string;
333
+
334
+ declare const nameValueObject: (name: any, value: any) => {
335
+ name: any;
336
+ value: any;
337
+ };
338
+ declare const getKeyByValue: (object: any, value: any) => string;
339
+
340
+ declare const getStringFromSource: (source: string | number | Array<string>) => string | null;
341
+ declare const mergeSources: (source: string | number | Array<string>, newSource: string | number | Array<string>) => string | null;
342
+
343
+ declare const capitalizeFirstChar: (string: any) => any;
344
+ declare const isNumber: (str: any) => boolean;
345
+
346
+ declare const invertArray: (array: any[]) => any[];
347
+ declare const functionsEqual: (a: Function, b: Function) => boolean;
348
+ declare const isObject: (obj: any) => boolean;
349
+ declare const deepEqual: (objA: Object, objB: Object) => boolean;
350
+ declare const difference: (objA: Object, objB: Object) => any[];
351
+ declare const rotateArray: (array: any, n: any) => any[];
352
+ declare const onlyUnique: (value: any, index: any, self: any) => boolean;
353
+ declare const makeEmptyArray: (w: any, h: any, value?: string) => any[];
354
+
355
+ export { AGG_TYPES, AxiosResponse, CHART_TYPES, Column, Columns, DATE_ONLY_CHART_TYPES, DAYJS_PRECISION_FORMATS, DEFAULT_AGG_TYPE, DEFAULT_DATA_PAGE_SIZE, DOUBLE_AXIS_CHART_TYPES, DOW_STYLES, DataFormatting, FilterLock, FrontendReq, MAX_DATA_PAGE_SIZE, MAX_LEGEND_LABELS, MIN_HISTOGRAM_SAMPLE, MONTH_NAMES, NumberColumnTypeDisplayNames, NumberColumnTypes, PrecisionTypes, QueryData, QueryResponse, Rows, SEASON_NAMES, Scale, TABLE_TYPES, TimestampFormats, WEEKDAY_NAMES_MON, WEEKDAY_NAMES_SUN, animateInputText, authenticationDefault, autoQLConfigDefault, capitalizeFirstChar, currentEventLoopEnd, dataConfigDefault, dataFormattingDefault, dateSortFn, dateStringSortFn, deepEqual, difference, formatChartLabel, formatDateStringType, formatDateType, formatElement, formatEpochDate, formatISODateWithPrecision, formatStringDate, formatStringDateWithPrecision, functionsEqual, getAuthentication, getAutoQLConfig, getBBoxFromRef, getColumnTypeAmounts, getCurrencySymbol, getDataConfig, getDataFormatting, getDateColumnIndex, getDayJSObj, getDayjsObjForStringType, getDefaultDisplayType, getEpochFromDate, getFirstChartDisplayType, getGroupBys, getGroupBysFromPivotTable, getGroupBysFromTable, getGroupableColumns, getKeyByValue, getNumberFormatConfig, getNumberOfGroupables, getPadding, getQueryParams, getSVGBase64, getStringFromSource, getSupportedDisplayTypes, getVisibleColumns, handleTooltipBoundaryCollision, hasData, hasDateColumn, hasNumberColumn, hasStringColumn, invertArray, isAggregation, isChartType, isColumnDateType, isColumnNumberType, isColumnStringType, isDisplayTypeValid, isListQuery, isNumber, isObject, isSingleValueResponse, isTableType, makeEmptyArray, mergeSources, nameValueObject, onlyUnique, removeFromDOM, rotateArray, setCaretPosition, shouldPlotMultiSeries, sortDataByDate, supports2DCharts, supportsDatePivotTable, supportsPieChart, supportsRegularPivotTable, svgToPng };