@harbortouch/skytab-analytics-report-utils 0.41.9 → 0.41.10
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.
|
@@ -3978,16 +3978,32 @@ function isAnalyticsField(key) {
|
|
|
3978
3978
|
function isReportColumnKey(key) {
|
|
3979
3979
|
return getColumnMetadata(key) !== void 0;
|
|
3980
3980
|
}
|
|
3981
|
-
function
|
|
3981
|
+
function getReportFieldColumnKey(key, reportType) {
|
|
3982
|
+
const config = getReportConfig(reportType);
|
|
3983
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
3984
|
+
for (const c of configs) {
|
|
3985
|
+
const fields = c?.fields;
|
|
3986
|
+
const columnKey = fields?.[key]?.columnKey;
|
|
3987
|
+
if (columnKey) {
|
|
3988
|
+
return columnKey;
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
return void 0;
|
|
3992
|
+
}
|
|
3993
|
+
function resolveFilterLabel(key, locale, reportType) {
|
|
3982
3994
|
if (isAnalyticsField(key)) {
|
|
3983
3995
|
return resolveTranslate(`analytics.field.${key}`, locale);
|
|
3984
3996
|
}
|
|
3997
|
+
const reportColumnKey = reportType ? getReportFieldColumnKey(key, reportType) : void 0;
|
|
3998
|
+
if (reportColumnKey && isReportColumnKey(reportColumnKey)) {
|
|
3999
|
+
return resolveTranslate(getColumnMetadata(reportColumnKey).titleKey, locale);
|
|
4000
|
+
}
|
|
3985
4001
|
if (isReportColumnKey(key)) {
|
|
3986
4002
|
return resolveTranslate(getColumnMetadata(key).titleKey, locale);
|
|
3987
4003
|
}
|
|
3988
4004
|
return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
3989
4005
|
}
|
|
3990
|
-
function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
4006
|
+
function resolveRawFiltersToExportFilters(rawFilters, locale, reportType) {
|
|
3991
4007
|
if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
|
|
3992
4008
|
return [];
|
|
3993
4009
|
}
|
|
@@ -3995,7 +4011,7 @@ function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
|
3995
4011
|
if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
|
|
3996
4012
|
return [];
|
|
3997
4013
|
}
|
|
3998
|
-
const label = resolveFilterLabel(key, locale);
|
|
4014
|
+
const label = resolveFilterLabel(key, locale, reportType);
|
|
3999
4015
|
const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
|
|
4000
4016
|
if (!value) {
|
|
4001
4017
|
return [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as ReportType, A as AnalyticsField } from '../report-LuHGzrLx.cjs';
|
|
2
2
|
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-JAEAu4KX.cjs';
|
|
3
3
|
|
|
4
|
-
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string): ExportFilter[];
|
|
4
|
+
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string, reportType?: ReportType): ExportFilter[];
|
|
5
5
|
|
|
6
6
|
type ReportDocumentSection = ExportSection;
|
|
7
7
|
interface ReportLocation {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as ReportType, A as AnalyticsField } from '../report-LuHGzrLx.js';
|
|
2
2
|
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-JAEAu4KX.js';
|
|
3
3
|
|
|
4
|
-
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string): ExportFilter[];
|
|
4
|
+
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string, reportType?: ReportType): ExportFilter[];
|
|
5
5
|
|
|
6
6
|
type ReportDocumentSection = ExportSection;
|
|
7
7
|
interface ReportLocation {
|
|
@@ -32,16 +32,32 @@ function isAnalyticsField(key) {
|
|
|
32
32
|
function isReportColumnKey(key) {
|
|
33
33
|
return getColumnMetadata(key) !== void 0;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function getReportFieldColumnKey(key, reportType) {
|
|
36
|
+
const config = getReportConfig(reportType);
|
|
37
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
38
|
+
for (const c of configs) {
|
|
39
|
+
const fields = c?.fields;
|
|
40
|
+
const columnKey = fields?.[key]?.columnKey;
|
|
41
|
+
if (columnKey) {
|
|
42
|
+
return columnKey;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
function resolveFilterLabel(key, locale, reportType) {
|
|
36
48
|
if (isAnalyticsField(key)) {
|
|
37
49
|
return resolveTranslate(`analytics.field.${key}`, locale);
|
|
38
50
|
}
|
|
51
|
+
const reportColumnKey = reportType ? getReportFieldColumnKey(key, reportType) : void 0;
|
|
52
|
+
if (reportColumnKey && isReportColumnKey(reportColumnKey)) {
|
|
53
|
+
return resolveTranslate(getColumnMetadata(reportColumnKey).titleKey, locale);
|
|
54
|
+
}
|
|
39
55
|
if (isReportColumnKey(key)) {
|
|
40
56
|
return resolveTranslate(getColumnMetadata(key).titleKey, locale);
|
|
41
57
|
}
|
|
42
58
|
return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
43
59
|
}
|
|
44
|
-
function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
60
|
+
function resolveRawFiltersToExportFilters(rawFilters, locale, reportType) {
|
|
45
61
|
if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
|
|
46
62
|
return [];
|
|
47
63
|
}
|
|
@@ -49,7 +65,7 @@ function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
|
49
65
|
if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
|
|
50
66
|
return [];
|
|
51
67
|
}
|
|
52
|
-
const label = resolveFilterLabel(key, locale);
|
|
68
|
+
const label = resolveFilterLabel(key, locale, reportType);
|
|
53
69
|
const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
|
|
54
70
|
if (!value) {
|
|
55
71
|
return [];
|