@happyvertical/smrt-reports 0.57.5 → 0.57.7
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/AGENTS.md +10 -0
- package/dist/chunks/runtime-time-D7JZ1e4J.js +1052 -0
- package/dist/chunks/runtime-time-D7JZ1e4J.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -591
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +28 -4
- package/dist/playground.js +1 -1
- package/dist/playground.js.map +1 -1
- package/dist/recipes.d.ts +21 -0
- package/dist/recipes.d.ts.map +1 -1
- package/dist/runtime-compiler.d.ts +7 -40
- package/dist/runtime-compiler.d.ts.map +1 -1
- package/dist/runtime-dimensions.d.ts +43 -0
- package/dist/runtime-dimensions.d.ts.map +1 -0
- package/dist/runtime-memory.d.ts +81 -0
- package/dist/runtime-memory.d.ts.map +1 -0
- package/dist/runtime-plan.d.ts +121 -0
- package/dist/runtime-plan.d.ts.map +1 -0
- package/dist/runtime-report.d.ts.map +1 -1
- package/dist/runtime-server.d.ts.map +1 -1
- package/dist/runtime-spec-hash.d.ts +11 -0
- package/dist/runtime-spec-hash.d.ts.map +1 -0
- package/dist/runtime-spec.d.ts +16 -4
- package/dist/runtime-spec.d.ts.map +1 -1
- package/dist/runtime-time.d.ts +41 -0
- package/dist/runtime-time.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +37 -12
- package/dist/spec.d.ts +25 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +2 -0
- package/dist/state.js +1 -1
- package/dist/state.js.map +1 -1
- package/dist/svelte/ReportConfirmation.svelte +97 -24
- package/dist/svelte/ReportConfirmation.svelte.d.ts +20 -0
- package/dist/svelte/ReportConfirmation.svelte.d.ts.map +1 -1
- package/dist/svelte/ReportDetail.svelte +263 -12
- package/dist/svelte/ReportDetail.svelte.d.ts +10 -1
- package/dist/svelte/ReportDetail.svelte.d.ts.map +1 -1
- package/dist/svelte/ReportPicker.svelte +47 -14
- package/dist/svelte/ReportPicker.svelte.d.ts +3 -0
- package/dist/svelte/ReportPicker.svelte.d.ts.map +1 -1
- package/dist/svelte/ReportResult.svelte +216 -35
- package/dist/svelte/ReportResult.svelte.d.ts +8 -2
- package/dist/svelte/ReportResult.svelte.d.ts.map +1 -1
- package/dist/svelte/RuntimeReportWidgetOptions.svelte +9 -1
- package/dist/svelte/RuntimeReportWidgetOptions.svelte.d.ts.map +1 -1
- package/dist/svelte/SavedReportCard.svelte +242 -0
- package/dist/svelte/SavedReportCard.svelte.d.ts +30 -0
- package/dist/svelte/SavedReportCard.svelte.d.ts.map +1 -0
- package/dist/svelte/SavedReports.svelte +206 -33
- package/dist/svelte/SavedReports.svelte.d.ts +13 -0
- package/dist/svelte/SavedReports.svelte.d.ts.map +1 -1
- package/dist/svelte/SavedReportsWidget.svelte +59 -0
- package/dist/svelte/SavedReportsWidget.svelte.d.ts +19 -0
- package/dist/svelte/SavedReportsWidget.svelte.d.ts.map +1 -0
- package/dist/svelte/client.d.ts.map +1 -1
- package/dist/svelte/client.js +3 -0
- package/dist/svelte/describe.d.ts +94 -0
- package/dist/svelte/describe.d.ts.map +1 -0
- package/dist/svelte/describe.js +249 -0
- package/dist/svelte/index.d.ts +4 -1
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +4 -1
- package/dist/svelte/messages.d.ts +48 -0
- package/dist/svelte/messages.d.ts.map +1 -1
- package/dist/svelte/messages.js +59 -11
- package/dist/svelte/playground.d.ts +2 -2
- package/dist/svelte/playground.d.ts.map +1 -1
- package/dist/svelte/playground.js +1 -1
- package/dist/svelte/types.d.ts +2 -0
- package/dist/svelte/types.d.ts.map +1 -1
- package/package.json +13 -9
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-reports",
|
|
5
|
-
"packageVersion": "0.57.
|
|
5
|
+
"packageVersion": "0.57.7",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-reports:SmrtReport": {
|
|
8
8
|
"name": "smrtreport",
|
|
@@ -2772,17 +2772,41 @@
|
|
|
2772
2772
|
],
|
|
2773
2773
|
"nav": [
|
|
2774
2774
|
{
|
|
2775
|
-
"label": "
|
|
2775
|
+
"label": "Saved reports",
|
|
2776
2776
|
"model": "@happyvertical/smrt-reports:RuntimeReport",
|
|
2777
|
-
"icon": "fileText"
|
|
2777
|
+
"icon": "fileText",
|
|
2778
|
+
"description": "Reports your team approved, kept up to date.",
|
|
2779
|
+
"noun": "report"
|
|
2778
2780
|
}
|
|
2779
2781
|
],
|
|
2780
2782
|
"requires": [],
|
|
2781
2783
|
"help": {
|
|
2782
|
-
"markdown": "# Reports\n\nAsk the assistant for a total, comparison, or trend. Review the proposed report\nand approve it to save it. Your saved reports are shared with your team; each\nperson sees results using their own access to the underlying information.\n\nReports run fresh when opened. You can archive a report to hide it from the\nactive list and restore it later. Creating and restoring reports needs report\nwriting access. Reports need a connected server
|
|
2784
|
+
"markdown": "# Reports\n\nAsk the assistant for a total, comparison, or trend. Review the proposed report\nand approve it to save it. Your saved reports are shared with your team; each\nperson sees results using their own access to the underlying information.\n\nReports run fresh when opened. You can archive a report to hide it from the\nactive list and restore it later. Creating and restoring reports needs report\nwriting access. Reports need a connected server; the smrt planner previews them over its\nsample records instead. Scheduling, renaming, and exporting reports are not available yet.\n",
|
|
2783
2785
|
"fieldRefs": []
|
|
2784
2786
|
},
|
|
2785
2787
|
"surfaces": [
|
|
2788
|
+
{
|
|
2789
|
+
"kind": "widget",
|
|
2790
|
+
"type": "saved-reports",
|
|
2791
|
+
"export": "@happyvertical/smrt-reports/svelte#SavedReportsWidget",
|
|
2792
|
+
"label": "Saved reports",
|
|
2793
|
+
"description": "Your team’s saved reports with their latest figures.",
|
|
2794
|
+
"icon": "fileText",
|
|
2795
|
+
"options": [
|
|
2796
|
+
{
|
|
2797
|
+
"key": "limit",
|
|
2798
|
+
"type": "integer",
|
|
2799
|
+
"label": "Reports shown",
|
|
2800
|
+
"default": 6,
|
|
2801
|
+
"min": 1,
|
|
2802
|
+
"max": 24
|
|
2803
|
+
}
|
|
2804
|
+
],
|
|
2805
|
+
"sectionDefault": true,
|
|
2806
|
+
"defaultSpan": 4,
|
|
2807
|
+
"minSpan": 2,
|
|
2808
|
+
"maxSpan": 4
|
|
2809
|
+
},
|
|
2786
2810
|
{
|
|
2787
2811
|
"kind": "route",
|
|
2788
2812
|
"path": "/reports",
|
package/dist/playground.js
CHANGED
|
@@ -84,7 +84,7 @@ var playground_default = {
|
|
|
84
84
|
{
|
|
85
85
|
id: "saved-reports",
|
|
86
86
|
title: "Saved reports",
|
|
87
|
-
description: "
|
|
87
|
+
description: "Saved reports as cards, whose and archived filters, and archive in a menu.",
|
|
88
88
|
loadComponent: () => import("./svelte/SavedReports.svelte").then((m) => m.default),
|
|
89
89
|
props: { client: client() },
|
|
90
90
|
order: 1
|
package/dist/playground.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.js","names":[],"sources":["../src/svelte/preview-data.ts","../src/svelte/playground.ts"],"sourcesContent":["import type {\n RuntimeReportProposal,\n RuntimeReportResult,\n RuntimeReportSpec,\n RuntimeReportsClient,\n SavedRuntimeReport,\n} from './types.js';\n\nexport const spec: RuntimeReportSpec = {\n version: 1,\n title: 'Sales by region',\n source: 'sales',\n dimensions: [{ field: 'region', as: 'region' }],\n measures: [{ fn: 'sum', field: 'amount', as: 'total' }],\n filters: [],\n having: [],\n sort: [],\n limit: 100,\n chart: { type: 'bar', x: 'region', y: ['total'] },\n};\nexport const result: RuntimeReportResult = {\n version: 1,\n specHash: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',\n title: spec.title,\n columns: [\n { id: 'region', label: 'Region', role: 'dimension', type: 'string' },\n {\n id: 'total',\n label: 'Total',\n role: 'measure',\n type: 'integer',\n format: 'money',\n },\n ],\n rows: [{ region: 'West', total: 12345 }],\n rowCount: 1,\n truncated: false,\n ranAt: '2026-10-13T12:00:00Z',\n chart: spec.chart,\n};\nexport const saved: SavedRuntimeReport = {\n id: 'report-1',\n title: spec.title,\n sourceId: 'sales',\n createdByUserId: 'alice',\n status: 'active',\n spec,\n canArchive: true,\n};\nexport const proposal: RuntimeReportProposal = {\n status: 'awaiting_confirmation',\n specHash: result.specHash,\n spec,\n preview: result,\n sourceLabel: 'Sales',\n confirmPath: '/api/_reports/runtime/confirm',\n};\nexport function client(\n overrides: Partial<RuntimeReportsClient> = {},\n): RuntimeReportsClient {\n return {\n list: async () => [saved],\n get: async () => saved,\n run: async () => result,\n archive: async () => {},\n confirm: async () => saved,\n ...overrides,\n };\n}\n","import { client, proposal, result, saved } from './preview-data.js';\n\nexport default {\n packageName: '@happyvertical/smrt-reports',\n displayName: 'Reports',\n description: 'Saved runtime reports and live results.',\n entries: [\n {\n id: 'saved-reports',\n title: 'Saved reports',\n description
|
|
1
|
+
{"version":3,"file":"playground.js","names":[],"sources":["../src/svelte/preview-data.ts","../src/svelte/playground.ts"],"sourcesContent":["import type {\n RuntimeReportProposal,\n RuntimeReportResult,\n RuntimeReportSpec,\n RuntimeReportsClient,\n SavedRuntimeReport,\n} from './types.js';\n\nexport const spec: RuntimeReportSpec = {\n version: 1,\n title: 'Sales by region',\n source: 'sales',\n dimensions: [{ field: 'region', as: 'region' }],\n measures: [{ fn: 'sum', field: 'amount', as: 'total' }],\n filters: [],\n having: [],\n sort: [],\n limit: 100,\n chart: { type: 'bar', x: 'region', y: ['total'] },\n};\nexport const result: RuntimeReportResult = {\n version: 1,\n specHash: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',\n title: spec.title,\n columns: [\n { id: 'region', label: 'Region', role: 'dimension', type: 'string' },\n {\n id: 'total',\n label: 'Total',\n role: 'measure',\n type: 'integer',\n format: 'money',\n },\n ],\n rows: [{ region: 'West', total: 12345 }],\n rowCount: 1,\n truncated: false,\n ranAt: '2026-10-13T12:00:00Z',\n chart: spec.chart,\n};\nexport const saved: SavedRuntimeReport = {\n id: 'report-1',\n title: spec.title,\n sourceId: 'sales',\n createdByUserId: 'alice',\n status: 'active',\n spec,\n canArchive: true,\n};\nexport const proposal: RuntimeReportProposal = {\n status: 'awaiting_confirmation',\n specHash: result.specHash,\n spec,\n preview: result,\n sourceLabel: 'Sales',\n confirmPath: '/api/_reports/runtime/confirm',\n};\nexport function client(\n overrides: Partial<RuntimeReportsClient> = {},\n): RuntimeReportsClient {\n return {\n list: async () => [saved],\n get: async () => saved,\n run: async () => result,\n archive: async () => {},\n confirm: async () => saved,\n ...overrides,\n };\n}\n","import { client, proposal, result, saved } from './preview-data.js';\n\nexport default {\n packageName: '@happyvertical/smrt-reports',\n displayName: 'Reports',\n description: 'Saved runtime reports and live results.',\n entries: [\n {\n id: 'saved-reports',\n title: 'Saved reports',\n description:\n 'Saved reports as cards, whose and archived filters, and archive in a menu.',\n loadComponent: () =>\n import('./SavedReports.svelte').then((m) => m.default),\n props: { client: client() },\n order: 1,\n },\n {\n id: 'report-detail',\n title: 'Report detail',\n description: 'Money values with chart and table views.',\n loadComponent: () =>\n import('./ReportDetail.svelte').then((m) => m.default),\n props: { id: saved.id, client: client(), locale: 'en-US' },\n order: 2,\n },\n {\n id: 'report-confirmation',\n title: 'Report confirmation',\n description: 'Review a bounded proposal before saving.',\n loadComponent: () =>\n import('./ReportConfirmation.svelte').then((m) => m.default),\n props: { proposal, confirm: async () => saved },\n order: 3,\n },\n {\n id: 'report-picker',\n title: 'Report picker',\n description: 'Choose a saved report and its measure.',\n loadComponent: () =>\n import('./ReportPicker.svelte').then((m) => m.default),\n props: {\n client: client(),\n reportId: saved.id,\n measure: 'total',\n dimension: 'region',\n onchange: () => {},\n },\n order: 4,\n },\n {\n id: 'reports-unavailable',\n title: 'Reports unavailable',\n description: 'Static hosts do not make server requests.',\n loadComponent: () =>\n import('./RuntimeReportsRoute.svelte').then((m) => m.default),\n props: { serverAvailable: false },\n order: 5,\n },\n {\n id: 'report-empty',\n title: 'Empty report',\n description: 'A valid report with no matching rows.',\n loadComponent: () =>\n import('./ReportResult.svelte').then((m) => m.default),\n props: { result: { ...result, rows: [], rowCount: 0 } },\n order: 6,\n },\n ],\n};\n"],"mappings":";AAQO,IAAM,OAA0B;CACrC,SAAS;CACT,OAAO;CACP,QAAQ;CACR,YAAY,CAAC;EAAE,OAAO;EAAU,IAAI;CAAS,CAAC;CAC9C,UAAU,CAAC;EAAE,IAAI;EAAO,OAAO;EAAU,IAAI;CAAQ,CAAC;CACtD,SAAS,CAAC;CACV,QAAQ,CAAC;CACT,MAAM,CAAC;CACP,OAAO;CACP,OAAO;EAAE,MAAM;EAAO,GAAG;EAAU,GAAG,CAAC,OAAO;CAAE;AAClD;AACO,IAAM,SAA8B;CACzC,SAAS;CACT,UAAU;CACV,OAAO,KAAK;CACZ,SAAS,CACP;EAAE,IAAI;EAAU,OAAO;EAAU,MAAM;EAAa,MAAM;CAAS,GACnE;EACE,IAAI;EACJ,OAAO;EACP,MAAM;EACN,MAAM;EACN,QAAQ;CACV,CACF;CACA,MAAM,CAAC;EAAE,QAAQ;EAAQ,OAAO;CAAM,CAAC;CACvC,UAAU;CACV,WAAW;CACX,OAAO;CACP,OAAO,KAAK;AACd;AACO,IAAM,QAA4B;CACvC,IAAI;CACJ,OAAO,KAAK;CACZ,UAAU;CACV,iBAAiB;CACjB,QAAQ;CACR;CACA,YAAY;AACd;AACO,IAAM,WAAkC;CAC7C,QAAQ;CACR,UAAU,OAAO;CACjB;CACA,SAAS;CACT,aAAa;CACb,aAAa;AACf;AACO,SAAS,OACd,YAA2C,CAAC,GACtB;CACtB,OAAO;EACL,MAAM,YAAY,CAAC,KAAK;EACxB,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,SAAS,YAAY,CAAC;EACtB,SAAS,YAAY;EACrB,GAAG;CACL;AACF;;;AClEA,IAAA,qBAAe;CACb,aAAa;CACb,aAAa;CACb,aAAa;CACb,SAAS;EACP;GACE,IAAI;GACJ,OAAO;GACP,aACE;GACF,qBACE,OAAO,+BAAuB,CAAE,MAAM,MAAM,EAAE,OAAO;GACvD,OAAO,EAAE,QAAQ,OAAO,EAAE;GAC1B,OAAO;EACT;EACA;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,qBACE,OAAO,+BAAuB,CAAE,MAAM,MAAM,EAAE,OAAO;GACvD,OAAO;IAAE,IAAI,MAAM;IAAI,QAAQ,OAAO;IAAG,QAAQ;GAAQ;GACzD,OAAO;EACT;EACA;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,qBACE,OAAO,qCAA6B,CAAE,MAAM,MAAM,EAAE,OAAO;GAC7D,OAAO;IAAE;IAAU,SAAS,YAAY;GAAM;GAC9C,OAAO;EACT;EACA;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,qBACE,OAAO,+BAAuB,CAAE,MAAM,MAAM,EAAE,OAAO;GACvD,OAAO;IACL,QAAQ,OAAO;IACf,UAAU,MAAM;IAChB,SAAS;IACT,WAAW;IACX,gBAAgB,CAAC;GACnB;GACA,OAAO;EACT;EACA;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,qBACE,OAAO,sCAA8B,CAAE,MAAM,MAAM,EAAE,OAAO;GAC9D,OAAO,EAAE,iBAAiB,MAAM;GAChC,OAAO;EACT;EACA;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,qBACE,OAAO,+BAAuB,CAAE,MAAM,MAAM,EAAE,OAAO;GACvD,OAAO,EAAE,QAAQ;IAAE,GAAG;IAAQ,MAAM,CAAC;IAAG,UAAU;GAAE,EAAE;GACtD,OAAO;EACT;CACF;AACF"}
|
package/dist/recipes.d.ts
CHANGED
|
@@ -38,8 +38,29 @@ export declare class RuntimeReportsRecipe extends SmrtRecipe {
|
|
|
38
38
|
label: string;
|
|
39
39
|
model: typeof RuntimeReport;
|
|
40
40
|
icon: string;
|
|
41
|
+
noun: string;
|
|
42
|
+
description: string;
|
|
41
43
|
}[];
|
|
42
44
|
static surfaces: readonly [{
|
|
45
|
+
readonly kind: "widget";
|
|
46
|
+
readonly type: "saved-reports";
|
|
47
|
+
readonly export: "@happyvertical/smrt-reports/svelte#SavedReportsWidget";
|
|
48
|
+
readonly label: "Saved reports";
|
|
49
|
+
readonly description: "Your team’s saved reports with their latest figures.";
|
|
50
|
+
readonly icon: "fileText";
|
|
51
|
+
readonly options: readonly [{
|
|
52
|
+
readonly key: "limit";
|
|
53
|
+
readonly type: "integer";
|
|
54
|
+
readonly label: "Reports shown";
|
|
55
|
+
readonly min: 1;
|
|
56
|
+
readonly max: 24;
|
|
57
|
+
readonly default: 6;
|
|
58
|
+
}];
|
|
59
|
+
readonly sectionDefault: true;
|
|
60
|
+
readonly defaultSpan: 4;
|
|
61
|
+
readonly minSpan: 2;
|
|
62
|
+
readonly maxSpan: 4;
|
|
63
|
+
}, {
|
|
43
64
|
readonly kind: "route";
|
|
44
65
|
readonly path: "/reports";
|
|
45
66
|
readonly export: "@happyvertical/smrt-reports/svelte#RuntimeReportsRoute";
|
package/dist/recipes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipes.d.ts","sourceRoot":"","sources":["../src/recipes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,8BAA8B,EAE/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,8EAA8E;AAC9E,qBAAa,yBAA0B,SAAQ,UAAU;IACvD,MAAM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K,SAAa;IACzB,MAAM,CAAC,QAAQ,WAOb;IACF,MAAM,CAAC,OAAO,SAC8D;IAC5E,MAAM,CAAC,IAAI,SAAyB;IACpC,MAAM,CAAC,MAAM,2BAAmB;IAEhC,MAAM,CAAC,GAAG;;;;;;QAQR;IACF,MAAM,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DJ;IACX,MAAM,CAAC,OAAO,EAAG,QAAQ,CAAU;CACpC"}
|
|
@@ -24,8 +24,10 @@
|
|
|
24
24
|
* cross-tenant option.
|
|
25
25
|
*/
|
|
26
26
|
import type { DatabaseInterface, SqlAdapterType } from '@happyvertical/sql';
|
|
27
|
-
import { type
|
|
27
|
+
import { type RuntimeReportColumn, type RuntimeReportResult, type RuntimeReportSourceDescription } from './runtime-plan.js';
|
|
28
|
+
import { type RuntimeReportSpec } from './runtime-spec.js';
|
|
28
29
|
import type { AggregateSpec } from './types.js';
|
|
30
|
+
export type { RuntimeReportColumn, RuntimeReportColumnType, RuntimeReportResult, RuntimeReportSourceDescription, } from './runtime-plan.js';
|
|
29
31
|
/** A server-owned report source. The spec refers to it only by `id`. */
|
|
30
32
|
export interface RuntimeReportSourceDefinition {
|
|
31
33
|
/** Opaque id the spec names; defaults to nothing, always explicit. */
|
|
@@ -44,6 +46,10 @@ export interface RuntimeReportSourceDefinition {
|
|
|
44
46
|
fields?: readonly string[];
|
|
45
47
|
/** Canonical public field names to remove; exclusions always win. */
|
|
46
48
|
excludeFields?: readonly string[];
|
|
49
|
+
/** The natural date "by month" buckets (an invoice's issue date); derived when omitted. */
|
|
50
|
+
timeField?: string;
|
|
51
|
+
/** Fields worth grouping by, most useful first; derived when omitted. */
|
|
52
|
+
dimensions?: readonly string[];
|
|
47
53
|
}
|
|
48
54
|
export interface RuntimeReportCompileContext {
|
|
49
55
|
/** Server-owned allow-list. A spec can reach nothing outside it. */
|
|
@@ -61,19 +67,6 @@ export interface RuntimeReportCompileContext {
|
|
|
61
67
|
/** Host authorization for reading the source (for example RBAC `read`). */
|
|
62
68
|
authorizeSource?: (source: RuntimeReportSourceDefinition) => void | Promise<void>;
|
|
63
69
|
}
|
|
64
|
-
export type RuntimeReportColumnType = 'string' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'id';
|
|
65
|
-
export interface RuntimeReportColumn {
|
|
66
|
-
id: string;
|
|
67
|
-
label: string;
|
|
68
|
-
role: 'dimension' | 'measure';
|
|
69
|
-
type: RuntimeReportColumnType;
|
|
70
|
-
/** Source field this column derives from (absent for a row count). */
|
|
71
|
-
field?: string;
|
|
72
|
-
fn?: string;
|
|
73
|
-
bucket?: string;
|
|
74
|
-
/** Field format hint carried from the model (for example `money`). */
|
|
75
|
-
format?: string;
|
|
76
|
-
}
|
|
77
70
|
export interface CompiledRuntimeReport {
|
|
78
71
|
version: 1;
|
|
79
72
|
specHash: string;
|
|
@@ -93,32 +86,6 @@ export interface CompiledRuntimeReport {
|
|
|
93
86
|
tenantId: string | null;
|
|
94
87
|
};
|
|
95
88
|
}
|
|
96
|
-
export interface RuntimeReportResult {
|
|
97
|
-
version: 1;
|
|
98
|
-
specHash: string;
|
|
99
|
-
title: string;
|
|
100
|
-
columns: RuntimeReportColumn[];
|
|
101
|
-
rows: Record<string, string | number | boolean | null>[];
|
|
102
|
-
rowCount: number;
|
|
103
|
-
/** True when more rows existed than the spec/host limit. */
|
|
104
|
-
truncated: boolean;
|
|
105
|
-
ranAt: string;
|
|
106
|
-
chart: RuntimeReportChart;
|
|
107
|
-
}
|
|
108
|
-
export interface RuntimeReportSourceDescription {
|
|
109
|
-
id: string;
|
|
110
|
-
label: string;
|
|
111
|
-
description?: string;
|
|
112
|
-
/** Fields the live principal may group by, filter on or aggregate. */
|
|
113
|
-
fields: {
|
|
114
|
-
name: string;
|
|
115
|
-
label: string;
|
|
116
|
-
type: RuntimeReportColumnType;
|
|
117
|
-
format?: string;
|
|
118
|
-
filterOperators: readonly string[];
|
|
119
|
-
aggregates: readonly string[];
|
|
120
|
-
}[];
|
|
121
|
-
}
|
|
122
89
|
/**
|
|
123
90
|
* Describe what a spec may reference on one source for the live principal:
|
|
124
91
|
* exactly the field set the compiler would admit, so a model never has to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-compiler.d.ts","sourceRoot":"","sources":["../src/runtime-compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-compiler.d.ts","sourceRoot":"","sources":["../src/runtime-compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAI5E,OAAO,EAML,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EAGpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAuB,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B,wEAAwE;AACxE,MAAM,WAAW,6BAA6B;IAC5C,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,qEAAqE;IACrE,aAAa,CAAC,EAAE,SAA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AW,uBAAuB;IACtC,EAAE,EAAE,iBAAiB,CAAC;IACtB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CAsC9B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouping and time hints for a report source (#4100): which fields read as a
|
|
3
|
+
* time axis, which one is the source's natural date, and which are worth
|
|
4
|
+
* grouping by, most useful first.
|
|
5
|
+
*
|
|
6
|
+
* Both runners' source descriptions (`describeRuntimeReportSource()`,
|
|
7
|
+
* `describeRuntimeReportMemorySource()`) carry these, so an assistant or a
|
|
8
|
+
* report builder offers "Issue date by month", "Status" and "Customer", never
|
|
9
|
+
* an id, a hash or internal bookkeeping. A source definition may declare them
|
|
10
|
+
* (`timeField`, `dimensions`); otherwise they are derived from field metadata
|
|
11
|
+
* in this order:
|
|
12
|
+
*
|
|
13
|
+
* - time fields: every datetime field except a soft-delete stamp;
|
|
14
|
+
* - the natural date: a business date (`@field({ ui: { format: 'date' } })`),
|
|
15
|
+
* else the first datetime that is not bookkeeping (`createdAt`, `updatedAt`,
|
|
16
|
+
* `syncedAt`, `last…At`), else `createdAt`;
|
|
17
|
+
* - groupings: closed text fields (declared `enum`) and booleans as
|
|
18
|
+
* categories, foreign keys as relations; never `id`, free text, or a field
|
|
19
|
+
* whose name marks it internal (`…Hash`, `…Json`, `…Token`, `…Authority`,
|
|
20
|
+
* `…Snapshot`, `external…`, `historical…`), ranked status, then kind/type,
|
|
21
|
+
* then people and things (customer, vendor, product), then other categories,
|
|
22
|
+
* other relations, then flags.
|
|
23
|
+
*
|
|
24
|
+
* These are hints for choosing, not authority: a spec may still group by any
|
|
25
|
+
* field the source exposes, and the compiler's field policy is unchanged.
|
|
26
|
+
* Browser-safe: no Node built-ins, no registry.
|
|
27
|
+
*/
|
|
28
|
+
import type { RuntimeReportDimensionHints, RuntimeReportDimensionKind, RuntimeReportPlanField, RuntimeReportSourceDescription } from './runtime-plan.js';
|
|
29
|
+
export interface RuntimeReportDimensionPlan {
|
|
30
|
+
kinds: Map<string, RuntimeReportDimensionKind>;
|
|
31
|
+
timeFields: string[];
|
|
32
|
+
defaultTimeField?: string;
|
|
33
|
+
dimensions: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Plan the time and grouping hints for resolved fields. Declared hints that
|
|
37
|
+
* name a field this principal cannot see are dropped (the field set already
|
|
38
|
+
* hides it), never reported.
|
|
39
|
+
*/
|
|
40
|
+
export declare function planRuntimeReportDimensions(fields: ReadonlyMap<string, RuntimeReportPlanField>, hints?: RuntimeReportDimensionHints): RuntimeReportDimensionPlan;
|
|
41
|
+
/** The described fields and grouping hints of a source with these fields. */
|
|
42
|
+
export declare function describeRuntimeReportSourceFields(fields: ReadonlyMap<string, RuntimeReportPlanField>, hints?: RuntimeReportDimensionHints): Pick<RuntimeReportSourceDescription, 'fields' | 'timeFields' | 'defaultTimeField' | 'dimensions'>;
|
|
43
|
+
//# sourceMappingURL=runtime-dimensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-dimensions.d.ts","sourceRoot":"","sources":["../src/runtime-dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,mBAAmB,CAAC;AAgD3B,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACnD,KAAK,GAAE,2BAAgC,GACtC,0BAA0B,CAyD5B;AAED,6EAA6E;AAC7E,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACnD,KAAK,GAAE,2BAAgC,GACtC,IAAI,CACL,8BAA8B,EAC9B,QAAQ,GAAG,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAC5D,CAsBA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database-free runtime report runner (#4100).
|
|
3
|
+
*
|
|
4
|
+
* `runRuntimeReportInMemory()` evaluates a parsed `RuntimeReportSpec` over
|
|
5
|
+
* rows the caller already holds and returns the same `RuntimeReportResult`
|
|
6
|
+
* shape `runRuntimeReport()` returns. It shares the column, operator, value
|
|
7
|
+
* coercion and cell rules with the SQL compiler (`runtime-plan.ts`), and its
|
|
8
|
+
* SQL-shaped semantics (NULL handling, grouping, buckets, HAVING, ordering,
|
|
9
|
+
* truncation) are held to the SQL path by `runtime-memory-parity.test.ts`.
|
|
10
|
+
*
|
|
11
|
+
* It is a BROWSER PREVIEW AND TEST RUNNER, NOT AN AUTHORITY BOUNDARY. Its
|
|
12
|
+
* source descriptions are caller-supplied and carry no registry field policy,
|
|
13
|
+
* principal, RBAC or tenant: whoever hands it rows has already decided the
|
|
14
|
+
* caller may see them. Production reports still compile on the server
|
|
15
|
+
* (`compileRuntimeReportSpec()` with the live principal) and save only through
|
|
16
|
+
* `saveRuntimeReport()`.
|
|
17
|
+
*/
|
|
18
|
+
import { type RuntimeReportColumnType, type RuntimeReportResult, type RuntimeReportSourceDescription } from './runtime-plan.js';
|
|
19
|
+
import { type RuntimeReportSpec } from './runtime-spec.js';
|
|
20
|
+
/** One declared field of an in-memory source; rows are keyed by `name`. */
|
|
21
|
+
export interface RuntimeReportMemoryField {
|
|
22
|
+
name: string;
|
|
23
|
+
type: RuntimeReportColumnType;
|
|
24
|
+
label?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Format hint carried onto result columns (`money`), as `@field({ ui:
|
|
27
|
+
* { format } })` declares it; `date` on a datetime marks a business date.
|
|
28
|
+
*/
|
|
29
|
+
format?: string;
|
|
30
|
+
/** Declared values of a closed text field (a status). */
|
|
31
|
+
enum?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* An in-memory report source: the browser counterpart of a server
|
|
35
|
+
* `RuntimeReportSourceDefinition`. `schema` declares the fields the rows
|
|
36
|
+
* carry; `fields` / `excludeFields` narrow them exactly as on the server
|
|
37
|
+
* (omitted `fields` keeps every declared field, exclusions win, unknown names
|
|
38
|
+
* reject the source). Names starting with `_` and `tenantId` are never
|
|
39
|
+
* nameable. A declared `deletedAt` field soft-deletes rows where it is set.
|
|
40
|
+
*/
|
|
41
|
+
export interface RuntimeReportMemorySource {
|
|
42
|
+
id: string;
|
|
43
|
+
label?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
schema: readonly RuntimeReportMemoryField[];
|
|
46
|
+
fields?: readonly string[];
|
|
47
|
+
excludeFields?: readonly string[];
|
|
48
|
+
/** The natural date "by month" buckets; derived when omitted. */
|
|
49
|
+
timeField?: string;
|
|
50
|
+
/** Fields worth grouping by, most useful first; derived when omitted. */
|
|
51
|
+
dimensions?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export type RuntimeReportMemoryRow = Readonly<Record<string, unknown>>;
|
|
54
|
+
export interface RunRuntimeReportInMemoryOptions {
|
|
55
|
+
/** Caller-owned allow-list; the spec reaches nothing outside it. */
|
|
56
|
+
sources: readonly RuntimeReportMemorySource[];
|
|
57
|
+
/** Host row ceiling applied on top of the spec's own limit. */
|
|
58
|
+
maxRows?: number;
|
|
59
|
+
/** Clock for `ranAt`; pass a fixed one for deterministic previews. */
|
|
60
|
+
now?: () => Date;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Describe what a spec may reference on an in-memory source: the browser
|
|
64
|
+
* counterpart of `describeRuntimeReportSource()` (`reports.runtime.sources`).
|
|
65
|
+
*/
|
|
66
|
+
export declare function describeRuntimeReportMemorySource(sources: readonly RuntimeReportMemorySource[], sourceId: string): RuntimeReportSourceDescription;
|
|
67
|
+
/**
|
|
68
|
+
* Evaluate a runtime report spec over in-memory rows of its source.
|
|
69
|
+
*
|
|
70
|
+
* Validation matches the server compiler: an unknown source, a field outside
|
|
71
|
+
* the source's allow-list, a bucket on a non-datetime field, `sum` on text, an
|
|
72
|
+
* operator the field type does not admit or an uncoercible filter value all
|
|
73
|
+
* throw the same `RuntimeReportError` codes and paths. Result datetimes
|
|
74
|
+
* (buckets, datetime dimensions, `min`/`max`) are ISO-8601 UTC strings, the
|
|
75
|
+
* form PostgreSQL and DuckDB results take; SQLite returns bucket TEXT.
|
|
76
|
+
*
|
|
77
|
+
* `rows` are the rows of `spec.source`; the caller picks them. A browser
|
|
78
|
+
* preview, never an authority boundary (see the module comment).
|
|
79
|
+
*/
|
|
80
|
+
export declare function runRuntimeReportInMemory(input: RuntimeReportSpec, rows: readonly RuntimeReportMemoryRow[], options: RunRuntimeReportInMemoryOptions): Promise<RuntimeReportResult>;
|
|
81
|
+
//# sourceMappingURL=runtime-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-memory.d.ts","sourceRoot":"","sources":["../src/runtime-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAOL,KAAK,uBAAuB,EAE5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EAGpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAOL,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAE3B,2EAA2E;AAC3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CAAC,CAiI9B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime report planning rules shared by the SQL compiler and the in-memory
|
|
3
|
+
* runner (#3711, #4100).
|
|
4
|
+
*
|
|
5
|
+
* Everything here is a pure function of a parsed spec and a resolved field
|
|
6
|
+
* set: which operators and aggregates a field type admits, how filter values
|
|
7
|
+
* are coerced, how result columns are described and how cells are normalized.
|
|
8
|
+
* `compileRuntimeReportSpec()` (server, ObjectRegistry + SQL) and
|
|
9
|
+
* `runRuntimeReportInMemory()` (browser-safe) both call these, so the two
|
|
10
|
+
* paths cannot disagree about what a spec means. Browser-safe: no Node
|
|
11
|
+
* built-ins, no registry.
|
|
12
|
+
*/
|
|
13
|
+
import { type RuntimeReportChart, type RuntimeReportFilter, type RuntimeReportSpec } from './runtime-spec.js';
|
|
14
|
+
export type RuntimeReportColumnType = 'string' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'id';
|
|
15
|
+
export interface RuntimeReportColumn {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
role: 'dimension' | 'measure';
|
|
19
|
+
type: RuntimeReportColumnType;
|
|
20
|
+
/** Source field this column derives from (absent for a row count). */
|
|
21
|
+
field?: string;
|
|
22
|
+
fn?: string;
|
|
23
|
+
bucket?: string;
|
|
24
|
+
/** Field format hint carried from the model (for example `money`). */
|
|
25
|
+
format?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RuntimeReportResult {
|
|
28
|
+
version: 1;
|
|
29
|
+
specHash: string;
|
|
30
|
+
title: string;
|
|
31
|
+
columns: RuntimeReportColumn[];
|
|
32
|
+
rows: Record<string, string | number | boolean | null>[];
|
|
33
|
+
rowCount: number;
|
|
34
|
+
/** True when more rows existed than the spec/host limit. */
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
ranAt: string;
|
|
37
|
+
chart: RuntimeReportChart;
|
|
38
|
+
}
|
|
39
|
+
export interface RuntimeReportSourceDescription {
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
/** Fields the live principal may group by, filter on or aggregate. */
|
|
44
|
+
fields: {
|
|
45
|
+
name: string;
|
|
46
|
+
label: string;
|
|
47
|
+
type: RuntimeReportColumnType;
|
|
48
|
+
format?: string;
|
|
49
|
+
/** Declared values of a closed text field (a status, a kind). */
|
|
50
|
+
enum?: readonly string[];
|
|
51
|
+
/**
|
|
52
|
+
* How the field reads as a grouping, when it is a useful one: a time axis
|
|
53
|
+
* (bucket it), a category (a status, a kind, a flag) or a relation (a
|
|
54
|
+
* customer). Absent: not offered as a grouping (ids, free text, hashes,
|
|
55
|
+
* internal bookkeeping), though a spec may still name it.
|
|
56
|
+
*/
|
|
57
|
+
dimension?: RuntimeReportDimensionKind;
|
|
58
|
+
filterOperators: readonly string[];
|
|
59
|
+
aggregates: readonly string[];
|
|
60
|
+
}[];
|
|
61
|
+
/** Datetime fields a report can bucket or filter by period, default first. */
|
|
62
|
+
timeFields: string[];
|
|
63
|
+
/** The source's natural date (an invoice's issue date): what "by month" buckets. */
|
|
64
|
+
defaultTimeField?: string;
|
|
65
|
+
/** Category and relation fields worth grouping by, most useful first. */
|
|
66
|
+
dimensions: string[];
|
|
67
|
+
}
|
|
68
|
+
/** How a field reads as a grouping; see `RuntimeReportSourceDescription`. */
|
|
69
|
+
export type RuntimeReportDimensionKind = 'time' | 'category' | 'relation';
|
|
70
|
+
/**
|
|
71
|
+
* Grouping hints a source definition may declare (#4100). `timeField` names
|
|
72
|
+
* the natural date; `dimensions` lists, in order, the fields worth grouping
|
|
73
|
+
* by. Both use canonical public names; unknown names reject the source.
|
|
74
|
+
* Omitted, both are derived from field metadata (`runtime-dimensions.ts`).
|
|
75
|
+
*/
|
|
76
|
+
export interface RuntimeReportDimensionHints {
|
|
77
|
+
timeField?: string;
|
|
78
|
+
dimensions?: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
/** A nameable source field after every exposure rule has been applied. */
|
|
81
|
+
export interface RuntimeReportPlanField {
|
|
82
|
+
name: string;
|
|
83
|
+
type: RuntimeReportColumnType;
|
|
84
|
+
format?: string;
|
|
85
|
+
label: string;
|
|
86
|
+
/** Declared values of a closed text field. */
|
|
87
|
+
enum?: readonly string[];
|
|
88
|
+
/** `@field({ ui: { format: 'date' } })`: a business date, not a timestamp. */
|
|
89
|
+
businessDate?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export declare function humanizeRuntimeReportName(name: string): string;
|
|
92
|
+
export declare function unknownRuntimeReportField(path: string, name: string): never;
|
|
93
|
+
export declare const RUNTIME_REPORT_OPERATORS_BY_TYPE: Readonly<Record<RuntimeReportColumnType, readonly RuntimeReportFilter['op'][]>>;
|
|
94
|
+
export declare function runtimeReportAggregatesFor(type: RuntimeReportColumnType): readonly string[];
|
|
95
|
+
/** Reject an operator the field's type does not admit. */
|
|
96
|
+
export declare function assertRuntimeReportFilterOperator(filter: RuntimeReportFilter, type: RuntimeReportColumnType, path: string): void;
|
|
97
|
+
/** Coerce one filter value to the field's type (ids lower-cased, datetimes to `Date`). */
|
|
98
|
+
export declare function coerceRuntimeReportValue(type: RuntimeReportColumnType, value: unknown, path: string): string | number | boolean | Date;
|
|
99
|
+
/**
|
|
100
|
+
* Resolve a source's `fields` allow-list and `excludeFields` deny-list against
|
|
101
|
+
* the canonical names it declares. Unknown or malformed names reject the whole
|
|
102
|
+
* source (`unsupported_source`), misspelled exclusions included.
|
|
103
|
+
*/
|
|
104
|
+
export declare function resolveRuntimeReportFieldPolicy(source: {
|
|
105
|
+
fields?: readonly string[];
|
|
106
|
+
excludeFields?: readonly string[];
|
|
107
|
+
timeField?: string;
|
|
108
|
+
dimensions?: readonly string[];
|
|
109
|
+
}, knownNames: ReadonlySet<string>): {
|
|
110
|
+
included?: Set<string>;
|
|
111
|
+
excluded?: Set<string>;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Validate the spec's dimensions and measures against the resolved fields and
|
|
115
|
+
* describe the result columns, dimensions first. Filters are validated by the
|
|
116
|
+
* caller, after this, so error order matches across both runners.
|
|
117
|
+
*/
|
|
118
|
+
export declare function planRuntimeReportColumns(spec: RuntimeReportSpec, fields: ReadonlyMap<string, RuntimeReportPlanField>): RuntimeReportColumn[];
|
|
119
|
+
/** Normalize one result cell to the wire shape (safe integers, ISO datetimes). */
|
|
120
|
+
export declare function normalizeRuntimeReportCell(column: RuntimeReportColumn, value: unknown): string | number | boolean | null;
|
|
121
|
+
//# sourceMappingURL=runtime-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-plan.d.ts","sourceRoot":"","sources":["../src/runtime-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,GACV,IAAI,CAAC;AAET,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,I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IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAClD,mBAAmB,EAAE,CAkEvB;AAED,kFAAkF;AAClF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,OAAO,GACb,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAgDlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-report.d.ts","sourceRoot":"","sources":["../src/runtime-report.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,cAAc,EACd,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAGL,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"runtime-report.d.ts","sourceRoot":"","sources":["../src/runtime-report.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,cAAc,EACd,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAYxD,qBAuCa,aAA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E,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE,OAAO,CAAC;IACT,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CA0DD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side stable hash of a normalized runtime report spec (#3711, #4100).
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `runtime-spec.ts` because it needs `node:crypto`: the
|
|
5
|
+
* grammar itself is browser-safe and ships on the `./spec` subpath. Browsers
|
|
6
|
+
* use `runtimeReportSpecDigest()` (Web Crypto), which yields the same hex.
|
|
7
|
+
*/
|
|
8
|
+
import { type RuntimeReportSpec } from './runtime-spec.js';
|
|
9
|
+
/** Stable fingerprint of a NORMALIZED spec; equal specs hash equally. */
|
|
10
|
+
export declare function runtimeReportSpecHash(spec: RuntimeReportSpec): string;
|
|
11
|
+
//# sourceMappingURL=runtime-spec-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-spec-hash.d.ts","sourceRoot":"","sources":["../src/runtime-spec-hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAE3B,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAIrE"}
|
package/dist/runtime-spec.d.ts
CHANGED
|
@@ -12,8 +12,13 @@
|
|
|
12
12
|
* The parser accepts no authority. Nothing in a spec names a tenant, a
|
|
13
13
|
* principal, a permission, a table, a column alias that is not a plain
|
|
14
14
|
* identifier, or an SQL fragment.
|
|
15
|
+
*
|
|
16
|
+
* Browser-safe (#4100): this module imports no Node built-in and, of
|
|
17
|
+
* smrt-core, only the import-free `SmrtError` subpath (never the root entry),
|
|
18
|
+
* so the grammar ships on the `./spec` subpath. The `node:crypto` hash lives in
|
|
19
|
+
* `runtime-spec-hash.ts`, which only server modules import.
|
|
15
20
|
*/
|
|
16
|
-
import { SmrtError } from '@happyvertical/smrt-core';
|
|
21
|
+
import { SmrtError } from '@happyvertical/smrt-core/smrt-error';
|
|
17
22
|
export declare const RUNTIME_REPORT_SPEC_VERSION: 1;
|
|
18
23
|
export declare const RUNTIME_REPORT_LIMITS: Readonly<{
|
|
19
24
|
maxTitleLength: 120;
|
|
@@ -120,8 +125,15 @@ export declare class RuntimeReportError extends SmrtError {
|
|
|
120
125
|
* depend on the registry and the live principal.
|
|
121
126
|
*/
|
|
122
127
|
export declare function parseRuntimeReportSpec(input: unknown): RuntimeReportSpec;
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Stable JSON text for storage (sorted keys). It is also the exact input of
|
|
130
|
+
* `runtimeReportSpecHash` (server) and `runtimeReportSpecDigest` (browser).
|
|
131
|
+
*/
|
|
126
132
|
export declare function serializeRuntimeReportSpec(spec: RuntimeReportSpec): string;
|
|
133
|
+
/**
|
|
134
|
+
* Browser-safe twin of the server's `runtimeReportSpecHash`: the same SHA-256
|
|
135
|
+
* hex over the same canonical JSON, computed with Web Crypto. Asynchronous
|
|
136
|
+
* because `crypto.subtle` is; it needs a secure context (https or localhost).
|
|
137
|
+
*/
|
|
138
|
+
export declare function runtimeReportSpecDigest(spec: RuntimeReportSpec): Promise<string>;
|
|
127
139
|
//# sourceMappingURL=runtime-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-spec.d.ts","sourceRoot":"","sources":["../src/runtime-spec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"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;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAYxE;AAwRD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAqKxE;AAcD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time language for runtime reports (#4100): "by month", "weekly", "over
|
|
3
|
+
* time", "last month", "this year", "last 90 days", "Q3".
|
|
4
|
+
*
|
|
5
|
+
* A person asks for reports in words; a spec needs a bucket and a `[from, to)`
|
|
6
|
+
* date range. These pure functions turn the words into those values against a
|
|
7
|
+
* caller-supplied `now`, so an assistant (smrt-chat, the planner) resolves
|
|
8
|
+
* time with code rather than asking a model to do date arithmetic. All dates
|
|
9
|
+
* are UTC, like the runners' buckets. Browser-safe.
|
|
10
|
+
*/
|
|
11
|
+
import type { RuntimeReportBucket } from './runtime-spec.js';
|
|
12
|
+
/** A resolved period: `[from, to)` as `YYYY-MM-DD`, and how to name it. */
|
|
13
|
+
export interface RuntimeReportTimeRange {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
/** Lower-case words for a title: "last month", "Q3 2025", "last 90 days". */
|
|
17
|
+
label: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RuntimeReportTimeIntent {
|
|
20
|
+
/** A time grouping the words ask for ("by month", "weekly", "over time"). */
|
|
21
|
+
bucket?: RuntimeReportBucket;
|
|
22
|
+
/** A period the words name ("last quarter", "Q3", "last 90 days"). */
|
|
23
|
+
range?: RuntimeReportTimeRange;
|
|
24
|
+
/** The words mention time at all (a grouping, a period or a trend). */
|
|
25
|
+
mentionsTime: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** The bucket "over time" means for a period of this many days. */
|
|
28
|
+
export declare function runtimeReportBucketForSpan(days: number | null): RuntimeReportBucket;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a period phrase against `now`. Null when the words name no period
|
|
31
|
+
* (or "all time"). A quarter or month named without a year is its latest
|
|
32
|
+
* occurrence that has started: in May, "Q3" is last year's.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveRuntimeReportTimeRange(phrase: string, now: Date): RuntimeReportTimeRange | null;
|
|
35
|
+
/**
|
|
36
|
+
* Read a request's time words: a grouping ("by month", "weekly"; "over time"
|
|
37
|
+
* picks one from the period's length), a period, and whether time came up at
|
|
38
|
+
* all ("the date month" mentions time without naming either).
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseRuntimeReportTime(text: string, now: Date): RuntimeReportTimeIntent;
|
|
41
|
+
//# sourceMappingURL=runtime-time.d.ts.map
|