@harbortouch/skytab-analytics-report-utils 0.41.9 → 0.41.11
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.
- package/dist/{chunk-ENBT7KRJ.js → chunk-UUKHJDV3.js} +6 -1
- package/dist/exporters/exportBuilder.cjs +30 -7
- package/dist/exporters/exportBuilder.d.cts +2 -2
- package/dist/exporters/exportBuilder.d.ts +2 -2
- package/dist/exporters/exportBuilder.js +24 -4
- package/dist/index.cjs +8 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{report-LuHGzrLx.d.cts → report-Dj8UU5d_.d.cts} +2 -2
- package/dist/{report-LuHGzrLx.d.ts → report-Dj8UU5d_.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -2838,6 +2838,7 @@ var dailySalesTrendsOrderTypeConfig = {
|
|
|
2838
2838
|
};
|
|
2839
2839
|
|
|
2840
2840
|
// src/report.ts
|
|
2841
|
+
import { isValid, parseISO } from "date-fns";
|
|
2841
2842
|
var Report = {
|
|
2842
2843
|
TICKET_LIVE: "ticket-live",
|
|
2843
2844
|
TICKET_ANALYTICS: "ticket-analytics",
|
|
@@ -2911,7 +2912,11 @@ var getReportExportFileName = ({
|
|
|
2911
2912
|
endDate,
|
|
2912
2913
|
format
|
|
2913
2914
|
}) => {
|
|
2914
|
-
const formatDate2 = (
|
|
2915
|
+
const formatDate2 = (value) => {
|
|
2916
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value) && isValid(parseISO(value))) {
|
|
2917
|
+
return value.slice(0, 10);
|
|
2918
|
+
}
|
|
2919
|
+
const date = typeof value === "string" ? new Date(value) : value;
|
|
2915
2920
|
return [
|
|
2916
2921
|
date.getFullYear(),
|
|
2917
2922
|
String(date.getMonth() + 1).padStart(2, "0"),
|
|
@@ -1861,6 +1861,9 @@ var formatFieldValue = (value, type, localeOptions, fullRecord, fieldConfig = DE
|
|
|
1861
1861
|
}
|
|
1862
1862
|
};
|
|
1863
1863
|
|
|
1864
|
+
// src/report.ts
|
|
1865
|
+
var import_date_fns = require("date-fns");
|
|
1866
|
+
|
|
1864
1867
|
// src/reports/salesByItemDetail.ts
|
|
1865
1868
|
var FIELDS = {
|
|
1866
1869
|
businessDate: { type: "date", columnKey: "date", filteringAvailable: false },
|
|
@@ -3978,16 +3981,32 @@ function isAnalyticsField(key) {
|
|
|
3978
3981
|
function isReportColumnKey(key) {
|
|
3979
3982
|
return getColumnMetadata(key) !== void 0;
|
|
3980
3983
|
}
|
|
3981
|
-
function
|
|
3984
|
+
function getReportFieldColumnKey(key, reportType) {
|
|
3985
|
+
const config = getReportConfig(reportType);
|
|
3986
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
3987
|
+
for (const c of configs) {
|
|
3988
|
+
const fields = c?.fields;
|
|
3989
|
+
const columnKey = fields?.[key]?.columnKey;
|
|
3990
|
+
if (columnKey) {
|
|
3991
|
+
return columnKey;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
return void 0;
|
|
3995
|
+
}
|
|
3996
|
+
function resolveFilterLabel(key, locale, reportType) {
|
|
3982
3997
|
if (isAnalyticsField(key)) {
|
|
3983
3998
|
return resolveTranslate(`analytics.field.${key}`, locale);
|
|
3984
3999
|
}
|
|
4000
|
+
const reportColumnKey = reportType ? getReportFieldColumnKey(key, reportType) : void 0;
|
|
4001
|
+
if (reportColumnKey && isReportColumnKey(reportColumnKey)) {
|
|
4002
|
+
return resolveTranslate(getColumnMetadata(reportColumnKey).titleKey, locale);
|
|
4003
|
+
}
|
|
3985
4004
|
if (isReportColumnKey(key)) {
|
|
3986
4005
|
return resolveTranslate(getColumnMetadata(key).titleKey, locale);
|
|
3987
4006
|
}
|
|
3988
4007
|
return key.replace(/(?:_id|Id)$/, "").replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
3989
4008
|
}
|
|
3990
|
-
function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
4009
|
+
function resolveRawFiltersToExportFilters(rawFilters, locale, reportType) {
|
|
3991
4010
|
if (!rawFilters || typeof rawFilters !== "object" || Array.isArray(rawFilters)) {
|
|
3992
4011
|
return [];
|
|
3993
4012
|
}
|
|
@@ -3995,7 +4014,7 @@ function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
|
3995
4014
|
if (key === "location_id" || !Array.isArray(values) || values.length === 0) {
|
|
3996
4015
|
return [];
|
|
3997
4016
|
}
|
|
3998
|
-
const label = resolveFilterLabel(key, locale);
|
|
4017
|
+
const label = resolveFilterLabel(key, locale, reportType);
|
|
3999
4018
|
const value = values.filter((v) => v !== null && v !== void 0).map(String).join(", ");
|
|
4000
4019
|
if (!value) {
|
|
4001
4020
|
return [];
|
|
@@ -4005,7 +4024,7 @@ function resolveRawFiltersToExportFilters(rawFilters, locale) {
|
|
|
4005
4024
|
}
|
|
4006
4025
|
|
|
4007
4026
|
// src/exporters/exportBuilder.ts
|
|
4008
|
-
var
|
|
4027
|
+
var import_date_fns2 = require("date-fns");
|
|
4009
4028
|
var ExportBuilder = class {
|
|
4010
4029
|
constructor(reportType, locations, locale) {
|
|
4011
4030
|
this.reportType = reportType;
|
|
@@ -4147,11 +4166,14 @@ var ExportBuilder = class {
|
|
|
4147
4166
|
return config.dataAccessKey ? data[config.dataAccessKey] ?? [] : [];
|
|
4148
4167
|
}
|
|
4149
4168
|
formatMaybeDate(value) {
|
|
4150
|
-
|
|
4151
|
-
|
|
4169
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value) && (0, import_date_fns2.isValid)((0, import_date_fns2.parseISO)(value))) {
|
|
4170
|
+
return value.slice(0, 10);
|
|
4171
|
+
}
|
|
4172
|
+
const date = typeof value === "string" ? (0, import_date_fns2.parseISO)(value) : value;
|
|
4173
|
+
if (!(0, import_date_fns2.isValid)(date)) {
|
|
4152
4174
|
return "";
|
|
4153
4175
|
}
|
|
4154
|
-
return (0,
|
|
4176
|
+
return (0, import_date_fns2.format)(date, "yyyy-MM-dd");
|
|
4155
4177
|
}
|
|
4156
4178
|
buildReportMetadataFilters(parameters, name, meta) {
|
|
4157
4179
|
const locationNames = this.locations.map((l) => l.name).join(", ");
|
|
@@ -4192,6 +4214,7 @@ var ExportBuilder = class {
|
|
|
4192
4214
|
day: "numeric",
|
|
4193
4215
|
hour: "numeric",
|
|
4194
4216
|
minute: "2-digit",
|
|
4217
|
+
timeZone: this.locations[0]?.timezone ?? "UTC",
|
|
4195
4218
|
timeZoneName: "short"
|
|
4196
4219
|
}).format(meta.generatedAt);
|
|
4197
4220
|
filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as ReportType, A as AnalyticsField } from '../report-
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-Dj8UU5d_.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
|
-
import { R as ReportType, A as AnalyticsField } from '../report-
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-Dj8UU5d_.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 {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getReportFormattingLocaleOptions,
|
|
9
9
|
getReportName,
|
|
10
10
|
resolveTranslate
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-UUKHJDV3.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/filter-resolver.ts
|
|
14
14
|
var ANALYTICS_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -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 [];
|
|
@@ -201,6 +217,9 @@ var ExportBuilder = class {
|
|
|
201
217
|
return config.dataAccessKey ? data[config.dataAccessKey] ?? [] : [];
|
|
202
218
|
}
|
|
203
219
|
formatMaybeDate(value) {
|
|
220
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value) && isValid(parseISO(value))) {
|
|
221
|
+
return value.slice(0, 10);
|
|
222
|
+
}
|
|
204
223
|
const date = typeof value === "string" ? parseISO(value) : value;
|
|
205
224
|
if (!isValid(date)) {
|
|
206
225
|
return "";
|
|
@@ -246,6 +265,7 @@ var ExportBuilder = class {
|
|
|
246
265
|
day: "numeric",
|
|
247
266
|
hour: "numeric",
|
|
248
267
|
minute: "2-digit",
|
|
268
|
+
timeZone: this.locations[0]?.timezone ?? "UTC",
|
|
249
269
|
timeZoneName: "short"
|
|
250
270
|
}).format(meta.generatedAt);
|
|
251
271
|
filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
|
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,9 @@ __export(index_exports, {
|
|
|
73
73
|
});
|
|
74
74
|
module.exports = __toCommonJS(index_exports);
|
|
75
75
|
|
|
76
|
+
// src/report.ts
|
|
77
|
+
var import_date_fns = require("date-fns");
|
|
78
|
+
|
|
76
79
|
// src/reports/salesByItemDetail.ts
|
|
77
80
|
var FIELDS = {
|
|
78
81
|
businessDate: { type: "date", columnKey: "date", filteringAvailable: false },
|
|
@@ -2985,7 +2988,11 @@ var getReportExportFileName = ({
|
|
|
2985
2988
|
endDate,
|
|
2986
2989
|
format
|
|
2987
2990
|
}) => {
|
|
2988
|
-
const formatDate2 = (
|
|
2991
|
+
const formatDate2 = (value) => {
|
|
2992
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}/.test(value) && (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(value))) {
|
|
2993
|
+
return value.slice(0, 10);
|
|
2994
|
+
}
|
|
2995
|
+
const date = typeof value === "string" ? new Date(value) : value;
|
|
2989
2996
|
return [
|
|
2990
2997
|
date.getFullYear(),
|
|
2991
2998
|
String(date.getMonth() + 1).padStart(2, "0"),
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-Dj8UU5d_.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-Dj8UU5d_.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
|
-
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-
|
|
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-
|
|
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-Dj8UU5d_.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-Dj8UU5d_.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
|
@@ -1477,8 +1477,8 @@ declare const getFixedColumns: <TField extends string = string>(config: ReportCo
|
|
|
1477
1477
|
}) => TField[];
|
|
1478
1478
|
declare const getReportExportFileName: ({ reportType, startDate, endDate, format, }: {
|
|
1479
1479
|
reportType: ReportType;
|
|
1480
|
-
startDate: Date;
|
|
1481
|
-
endDate: Date;
|
|
1480
|
+
startDate: string | Date;
|
|
1481
|
+
endDate: string | Date;
|
|
1482
1482
|
format: "csv" | "xlsx" | "pdf";
|
|
1483
1483
|
}) => string;
|
|
1484
1484
|
|
|
@@ -1477,8 +1477,8 @@ declare const getFixedColumns: <TField extends string = string>(config: ReportCo
|
|
|
1477
1477
|
}) => TField[];
|
|
1478
1478
|
declare const getReportExportFileName: ({ reportType, startDate, endDate, format, }: {
|
|
1479
1479
|
reportType: ReportType;
|
|
1480
|
-
startDate: Date;
|
|
1481
|
-
endDate: Date;
|
|
1480
|
+
startDate: string | Date;
|
|
1481
|
+
endDate: string | Date;
|
|
1482
1482
|
format: "csv" | "xlsx" | "pdf";
|
|
1483
1483
|
}) => string;
|
|
1484
1484
|
|