@harbortouch/skytab-analytics-report-utils 0.39.0 → 0.40.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.
@@ -744,7 +744,10 @@ var enUS = {
744
744
  "common.report-section.rev-class-footer.non-sales-revenue": false,
745
745
  "common.report-section.rev-class-footer.house-account": false,
746
746
  "common.report-section.rev-class-footer.total-accountable": false,
747
+ "scheduled-reports.report-name": false,
747
748
  "scheduled-reports.period": false,
749
+ "scheduled-reports.generated-at": false,
750
+ "scheduled-reports.generated-by": false,
748
751
  "components.form.field.group-by": false,
749
752
  "components.form.field.last-week": false,
750
753
  "components.form.field.last-year": false,
@@ -1272,7 +1275,10 @@ var enUS2 = {
1272
1275
  "common.report-section.rev-class-footer.non-sales-revenue": false,
1273
1276
  "common.report-section.rev-class-footer.house-account": false,
1274
1277
  "common.report-section.rev-class-footer.total-accountable": false,
1278
+ "scheduled-reports.report-name": false,
1275
1279
  "scheduled-reports.period": false,
1280
+ "scheduled-reports.generated-at": false,
1281
+ "scheduled-reports.generated-by": false,
1276
1282
  "components.form.field.group-by": false,
1277
1283
  "components.form.field.last-week": false,
1278
1284
  "components.form.field.last-year": false,
@@ -1800,7 +1806,10 @@ var enUS3 = {
1800
1806
  "common.report-section.rev-class-footer.non-sales-revenue": "Non-Sales Revenue",
1801
1807
  "common.report-section.rev-class-footer.house-account": "House Account",
1802
1808
  "common.report-section.rev-class-footer.total-accountable": "Total Accountable",
1809
+ "scheduled-reports.report-name": "Report",
1803
1810
  "scheduled-reports.period": "Period",
1811
+ "scheduled-reports.generated-at": "Generated at",
1812
+ "scheduled-reports.generated-by": "Generated by",
1804
1813
  "components.form.field.group-by": "Group By",
1805
1814
  "components.form.field.last-week": "Compare to Last Week",
1806
1815
  "components.form.field.last-year": "Compare to Last Year",
@@ -1,5 +1,5 @@
1
- import { E as ExportSection } from '../../types-BPT5hjCR.cjs';
2
- export { a as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-BPT5hjCR.cjs';
1
+ import { a as ExportSection } from '../../types-MalWTEdo.cjs';
2
+ export { E as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-MalWTEdo.cjs';
3
3
 
4
4
  declare class ExcelExporter {
5
5
  generate(content: {
@@ -1,5 +1,5 @@
1
- import { E as ExportSection } from '../../types-BPT5hjCR.js';
2
- export { a as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-BPT5hjCR.js';
1
+ import { a as ExportSection } from '../../types-MalWTEdo.js';
2
+ export { E as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-MalWTEdo.js';
3
3
 
4
4
  declare class ExcelExporter {
5
5
  generate(content: {
@@ -516,7 +516,10 @@ var enUS = {
516
516
  "common.report-section.rev-class-footer.non-sales-revenue": "Non-Sales Revenue",
517
517
  "common.report-section.rev-class-footer.house-account": "House Account",
518
518
  "common.report-section.rev-class-footer.total-accountable": "Total Accountable",
519
+ "scheduled-reports.report-name": "Report",
519
520
  "scheduled-reports.period": "Period",
521
+ "scheduled-reports.generated-at": "Generated at",
522
+ "scheduled-reports.generated-by": "Generated by",
520
523
  "components.form.field.group-by": "Group By",
521
524
  "components.form.field.last-week": "Compare to Last Week",
522
525
  "components.form.field.last-year": "Compare to Last Year",
@@ -1044,7 +1047,10 @@ var enUS2 = {
1044
1047
  "common.report-section.rev-class-footer.non-sales-revenue": false,
1045
1048
  "common.report-section.rev-class-footer.house-account": false,
1046
1049
  "common.report-section.rev-class-footer.total-accountable": false,
1050
+ "scheduled-reports.report-name": false,
1047
1051
  "scheduled-reports.period": false,
1052
+ "scheduled-reports.generated-at": false,
1053
+ "scheduled-reports.generated-by": false,
1048
1054
  "components.form.field.group-by": false,
1049
1055
  "components.form.field.last-week": false,
1050
1056
  "components.form.field.last-year": false,
@@ -1572,7 +1578,10 @@ var enUS3 = {
1572
1578
  "common.report-section.rev-class-footer.non-sales-revenue": false,
1573
1579
  "common.report-section.rev-class-footer.house-account": false,
1574
1580
  "common.report-section.rev-class-footer.total-accountable": false,
1581
+ "scheduled-reports.report-name": false,
1575
1582
  "scheduled-reports.period": false,
1583
+ "scheduled-reports.generated-at": false,
1584
+ "scheduled-reports.generated-by": false,
1576
1585
  "components.form.field.group-by": false,
1577
1586
  "components.form.field.last-week": false,
1578
1587
  "components.form.field.last-year": false,
@@ -3959,50 +3968,71 @@ var ExportBuilder = class {
3959
3968
  }
3960
3969
  return (0, import_date_fns.format)(date, "yyyy-MM-dd");
3961
3970
  }
3962
- buildMetadata(parameters) {
3963
- const rows = [];
3964
- rows.push([
3965
- this.translate("scheduled-reports.period"),
3966
- `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`
3967
- ]);
3971
+ buildReportMetadataFilters(parameters, name, meta) {
3972
+ const locationNames = this.locations.map((l) => l.name).join(", ");
3973
+ const period = `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`;
3974
+ const filters = [
3975
+ { label: this.translate("scheduled-reports.report-name"), value: name },
3976
+ { label: this.translate("common.labels.locations"), value: locationNames },
3977
+ { label: this.translate("scheduled-reports.period"), value: period }
3978
+ ];
3968
3979
  if (parameters.groupBy) {
3969
- rows.push([
3970
- this.translate("components.form.field.group-by"),
3971
- this.translate(`analytics.field.${parameters.groupBy}`)
3972
- ]);
3973
- }
3974
- const locationNames = this.locations.map((l) => l.name);
3975
- if (locationNames.length > 0) {
3976
- rows.push([this.translate("common.labels.locations"), locationNames.join(", ")]);
3980
+ filters.push({
3981
+ label: this.translate("components.form.field.group-by"),
3982
+ value: this.translate(`analytics.field.${parameters.groupBy}`)
3983
+ });
3977
3984
  }
3978
3985
  if (parameters.compareToLastWeek === true) {
3979
- rows.push([this.translate("components.form.field.last-week"), this.translate("common.labels.yes")]);
3986
+ filters.push({
3987
+ label: this.translate("components.form.field.last-week"),
3988
+ value: this.translate("common.labels.yes")
3989
+ });
3980
3990
  }
3981
3991
  if (parameters.compareToLastYear === true) {
3982
- rows.push([this.translate("components.form.field.last-year"), this.translate("common.labels.yes")]);
3992
+ filters.push({
3993
+ label: this.translate("components.form.field.last-year"),
3994
+ value: this.translate("common.labels.yes")
3995
+ });
3996
+ }
3997
+ if (meta.generatedAt) {
3998
+ const formatted = new Intl.DateTimeFormat(this.locale, {
3999
+ year: "numeric",
4000
+ month: "short",
4001
+ day: "numeric",
4002
+ hour: "numeric",
4003
+ minute: "2-digit",
4004
+ timeZoneName: "short"
4005
+ }).format(meta.generatedAt);
4006
+ filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
4007
+ }
4008
+ if (meta.generatedBy.email) {
4009
+ filters.push({ label: this.translate("scheduled-reports.generated-by"), value: meta.generatedBy.email });
3983
4010
  }
3984
- return rows;
4011
+ return filters.filter(({ value }) => value !== "");
3985
4012
  }
3986
- getContent(reportData, parameters, name) {
4013
+ getContent(reportData, parameters, name, metadata, appliedFilters) {
3987
4014
  const rawConfig = this.getConfig();
3988
4015
  if (!rawConfig) {
3989
4016
  throw new Error("Missing report config");
3990
4017
  }
4018
+ const metadataFilters = this.buildReportMetadataFilters(parameters, name, metadata);
4019
+ const resolvedAppliedFilters = appliedFilters ?? [];
3991
4020
  let sections;
3992
4021
  if (Array.isArray(rawConfig)) {
3993
4022
  const sectionParameters = { ...parameters, cols: void 0 };
3994
- sections = rawConfig.map((config) => {
3995
- return {
4023
+ sections = [
4024
+ { title: name, filters: metadataFilters, appliedFilters: resolvedAppliedFilters },
4025
+ ...rawConfig.map((config) => ({
3996
4026
  title: this.getConfigSectionName(config),
3997
4027
  ...this.renderTableContent(config, reportData, sectionParameters)
3998
- };
3999
- });
4028
+ }))
4029
+ ];
4000
4030
  } else {
4001
- const metadata = this.buildMetadata(parameters);
4002
4031
  sections = [
4003
4032
  {
4004
4033
  title: name,
4005
- filters: metadata.map(([label, value]) => ({ label, value })),
4034
+ filters: metadataFilters,
4035
+ appliedFilters: resolvedAppliedFilters,
4006
4036
  ...this.renderTableContent(rawConfig, reportData, parameters)
4007
4037
  }
4008
4038
  ];
@@ -1,5 +1,5 @@
1
- import { R as ReportType, A as AnalyticsField } from '../report-CDeQvFgd.cjs';
2
- import { E as ExportSection } from '../types-BPT5hjCR.cjs';
1
+ import { R as ReportType, A as AnalyticsField } from '../report-BNVH_1-b.cjs';
2
+ import { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.cjs';
3
3
 
4
4
  type ReportDocumentSection = ExportSection;
5
5
  interface ReportLocation {
@@ -45,8 +45,8 @@ declare class ExportBuilder {
45
45
  private renderTableContent;
46
46
  private getDataForConfig;
47
47
  private formatMaybeDate;
48
- private buildMetadata;
49
- getContent(reportData: ReportData, parameters: ReportParameters, name: string): ExportSection[];
48
+ private buildReportMetadataFilters;
49
+ getContent(reportData: ReportData, parameters: ReportParameters, name: string, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
50
50
  }
51
51
 
52
- export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
52
+ export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
@@ -1,5 +1,5 @@
1
- import { R as ReportType, A as AnalyticsField } from '../report-CDeQvFgd.js';
2
- import { E as ExportSection } from '../types-BPT5hjCR.js';
1
+ import { R as ReportType, A as AnalyticsField } from '../report-BNVH_1-b.js';
2
+ import { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.js';
3
3
 
4
4
  type ReportDocumentSection = ExportSection;
5
5
  interface ReportLocation {
@@ -45,8 +45,8 @@ declare class ExportBuilder {
45
45
  private renderTableContent;
46
46
  private getDataForConfig;
47
47
  private formatMaybeDate;
48
- private buildMetadata;
49
- getContent(reportData: ReportData, parameters: ReportParameters, name: string): ExportSection[];
48
+ private buildReportMetadataFilters;
49
+ getContent(reportData: ReportData, parameters: ReportParameters, name: string, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
50
50
  }
51
51
 
52
- export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
52
+ export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
@@ -7,7 +7,7 @@ import {
7
7
  getReportConfig,
8
8
  getReportFormattingLocaleOptions,
9
9
  resolveTranslate
10
- } from "../chunk-HRMMRGR7.js";
10
+ } from "../chunk-HKSLZ6DJ.js";
11
11
 
12
12
  // src/exporters/exportBuilder.ts
13
13
  import { format, isValid, parseISO } from "date-fns";
@@ -158,50 +158,71 @@ var ExportBuilder = class {
158
158
  }
159
159
  return format(date, "yyyy-MM-dd");
160
160
  }
161
- buildMetadata(parameters) {
162
- const rows = [];
163
- rows.push([
164
- this.translate("scheduled-reports.period"),
165
- `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`
166
- ]);
161
+ buildReportMetadataFilters(parameters, name, meta) {
162
+ const locationNames = this.locations.map((l) => l.name).join(", ");
163
+ const period = `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`;
164
+ const filters = [
165
+ { label: this.translate("scheduled-reports.report-name"), value: name },
166
+ { label: this.translate("common.labels.locations"), value: locationNames },
167
+ { label: this.translate("scheduled-reports.period"), value: period }
168
+ ];
167
169
  if (parameters.groupBy) {
168
- rows.push([
169
- this.translate("components.form.field.group-by"),
170
- this.translate(`analytics.field.${parameters.groupBy}`)
171
- ]);
172
- }
173
- const locationNames = this.locations.map((l) => l.name);
174
- if (locationNames.length > 0) {
175
- rows.push([this.translate("common.labels.locations"), locationNames.join(", ")]);
170
+ filters.push({
171
+ label: this.translate("components.form.field.group-by"),
172
+ value: this.translate(`analytics.field.${parameters.groupBy}`)
173
+ });
176
174
  }
177
175
  if (parameters.compareToLastWeek === true) {
178
- rows.push([this.translate("components.form.field.last-week"), this.translate("common.labels.yes")]);
176
+ filters.push({
177
+ label: this.translate("components.form.field.last-week"),
178
+ value: this.translate("common.labels.yes")
179
+ });
179
180
  }
180
181
  if (parameters.compareToLastYear === true) {
181
- rows.push([this.translate("components.form.field.last-year"), this.translate("common.labels.yes")]);
182
+ filters.push({
183
+ label: this.translate("components.form.field.last-year"),
184
+ value: this.translate("common.labels.yes")
185
+ });
186
+ }
187
+ if (meta.generatedAt) {
188
+ const formatted = new Intl.DateTimeFormat(this.locale, {
189
+ year: "numeric",
190
+ month: "short",
191
+ day: "numeric",
192
+ hour: "numeric",
193
+ minute: "2-digit",
194
+ timeZoneName: "short"
195
+ }).format(meta.generatedAt);
196
+ filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
182
197
  }
183
- return rows;
198
+ if (meta.generatedBy.email) {
199
+ filters.push({ label: this.translate("scheduled-reports.generated-by"), value: meta.generatedBy.email });
200
+ }
201
+ return filters.filter(({ value }) => value !== "");
184
202
  }
185
- getContent(reportData, parameters, name) {
203
+ getContent(reportData, parameters, name, metadata, appliedFilters) {
186
204
  const rawConfig = this.getConfig();
187
205
  if (!rawConfig) {
188
206
  throw new Error("Missing report config");
189
207
  }
208
+ const metadataFilters = this.buildReportMetadataFilters(parameters, name, metadata);
209
+ const resolvedAppliedFilters = appliedFilters ?? [];
190
210
  let sections;
191
211
  if (Array.isArray(rawConfig)) {
192
212
  const sectionParameters = { ...parameters, cols: void 0 };
193
- sections = rawConfig.map((config) => {
194
- return {
213
+ sections = [
214
+ { title: name, filters: metadataFilters, appliedFilters: resolvedAppliedFilters },
215
+ ...rawConfig.map((config) => ({
195
216
  title: this.getConfigSectionName(config),
196
217
  ...this.renderTableContent(config, reportData, sectionParameters)
197
- };
198
- });
218
+ }))
219
+ ];
199
220
  } else {
200
- const metadata = this.buildMetadata(parameters);
201
221
  sections = [
202
222
  {
203
223
  title: name,
204
- filters: metadata.map(([label, value]) => ({ label, value })),
224
+ filters: metadataFilters,
225
+ appliedFilters: resolvedAppliedFilters,
205
226
  ...this.renderTableContent(rawConfig, reportData, parameters)
206
227
  }
207
228
  ];