@happyvertical/smrt-reports 0.51.31 → 0.51.33

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/index.d.ts CHANGED
@@ -1,1276 +1,16 @@
1
- import { AggregateBuildResult } from '@happyvertical/sql';
2
- import { AggregateFunction } from '@happyvertical/sql';
3
- import { AggregateSelectExpr } from '@happyvertical/sql';
4
- import { AggregateSpec } from '@happyvertical/sql';
5
- import { AggregateTimeBucketUnit } from '@happyvertical/sql';
6
- import { bucketExpr } from '@happyvertical/sql';
7
- import { buildAggregate } from '@happyvertical/sql';
8
- import { DatabaseInterface } from '@happyvertical/sql';
9
- import { DataQueryFieldDescriptor } from '@happyvertical/smrt-types';
10
- import { DataQueryFilter } from '@happyvertical/smrt-types';
11
- import { DataQueryFreshness } from '@happyvertical/smrt-types';
12
- import { DataQueryRequest } from '@happyvertical/smrt-types';
13
- import { DataQueryResult } from '@happyvertical/smrt-types';
14
- import { DataQuerySchema } from '@happyvertical/smrt-types';
15
- import { DataQuerySort } from '@happyvertical/smrt-types';
16
- import { DurableJobPayloadIntegrity } from '@happyvertical/smrt-jobs';
17
- import { DurableJobPayloadSigner } from '@happyvertical/smrt-jobs';
18
- import { EventEmitter } from 'node:events';
19
- import { JobExecutionContext } from '@happyvertical/smrt-jobs';
20
- import { SmrtCollection } from '@happyvertical/smrt-core';
21
- import { SmrtJob } from '@happyvertical/smrt-jobs';
22
- import { SmrtListOptions } from '@happyvertical/smrt-core';
23
- import { SmrtObject } from '@happyvertical/smrt-core';
24
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
25
- import { SmrtSelectedRow } from '@happyvertical/smrt-core';
26
- import { SmrtSelectField } from '@happyvertical/smrt-core';
27
- import { SmrtStiReadScope } from '@happyvertical/smrt-core';
28
- import { SqlAdapterType } from '@happyvertical/sql';
29
- import { WhereClause } from '@happyvertical/sql';
30
-
31
- export declare function aggregate(options: AggregateDecoratorOptions): PropertyDecorator;
32
-
33
- export { AggregateBuildResult }
34
-
35
- declare interface AggregateDecoratorOptions {
36
- fn: ReportAggregateFn;
37
- column?: string;
38
- distinct?: boolean;
39
- }
40
-
41
- export { AggregateSelectExpr }
42
-
43
- export { AggregateSpec }
44
-
45
- export declare type AppliedReportExport = {
46
- phase: 'apply';
47
- execution: 'stream';
48
- status: 'ready';
49
- request: ReportExportRequest;
50
- } | {
51
- phase: 'apply';
52
- execution: 'background';
53
- status: 'queued';
54
- taskId: string;
55
- request: ReportExportRequest;
56
- };
57
-
58
- export declare interface AppliedReportRefresh {
59
- phase: 'apply';
60
- job: ReportRefreshJobHandle;
61
- }
62
-
63
- /**
64
- * Queue large exports without embedding rows in a browser/agent response.
65
- * A host must verify current principal, tenant, report definition, and field
66
- * policy again before it renders or serves the artifact.
67
- */
68
- export declare function applyReportExport(descriptor: ReportAdapterDescriptor, request: ReportExportRequest, host: ReportExportActionHost, options?: {
69
- confirmed?: boolean;
70
- }): Promise<AppliedReportExport>;
71
-
72
- /** Queue a manual refresh only after the action host authorizes and audits it. */
73
- export declare function applyReportRefresh(reportCtor: ReportCtor, options: ApplyReportRefreshOptions): Promise<AppliedReportRefresh>;
74
-
75
- export declare interface ApplyReportRefreshOptions extends PreviewReportRefreshOptions {
76
- jobIntegritySigner?: DurableJobPayloadSigner;
77
- queue?: string;
78
- priority?: number;
79
- timeout?: number;
80
- maxAttempts?: number;
81
- tenantJobCap?: number;
82
- }
83
-
84
- export declare function assertReportTablesReady(db: DatabaseInterface, tables?: readonly string[]): Promise<void>;
85
-
86
- export declare const avg: (column?: string, options?: {
87
- distinct?: boolean;
88
- }) => PropertyDecorator;
89
-
90
- export { bucketExpr }
91
-
92
- export { buildAggregate }
93
-
94
- export declare function buildReportAdapterDescriptor(reportCtor: new (...args: any[]) => SmrtObject, options?: ReportAdapterOptions): Promise<ReportAdapterDescriptor>;
95
-
96
- export declare function buildReportDefinition(reportCtor: new (...args: any[]) => SmrtObject): Promise<ReportDefinition>;
97
-
98
- /**
99
- * Bind a materialized report row to its declared source dimensions. This is a
100
- * query handoff, not an executor: an authenticated source adapter must apply
101
- * the inherited principal, tenant, definition, and field policy before it
102
- * reads source records.
103
- */
104
- export declare function buildReportDrilldownQuery(reportCtor: new (...args: any[]) => SmrtObject, row: Readonly<Record<string, unknown>>, options?: ReportAdapterOptions): Promise<ReportDrilldownQuery>;
105
-
106
- export declare function compileReportDefinition(definition: ReportDefinition): AggregateSpec;
107
-
108
- export declare function compileReportSpec(reportCtor: new (...args: any[]) => SmrtObject): Promise<AggregateSpec>;
109
-
110
- export declare function count(): PropertyDecorator;
111
-
112
- export declare function count(column: string, options?: {
113
- distinct?: boolean;
114
- }): PropertyDecorator;
115
-
116
- export declare function count(options: {
117
- distinct?: boolean;
118
- }): PropertyDecorator;
119
-
120
- /**
121
- * Build one bounded page of the immutable export read. The host applies the
122
- * opaque snapshot binding separately; this function preserves the frozen
123
- * projection, predicate, and deterministic sort while replacing only visible
124
- * pagination. A zero-row export therefore has no pages to execute.
125
- */
126
- export declare function createReportExportPageRequest(descriptor: ReportAdapterDescriptor, request: ReportExportRequest, offset: number): DataQueryRequest;
127
-
128
- /**
129
- * Build one common request for both agent and human export clients. The
130
- * resulting request carries no actor, tenant, storage location, or token.
131
- */
132
- export declare function createReportExportRequest(descriptor: ReportAdapterDescriptor, snapshot: ReportExportSnapshot, value: unknown): ReportExportRequest;
133
-
134
- /**
135
- * Freeze a previously executed materialized read for export. The caller must
136
- * supply the exact request and a result that exposes lifecycle freshness; an
137
- * export never invents an as-of value or accepts a caller-supplied tenant.
138
- */
139
- export declare function createReportExportSnapshot(descriptor: ReportAdapterDescriptor, input: unknown, result: Pick<DataQueryResult, 'queryFingerprint' | 'identityField' | 'total' | 'freshness' | 'truncated'> & Pick<ReportDataQueryResult, 'reportLifecycle'>, binding: unknown): ReportExportSnapshot;
140
-
141
- export declare const day: (sourceColumn: string) => PropertyDecorator;
142
-
143
- export declare function enqueueReportRefresh(options: EnqueueReportRefreshOptions): Promise<SmrtJob>;
144
-
145
- export declare interface EnqueueReportRefreshOptions extends ReportRefreshJobArgs {
146
- report?: ReportCtor_3;
147
- reportClass: string;
148
- db: DatabaseInterface;
149
- queue?: string;
150
- priority?: number;
151
- timeout?: number;
152
- maxAttempts?: number;
153
- tenantJobCap?: number;
154
- /** Server-only signer; register the same key in every worker process. */
155
- integritySigner?: DurableJobPayloadSigner;
156
- }
157
-
158
- export declare function ensureReportRefreshSchedules(options: EnsureReportSchedulesOptions): Promise<void>;
159
-
160
- export declare interface EnsureReportSchedulesOptions {
161
- db: DatabaseInterface;
162
- reports: ReportCtor_3[];
163
- tenantIds?: string[];
164
- queue?: string;
165
- priority?: number;
166
- timeout?: number;
167
- }
168
-
169
- export declare function getReportGroupingColumns(definition: Pick<ReportDefinition, 'fields'>): string[];
170
-
171
- /**
172
- * Read only the ambient tenant's report state. The caller cannot supply a
173
- * tenant selector, which prevents lifecycle lookup from becoming a tenant
174
- * enumeration surface.
175
- */
176
- export declare function getReportLifecycle(reportCtor: ReportCtor, options: ReportLifecycleOptions): Promise<ReportLifecycleSnapshot>;
177
-
178
- export declare function getRuntimeReportOptions(ctor: Function): ReportOptions | undefined;
179
-
180
- export declare function groupBy(sourceColumn?: string): PropertyDecorator;
181
-
182
- export declare const hour: (sourceColumn: string) => PropertyDecorator;
183
-
184
- declare const INHERITED_REPORT_SCOPE: readonly ["principal", "tenant", "report-definition", "field-policy"];
185
-
186
- export declare const max: (column?: string, options?: {
187
- distinct?: boolean;
188
- }) => PropertyDecorator;
189
-
190
- /**
191
- * Version 0 is the original unversioned persisted layout shape. It contains
192
- * the same allowlisted fields as v1, so the migration only records the schema
193
- * version; current descriptor normalization still revalidates every field.
194
- */
195
- export declare function migrateReportSavedView(value: unknown): SavedViewInput;
196
-
197
- export declare const min: (column?: string, options?: {
198
- distinct?: boolean;
199
- }) => PropertyDecorator;
200
-
201
- export declare const minute: (sourceColumn: string) => PropertyDecorator;
202
-
203
- export declare const month: (sourceColumn: string) => PropertyDecorator;
204
-
205
- /**
206
- * Normalize a view both when it is saved and when it is restored. Re-running
207
- * this against the live descriptor is what prevents a former field/action
208
- * grant from surviving a policy or definition change.
209
- */
210
- export declare function normalizeReportSavedView(descriptor: ReportAdapterDescriptor, value: unknown): ReportSavedView;
211
-
212
- export declare function previewReportExport(descriptor: ReportAdapterDescriptor, request: ReportExportRequest, host: ReportExportActionHost): Promise<ReportExportPreview>;
213
-
214
- /** Preview only declares a separately authorized and audited refresh request. */
215
- export declare function previewReportRefresh(reportCtor: ReportCtor, options: PreviewReportRefreshOptions): Promise<ReportRefreshPreview>;
216
-
217
- export declare interface PreviewReportRefreshOptions extends ReportLifecycleOptions {
218
- host: ReportRefreshActionHost;
219
- mode?: ReportRefreshMode;
220
- /**
221
- * Pass `descriptor.refresh.action` when the adapter declares a custom
222
- * refresh permission, so the displayed and enforced action stay aligned.
223
- */
224
- refreshAction?: Pick<ReportRefreshActionDescriptor, 'requiredPermission'>;
225
- }
226
-
227
- export declare const quarter: (sourceColumn: string) => PropertyDecorator;
228
-
229
- /**
230
- * Execute bounded materialized report reads through the canonical query
231
- * envelope. Every predicate is an adapter-declared field/operator pair; the
232
- * collection converts it to parameterized SQL and applies tenant interceptors
233
- * to list, count, and facet reads alike.
234
- */
235
- export declare function queryReportMaterializedRows(reportCtor: new (...args: any[]) => SmrtObject, input: unknown, options: ReportBackgroundQueryOptions): Promise<ReportBackgroundQueryResult>;
236
-
237
- export declare function queryReportMaterializedRows(reportCtor: new (...args: any[]) => SmrtObject, input: unknown, options?: ReportQueryOptions): Promise<ReportDataQueryResult>;
238
-
239
- export declare function refreshReport(reportCtor: ReportCtor_2, options?: ReportRefreshOptions): Promise<ReportRefreshResult>;
240
-
241
- export declare function registerReportRefreshExecutionAuthorityHost(hostId: string, host: ReportRefreshExecutionAuthorityHost): () => void;
242
-
243
- export declare function registerReportRefreshInterceptor(options: ReportRefreshInterceptorOptions): () => boolean;
244
-
245
- export declare function registerReportRefreshJobIntegritySigner(signer: DurableJobPayloadSigner): () => void;
246
-
247
- export declare function report(options: ReportOptions): <T extends abstract new (...args: any[]) => any>(ctor: T) => T;
248
-
249
- export declare const REPORT_LOCKS_TABLE = "_smrt_report_locks";
250
-
251
- export declare const REPORT_REFRESH_TASKS_TABLE = "_smrt_report_refresh_tasks";
252
-
253
- export declare const REPORT_RUNS_TABLE = "_smrt_report_runs";
254
-
255
- export declare const REPORT_RUNTIME_TABLES: readonly ["_smrt_report_runs", "_smrt_report_watermarks", "_smrt_report_locks"];
256
-
257
- export declare const REPORT_SCHEDULER_TABLES: readonly ["_smrt_report_schedules", "_smrt_report_refresh_tasks"];
258
-
259
- export declare const REPORT_SCHEDULES_TABLE = "_smrt_report_schedules";
260
-
261
- export declare const REPORT_WATERMARKS_TABLE = "_smrt_report_watermarks";
262
-
263
- /**
264
- * The report-owned, transport-neutral descriptor. Consumers can map `schema`
265
- * to the canonical data-query runtime and `columns` to their presentation
266
- * contract without importing smrt-ui or a report domain class.
267
- */
268
- export declare interface ReportAdapterDescriptor {
269
- version: 1;
270
- resourceId: string;
271
- reportClassName: string;
272
- sourceClassName: string;
273
- tenantScoped: boolean;
274
- tenantField?: string;
275
- identityField: 'id';
276
- columns: ReportColumnDescriptor[];
277
- schema: DataQuerySchema;
278
- queryExecution: ReportQueryExecutionDescriptor;
279
- dataTable: ReportDataTableDescriptor;
280
- drilldown: ReportDrilldownDescriptor;
281
- refresh: ReportRefreshDescriptor;
282
- }
283
-
284
- export declare interface ReportAdapterOptions {
285
- /** Scope used only to make a stable resource id; it is not authority. */
286
- tenantScope?: 'current' | 'global' | 'tenant';
287
- /** Permission that a lifecycle action host must require before refresh. */
288
- refreshPermission?: string;
289
- /** Consumer-owned presentational preferences; they never affect query rows. */
290
- dataTable?: ReportDataTablePresentationOptions;
291
- }
292
-
293
- export declare interface ReportAggregateFieldMetadata {
294
- kind: 'aggregate';
295
- fn: ReportAggregateFn;
296
- column?: string;
297
- distinct?: boolean;
298
- }
299
-
300
- export declare type ReportAggregateFn = AggregateFunction;
301
-
302
- /**
303
- * An authority-free job handoff. The queue must re-enter the bound principal
304
- * and tenant, resolve the current report definition/field policy, and verify
305
- * this snapshot before materializing an artifact.
306
- */
307
- export declare interface ReportBackgroundExportTask {
308
- version: 1;
309
- execution: 'background';
310
- request: ReportExportRequest;
311
- inherits: Array<(typeof INHERITED_REPORT_SCOPE)[number]>;
312
- }
313
-
314
- /** Background execution is possible only through an application-owned queue host. */
315
- export declare interface ReportBackgroundQueryOptions extends ReportQueryCommonOptions {
316
- execution: 'background';
317
- enqueueBackgroundQuery(task: ReportBackgroundQueryTask): Promise<{
318
- taskId: string;
319
- }>;
320
- }
321
-
322
- /** Queuing a background query returns a handle, never rows from another scope. */
323
- export declare interface ReportBackgroundQueryResult {
324
- version: 1;
325
- execution: 'background';
326
- status: 'queued';
327
- taskId: string;
328
- queryFingerprint: string;
329
- }
330
-
331
- /**
332
- * The exact bounded request a background host may persist. Tenant, principal,
333
- * collection, database, and display state deliberately remain with that host.
334
- */
335
- export declare interface ReportBackgroundQueryTask {
336
- version: 1;
337
- execution: 'background';
338
- resourceId: string;
339
- reportClassName: string;
340
- request: DataQueryRequest;
341
- inherits: Array<'principal' | 'tenant' | 'report-definition' | 'field-policy'>;
342
- }
343
-
344
- export declare interface ReportBucketFieldMetadata {
345
- kind: 'bucket';
346
- unit: ReportTimeBucketUnit;
347
- sourceColumn: string;
348
- }
349
-
350
- export declare type ReportColumnCapability = 'read' | 'project' | 'filter' | 'sort' | 'facet' | 'group' | 'aggregate';
351
-
352
- export declare interface ReportColumnDescriptor extends DataQueryFieldDescriptor {
353
- /** Stable output column id (never a property path). */
354
- id: string;
355
- fieldName: string;
356
- label: string;
357
- kind: ReportColumnKind;
358
- filterScope: ReportFilterScope;
359
- /** Capabilities available from this adapter revision. */
360
- capabilities: ReportColumnCapability[];
361
- format?: string;
362
- sensitivity?: ReportColumnSensitivity;
363
- sourceColumn?: string;
364
- bucket?: ReportTimeBucketUnit;
365
- aggregate?: ReportAggregateFn;
366
- distinct?: boolean;
367
- }
368
-
369
- export declare type ReportColumnKind = 'identity' | 'group' | 'bucket' | 'aggregate';
370
-
371
- /** Presentation and policy metadata understood by the report adapter. */
372
- export declare type ReportColumnSensitivity = 'public' | 'personal' | 'sensitive' | 'secret';
373
-
374
- declare type ReportCtor = new (...args: any[]) => SmrtObject;
375
-
376
- declare type ReportCtor_2 = new (...args: any[]) => SmrtObject;
377
-
378
- declare type ReportCtor_3 = new (...args: any[]) => SmrtObject;
379
-
380
- export declare interface ReportDataQueryResult extends DataQueryResult {
381
- /** Delivery intent only; the adapter never mutates a visible surface. */
382
- execution: 'visible' | 'silent';
383
- reportLifecycle?: ReportMaterializedReadLifecycle;
384
- }
385
-
386
- export declare interface ReportDataTableColumn {
387
- id: string;
388
- label: string;
389
- accessor: string;
390
- sortable: boolean;
391
- searchable: false;
392
- filterable: boolean;
393
- /** Group ancestry for consumers with multi-level table headers. */
394
- headerPath: ReportDataTableHeaderPathSegment[];
395
- /** Consumer-side display instruction; materialized rows remain raw. */
396
- valueFormat: ReportDataTableValueFormat;
397
- /** The default alignment for the formatted display value. */
398
- align: 'left' | 'right';
399
- /** Generic semantic role for status/action columns introduced by later slices. */
400
- role: ReportDataTableColumnRole;
401
- responsive: ReportDataTableColumnResponsive;
402
- }
403
-
404
- /** Per-column presentation overrides owned by the consuming report surface. */
405
- export declare interface ReportDataTableColumnOverride {
406
- label?: string;
407
- headerPath?: readonly ReportDataTableHeaderPathSegment[];
408
- valueFormat?: ReportDataTableValueFormat;
409
- align?: 'left' | 'right';
410
- role?: ReportDataTableColumnRole;
411
- responsive?: ReportDataTableColumnResponsive;
412
- }
413
-
414
- /** Responsive metadata that maps directly to a consumer's table contract. */
415
- export declare interface ReportDataTableColumnResponsive {
416
- /** Higher values make a column more important during responsive collapse. */
417
- priority?: number;
418
- /** Keep key dimensions reachable during responsive collapse. */
419
- keepVisible?: boolean;
420
- }
421
-
422
- export declare type ReportDataTableColumnRole = 'data' | 'status' | 'action';
423
-
424
- export declare interface ReportDataTableDescriptor {
425
- rowKey: 'id';
426
- manualPagination: true;
427
- manualSorting: true;
428
- enableFiltering: true;
429
- enableSearch: false;
430
- columns: ReportDataTableColumn[];
431
- structuralRows: ReportDataTableStructuralRow[];
432
- }
433
-
434
- /** Structural DataTable view hints; deliberately not a smrt-ui dependency. */
435
- export declare interface ReportDataTableHeaderPathSegment {
436
- /** Stable group identity within a header level. */
437
- id: string;
438
- /** Human-readable grouped-header label. */
439
- label: string;
440
- }
441
-
442
- export declare interface ReportDataTablePresentationOptions {
443
- /** Overrides are keyed by stable adapter column id, not display labels. */
444
- columns?: Readonly<Record<string, ReportDataTableColumnOverride>>;
445
- /** Summary/subtotal rows remain structural rather than materialized data rows. */
446
- structuralRows?: readonly ReportDataTableStructuralRowInput[];
447
- }
448
-
449
- /**
450
- * Structural rows are intentionally separate from materialized data rows.
451
- * Consumers pass them to their DataTable's structural-row slot/prop, never its
452
- * selectable data collection.
453
- */
454
- export declare interface ReportDataTableStructuralRow extends ReportDataTableStructuralRowInput {
455
- selection: 'excluded';
456
- actions: 'excluded';
457
- }
458
-
459
- /** Input supplied by a report consumer that computes a summary or subtotal. */
460
- export declare interface ReportDataTableStructuralRowInput {
461
- id: string;
462
- kind: ReportDataTableStructuralRowKind;
463
- label: string;
464
- /** Raw values keyed by the adapter's stable column id. */
465
- values?: Readonly<Record<string, unknown>>;
466
- /** Column that renders this row's accessible row header. */
467
- labelColumnId?: string;
468
- }
469
-
470
- export declare type ReportDataTableStructuralRowKind = 'summary' | 'subtotal' | 'aggregate' | 'footer';
471
-
472
- /**
473
- * A rendering instruction for a raw materialized value. Formatting is never
474
- * applied to a query row, so sorting, export, and agent consumers retain it.
475
- */
476
- export declare type ReportDataTableValueFormat = 'text' | 'date' | 'datetime' | 'percentage' | 'count' | 'money' | 'number';
477
-
478
- export declare interface ReportDefinition {
479
- reportClassName: string;
480
- sourceClassName: string;
481
- sourceTable: string;
482
- fields: ReportFieldDefinition[];
483
- where?: WhereClause;
484
- having?: WhereClause;
485
- refresh?: ReportRefreshConfig;
486
- }
487
-
488
- /**
489
- * A change to report fields, their capabilities, schema, scope, or source
490
- * invalidates a stored view/export snapshot rather than silently widening it.
491
- */
492
- export declare function reportDefinitionFingerprint(descriptor: ReportAdapterDescriptor): string;
493
-
494
- export declare interface ReportDrilldownConstraint {
495
- id: string;
496
- sourceColumn: string;
497
- kind: 'group' | 'bucket';
498
- value: unknown;
499
- bucket?: ReportTimeBucketUnit;
500
- }
501
-
502
- /**
503
- * Declarative source-query handoff for a report row. No client can supply a
504
- * principal, tenant, report definition, or arbitrary source field here.
505
- */
506
- export declare interface ReportDrilldownDescriptor {
507
- id: 'drilldown';
508
- sourceClassName: string;
509
- fields: ReportDrilldownFieldDescriptor[];
510
- inherits: Array<'principal' | 'tenant' | 'report-definition' | 'field-policy'>;
511
- }
512
-
513
- /** One row value that can safely constrain a source-record drilldown. */
514
- export declare interface ReportDrilldownFieldDescriptor {
515
- /** Stable report column id; never a display label. */
516
- id: string;
517
- /** Declared source field/column chosen by report metadata, not caller input. */
518
- sourceColumn: string;
519
- kind: 'group' | 'bucket';
520
- /** A bucket stays declarative so the source adapter preserves report timezone semantics. */
521
- bucket?: ReportTimeBucketUnit;
522
- }
523
-
524
- /** A server adapter uses this authority-free handoff to execute a source drilldown. */
525
- export declare interface ReportDrilldownQuery {
526
- version: 1;
527
- resourceId: string;
528
- reportClassName: string;
529
- sourceClassName: string;
530
- constraints: ReportDrilldownConstraint[];
531
- inherits: Array<'principal' | 'tenant' | 'report-definition' | 'field-policy'>;
532
- }
533
-
534
- export declare interface ReportExecutionPrincipalReference {
535
- version: 1;
536
- actorUserId: string;
537
- tenantId: string | null;
538
- onBehalfOfUserId?: string | null;
539
- actsAsProfileId?: string | null;
540
- agentClass?: string | null;
541
- }
542
-
543
- export declare interface ReportExportActionContext {
544
- phase: 'preview' | 'apply';
545
- reportClassName: string;
546
- resourceId: string;
547
- requiredPermission: string;
548
- confirmationRequired: boolean;
549
- execution: 'stream' | 'background';
550
- queryFingerprint: string;
551
- definitionFingerprint: string;
552
- snapshotId: string;
553
- asOf: string;
554
- pageSize: number;
555
- }
556
-
557
- /** The same host is used by human and agent callers. */
558
- export declare interface ReportExportActionHost {
559
- /**
560
- * Prove that this opaque binding still resolves to the exact immutable
561
- * materialization snapshot under the host's current principal and tenant.
562
- * The background worker must call `validateReportExportExecution()` again
563
- * before reading or serving any rows.
564
- */
565
- assertSnapshot(context: ReportExportSnapshotContext): Promise<void> | void;
566
- authorize(context: ReportExportActionContext): Promise<void> | void;
567
- audit(context: ReportExportActionContext): Promise<void> | void;
568
- enqueue?(task: ReportBackgroundExportTask): Promise<{
569
- taskId: string;
570
- }> | {
571
- taskId: string;
572
- };
573
- }
574
-
575
- /**
576
- * Artifact metadata is deliberately URL- and token-free. An application-owned
577
- * serving boundary must authorize every download using the caller's current
578
- * principal and tenant before it reveals any artifact location.
579
- */
580
- export declare interface ReportExportArtifact {
581
- id: string;
582
- request: ReportExportRequest;
583
- progress: ReportExportProgress;
584
- expiresAt: string;
585
- }
586
-
587
- export declare type ReportExportFormat = 'csv' | 'json';
588
-
589
- /** Every export is bounded before it is streamed or delegated to a worker. */
590
- export declare interface ReportExportLimits {
591
- maxRows: number;
592
- maxBytes: number;
593
- deadlineMs: number;
594
- /** Exports above this exact row count must use the application queue. */
595
- foregroundRowLimit: number;
596
- }
597
-
598
- export declare interface ReportExportPreview {
599
- phase: 'preview';
600
- action: ReportExportActionContext;
601
- request: ReportExportRequest;
602
- }
603
-
604
- export declare interface ReportExportProgress {
605
- state: 'queued' | 'running' | 'completed' | 'failed';
606
- rowCount: number;
607
- byteCount: number;
608
- truncated: boolean;
609
- }
610
-
611
- /**
612
- * A deterministic offset-page plan over the immutable host snapshot. A worker
613
- * starts at offset zero and advances by `page.limit` until `rowCount` rows have
614
- * been produced or the byte/deadline limits are reached.
615
- */
616
- export declare interface ReportExportReadPlan {
617
- snapshotId: string;
618
- queryFingerprint: string;
619
- asOf: string;
620
- page: {
621
- kind: 'offset';
622
- offset: 0;
623
- limit: number;
624
- };
625
- }
626
-
627
- export declare interface ReportExportRequest {
628
- version: 1;
629
- format: ReportExportFormat;
630
- execution: 'stream' | 'background';
631
- snapshot: ReportExportSnapshot;
632
- limits: ReportExportLimits;
633
- read: ReportExportReadPlan;
634
- rowCount: number;
635
- truncated: boolean;
636
- action: {
637
- id: 'export';
638
- requiredPermission: string;
639
- auditRequired: true;
640
- confirmationRequired: boolean;
641
- };
642
- }
643
-
644
- export declare interface ReportExportSnapshot {
645
- version: 1;
646
- resourceId: string;
647
- reportClassName: string;
648
- definitionFingerprint: string;
649
- binding: ReportExportSnapshotBinding;
650
- request: DataQueryRequest;
651
- queryFingerprint: string;
652
- projection: string[];
653
- sort: DataQuerySort[];
654
- freshness: DataQueryFreshness;
655
- snapshot: {
656
- asOf: string;
657
- refreshedAt?: string;
658
- stale: boolean;
659
- };
660
- total: {
661
- kind: 'exact';
662
- value: number;
663
- };
664
- inherits: Array<(typeof INHERITED_REPORT_SCOPE)[number]>;
665
- }
666
-
667
- /**
668
- * Opaque identity of a host-captured materialization snapshot. The application
669
- * creates and verifies it while bound to its principal and tenant; callers
670
- * cannot turn an `asOf` label into a snapshot by supplying this id alone.
671
- */
672
- export declare interface ReportExportSnapshotBinding {
673
- id: string;
674
- }
675
-
676
- export declare interface ReportExportSnapshotContext {
677
- bindingId: string;
678
- resourceId: string;
679
- reportClassName: string;
680
- definitionFingerprint: string;
681
- queryFingerprint: string;
682
- asOf: string;
683
- }
684
-
685
- export declare interface ReportFieldDefinition {
686
- fieldName: string;
687
- columnName?: string;
688
- type?: string;
689
- report?: ReportFieldMetadata;
690
- }
691
-
692
- export declare type ReportFieldMetadata = ReportGroupFieldMetadata | ReportBucketFieldMetadata | ReportAggregateFieldMetadata;
693
-
694
- /**
695
- * Source-query clause a field belongs to. The materialized read executor
696
- * applies both kinds through its tenant-scoped collection, but consumers use
697
- * this declaration to keep dimensions/periods (WHERE) distinct from measures
698
- * (HAVING) when constructing drilldowns, saved views, or a live query.
699
- */
700
- export declare type ReportFilterScope = 'where' | 'having';
701
-
702
- export declare interface ReportGroupFieldMetadata {
703
- kind: 'group';
704
- sourceColumn?: string;
705
- }
706
-
707
- export declare interface ReportLifecycleOptions {
708
- db: DatabaseInterface;
709
- /** Test seam; production callers use the current clock. */
710
- now?: Date;
711
- }
712
-
713
- export declare interface ReportLifecycleRun {
714
- id: string;
715
- status: 'running' | 'success' | 'failed' | 'skipped';
716
- mode: ReportRefreshMode;
717
- trigger: ReportRefreshTrigger;
718
- startedAt?: string;
719
- completedAt?: string;
720
- rowCount: number;
721
- changedGroupCount: number;
722
- /** A failed run is safe to retry through the separately permissioned action. */
723
- mayRetry: boolean;
724
- }
725
-
726
- /**
727
- * Transport-neutral report lifecycle state. It deliberately never includes a
728
- * lock owner, a raw failure message, or tenant fanout identifiers.
729
- */
730
- export declare interface ReportLifecycleSnapshot {
731
- version: 1;
732
- state: ReportLifecycleState;
733
- asOf?: string;
734
- refreshedAt?: string;
735
- /** Whether existing materialized rows can remain visible while work changes state. */
736
- hasUsableRows: boolean;
737
- mode: ReportRefreshMode;
738
- run?: ReportLifecycleRun;
739
- /** A stable, redacted failure signal; raw executor errors stay server-side. */
740
- failure?: {
741
- code: 'refresh_failed';
742
- retryable: true;
743
- };
744
- lock: {
745
- held: boolean;
746
- expiresAt?: string;
747
- };
748
- }
749
-
750
- export declare type ReportLifecycleState = 'current' | 'stale' | 'refreshing' | 'lock-skipped' | 'failed';
751
-
752
- /** Lifecycle context attached only when a caller explicitly opts in. */
753
- export declare interface ReportMaterializedReadLifecycle {
754
- snapshot: ReportLifecycleSnapshot;
755
- /** Whether this collection read appears to have completed a TTL refresh. */
756
- read: 'current' | 'stale' | 'refresh-triggered';
757
- }
758
-
759
- /** Read the already-materialized primary key; never use a display/page index. */
760
- export declare function reportMaterializedRowKey(row: Record<string, unknown>): string;
761
-
762
- export declare interface ReportOptions {
763
- source: ReportSource;
764
- where?: WhereClause;
765
- having?: WhereClause;
766
- refresh?: ReportRefreshConfig;
767
- }
768
-
769
- declare interface ReportQueryCommonOptions {
770
- /** Injected collection seam for tests and application-owned adapters. */
771
- collection?: {
772
- list(options: Record<string, unknown>): Promise<Array<Record<string, unknown>>>;
773
- count(options?: Record<string, unknown>): Promise<number>;
774
- facets?(options: Record<string, unknown>): Promise<Array<{
775
- field: string;
776
- values: Array<{
777
- value: string | number | boolean | null;
778
- count: number;
779
- }>;
780
- }>>;
781
- };
782
- db?: DatabaseInterface;
783
- /**
784
- * Consumer-owned descriptor preferences. They contribute to the stable
785
- * resource identity and must match the catalog used to select this report.
786
- */
787
- adapter?: ReportAdapterOptions;
788
- /**
789
- * Opt in to a tenant-safe lifecycle snapshot alongside this materialized
790
- * read. It never makes a generic read mutate.
791
- */
792
- lifecycle?: Omit<ReportLifecycleOptions, 'db'>;
793
- }
794
-
795
- export declare interface ReportQueryExecutionDescriptor {
796
- modes: ReportQueryExecutionMode[];
797
- /** The caller may apply the returned rows to an already-authorized surface. */
798
- visible: {
799
- delivery: 'result';
800
- };
801
- /** A host queues the authority-free task and returns no materialized rows yet. */
802
- background: {
803
- delivery: 'queued';
804
- requiresHost: true;
805
- };
806
- /** The caller receives rows but the adapter makes no visible-surface change. */
807
- silent: {
808
- delivery: 'result';
809
- mutatesVisibleSurface: false;
810
- };
811
- }
812
-
813
- /**
814
- * Delivery choices for the same bounded report query. They never add
815
- * authority: a host owns visible state and background-job execution.
816
- */
817
- export declare type ReportQueryExecutionMode = 'visible' | 'background' | 'silent';
818
-
819
- /** Visible is the default; silent has identical data authority but no UI intent. */
820
- export declare interface ReportQueryOptions extends ReportQueryCommonOptions {
821
- execution?: 'visible' | 'silent';
822
- }
823
-
824
- export declare interface ReportRefreshActionContext {
825
- phase: 'preview' | 'apply';
826
- reportClassName: string;
827
- /** The action always applies to the caller's already-bound tenant scope. */
828
- tenantScope: 'ambient';
829
- mode: ReportRefreshMode;
830
- requiredPermission: string;
831
- }
832
-
833
- /** A report-wide lifecycle action, never a mutation performed by this adapter. */
834
- export declare interface ReportRefreshActionDescriptor {
835
- id: 'refresh';
836
- label: 'Refresh report';
837
- scope: 'surface';
838
- phases: Array<'preview' | 'apply'>;
839
- requiresPermission: true;
840
- requiredPermission: string;
841
- auditRequired: true;
842
- }
843
-
844
- /** Authority and audit stay with the application action host, not reports. */
845
- export declare interface ReportRefreshActionHost {
846
- authorize(context: ReportRefreshActionContext, authority?: ReportRefreshExecutionAuthority): Promise<void> | void;
847
- audit(context: ReportRefreshActionContext, authority?: ReportRefreshExecutionAuthority): Promise<void> | void;
848
- /** Capture only a non-secret identity reference for worker-time reauthorization. */
849
- executionAuthority?(context: ReportRefreshActionContext): ReportRefreshExecutionAuthority | Promise<ReportRefreshExecutionAuthority>;
850
- /** Server-only signer shared with report worker processes. */
851
- jobIntegritySigner?(context: ReportRefreshActionContext): DurableJobPayloadSigner | Promise<DurableJobPayloadSigner>;
852
- }
853
-
854
- export declare interface ReportRefreshConfig {
855
- mode?: ReportRefreshMode;
856
- schedule?: string;
857
- onChange?: ReportSource[];
858
- /**
859
- * Milliseconds before collection reads trigger a synchronous refresh.
860
- *
861
- * TTL refresh checks add a read-time MAX(refreshedAt) query, and stale reads
862
- * perform the refresh before returning list/get results.
863
- */
864
- ttl?: number;
865
- manual?: boolean;
866
- watermarkColumn?: string;
867
- softDeleteColumn?: string;
868
- fullRebuildSchedule?: string;
869
- tenantFanout?: boolean;
870
- }
871
-
872
- export declare interface ReportRefreshDescriptor {
873
- mode: 'rebuild' | 'incremental';
874
- /**
875
- * Whether the report configuration lets a registered SmrtReportCollection
876
- * synchronously refresh a stale read. Generic collection reads stay
877
- * read-only and report unknown freshness until the lifecycle adapter runs.
878
- */
879
- mayRefreshOnRead: boolean;
880
- ttlMs?: number;
881
- triggers: Array<'manual' | 'schedule' | 'change' | 'ttl' | 'job'>;
882
- /** Declared only; the lifecycle adapter owns authorization, audit, and run state. */
883
- action: ReportRefreshActionDescriptor;
884
- }
885
-
886
- export declare interface ReportRefreshExecutionAuditEvent extends ReportRefreshExecutionAuthorityContext {
887
- outcome: 'allowed' | 'denied';
888
- principal: ReportExecutionPrincipalReference;
889
- reason?: string;
890
- }
891
-
892
- export declare interface ReportRefreshExecutionAuthority {
893
- version: 1;
894
- hostId: string;
895
- principal: ReportExecutionPrincipalReference;
896
- }
897
-
898
- export declare interface ReportRefreshExecutionAuthorityContext {
899
- phase: 'execute';
900
- reportClass: string;
901
- mode: ReportRefreshMode;
902
- trigger: ReportRefreshTrigger;
903
- tenantId: string | null;
904
- }
905
-
906
- export declare interface ReportRefreshExecutionAuthorityHost {
907
- authorize(principal: Readonly<ReportExecutionPrincipalReference>, context: Readonly<ReportRefreshExecutionAuthorityContext>): Promise<void> | void;
908
- audit(event: Readonly<ReportRefreshExecutionAuditEvent>): Promise<void> | void;
909
- }
910
-
911
- export declare interface ReportRefreshInterceptorOptions {
912
- db: DatabaseInterface;
913
- reports: ReportCtor_3[];
914
- enqueue?: boolean;
915
- queue?: string;
916
- priority?: number;
917
- timeout?: number;
918
- tenantJobCap?: number;
919
- name?: string;
920
- integritySigner?: DurableJobPayloadSigner;
921
- }
922
-
923
- export declare interface ReportRefreshJobArgs {
924
- reportClass?: string;
925
- mode?: ReportRefreshMode;
926
- trigger?: ReportRefreshTrigger;
927
- tenantId?: string | null;
928
- tenantIds?: string[];
929
- scheduleId?: string;
930
- adapterType?: SqlAdapterType;
931
- changedRows?: Record<string, unknown>[];
932
- _scheduleId?: string;
933
- executionAuthority?: ReportRefreshExecutionAuthority;
934
- integrity?: DurableJobPayloadIntegrity;
935
- }
936
-
937
- export declare interface ReportRefreshJobHandle {
938
- jobId: string;
939
- status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
940
- attempts: number;
941
- maxAttempts: number;
942
- /** Bounded polling guidance; this API does not create a second queue. */
943
- pollAfterMs: number;
944
- }
945
-
946
- export declare type ReportRefreshMode = 'rebuild' | 'incremental';
947
-
948
- export declare interface ReportRefreshOptions {
949
- db?: DatabaseInterface;
950
- mode?: ReportRefreshMode;
951
- adapterType?: SqlAdapterType;
952
- trigger?: ReportRefreshTrigger;
953
- tenantId?: string | null;
954
- tenantIds?: string[];
955
- lock?: boolean;
956
- lockTtlMs?: number;
957
- trackRuns?: boolean;
958
- scheduleId?: string;
959
- changedRows?: Record<string, unknown>[];
960
- }
961
-
962
- export declare interface ReportRefreshOutcome {
963
- state: 'current' | 'lock-skipped' | 'partial';
964
- rowCount: number;
965
- changedGroupCount: number;
966
- completedScopes: number;
967
- lockSkippedScopes: number;
968
- mode: ReportRefreshMode;
969
- refreshedAt: string;
970
- runId?: string;
971
- }
972
-
973
- /** Normalize executor results without exposing the tenant identifiers in a fanout. */
974
- export declare function reportRefreshOutcome(result: ReportRefreshResult): ReportRefreshOutcome;
975
-
976
- export declare interface ReportRefreshPreview {
977
- phase: 'preview';
978
- lifecycle: ReportLifecycleSnapshot;
979
- action: ReportRefreshActionContext;
980
- execution: 'background';
981
- }
982
-
983
- export declare interface ReportRefreshResult {
984
- rowCount: number;
985
- refreshedAt: Date;
986
- mode: ReportRefreshMode;
987
- tenantId?: string | null;
988
- runId?: string;
989
- changedGroupCount?: number;
990
- skipped?: boolean;
991
- tenantResults?: ReportRefreshResult[];
992
- }
993
-
994
- export declare type ReportRefreshTrigger = 'manual' | 'schedule' | 'change' | 'ttl' | 'job';
995
-
996
- export declare function reportRowIdentity(row: Record<string, any>, definition: ReportDefinition): string;
997
-
998
- declare type ReportRunStatus = 'running' | 'success' | 'failed' | 'skipped';
999
-
1000
- /**
1001
- * A normalized, policy-neutral stored view. The storage host associates it
1002
- * with its owner and tenant; neither identity is accepted here.
1003
- */
1004
- export declare interface ReportSavedView {
1005
- version: 1;
1006
- id: string;
1007
- title: string;
1008
- resourceId: string;
1009
- reportClassName: string;
1010
- definitionFingerprint: string;
1011
- query: DataQueryRequest;
1012
- columns: ReportSavedViewColumn[];
1013
- grouping?: ReportSavedViewGrouping;
1014
- display?: ReportSavedViewDisplay;
1015
- }
1016
-
1017
- /** A view's column order is its array order; ids are always adapter-defined. */
1018
- export declare interface ReportSavedViewColumn {
1019
- id: string;
1020
- width?: number;
1021
- pinned?: ReportSavedViewPinnedSide;
1022
- }
1023
-
1024
- export declare interface ReportSavedViewDisplay {
1025
- density: 'compact' | 'comfortable';
1026
- showTotals?: boolean;
1027
- }
1028
-
1029
- export declare interface ReportSavedViewGrouping {
1030
- fields: string[];
1031
- expanded?: boolean;
1032
- }
1033
-
1034
- export declare type ReportSavedViewPinnedSide = 'start' | 'end';
1035
-
1036
- export declare interface ReportScheduleInfo {
1037
- id: string;
1038
- reportClass: string;
1039
- tenantId: string | null;
1040
- cron: string;
1041
- mode: ReportRefreshMode;
1042
- }
1043
-
1044
- export declare class ReportScheduleRunner extends EventEmitter {
1045
- readonly id: string;
1046
- private readonly config;
1047
- private db;
1048
- private running;
1049
- private pollTimer;
1050
- constructor(config?: ReportScheduleRunnerConfig);
1051
- initialize(db: DatabaseInterface): Promise<void>;
1052
- start(): Promise<void>;
1053
- stop(): Promise<void>;
1054
- isRunning(): boolean;
1055
- handleJobCompletion(scheduleId: string, success: boolean, errorMessage?: string): Promise<void>;
1056
- private startPolling;
1057
- poll(): Promise<void>;
1058
- private triggerSchedule;
1059
- }
1060
-
1061
- export declare interface ReportScheduleRunnerConfig {
1062
- id?: string;
1063
- pollInterval?: number;
1064
- batchSize?: number;
1065
- integritySigner?: DurableJobPayloadSigner;
1066
- }
1067
-
1068
- export declare interface ReportScheduleRunnerEvents {
1069
- 'schedule:triggered': (schedule: ReportScheduleInfo) => void;
1070
- 'schedule:error': (schedule: ReportScheduleInfo, error: Error) => void;
1071
- 'schedule:completed': (scheduleId: string) => void;
1072
- 'schedule:failed': (scheduleId: string, error: string) => void;
1073
- 'runner:started': () => void;
1074
- 'runner:stopped': () => void;
1075
- 'runner:error': (error: Error) => void;
1076
- }
1077
-
1078
- declare type ReportScheduleStatus = 'active' | 'paused' | 'disabled' | 'error';
1079
-
1080
- export declare type ReportSource = string | (new (...args: any[]) => SmrtObject) | (abstract new (...args: any[]) => SmrtObject);
1081
-
1082
- export declare class ReportSurfaceValidationError extends Error {
1083
- constructor(message: string);
1084
- }
1085
-
1086
- export declare type ReportTimeBucketUnit = AggregateTimeBucketUnit;
1087
-
1088
- /** Restore through current policy rather than trusting a stored JSON record. */
1089
- export declare function restoreReportSavedView(descriptor: ReportAdapterDescriptor, savedView: ReportSavedView): ReportSavedView;
1090
-
1091
- declare interface SavedViewInput {
1092
- version?: unknown;
1093
- id: unknown;
1094
- title: unknown;
1095
- resourceId?: unknown;
1096
- reportClassName?: unknown;
1097
- definitionFingerprint?: unknown;
1098
- query: unknown;
1099
- columns?: unknown;
1100
- grouping?: unknown;
1101
- display?: unknown;
1102
- }
1103
-
1104
- export declare function scopeKeyForTenant(tenantId: string | null | undefined): string;
1105
-
1106
- /** Worker target whose authority requirement cannot be downgraded by job args. */
1107
- export declare class SmrtPrincipalReportRefreshTask extends SmrtReportRefreshTask {
1108
- run(args?: ReportRefreshJobArgs, context?: JobExecutionContext): Promise<unknown>;
1109
- }
1110
-
1111
- export declare class SmrtReport extends SmrtObject {
1112
- static readonly _isReportBase: true;
1113
- refreshedAt: Date | null;
1114
- constructor(options?: SmrtObjectOptions);
1115
- isStale(ttlMs?: number): boolean;
1116
- refresh(options?: Omit<ReportRefreshOptions, 'db'>): Promise<ReportRefreshResult>;
1117
- }
1118
-
1119
- export declare class SmrtReportCollection<ModelType extends SmrtReport> extends SmrtCollection<ModelType> {
1120
- private refreshIfStale;
1121
- refresh(options?: Omit<ReportRefreshOptions, 'db'>): Promise<ReportRefreshResult>;
1122
- list<const Select extends readonly SmrtSelectField<ModelType>[]>(options: Omit<SmrtListOptions<ModelType>, 'select' | 'stiScope'> & {
1123
- select: Select;
1124
- include?: never;
1125
- stiScope: SmrtStiReadScope;
1126
- }): Promise<Record<string, unknown>[]>;
1127
- list<const Select extends readonly SmrtSelectField<ModelType>[]>(options: Omit<SmrtListOptions<ModelType>, 'select' | 'stiScope'> & {
1128
- select: Select;
1129
- include?: never;
1130
- stiScope?: undefined;
1131
- }): Promise<SmrtSelectedRow<ModelType, Select>[]>;
1132
- list(options: Omit<SmrtListOptions<ModelType>, 'select' | 'stiScope'> & {
1133
- select?: undefined;
1134
- stiScope: SmrtStiReadScope;
1135
- }): Promise<SmrtObject[]>;
1136
- list(options?: undefined): Promise<ModelType[]>;
1137
- list(options: Omit<SmrtListOptions<ModelType>, 'select' | 'stiScope'> & {
1138
- select?: undefined;
1139
- stiScope?: undefined;
1140
- }): Promise<ModelType[]>;
1141
- list(options: (Omit<SmrtListOptions<ModelType>, 'select'> & {
1142
- select?: undefined;
1143
- }) | undefined): Promise<SmrtObject[]>;
1144
- list(options: SmrtListOptions<ModelType> | undefined): Promise<SmrtObject[] | Record<string, unknown>[]>;
1145
- get(filter: Parameters<SmrtCollection<ModelType>['get']>[0], options?: Parameters<SmrtCollection<ModelType>['get']>[1]): Promise<ModelType | null>;
1146
- }
1147
-
1148
- export declare class SmrtReportLock extends SmrtObject {
1149
- tenantId: string | null;
1150
- scopeKey: string;
1151
- reportClass: string;
1152
- ownerId: string | null;
1153
- acquiredAt: Date | null;
1154
- heartbeatAt: Date | null;
1155
- expiresAt: Date | null;
1156
- }
1157
-
1158
- export declare class SmrtReportLockCollection extends SmrtCollection<SmrtReportLock> {
1159
- static readonly _itemClass: typeof SmrtReportLock;
1160
- }
1161
-
1162
- export declare class SmrtReportRefreshTask extends SmrtObject {
1163
- tenantId: string | null;
1164
- reportClass: string;
1165
- mode: ReportRefreshMode;
1166
- trigger: ReportRefreshTrigger;
1167
- args: ReportRefreshJobArgs;
1168
- run(args?: ReportRefreshJobArgs, context?: JobExecutionContext): Promise<unknown>;
1169
- }
1170
-
1171
- export declare class SmrtReportRun extends SmrtObject {
1172
- tenantId: string | null;
1173
- scopeKey: string;
1174
- reportClass: string;
1175
- sourceClass: string;
1176
- mode: ReportRefreshMode;
1177
- trigger: ReportRefreshTrigger;
1178
- status: ReportRunStatus;
1179
- startedAt: Date;
1180
- completedAt: Date | null;
1181
- rowCount: number;
1182
- changedGroupCount: number;
1183
- watermarkBefore: string | null;
1184
- watermarkAfter: string | null;
1185
- error: string | null;
1186
- metadata: Record<string, unknown>;
1187
- }
1188
-
1189
- export declare class SmrtReportRunCollection extends SmrtCollection<SmrtReportRun> {
1190
- static readonly _itemClass: typeof SmrtReportRun;
1191
- }
1192
-
1193
- export declare class SmrtReportSchedule extends SmrtObject {
1194
- tenantId: string | null;
1195
- scopeKey: string;
1196
- reportClass: string;
1197
- cron: string;
1198
- trigger: ReportRefreshTrigger;
1199
- mode: ReportRefreshMode;
1200
- enabled: boolean;
1201
- status: ReportScheduleStatus;
1202
- nextRun: Date | null;
1203
- lastRun: Date | null;
1204
- lastStatus: 'success' | 'failed' | null;
1205
- lastError: string | null;
1206
- runCount: number;
1207
- successCount: number;
1208
- failureCount: number;
1209
- runningCount: number;
1210
- maxConcurrent: number;
1211
- queue: string;
1212
- priority: number;
1213
- timeout: number;
1214
- }
1215
-
1216
- export declare class SmrtReportScheduleCollection extends SmrtCollection<SmrtReportSchedule> {
1217
- static readonly _itemClass: typeof SmrtReportSchedule;
1218
- }
1219
-
1220
- export declare class SmrtReportWatermark extends SmrtObject {
1221
- tenantId: string | null;
1222
- scopeKey: string;
1223
- reportClass: string;
1224
- sourceClass: string;
1225
- watermarkColumn: string;
1226
- watermarkValue: string | null;
1227
- lastRunId: string | null;
1228
- }
1229
-
1230
- export declare class SmrtReportWatermarkCollection extends SmrtCollection<SmrtReportWatermark> {
1231
- static readonly _itemClass: typeof SmrtReportWatermark;
1232
- }
1233
-
1234
- /**
1235
- * Split the declared filter language by report semantics for consumers that
1236
- * construct a live source query. Mixed AND expressions are represented as two
1237
- * independent clauses; mixed OR/NOT expressions are rejected because moving
1238
- * either half across WHERE/HAVING would change their meaning.
1239
- */
1240
- export declare function splitReportFilterScopes(descriptor: ReportAdapterDescriptor, filter: DataQueryFilter | undefined): {
1241
- where?: DataQueryFilter;
1242
- having?: DataQueryFilter;
1243
- };
1244
-
1245
- export declare const sum: (column?: string, options?: {
1246
- distinct?: boolean;
1247
- }) => PropertyDecorator;
1248
-
1249
- /**
1250
- * Validate artifact metadata before a host serves it. Download locations and
1251
- * tokens stay application-private; expired artifacts fail before that boundary.
1252
- */
1253
- export declare function validateReportExportArtifact(descriptor: ReportAdapterDescriptor, artifact: ReportExportArtifact, now?: Date): ReportExportArtifact;
1254
-
1255
- /**
1256
- * Revalidate the request and prove the opaque snapshot binding through the
1257
- * application host. Preview, apply, and every background worker use this same
1258
- * operation before reading or serving export data.
1259
- */
1260
- export declare function validateReportExportExecution(descriptor: ReportAdapterDescriptor, request: ReportExportRequest, host: Pick<ReportExportActionHost, 'assertSnapshot'>): Promise<ReportExportRequest>;
1261
-
1262
- /**
1263
- * Recreate the deterministic request from its current descriptor and frozen
1264
- * snapshot. Preview, apply, queue, and serving hosts call this instead of
1265
- * trusting browser- or agent-supplied action metadata.
1266
- */
1267
- export declare function validateReportExportRequest(descriptor: ReportAdapterDescriptor, request: ReportExportRequest): ReportExportRequest;
1268
-
1269
- /** Reject definitions/policies that changed after a snapshot was frozen. */
1270
- export declare function verifyReportExportSnapshot(descriptor: ReportAdapterDescriptor, snapshot: ReportExportSnapshot): ReportExportSnapshot;
1271
-
1272
- export declare const week: (sourceColumn: string) => PropertyDecorator;
1273
-
1274
- export declare const year: (sourceColumn: string) => PropertyDecorator;
1275
-
1276
- export { }
1
+ export type { ReportAdapterDescriptor, ReportAdapterOptions, ReportBackgroundQueryOptions, ReportBackgroundQueryResult, ReportBackgroundQueryTask, ReportColumnCapability, ReportColumnDescriptor, ReportColumnKind, ReportColumnSensitivity, ReportDataQueryResult, ReportDataTableColumn, ReportDataTableColumnOverride, ReportDataTableColumnResponsive, ReportDataTableColumnRole, ReportDataTableDescriptor, ReportDataTableHeaderPathSegment, ReportDataTablePresentationOptions, ReportDataTableStructuralRow, ReportDataTableStructuralRowInput, ReportDataTableStructuralRowKind, ReportDataTableValueFormat, ReportDrilldownConstraint, ReportDrilldownDescriptor, ReportDrilldownFieldDescriptor, ReportDrilldownQuery, ReportFilterScope, ReportMaterializedReadLifecycle, ReportQueryExecutionDescriptor, ReportQueryExecutionMode, ReportQueryOptions, ReportRefreshActionDescriptor, ReportRefreshDescriptor, } from './adapter.js';
2
+ export { buildReportAdapterDescriptor, buildReportDrilldownQuery, queryReportMaterializedRows, reportMaterializedRowKey, splitReportFilterScopes, } from './adapter.js';
3
+ export { bucketExpr, buildAggregate, } from './aggregate.js';
4
+ export { buildReportDefinition, compileReportDefinition, compileReportSpec, getReportGroupingColumns, } from './compiler.js';
5
+ export { aggregate, avg, count, day, getRuntimeReportOptions, groupBy, hour, max, min, minute, month, quarter, report, sum, week, year, } from './decorators.js';
6
+ export type { AppliedReportRefresh, ApplyReportRefreshOptions, PreviewReportRefreshOptions, ReportLifecycleOptions, ReportLifecycleRun, ReportLifecycleSnapshot, ReportLifecycleState, ReportRefreshActionContext, ReportRefreshActionHost, ReportRefreshJobHandle, ReportRefreshOutcome, ReportRefreshPreview, } from './lifecycle.js';
7
+ export { applyReportRefresh, getReportLifecycle, previewReportRefresh, reportRefreshOutcome, } from './lifecycle.js';
8
+ export { refreshReport, reportRowIdentity, } from './refresh.js';
9
+ export { SmrtReport, SmrtReportCollection } from './report.js';
10
+ export type { EnqueueReportRefreshOptions, EnsureReportSchedulesOptions, ReportExecutionPrincipalReference, ReportRefreshExecutionAuditEvent, ReportRefreshExecutionAuthority, ReportRefreshExecutionAuthorityContext, ReportRefreshExecutionAuthorityHost, ReportRefreshInterceptorOptions, ReportRefreshJobArgs, ReportScheduleInfo, ReportScheduleRunnerConfig, ReportScheduleRunnerEvents, } from './scheduler.js';
11
+ export { enqueueReportRefresh, ensureReportRefreshSchedules, ReportScheduleRunner, registerReportRefreshExecutionAuthorityHost, registerReportRefreshInterceptor, registerReportRefreshJobIntegritySigner, SmrtPrincipalReportRefreshTask, SmrtReportRefreshTask, } from './scheduler.js';
12
+ export { assertReportTablesReady, REPORT_LOCKS_TABLE, REPORT_REFRESH_TASKS_TABLE, REPORT_RUNS_TABLE, REPORT_RUNTIME_TABLES, REPORT_SCHEDULER_TABLES, REPORT_SCHEDULES_TABLE, REPORT_WATERMARKS_TABLE, SmrtReportLock, SmrtReportLockCollection, SmrtReportRun, SmrtReportRunCollection, SmrtReportSchedule, SmrtReportScheduleCollection, SmrtReportWatermark, SmrtReportWatermarkCollection, scopeKeyForTenant, } from './state.js';
13
+ export type { AggregateBuildResult, AggregateSelectExpr, AggregateSpec, ReportAggregateFieldMetadata, ReportAggregateFn, ReportBucketFieldMetadata, ReportDefinition, ReportFieldDefinition, ReportFieldMetadata, ReportGroupFieldMetadata, ReportOptions, ReportRefreshConfig, ReportRefreshMode, ReportRefreshOptions, ReportRefreshResult, ReportRefreshTrigger, ReportSource, ReportTimeBucketUnit, } from './types.js';
14
+ export type { AppliedReportExport, ReportBackgroundExportTask, ReportExportActionContext, ReportExportActionHost, ReportExportArtifact, ReportExportFormat, ReportExportLimits, ReportExportPreview, ReportExportProgress, ReportExportReadPlan, ReportExportRequest, ReportExportSnapshot, ReportExportSnapshotBinding, ReportExportSnapshotContext, ReportSavedView, ReportSavedViewColumn, ReportSavedViewDisplay, ReportSavedViewGrouping, ReportSavedViewPinnedSide, } from './views.js';
15
+ export { applyReportExport, createReportExportPageRequest, createReportExportRequest, createReportExportSnapshot, migrateReportSavedView, normalizeReportSavedView, previewReportExport, ReportSurfaceValidationError, reportDefinitionFingerprint, restoreReportSavedView, validateReportExportArtifact, validateReportExportExecution, validateReportExportRequest, verifyReportExportSnapshot, } from './views.js';
16
+ //# sourceMappingURL=index.d.ts.map