dsh-data-quality 0.2.0 → 0.3.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.
@@ -7,6 +7,8 @@
7
7
 
8
8
  import { defineTool } from '@deepseek-ai/dsh-tools'
9
9
  import type { JsonValue } from '@deepseek-ai/dsh-session'
10
+ import type { ProfileReport } from '../profile.ts'
11
+ import { renderCleanHtml, renderProfileHtml, type CleanReportHtml } from '../report-html.ts'
10
12
  import type { DataQualityService } from '../service.ts'
11
13
  import type { ReportRecord, StoredReport } from '../store.ts'
12
14
 
@@ -27,6 +29,19 @@ interface DataReportValue {
27
29
  readonly key?: string
28
30
  readonly kind?: ReportRecord['kind']
29
31
  readonly records: ReportView[]
32
+ /** Self-contained offline HTML (present only when `format: html`). */
33
+ readonly html?: string
34
+ }
35
+
36
+ /** Render one stored report as a self-contained HTML document (profile/clean only). */
37
+ function renderRecordHtml(record: StoredReport): string {
38
+ if (record.kind === 'profile') {
39
+ return renderProfileHtml(record.report as unknown as ProfileReport)
40
+ }
41
+ if (record.kind === 'clean' || record.kind === 'clean-diff') {
42
+ return renderCleanHtml(record.report as unknown as CleanReportHtml, record.dataset)
43
+ }
44
+ throw new Error(`data_report html format does not support kind "${record.kind}" (profile/clean only)`)
30
45
  }
31
46
 
32
47
  /** Project a stored report into the canonical value (the stored report is already lossless JSON). */
@@ -64,6 +79,7 @@ export function defineReportTool(service: DataQualityService) {
64
79
  parameters: {
65
80
  key: { type: 'string', description: 'Exact storage reportKey (e.g. 20260819000000000-profile-1a2b3c4d); fetches that one report.' },
66
81
  kind: { type: 'string', enum: [...REPORT_KINDS], description: 'Report kind to list (profile/clean/clean-diff/verify/citations).' },
82
+ format: { type: 'string', enum: ['json', 'html'], description: 'Output format. json (default) returns the report envelope(s); html renders one report as a self-contained offline HTML document (requires key; profile/clean only).' },
67
83
  },
68
84
  output: {
69
85
  schema: {
@@ -86,10 +102,15 @@ export function defineReportTool(service: DataQualityService) {
86
102
  },
87
103
  required: true,
88
104
  },
105
+ html: { type: 'string', description: 'Self-contained offline HTML (present only when format: html).' },
89
106
  },
90
107
  additionalProperties: false,
91
108
  },
92
- render: (_args, value) => [{ type: 'text', text: renderReportText(value as unknown as DataReportValue) }],
109
+ render: (_args, value) => {
110
+ const view = value as unknown as DataReportValue
111
+ if (view.html !== undefined) return [{ type: 'text', text: view.html }]
112
+ return [{ type: 'text', text: renderReportText(view) }]
113
+ },
93
114
  },
94
115
  async execute(args, _exec): Promise<DataReportValue> {
95
116
  const hasKey = args.key !== undefined
@@ -97,9 +118,17 @@ export function defineReportTool(service: DataQualityService) {
97
118
  if (hasKey === hasKind) {
98
119
  throw new Error('data_report needs exactly one of key/kind')
99
120
  }
121
+ const format = (args.format ?? 'json') as 'json' | 'html'
100
122
  if (hasKey) {
101
123
  const record = await service.getReport(args.key as string)
102
- return { key: args.key as string, records: [toView(record)] }
124
+ return {
125
+ key: args.key as string,
126
+ records: [toView(record)],
127
+ ...(format === 'html' ? { html: renderRecordHtml(record) } : {}),
128
+ }
129
+ }
130
+ if (format === 'html') {
131
+ throw new Error('data_report html format requires key (exactly one report)')
103
132
  }
104
133
  const records = await service.listReports(args.kind as ReportRecord['kind'])
105
134
  return { kind: args.kind as ReportRecord['kind'], records: records.map(toView) }
package/src/version.ts CHANGED
@@ -5,4 +5,12 @@
5
5
  */
6
6
 
7
7
  /** The package version reported in persisted reports. */
8
- export const VERSION = '0.2.0'
8
+ export const VERSION = '0.3.0'
9
+
10
+ /**
11
+ * Version of the persisted report schema. Bump it whenever a report's
12
+ * canonical shape changes in a way old consumers cannot read (the durable
13
+ * `data_quality` records keep their own `schemaVersion` so a future reader
14
+ * can detect and reject an incompatible record instead of misreading it).
15
+ */
16
+ export const REPORT_SCHEMA_VERSION = 1