@harbortouch/skytab-analytics-report-utils 0.41.14 → 0.42.1
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-LOMK2QOF.js → chunk-KLJKY4F3.js} +1144 -1109
- package/dist/exporters/exportBuilder.cjs +1173 -1111
- package/dist/exporters/exportBuilder.d.cts +14 -8
- package/dist/exporters/exportBuilder.d.ts +14 -8
- package/dist/exporters/exportBuilder.js +30 -3
- package/dist/index.cjs +1144 -1109
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{report-CbS_hnrr.d.cts → report-D307oJxt.d.cts} +16 -1
- package/dist/{report-CbS_hnrr.d.ts → report-D307oJxt.d.ts} +16 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReportType, A as AnalyticsField } from '../report-
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-D307oJxt.cjs';
|
|
2
2
|
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-D3IyO__4.cjs';
|
|
3
3
|
|
|
4
4
|
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string, reportType?: ReportType): ExportFilter[];
|
|
@@ -13,16 +13,22 @@ interface ReportLocation {
|
|
|
13
13
|
countryCode: string;
|
|
14
14
|
merchantId: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/** Report options shared by exports, saved reports and subscriptions (everything except the date range). */
|
|
17
|
+
interface ReportOptions {
|
|
18
|
+
groupBy?: AnalyticsField;
|
|
19
|
+
secondGroupBy?: AnalyticsField;
|
|
20
|
+
sortBy?: string;
|
|
21
|
+
order?: string;
|
|
22
|
+
cols?: string[];
|
|
23
|
+
viewMode?: 'detail' | 'summary';
|
|
17
24
|
compareToLastWeek?: boolean;
|
|
18
25
|
compareToLastYear?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
showZeroAmounts?: boolean;
|
|
27
|
+
showNonSales?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface ReportParameters extends ReportOptions {
|
|
21
30
|
startDate: string | Date;
|
|
22
31
|
endDate: string | Date;
|
|
23
|
-
groupBy?: AnalyticsField;
|
|
24
|
-
showZeroAmounts?: boolean;
|
|
25
|
-
order?: string;
|
|
26
32
|
}
|
|
27
33
|
type ReportData = SingleReportData | Record<string, SingleReportData>;
|
|
28
34
|
type SingleReportData = Record<string, unknown>[];
|
|
@@ -52,4 +58,4 @@ declare class ExportBuilder {
|
|
|
52
58
|
getContent(reportData: ReportData, parameters: ReportParameters, name: string | undefined, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
61
|
+
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportOptions, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReportType, A as AnalyticsField } from '../report-
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-D307oJxt.js';
|
|
2
2
|
import { E as ExportFilter, R as ReportMetadata, a as ExportSection } from '../types-D3IyO__4.js';
|
|
3
3
|
|
|
4
4
|
declare function resolveRawFiltersToExportFilters(rawFilters: Record<string, (string | number)[] | undefined>, locale: string, reportType?: ReportType): ExportFilter[];
|
|
@@ -13,16 +13,22 @@ interface ReportLocation {
|
|
|
13
13
|
countryCode: string;
|
|
14
14
|
merchantId: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/** Report options shared by exports, saved reports and subscriptions (everything except the date range). */
|
|
17
|
+
interface ReportOptions {
|
|
18
|
+
groupBy?: AnalyticsField;
|
|
19
|
+
secondGroupBy?: AnalyticsField;
|
|
20
|
+
sortBy?: string;
|
|
21
|
+
order?: string;
|
|
22
|
+
cols?: string[];
|
|
23
|
+
viewMode?: 'detail' | 'summary';
|
|
17
24
|
compareToLastWeek?: boolean;
|
|
18
25
|
compareToLastYear?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
showZeroAmounts?: boolean;
|
|
27
|
+
showNonSales?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface ReportParameters extends ReportOptions {
|
|
21
30
|
startDate: string | Date;
|
|
22
31
|
endDate: string | Date;
|
|
23
|
-
groupBy?: AnalyticsField;
|
|
24
|
-
showZeroAmounts?: boolean;
|
|
25
|
-
order?: string;
|
|
26
32
|
}
|
|
27
33
|
type ReportData = SingleReportData | Record<string, SingleReportData>;
|
|
28
34
|
type SingleReportData = Record<string, unknown>[];
|
|
@@ -52,4 +58,4 @@ declare class ExportBuilder {
|
|
|
52
58
|
getContent(reportData: ReportData, parameters: ReportParameters, name: string | undefined, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
61
|
+
export { ExportBuilder, ExportFilter, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportOptions, type ReportParameters, ReportType, type SingleReportData, resolveRawFiltersToExportFilters };
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getReportFormattingLocaleOptions,
|
|
9
9
|
getReportName,
|
|
10
10
|
resolveTranslate
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-KLJKY4F3.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/filter-resolver.ts
|
|
14
14
|
var ANALYTICS_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -229,7 +229,7 @@ var ExportBuilder = class {
|
|
|
229
229
|
}
|
|
230
230
|
return format(date, "yyyy-MM-dd");
|
|
231
231
|
}
|
|
232
|
-
buildReportMetadataFilters(parameters, name, meta) {
|
|
232
|
+
buildReportMetadataFilters(configs, parameters, name, meta) {
|
|
233
233
|
const locationNames = this.locations.map((l) => l.name).join(", ");
|
|
234
234
|
const period = `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`;
|
|
235
235
|
const filters = [
|
|
@@ -267,6 +267,28 @@ var ExportBuilder = class {
|
|
|
267
267
|
value: this.translate("common.labels.yes")
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
+
const { order, sortBy } = parameters;
|
|
271
|
+
if (order && sortBy) {
|
|
272
|
+
const sortConfig = configs.find((c) => sortBy in c.fields) ?? configs[0];
|
|
273
|
+
const resolvedLabel = this.getColumnHeader(sortBy, sortConfig, parameters);
|
|
274
|
+
const direction = order === "asc" ? this.translate("common.sort-direction.ascending") : this.translate("common.sort-direction.descending");
|
|
275
|
+
filters.push({
|
|
276
|
+
label: this.translate("components.form.field.ordering"),
|
|
277
|
+
value: `${resolvedLabel} (${direction})`
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (parameters.viewMode) {
|
|
281
|
+
filters.push({
|
|
282
|
+
label: this.translate("components.form.field.view-mode"),
|
|
283
|
+
value: parameters.viewMode === "detail" ? this.translate("components.filter.view-mode.detail") : this.translate("components.filter.view-mode.summary")
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (parameters.showNonSales) {
|
|
287
|
+
filters.push({
|
|
288
|
+
label: this.translate("components.form.field.show-non-sales"),
|
|
289
|
+
value: parameters.showNonSales ? this.translate("common.labels.yes") : this.translate("common.labels.no")
|
|
290
|
+
});
|
|
291
|
+
}
|
|
270
292
|
if (meta.generatedAt) {
|
|
271
293
|
const formatted = new Intl.DateTimeFormat(this.locale, {
|
|
272
294
|
year: "numeric",
|
|
@@ -290,7 +312,12 @@ var ExportBuilder = class {
|
|
|
290
312
|
throw new Error("Missing report config");
|
|
291
313
|
}
|
|
292
314
|
const resolvedName = name ?? getReportName(this.reportType);
|
|
293
|
-
const metadataFilters = this.buildReportMetadataFilters(
|
|
315
|
+
const metadataFilters = this.buildReportMetadataFilters(
|
|
316
|
+
Array.isArray(rawConfig) ? rawConfig : [rawConfig],
|
|
317
|
+
parameters,
|
|
318
|
+
resolvedName,
|
|
319
|
+
metadata
|
|
320
|
+
);
|
|
294
321
|
const metaData = {
|
|
295
322
|
[""]: metadataFilters,
|
|
296
323
|
[this.translate("scheduled-reports.applied-filters")]: appliedFilters ?? this.translate("common.labels.none")
|