@harbortouch/skytab-analytics-report-utils 0.24.0 → 0.26.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.
- package/dist/{chunk-SZ4VPNAX.js → chunk-SUWIUPHT.js} +2 -0
- package/dist/exporters/exportBuilder.cjs +9 -4
- package/dist/exporters/exportBuilder.js +8 -5
- package/dist/exporters/json/index.cjs +39 -0
- package/dist/exporters/json/index.d.cts +7 -0
- package/dist/exporters/json/index.d.ts +7 -0
- package/dist/exporters/json/index.js +14 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/ir-CUi0Z9hv.d.cts +55 -0
- package/dist/ir-CUi0Z9hv.d.ts +55 -0
- package/package.json +6 -1
|
@@ -180,6 +180,7 @@ var salesSummaryConfig = {
|
|
|
180
180
|
fields: FIELDS2,
|
|
181
181
|
availableColumns: SALES_SUMMARY_AVAILABLE_COLUMNS,
|
|
182
182
|
defaultVisibleColumns: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
183
|
+
chartFields: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
183
184
|
columnGroups: COLUMN_GROUPS,
|
|
184
185
|
hasFooter: true
|
|
185
186
|
};
|
|
@@ -473,6 +474,7 @@ var MODIFIER_MIX_AVAILABLE_COLUMNS = [
|
|
|
473
474
|
];
|
|
474
475
|
var modifierMixConfig = {
|
|
475
476
|
fields: FIELDS6,
|
|
477
|
+
chartFields: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
476
478
|
availableColumns: MODIFIER_MIX_AVAILABLE_COLUMNS,
|
|
477
479
|
defaultVisibleColumns: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
478
480
|
hasFooter: true
|
|
@@ -1814,6 +1814,7 @@ var salesSummaryConfig = {
|
|
|
1814
1814
|
fields: FIELDS2,
|
|
1815
1815
|
availableColumns: SALES_SUMMARY_AVAILABLE_COLUMNS,
|
|
1816
1816
|
defaultVisibleColumns: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
1817
|
+
chartFields: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
1817
1818
|
columnGroups: COLUMN_GROUPS,
|
|
1818
1819
|
hasFooter: true
|
|
1819
1820
|
};
|
|
@@ -2107,6 +2108,7 @@ var MODIFIER_MIX_AVAILABLE_COLUMNS = [
|
|
|
2107
2108
|
];
|
|
2108
2109
|
var modifierMixConfig = {
|
|
2109
2110
|
fields: FIELDS6,
|
|
2111
|
+
chartFields: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
2110
2112
|
availableColumns: MODIFIER_MIX_AVAILABLE_COLUMNS,
|
|
2111
2113
|
defaultVisibleColumns: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
2112
2114
|
hasFooter: true
|
|
@@ -3535,10 +3537,13 @@ var ExportBuilder = class {
|
|
|
3535
3537
|
}
|
|
3536
3538
|
let sections;
|
|
3537
3539
|
if (Array.isArray(rawConfig)) {
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3540
|
+
const sectionParameters = { ...parameters, cols: void 0 };
|
|
3541
|
+
sections = rawConfig.map((config) => {
|
|
3542
|
+
return {
|
|
3543
|
+
sheetName: this.getConfigSectionName(config),
|
|
3544
|
+
...this.renderTableContent(config, reportData, sectionParameters)
|
|
3545
|
+
};
|
|
3546
|
+
});
|
|
3542
3547
|
} else {
|
|
3543
3548
|
const metadata = this.buildMetadata(parameters);
|
|
3544
3549
|
sections = [
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getReportConfig,
|
|
7
7
|
getReportFormattingLocaleOptions,
|
|
8
8
|
resolveTranslate
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-SUWIUPHT.js";
|
|
10
10
|
|
|
11
11
|
// src/exporters/exportBuilder.ts
|
|
12
12
|
import { format, isValid, parseISO } from "date-fns";
|
|
@@ -193,10 +193,13 @@ var ExportBuilder = class {
|
|
|
193
193
|
}
|
|
194
194
|
let sections;
|
|
195
195
|
if (Array.isArray(rawConfig)) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
const sectionParameters = { ...parameters, cols: void 0 };
|
|
197
|
+
sections = rawConfig.map((config) => {
|
|
198
|
+
return {
|
|
199
|
+
sheetName: this.getConfigSectionName(config),
|
|
200
|
+
...this.renderTableContent(config, reportData, sectionParameters)
|
|
201
|
+
};
|
|
202
|
+
});
|
|
200
203
|
} else {
|
|
201
204
|
const metadata = this.buildMetadata(parameters);
|
|
202
205
|
sections = [
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/exporters/json/index.ts
|
|
21
|
+
var json_exports = {};
|
|
22
|
+
__export(json_exports, {
|
|
23
|
+
JsonRenderer: () => JsonRenderer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(json_exports);
|
|
26
|
+
var JsonRenderer = class {
|
|
27
|
+
render(doc) {
|
|
28
|
+
const slug = doc.title.trim().replace(/[^\w-]/g, "_") || "report";
|
|
29
|
+
return {
|
|
30
|
+
buffer: Buffer.from(JSON.stringify(doc)),
|
|
31
|
+
contentType: "application/json",
|
|
32
|
+
fileName: `${slug}.json`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
JsonRenderer
|
|
39
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/exporters/json/index.ts
|
|
2
|
+
var JsonRenderer = class {
|
|
3
|
+
render(doc) {
|
|
4
|
+
const slug = doc.title.trim().replace(/[^\w-]/g, "_") || "report";
|
|
5
|
+
return {
|
|
6
|
+
buffer: Buffer.from(JSON.stringify(doc)),
|
|
7
|
+
contentType: "application/json",
|
|
8
|
+
fileName: `${slug}.json`
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
JsonRenderer
|
|
14
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -252,6 +252,7 @@ var salesSummaryConfig = {
|
|
|
252
252
|
fields: FIELDS2,
|
|
253
253
|
availableColumns: SALES_SUMMARY_AVAILABLE_COLUMNS,
|
|
254
254
|
defaultVisibleColumns: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
255
|
+
chartFields: SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS,
|
|
255
256
|
columnGroups: COLUMN_GROUPS,
|
|
256
257
|
hasFooter: true
|
|
257
258
|
};
|
|
@@ -545,6 +546,7 @@ var MODIFIER_MIX_AVAILABLE_COLUMNS = [
|
|
|
545
546
|
];
|
|
546
547
|
var modifierMixConfig = {
|
|
547
548
|
fields: FIELDS6,
|
|
549
|
+
chartFields: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
548
550
|
availableColumns: MODIFIER_MIX_AVAILABLE_COLUMNS,
|
|
549
551
|
defaultVisibleColumns: MODIFIER_MIX_VISIBLE_COLUMNS,
|
|
550
552
|
hasFooter: true
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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-Bx5XpFQ0.cjs';
|
|
2
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 getReportConfig, n as getReportExportFileName } from './report-Bx5XpFQ0.cjs';
|
|
3
3
|
import { LocaleCode } from '@harbortouch/locale-registry';
|
|
4
|
+
export { R as RenderedReport, a as ReportDocument, b as ReportFormat, c as ReportSection, d as ResolvedColumn, S as SummaryRow } from './ir-CUi0Z9hv.cjs';
|
|
4
5
|
|
|
5
6
|
type SupportedLocale = LocaleCode;
|
|
6
7
|
declare function resolveTranslate(key: MessageKey, locale: string): string;
|
|
@@ -16,6 +17,7 @@ declare const salesSummaryConfig: {
|
|
|
16
17
|
readonly fields: Record<SalesSummaryField, ColumnPresentationConfig<SalesSummaryField>>;
|
|
17
18
|
readonly availableColumns: SalesSummaryField[];
|
|
18
19
|
readonly defaultVisibleColumns: SalesSummaryField[];
|
|
20
|
+
readonly chartFields: SalesSummaryField[];
|
|
19
21
|
readonly columnGroups: ColumnGroupConfig[];
|
|
20
22
|
readonly hasFooter: true;
|
|
21
23
|
};
|
|
@@ -48,6 +50,7 @@ declare const productMixConfig: {
|
|
|
48
50
|
type ModifierMixField = 'groupById' | 'groupByName' | 'groupById2' | 'groupByName2' | 'modifiersSales' | 'modifiersQuantity' | 'itemsQuantity' | 'avgGross' | 'attachRate' | 'modifiersSalesComp' | 'modifiersQuantityComp' | 'itemsQuantityComp' | 'attachRateComp' | 'modifiersSalesVar' | 'modifiersSalesVarPct' | 'modifiersQuantityVar' | 'modifiersQuantityVarPct' | 'attachRateVar' | 'attachRateVarPct';
|
|
49
51
|
declare const modifierMixConfig: {
|
|
50
52
|
readonly fields: Record<ModifierMixField, ColumnPresentationConfig<ModifierMixField>>;
|
|
53
|
+
readonly chartFields: ModifierMixField[];
|
|
51
54
|
readonly availableColumns: ModifierMixField[];
|
|
52
55
|
readonly defaultVisibleColumns: ModifierMixField[];
|
|
53
56
|
readonly hasFooter: true;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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-Bx5XpFQ0.js';
|
|
2
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 getReportConfig, n as getReportExportFileName } from './report-Bx5XpFQ0.js';
|
|
3
3
|
import { LocaleCode } from '@harbortouch/locale-registry';
|
|
4
|
+
export { R as RenderedReport, a as ReportDocument, b as ReportFormat, c as ReportSection, d as ResolvedColumn, S as SummaryRow } from './ir-CUi0Z9hv.js';
|
|
4
5
|
|
|
5
6
|
type SupportedLocale = LocaleCode;
|
|
6
7
|
declare function resolveTranslate(key: MessageKey, locale: string): string;
|
|
@@ -16,6 +17,7 @@ declare const salesSummaryConfig: {
|
|
|
16
17
|
readonly fields: Record<SalesSummaryField, ColumnPresentationConfig<SalesSummaryField>>;
|
|
17
18
|
readonly availableColumns: SalesSummaryField[];
|
|
18
19
|
readonly defaultVisibleColumns: SalesSummaryField[];
|
|
20
|
+
readonly chartFields: SalesSummaryField[];
|
|
19
21
|
readonly columnGroups: ColumnGroupConfig[];
|
|
20
22
|
readonly hasFooter: true;
|
|
21
23
|
};
|
|
@@ -48,6 +50,7 @@ declare const productMixConfig: {
|
|
|
48
50
|
type ModifierMixField = 'groupById' | 'groupByName' | 'groupById2' | 'groupByName2' | 'modifiersSales' | 'modifiersQuantity' | 'itemsQuantity' | 'avgGross' | 'attachRate' | 'modifiersSalesComp' | 'modifiersQuantityComp' | 'itemsQuantityComp' | 'attachRateComp' | 'modifiersSalesVar' | 'modifiersSalesVarPct' | 'modifiersQuantityVar' | 'modifiersQuantityVarPct' | 'attachRateVar' | 'attachRateVarPct';
|
|
49
51
|
declare const modifierMixConfig: {
|
|
50
52
|
readonly fields: Record<ModifierMixField, ColumnPresentationConfig<ModifierMixField>>;
|
|
53
|
+
readonly chartFields: ModifierMixField[];
|
|
51
54
|
readonly availableColumns: ModifierMixField[];
|
|
52
55
|
readonly defaultVisibleColumns: ModifierMixField[];
|
|
53
56
|
readonly hasFooter: true;
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Output format a renderer produces. */
|
|
2
|
+
type ReportFormat = 'csv' | 'xlsx' | 'pdf' | 'html' | 'json';
|
|
3
|
+
/**
|
|
4
|
+
* A fully resolved column — header text already translated, alignment
|
|
5
|
+
* already derived. Renderers consume this directly without touching the
|
|
6
|
+
* column registry or i18n layer.
|
|
7
|
+
*/
|
|
8
|
+
interface ResolvedColumn {
|
|
9
|
+
key: string;
|
|
10
|
+
header: string;
|
|
11
|
+
shortHeader: string;
|
|
12
|
+
align: 'left' | 'right' | 'center';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A name + value pair for rows that do not conform to the section's column
|
|
16
|
+
* schema. Used for footer lines such as "Tax Total €7.00" or
|
|
17
|
+
* "Total Accountable €13.09" in the Daily Sales Revenue Class section.
|
|
18
|
+
*/
|
|
19
|
+
interface SummaryRow {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
bold?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A single section within a report (e.g. "Payments", "Taxes").
|
|
26
|
+
* Each section has its own column schema and optional footer / summary rows.
|
|
27
|
+
*/
|
|
28
|
+
interface ReportSection {
|
|
29
|
+
title?: string;
|
|
30
|
+
columns: ResolvedColumn[];
|
|
31
|
+
rows: Record<string, string | null>[];
|
|
32
|
+
footer?: Record<string, string | null>;
|
|
33
|
+
summary?: SummaryRow[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Format-agnostic intermediate representation of a complete report.
|
|
37
|
+
* Built once by a document builder, then passed to any renderer
|
|
38
|
+
* (CSV, XLSX, PDF, HTML, JSON) without further data access.
|
|
39
|
+
*/
|
|
40
|
+
interface ReportDocument {
|
|
41
|
+
title: string;
|
|
42
|
+
locale: string;
|
|
43
|
+
filters: [string, string][];
|
|
44
|
+
sections: ReportSection[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The output produced by a renderer after consuming a ReportDocument.
|
|
48
|
+
*/
|
|
49
|
+
interface RenderedReport {
|
|
50
|
+
buffer: Buffer;
|
|
51
|
+
contentType: string;
|
|
52
|
+
fileName: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type { RenderedReport as R, SummaryRow as S, ReportDocument as a, ReportFormat as b, ReportSection as c, ResolvedColumn as d };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Output format a renderer produces. */
|
|
2
|
+
type ReportFormat = 'csv' | 'xlsx' | 'pdf' | 'html' | 'json';
|
|
3
|
+
/**
|
|
4
|
+
* A fully resolved column — header text already translated, alignment
|
|
5
|
+
* already derived. Renderers consume this directly without touching the
|
|
6
|
+
* column registry or i18n layer.
|
|
7
|
+
*/
|
|
8
|
+
interface ResolvedColumn {
|
|
9
|
+
key: string;
|
|
10
|
+
header: string;
|
|
11
|
+
shortHeader: string;
|
|
12
|
+
align: 'left' | 'right' | 'center';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A name + value pair for rows that do not conform to the section's column
|
|
16
|
+
* schema. Used for footer lines such as "Tax Total €7.00" or
|
|
17
|
+
* "Total Accountable €13.09" in the Daily Sales Revenue Class section.
|
|
18
|
+
*/
|
|
19
|
+
interface SummaryRow {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
bold?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A single section within a report (e.g. "Payments", "Taxes").
|
|
26
|
+
* Each section has its own column schema and optional footer / summary rows.
|
|
27
|
+
*/
|
|
28
|
+
interface ReportSection {
|
|
29
|
+
title?: string;
|
|
30
|
+
columns: ResolvedColumn[];
|
|
31
|
+
rows: Record<string, string | null>[];
|
|
32
|
+
footer?: Record<string, string | null>;
|
|
33
|
+
summary?: SummaryRow[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Format-agnostic intermediate representation of a complete report.
|
|
37
|
+
* Built once by a document builder, then passed to any renderer
|
|
38
|
+
* (CSV, XLSX, PDF, HTML, JSON) without further data access.
|
|
39
|
+
*/
|
|
40
|
+
interface ReportDocument {
|
|
41
|
+
title: string;
|
|
42
|
+
locale: string;
|
|
43
|
+
filters: [string, string][];
|
|
44
|
+
sections: ReportSection[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The output produced by a renderer after consuming a ReportDocument.
|
|
48
|
+
*/
|
|
49
|
+
interface RenderedReport {
|
|
50
|
+
buffer: Buffer;
|
|
51
|
+
contentType: string;
|
|
52
|
+
fileName: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type { RenderedReport as R, SummaryRow as S, ReportDocument as a, ReportFormat as b, ReportSection as c, ResolvedColumn as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harbortouch/skytab-analytics-report-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Centralized report column presentation configuration for SkyTab Analytics",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.6.0",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"types": "./dist/exporters/exportBuilder.d.ts",
|
|
35
35
|
"import": "./dist/exporters/exportBuilder.js",
|
|
36
36
|
"require": "./dist/exporters/exportBuilder.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./json": {
|
|
39
|
+
"types": "./dist/exporters/json/index.d.ts",
|
|
40
|
+
"import": "./dist/exporters/json/index.js",
|
|
41
|
+
"require": "./dist/exporters/json/index.cjs"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"files": [
|