@harbortouch/skytab-analytics-report-utils 0.25.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.
@@ -3537,10 +3537,13 @@ var ExportBuilder = class {
3537
3537
  }
3538
3538
  let sections;
3539
3539
  if (Array.isArray(rawConfig)) {
3540
- sections = rawConfig.map((config) => ({
3541
- sheetName: this.getConfigSectionName(config),
3542
- ...this.renderTableContent(config, reportData, parameters)
3543
- }));
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
+ });
3544
3547
  } else {
3545
3548
  const metadata = this.buildMetadata(parameters);
3546
3549
  sections = [
@@ -193,10 +193,13 @@ var ExportBuilder = class {
193
193
  }
194
194
  let sections;
195
195
  if (Array.isArray(rawConfig)) {
196
- sections = rawConfig.map((config) => ({
197
- sheetName: this.getConfigSectionName(config),
198
- ...this.renderTableContent(config, reportData, parameters)
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,7 @@
1
+ import { a as ReportDocument, R as RenderedReport } from '../../ir-CUi0Z9hv.cjs';
2
+
3
+ declare class JsonRenderer {
4
+ render(doc: ReportDocument): RenderedReport;
5
+ }
6
+
7
+ export { JsonRenderer };
@@ -0,0 +1,7 @@
1
+ import { a as ReportDocument, R as RenderedReport } from '../../ir-CUi0Z9hv.js';
2
+
3
+ declare class JsonRenderer {
4
+ render(doc: ReportDocument): RenderedReport;
5
+ }
6
+
7
+ export { JsonRenderer };
@@ -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.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;
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;
@@ -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.25.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": [