@happyvertical/smrt-reports 0.61.1 → 0.61.3
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/display.d.ts +9 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +38 -0
- package/dist/display.js.map +1 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/runtime-compiler.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +8 -7
- package/dist/smrt-knowledge.okf.md +3 -2
- package/dist/state.js +1 -1
- package/dist/state.js.map +1 -1
- package/dist/svelte/ReportResult.svelte +23 -3
- package/dist/svelte/ReportResult.svelte.d.ts +5 -0
- package/dist/svelte/ReportResult.svelte.d.ts.map +1 -1
- package/dist/svelte/describe.d.ts +1 -3
- package/dist/svelte/describe.d.ts.map +1 -1
- package/dist/svelte/describe.js +1 -19
- package/dist/svelte/result.d.ts +1 -2
- package/dist/svelte/result.d.ts.map +1 -1
- package/dist/svelte/result.js +2 -43
- package/package.json +15 -10
|
@@ -37,6 +37,17 @@ export interface Props {
|
|
|
37
37
|
view?: 'chart' | 'table';
|
|
38
38
|
locale?: string;
|
|
39
39
|
currency?: string;
|
|
40
|
+
/** Host-owned labels/formatting; raw values remain available for links. */
|
|
41
|
+
formatCell?: (
|
|
42
|
+
value: unknown,
|
|
43
|
+
column: Column,
|
|
44
|
+
row: RuntimeReportResult['rows'][number],
|
|
45
|
+
) => string | undefined;
|
|
46
|
+
/** Optional same-origin record destination, used only in the table. */
|
|
47
|
+
cellHref?: (
|
|
48
|
+
column: Column,
|
|
49
|
+
row: RuntimeReportResult['rows'][number],
|
|
50
|
+
) => string | undefined;
|
|
40
51
|
}
|
|
41
52
|
let {
|
|
42
53
|
result,
|
|
@@ -45,6 +56,8 @@ let {
|
|
|
45
56
|
view = $bindable('chart'),
|
|
46
57
|
locale = 'en',
|
|
47
58
|
currency = 'USD',
|
|
59
|
+
formatCell,
|
|
60
|
+
cellHref,
|
|
48
61
|
}: Props = $props();
|
|
49
62
|
const { t } = useI18n();
|
|
50
63
|
const valid = $derived(validReportResult(result));
|
|
@@ -69,14 +82,20 @@ function bucketLabel(value: unknown, column: Column | undefined) {
|
|
|
69
82
|
}
|
|
70
83
|
return undefined;
|
|
71
84
|
}
|
|
72
|
-
function cell(
|
|
85
|
+
function cell(
|
|
86
|
+
value: unknown,
|
|
87
|
+
column: Column,
|
|
88
|
+
row: RuntimeReportResult['rows'][number],
|
|
89
|
+
) {
|
|
90
|
+
const formatted = formatCell?.(value, column, row);
|
|
91
|
+
if (formatted !== undefined) return formatted;
|
|
73
92
|
return typeof value === 'boolean'
|
|
74
93
|
? t(M[value ? 'reports.yes' : 'reports.no'])
|
|
75
94
|
: (bucketLabel(value, column) ??
|
|
76
95
|
reportCell(value, column, locale, currency));
|
|
77
96
|
}
|
|
78
97
|
const groupLabel = (row: RuntimeReportResult['rows'][number]) =>
|
|
79
|
-
xColumn ? cell(row[xColumn.id], xColumn) : (measure?.label ?? '');
|
|
98
|
+
xColumn ? cell(row[xColumn.id], xColumn, row) : (measure?.label ?? '');
|
|
80
99
|
const figures = $derived(
|
|
81
100
|
variant === 'full' && valid && measure
|
|
82
101
|
? reportFigures(result, measure, {
|
|
@@ -193,7 +212,8 @@ const measureOptions = $derived(
|
|
|
193
212
|
{#each result.rows as row, i (i)}
|
|
194
213
|
<tr>
|
|
195
214
|
{#each result.columns as column (column.id)}
|
|
196
|
-
|
|
215
|
+
{@const href = cellHref?.(column, row)}
|
|
216
|
+
<td class:smrt-report-result__num={numeric(column)} data-smrt-part="cell">{#if href?.startsWith('/') && !href.startsWith('//')}<a {href}>{cell(row[column.id], column, row)}</a>{:else}{cell(row[column.id], column, row)}{/if}</td>
|
|
197
217
|
{/each}
|
|
198
218
|
</tr>
|
|
199
219
|
{/each}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RuntimeReportResult, RuntimeReportSpec } from './types.js';
|
|
2
|
+
type Column = RuntimeReportResult['columns'][number];
|
|
2
3
|
export interface Props {
|
|
3
4
|
result: RuntimeReportResult;
|
|
4
5
|
/** `compact` (default) for a preview card, `full` for a report's page. */
|
|
@@ -9,6 +10,10 @@ export interface Props {
|
|
|
9
10
|
view?: 'chart' | 'table';
|
|
10
11
|
locale?: string;
|
|
11
12
|
currency?: string;
|
|
13
|
+
/** Host-owned labels/formatting; raw values remain available for links. */
|
|
14
|
+
formatCell?: (value: unknown, column: Column, row: RuntimeReportResult['rows'][number]) => string | undefined;
|
|
15
|
+
/** Optional same-origin record destination, used only in the table. */
|
|
16
|
+
cellHref?: (column: Column, row: RuntimeReportResult['rows'][number]) => string | undefined;
|
|
12
17
|
}
|
|
13
18
|
declare const ReportResult: import("svelte").Component<Props, {}, "view">;
|
|
14
19
|
type ReportResult = ReturnType<typeof ReportResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportResult.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/ReportResult.svelte.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ReportResult.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/ReportResult.svelte.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGzE,KAAK,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC7B,gEAAgE;IAChE,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,oEAAoE;IACpE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,CACX,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KACrC,MAAM,GAAG,SAAS,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,CACT,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KACrC,MAAM,GAAG,SAAS,CAAC;CACzB;AA6LD,QAAA,MAAM,YAAY,+CAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -88,7 +88,5 @@ export declare function reportFigures(result: RuntimeReportResult, measure: Colu
|
|
|
88
88
|
export declare function relativeTime(iso: string, locale: string, now?: Date,
|
|
89
89
|
/** What under a minute reads as ("just now"); default the locale's "now". */
|
|
90
90
|
justNow?: string): string;
|
|
91
|
-
|
|
92
|
-
export declare function reportCsv(result: RuntimeReportResult, cell: (value: unknown, column: Column) => string): string;
|
|
93
|
-
export {};
|
|
91
|
+
export { reportCsv } from '../display.js';
|
|
94
92
|
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/svelte/describe.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEzE,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED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,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;IACjE,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,GACA,YAAY,EAAE,CA+ChB;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,IAAiB;AACtB,6EAA6E;AAC7E,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAyBR;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/svelte/describe.js
CHANGED
|
@@ -228,22 +228,4 @@ justNow) {
|
|
|
228
228
|
}
|
|
229
229
|
return justNow ?? format.format(0, 'second');
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
* A cell as CSV text: quoted when needed, and a text cell is never read as a
|
|
233
|
-
* formula. A number column's cell ("-$5.00", "-3") is left as a number.
|
|
234
|
-
*/
|
|
235
|
-
function csvCell(text, numeric = false) {
|
|
236
|
-
const safe = !numeric && /^[=+\-@\t\r]/.test(text) ? `'${text}` : text;
|
|
237
|
-
return /[",\n\r]/.test(safe) ? `"${safe.replaceAll('"', '""')}"` : safe;
|
|
238
|
-
}
|
|
239
|
-
/** The result as CSV with the screen's own formatting (labels, buckets, money). */
|
|
240
|
-
export function reportCsv(result, cell) {
|
|
241
|
-
const lines = [
|
|
242
|
-
result.columns.map((column) => csvCell(column.label)).join(','),
|
|
243
|
-
...result.rows.map((row) => result.columns
|
|
244
|
-
.map((column) => csvCell(cell(row[column.id], column), (column.type === 'integer' || column.type === 'decimal') &&
|
|
245
|
-
typeof row[column.id] === 'number'))
|
|
246
|
-
.join(',')),
|
|
247
|
-
];
|
|
248
|
-
return `${lines.join('\r\n')}\r\n`;
|
|
249
|
-
}
|
|
231
|
+
export { reportCsv } from '../display.js';
|
package/dist/svelte/result.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { RuntimeReportResult } from './types.js';
|
|
2
2
|
export declare function reportError(error: unknown): 'reports.denied' | 'reports.invalid' | 'reports.error';
|
|
3
|
-
|
|
4
|
-
export declare function validReportResult(value: unknown): value is RuntimeReportResult;
|
|
3
|
+
export { validReportResult } from '../display.js';
|
|
5
4
|
export declare function reportCell(value: unknown, column: RuntimeReportResult['columns'][number], locale: string, currency: string): string;
|
|
6
5
|
/** Narrow the UI projection; canonical spec validation remains server-owned. */
|
|
7
6
|
export declare function validReportProposal(value: unknown): value is import('./types.js').RuntimeReportProposal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/svelte/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/svelte/result.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,GACb,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAQxD;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAC9C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAcR;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,OAAO,YAAY,EAAE,qBAAqB,CA8BrD"}
|
package/dist/svelte/result.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatWidgetValue } from '@happyvertical/smrt-ui/charts/format';
|
|
2
|
+
import { validReportResult } from '../display.js';
|
|
2
3
|
import { validRuntimeReportSpec } from './spec.js';
|
|
3
4
|
export function reportError(error) {
|
|
4
5
|
if (error && typeof error === 'object') {
|
|
@@ -10,49 +11,7 @@ export function reportError(error) {
|
|
|
10
11
|
}
|
|
11
12
|
return 'reports.error';
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
export function validReportResult(value) {
|
|
15
|
-
if (!value || typeof value !== 'object')
|
|
16
|
-
return false;
|
|
17
|
-
const r = value;
|
|
18
|
-
return (r.version === 1 &&
|
|
19
|
-
typeof r.title === 'string' &&
|
|
20
|
-
typeof r.specHash === 'string' &&
|
|
21
|
-
typeof r.ranAt === 'string' &&
|
|
22
|
-
typeof r.truncated === 'boolean' &&
|
|
23
|
-
Array.isArray(r.columns) &&
|
|
24
|
-
r.columns.length > 0 &&
|
|
25
|
-
r.columns.length <= 10 &&
|
|
26
|
-
new Set(r.columns.map((c) => c?.id)).size === r.columns.length &&
|
|
27
|
-
r.columns.every((c) => c &&
|
|
28
|
-
typeof c.id === 'string' &&
|
|
29
|
-
typeof c.label === 'string' &&
|
|
30
|
-
['dimension', 'measure'].includes(c.role) &&
|
|
31
|
-
['string', 'integer', 'decimal', 'boolean', 'datetime', 'id'].includes(c.type)) &&
|
|
32
|
-
Array.isArray(r.rows) &&
|
|
33
|
-
r.rows.length <= 1000 &&
|
|
34
|
-
r.rowCount === r.rows.length &&
|
|
35
|
-
r.rows.every((row) => row &&
|
|
36
|
-
typeof row === 'object' &&
|
|
37
|
-
r.columns.every((c) => {
|
|
38
|
-
const v = row[c.id];
|
|
39
|
-
if (v === null)
|
|
40
|
-
return true;
|
|
41
|
-
if (c.type === 'integer')
|
|
42
|
-
return typeof v === 'number' && Number.isSafeInteger(v);
|
|
43
|
-
if (c.type === 'decimal')
|
|
44
|
-
return typeof v === 'number' && Number.isFinite(v);
|
|
45
|
-
if (c.type === 'boolean')
|
|
46
|
-
return typeof v === 'boolean';
|
|
47
|
-
return typeof v === 'string';
|
|
48
|
-
})) &&
|
|
49
|
-
!!r.chart &&
|
|
50
|
-
['bar', 'line', 'table', 'pie', 'stat'].includes(r.chart.type) &&
|
|
51
|
-
(r.chart.y === undefined ||
|
|
52
|
-
(Array.isArray(r.chart.y) &&
|
|
53
|
-
r.chart.y.every((id) => r.columns.some((c) => c.id === id && c.role === 'measure')))) &&
|
|
54
|
-
(r.chart.x === undefined || r.columns.some((c) => c.id === r.chart.x)));
|
|
55
|
-
}
|
|
14
|
+
export { validReportResult } from '../display.js';
|
|
56
15
|
export function reportCell(value, column, locale, currency) {
|
|
57
16
|
if (value === null || value === undefined)
|
|
58
17
|
return '–';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-reports",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.3",
|
|
4
4
|
"description": "Materialized aggregate report models for SMRT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"types": "./dist/state.d.ts",
|
|
40
40
|
"import": "./dist/state.js"
|
|
41
41
|
},
|
|
42
|
+
"./display": {
|
|
43
|
+
"types": "./dist/display.d.ts",
|
|
44
|
+
"import": "./dist/display.js"
|
|
45
|
+
},
|
|
42
46
|
"./spec": {
|
|
43
47
|
"types": "./dist/spec.d.ts",
|
|
44
48
|
"import": "./dist/spec.js"
|
|
@@ -56,17 +60,17 @@
|
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
"dependencies": {
|
|
59
|
-
"@happyvertical/smrt-core": "0.61.
|
|
60
|
-
"@happyvertical/smrt-jobs": "0.61.
|
|
61
|
-
"@happyvertical/smrt-types": "0.61.
|
|
62
|
-
"@happyvertical/smrt-tenancy": "0.61.
|
|
63
|
+
"@happyvertical/smrt-core": "0.61.3",
|
|
64
|
+
"@happyvertical/smrt-jobs": "0.61.3",
|
|
65
|
+
"@happyvertical/smrt-types": "0.61.3",
|
|
66
|
+
"@happyvertical/smrt-tenancy": "0.61.3",
|
|
63
67
|
"@happyvertical/sql": "^0.112.3",
|
|
64
|
-
"@happyvertical/smrt-config": "0.61.
|
|
65
|
-
"@happyvertical/smrt-ui": "0.61.
|
|
68
|
+
"@happyvertical/smrt-config": "0.61.3",
|
|
69
|
+
"@happyvertical/smrt-ui": "0.61.3"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
|
-
"@happyvertical/smrt-scanner": "0.61.
|
|
69
|
-
"@happyvertical/smrt-vitest": "0.61.
|
|
72
|
+
"@happyvertical/smrt-scanner": "0.61.3",
|
|
73
|
+
"@happyvertical/smrt-vitest": "0.61.3",
|
|
70
74
|
"@types/node": "24.13.6",
|
|
71
75
|
"typescript": "6.0.3",
|
|
72
76
|
"vite": "8.1.6",
|
|
@@ -113,6 +117,7 @@
|
|
|
113
117
|
"test:postgres": "node ../../scripts/run-with-ci-postgres.mjs -- pnpm exec vitest run optional.test.ts",
|
|
114
118
|
"test:watch": "vitest",
|
|
115
119
|
"typecheck": "tsc --noEmit -p tsconfig.json && node ../../scripts/svelte-check-a11y.mjs --tsconfig ./tsconfig.svelte.json",
|
|
116
|
-
"verify:pack": "node ../../scripts/verify-package-types-exports.js ."
|
|
120
|
+
"verify:pack": "node ../../scripts/verify-package-types-exports.js .",
|
|
121
|
+
"test:pglite": "node ../core/scripts/test-pglite.mjs src/__tests__/runtime-generated-field.test.ts"
|
|
117
122
|
}
|
|
118
123
|
}
|