@harbortouch/skytab-analytics-report-utils 0.41.3 → 0.41.4
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.
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/exporters/exportBuilder.ts
|
|
21
21
|
var exportBuilder_exports = {};
|
|
22
22
|
__export(exportBuilder_exports, {
|
|
23
|
-
ExportBuilder: () => ExportBuilder
|
|
23
|
+
ExportBuilder: () => ExportBuilder,
|
|
24
|
+
resolveRawFiltersToExportFilters: () => resolveRawFiltersToExportFilters
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(exportBuilder_exports);
|
|
26
27
|
|
|
@@ -3950,6 +3951,54 @@ var calculateReportTotals = (data, fieldConfig) => {
|
|
|
3950
3951
|
return result;
|
|
3951
3952
|
};
|
|
3952
3953
|
|
|
3954
|
+
// src/utils/filter-resolver.ts
|
|
3955
|
+
var ANALYTICS_FIELDS = /* @__PURE__ */ new Set([
|
|
3956
|
+
"location_id",
|
|
3957
|
+
"order_type_id",
|
|
3958
|
+
"revenue_center_id",
|
|
3959
|
+
"hour_id",
|
|
3960
|
+
"timeslot_id",
|
|
3961
|
+
"employee_id",
|
|
3962
|
+
"employee_name",
|
|
3963
|
+
"payroll_id",
|
|
3964
|
+
"daypart_id",
|
|
3965
|
+
"item_id",
|
|
3966
|
+
"department_id",
|
|
3967
|
+
"revenue_class_id",
|
|
3968
|
+
"modifier_id"
|
|
3969
|
+
]);
|
|
3970
|
+
function isAnalyticsField(key) {
|
|
3971
|
+
return ANALYTICS_FIELDS.has(key);
|
|
3972
|
+
}
|
|
3973
|
+
function isReportColumnKey(key) {
|
|
3974
|
+
return getColumnMetadata(key) !== void 0;
|
|
3975
|
+
}
|
|
3976
|
+
function resolveFilterLabel(key, locale) {
|
|
3977
|
+
if (isAnalyticsField(key)) {
|
|
3978
|
+
return resolveTranslate(`analytics.field.${key}`, locale);
|
|
3979
|
+
}
|
|
3980
|
+
if (isReportColumnKey(key)) {
|
|
3981
|
+
return resolveTranslate(getColumnMetadata(key).titleKey, locale);
|
|
3982
|
+
}
|
|
3983
|
+
return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
3984
|
+
}
|
|
3985
|
+
function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
3986
|
+
if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
|
|
3987
|
+
return [];
|
|
3988
|
+
}
|
|
3989
|
+
return Object.entries(rawFilters).flatMap(([key, values]) => {
|
|
3990
|
+
if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
|
|
3991
|
+
return [];
|
|
3992
|
+
}
|
|
3993
|
+
const label = resolveFilterLabel(key, locale);
|
|
3994
|
+
const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
|
|
3995
|
+
if (!value) {
|
|
3996
|
+
return [];
|
|
3997
|
+
}
|
|
3998
|
+
return [{ label, value }];
|
|
3999
|
+
});
|
|
4000
|
+
}
|
|
4001
|
+
|
|
3953
4002
|
// src/exporters/exportBuilder.ts
|
|
3954
4003
|
var import_date_fns = require("date-fns");
|
|
3955
4004
|
var ExportBuilder = class {
|
|
@@ -4174,5 +4223,6 @@ var ExportBuilder = class {
|
|
|
4174
4223
|
};
|
|
4175
4224
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4176
4225
|
0 && (module.exports = {
|
|
4177
|
-
ExportBuilder
|
|
4226
|
+
ExportBuilder,
|
|
4227
|
+
resolveRawFiltersToExportFilters
|
|
4178
4228
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { R as ReportType, A as AnalyticsField } from '../report-pbGeYM8Q.cjs';
|
|
2
|
-
import {
|
|
2
|
+
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-MalWTEdo.cjs';
|
|
3
|
+
|
|
4
|
+
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string): ExportFilter[];
|
|
3
5
|
|
|
4
6
|
type ReportDocumentSection = ExportSection;
|
|
5
7
|
interface ReportLocation {
|
|
@@ -49,4 +51,4 @@ declare class ExportBuilder {
|
|
|
49
51
|
getContent(reportData: ReportData, parameters: ReportParameters, name: string | undefined, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
|
|
54
|
+
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { R as ReportType, A as AnalyticsField } from '../report-pbGeYM8Q.js';
|
|
2
|
-
import {
|
|
2
|
+
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-MalWTEdo.js';
|
|
3
|
+
|
|
4
|
+
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string): ExportFilter[];
|
|
3
5
|
|
|
4
6
|
type ReportDocumentSection = ExportSection;
|
|
5
7
|
interface ReportLocation {
|
|
@@ -49,4 +51,4 @@ declare class ExportBuilder {
|
|
|
49
51
|
getContent(reportData: ReportData, parameters: ReportParameters, name: string | undefined, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
|
|
54
|
+
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
@@ -10,6 +10,54 @@ import {
|
|
|
10
10
|
resolveTranslate
|
|
11
11
|
} from "../chunk-DDHOYPIA.js";
|
|
12
12
|
|
|
13
|
+
// src/utils/filter-resolver.ts
|
|
14
|
+
var ANALYTICS_FIELDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"location_id",
|
|
16
|
+
"order_type_id",
|
|
17
|
+
"revenue_center_id",
|
|
18
|
+
"hour_id",
|
|
19
|
+
"timeslot_id",
|
|
20
|
+
"employee_id",
|
|
21
|
+
"employee_name",
|
|
22
|
+
"payroll_id",
|
|
23
|
+
"daypart_id",
|
|
24
|
+
"item_id",
|
|
25
|
+
"department_id",
|
|
26
|
+
"revenue_class_id",
|
|
27
|
+
"modifier_id"
|
|
28
|
+
]);
|
|
29
|
+
function isAnalyticsField(key) {
|
|
30
|
+
return ANALYTICS_FIELDS.has(key);
|
|
31
|
+
}
|
|
32
|
+
function isReportColumnKey(key) {
|
|
33
|
+
return getColumnMetadata(key) !== void 0;
|
|
34
|
+
}
|
|
35
|
+
function resolveFilterLabel(key, locale) {
|
|
36
|
+
if (isAnalyticsField(key)) {
|
|
37
|
+
return resolveTranslate(`analytics.field.${key}`, locale);
|
|
38
|
+
}
|
|
39
|
+
if (isReportColumnKey(key)) {
|
|
40
|
+
return resolveTranslate(getColumnMetadata(key).titleKey, locale);
|
|
41
|
+
}
|
|
42
|
+
return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
43
|
+
}
|
|
44
|
+
function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
45
|
+
if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return Object.entries(rawFilters).flatMap(([key, values]) => {
|
|
49
|
+
if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const label = resolveFilterLabel(key, locale);
|
|
53
|
+
const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
|
|
54
|
+
if (!value) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
return [{ label, value }];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
13
61
|
// src/exporters/exportBuilder.ts
|
|
14
62
|
import { format, isValid, parseISO } from "date-fns";
|
|
15
63
|
var ExportBuilder = class {
|
|
@@ -233,5 +281,6 @@ var ExportBuilder = class {
|
|
|
233
281
|
}
|
|
234
282
|
};
|
|
235
283
|
export {
|
|
236
|
-
ExportBuilder
|
|
284
|
+
ExportBuilder,
|
|
285
|
+
resolveRawFiltersToExportFilters
|
|
237
286
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as MessageKey, F as FieldType, C as ColumnAlignment, a as ColumnPresentationConfig, b as ColumnGroupConfig, R as ReportType, c as ReportConfig, d as ReportColumnKey } from './report-pbGeYM8Q.cjs';
|
|
2
|
-
export { e as COLUMN_REGISTRY, f as ColumnMessageKey, g as ColumnMetadata, h as FooterCalculation, i as FooterCalculationType, j as Report, k as getColumnExportHeaderLabel, l as getColumnMetadata, m as getFixedColumns, n as getReportConfig, o as getReportExportFileName } from './report-pbGeYM8Q.cjs';
|
|
2
|
+
export { A as AnalyticsField, e as COLUMN_REGISTRY, f as ColumnMessageKey, g as ColumnMetadata, h as FooterCalculation, i as FooterCalculationType, j as Report, k as getColumnExportHeaderLabel, l as getColumnMetadata, m as getFixedColumns, n as getReportConfig, o as getReportExportFileName } from './report-pbGeYM8Q.cjs';
|
|
3
3
|
import { LocaleCode } from '@harbortouch/locale-registry';
|
|
4
4
|
export { R as RenderedReport, a as ReportDocument, b as ReportFormat, c as ReportSection, d as ResolvedColumn, S as SummaryRow } from './ir-CUi0Z9hv.cjs';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as MessageKey, F as FieldType, C as ColumnAlignment, a as ColumnPresentationConfig, b as ColumnGroupConfig, R as ReportType, c as ReportConfig, d as ReportColumnKey } from './report-pbGeYM8Q.js';
|
|
2
|
-
export { e as COLUMN_REGISTRY, f as ColumnMessageKey, g as ColumnMetadata, h as FooterCalculation, i as FooterCalculationType, j as Report, k as getColumnExportHeaderLabel, l as getColumnMetadata, m as getFixedColumns, n as getReportConfig, o as getReportExportFileName } from './report-pbGeYM8Q.js';
|
|
2
|
+
export { A as AnalyticsField, e as COLUMN_REGISTRY, f as ColumnMessageKey, g as ColumnMetadata, h as FooterCalculation, i as FooterCalculationType, j as Report, k as getColumnExportHeaderLabel, l as getColumnMetadata, m as getFixedColumns, n as getReportConfig, o as getReportExportFileName } from './report-pbGeYM8Q.js';
|
|
3
3
|
import { LocaleCode } from '@harbortouch/locale-registry';
|
|
4
4
|
export { R as RenderedReport, a as ReportDocument, b as ReportFormat, c as ReportSection, d as ResolvedColumn, S as SummaryRow } from './ir-CUi0Z9hv.js';
|
|
5
5
|
|