@harbortouch/skytab-analytics-report-utils 0.41.3 → 0.41.5

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.
@@ -2493,9 +2493,7 @@ var FIELDS10 = {
2493
2493
  };
2494
2494
  var VISIBLE_COLUMNS2 = [
2495
2495
  "groupByName",
2496
- "locationName",
2497
2496
  "employeeName",
2498
- "payrollId",
2499
2497
  "netSales",
2500
2498
  "cashCollected",
2501
2499
  "grossTips",
@@ -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
 
@@ -2659,9 +2660,7 @@ var FIELDS10 = {
2659
2660
  };
2660
2661
  var VISIBLE_COLUMNS2 = [
2661
2662
  "groupByName",
2662
- "locationName",
2663
2663
  "employeeName",
2664
- "payrollId",
2665
2664
  "netSales",
2666
2665
  "cashCollected",
2667
2666
  "grossTips",
@@ -3950,6 +3949,54 @@ var calculateReportTotals = (data, fieldConfig) => {
3950
3949
  return result;
3951
3950
  };
3952
3951
 
3952
+ // src/utils/filter-resolver.ts
3953
+ var ANALYTICS_FIELDS = /* @__PURE__ */ new Set([
3954
+ "location_id",
3955
+ "order_type_id",
3956
+ "revenue_center_id",
3957
+ "hour_id",
3958
+ "timeslot_id",
3959
+ "employee_id",
3960
+ "employee_name",
3961
+ "payroll_id",
3962
+ "daypart_id",
3963
+ "item_id",
3964
+ "department_id",
3965
+ "revenue_class_id",
3966
+ "modifier_id"
3967
+ ]);
3968
+ function isAnalyticsField(key) {
3969
+ return ANALYTICS_FIELDS.has(key);
3970
+ }
3971
+ function isReportColumnKey(key) {
3972
+ return getColumnMetadata(key) !== void 0;
3973
+ }
3974
+ function resolveFilterLabel(key, locale) {
3975
+ if (isAnalyticsField(key)) {
3976
+ return resolveTranslate(`analytics.field.${key}`, locale);
3977
+ }
3978
+ if (isReportColumnKey(key)) {
3979
+ return resolveTranslate(getColumnMetadata(key).titleKey, locale);
3980
+ }
3981
+ return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
3982
+ }
3983
+ function resolveRawFiltersToExportFilters(rawFilters, locale) {
3984
+ if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
3985
+ return [];
3986
+ }
3987
+ return Object.entries(rawFilters).flatMap(([key, values]) => {
3988
+ if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
3989
+ return [];
3990
+ }
3991
+ const label = resolveFilterLabel(key, locale);
3992
+ const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
3993
+ if (!value) {
3994
+ return [];
3995
+ }
3996
+ return [{ label, value }];
3997
+ });
3998
+ }
3999
+
3953
4000
  // src/exporters/exportBuilder.ts
3954
4001
  var import_date_fns = require("date-fns");
3955
4002
  var ExportBuilder = class {
@@ -4174,5 +4221,6 @@ var ExportBuilder = class {
4174
4221
  };
4175
4222
  // Annotate the CommonJS export names for ESM import in node:
4176
4223
  0 && (module.exports = {
4177
- ExportBuilder
4224
+ ExportBuilder,
4225
+ resolveRawFiltersToExportFilters
4178
4226
  });
@@ -1,5 +1,7 @@
1
1
  import { R as ReportType, A as AnalyticsField } from '../report-pbGeYM8Q.cjs';
2
- import { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.cjs';
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 { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.js';
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 };
@@ -8,7 +8,55 @@ import {
8
8
  getReportFormattingLocaleOptions,
9
9
  getReportName,
10
10
  resolveTranslate
11
- } from "../chunk-DDHOYPIA.js";
11
+ } from "../chunk-Z36HJZOP.js";
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
+ }
12
60
 
13
61
  // src/exporters/exportBuilder.ts
14
62
  import { format, isValid, parseISO } from "date-fns";
@@ -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.cjs CHANGED
@@ -2568,9 +2568,7 @@ var FIELDS10 = {
2568
2568
  };
2569
2569
  var VISIBLE_COLUMNS2 = [
2570
2570
  "groupByName",
2571
- "locationName",
2572
2571
  "employeeName",
2573
- "payrollId",
2574
2572
  "netSales",
2575
2573
  "cashCollected",
2576
2574
  "grossTips",
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
 
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  ticketLiveConfig,
41
41
  ticketSummaryConfig,
42
42
  tipCashoutReconciliationConfig
43
- } from "./chunk-DDHOYPIA.js";
43
+ } from "./chunk-Z36HJZOP.js";
44
44
 
45
45
  // src/utils/alignment.ts
46
46
  function getColumnAlignment(type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbortouch/skytab-analytics-report-utils",
3
- "version": "0.41.3",
3
+ "version": "0.41.5",
4
4
  "description": "Centralized report column presentation configuration for SkyTab Analytics",
5
5
  "engines": {
6
6
  "node": ">=22.6.0",