@altertable/data-app 0.74.0 → 0.76.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.
Files changed (54) hide show
  1. package/AGENTS.md +11 -3
  2. package/CONTRIBUTING.md +14 -3
  3. package/README.md +56 -9
  4. package/REFERENCE.md +194 -99
  5. package/dist/chunks/{contract-BeLPJwlO.js → contract-DsyRYgN_.js} +176 -108
  6. package/dist/chunks/contract-DsyRYgN_.js.map +1 -0
  7. package/dist/chunks/{contract-Di8SP74I.js → contract-kNFYPHRK.js} +255 -4
  8. package/dist/chunks/contract-kNFYPHRK.js.map +1 -0
  9. package/dist/chunks/date-time-range-value-TE8KCsfV.js +648 -0
  10. package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +1 -0
  11. package/dist/chunks/{diagnostics-BTZSlNtW.js → diagnostics-DhCqGklq.js} +2 -2
  12. package/dist/chunks/{diagnostics-BTZSlNtW.js.map → diagnostics-DhCqGklq.js.map} +1 -1
  13. package/dist/chunks/{operation-CSM9UmO3.js → operation-7tiT4cpJ.js} +3 -3
  14. package/dist/chunks/{operation-CSM9UmO3.js.map → operation-7tiT4cpJ.js.map} +1 -1
  15. package/dist/client/index.js +51 -5
  16. package/dist/client/index.js.map +1 -1
  17. package/dist/core/config.js +4 -3
  18. package/dist/core/config.js.map +1 -1
  19. package/dist/core/contract.js +4 -3
  20. package/dist/core/format.js +149 -1
  21. package/dist/core/format.js.map +1 -0
  22. package/dist/internal.js +6 -189
  23. package/dist/internal.js.map +1 -1
  24. package/dist/server/index.js +3 -3
  25. package/dist/server/index.js.map +1 -1
  26. package/dist/types/chunks/contract.d.ts +133 -264
  27. package/dist/types/chunks/contract2.d.ts +207 -0
  28. package/dist/types/chunks/date-time-range-value.d.ts +20 -0
  29. package/dist/types/chunks/date-time-range.d.ts +29 -0
  30. package/dist/types/chunks/index.d.ts +14 -2
  31. package/dist/types/client/index.d.ts +3 -3
  32. package/dist/types/core/config.d.ts +6 -4
  33. package/dist/types/core/contract.d.ts +5 -2
  34. package/dist/types/core/format.d.ts +21 -1
  35. package/dist/types/index.d.ts +3 -2
  36. package/dist/types/internal.d.ts +11 -4
  37. package/dist/types/server/index.d.ts +2 -2
  38. package/docs/app-authoring.md +46 -14
  39. package/docs/composition.md +4 -23
  40. package/docs/contract.md +42 -9
  41. package/docs/diagnostics.md +37 -0
  42. package/docs/embed.md +38 -0
  43. package/docs/hosted-apps.md +7 -4
  44. package/docs/local-data-apps.md +17 -2
  45. package/docs/react.md +6 -3
  46. package/docs/stories-and-export.md +14 -5
  47. package/docs/ui-quality.md +3 -2
  48. package/docs/ui.md +53 -2
  49. package/docs/variables.md +80 -8
  50. package/package.json +17 -5
  51. package/dist/chunks/contract-BeLPJwlO.js.map +0 -1
  52. package/dist/chunks/contract-Di8SP74I.js.map +0 -1
  53. package/dist/chunks/format-BdFlv_xa.js +0 -148
  54. package/dist/chunks/format-BdFlv_xa.js.map +0 -1
@@ -1,3 +1,30 @@
1
+ import { n as DateTimeRange, s as ResolvedDateTimeRange } from "./date-time-range.js";
2
+ //#region src/core/date-time-range-contract.d.ts
3
+ /** Resolved UTC-rebased bounds for one execution, optionally with the preceding equal-length interval. */
4
+ type DateTimeRangeRequest = {
5
+ range: ResolvedDateTimeRange;
6
+ comparison: ResolvedDateTimeRange | null;
7
+ };
8
+ /** Datetime policy exposed by defineDateRangeContract().datetime. Parsing preserves relative values. */
9
+ type DateTimeRangeContract = ReturnType<typeof createDateTimeRangeContract>;
10
+ declare function createDateTimeRangeContract(options: DateRangeContractOptions): {
11
+ timeZone: string;
12
+ bounds: (now?: Date) => {
13
+ minDate: string | undefined;
14
+ maxDate: string;
15
+ maxRangeDays: number;
16
+ timeZone: string;
17
+ };
18
+ /** Validate coverage and duration while preserving symbolic relative bounds. */
19
+ parse: (value: unknown, now?: Date) => DateTimeRange;
20
+ /** Resolve to UTC-rebased bounds using reporting-zone wall-clock fields, then validate policy. */
21
+ resolve: (value: unknown, now?: Date) => DateTimeRangeRequest['range'];
22
+ /** Return the preceding equal-length interval, or null when source coverage excludes it. */
23
+ comparison: (value: unknown, now?: Date) => DateTimeRangeRequest['comparison'];
24
+ /** Resolve both periods against one reference instant. Use these bounds for comparison queries. */
25
+ request(value: unknown, compare?: boolean, now?: Date): DateTimeRangeRequest;
26
+ };
27
+ //#endregion
1
28
  //#region src/core/operation-types.d.ts
2
29
  type OperationContracts = Record<string, {
3
30
  input: (value: unknown) => unknown;
@@ -77,6 +104,7 @@ type TransportResponse<Body = unknown> = {
77
104
  };
78
105
  //#endregion
79
106
  //#region src/core/queries.d.ts
107
+ declare const MAX_QUERY_ROWS = 10000;
80
108
  type QueryValues = {
81
109
  string: string;
82
110
  number: number;
@@ -95,8 +123,13 @@ type QueryValue<Field extends QueryField> = QueryValues[Field['type']] | (Field
95
123
  } ? null : never);
96
124
  type QueryRow<Projections extends QueryProjections> = { -readonly [Name in keyof Projections]: QueryValue<Projections[Name]>; };
97
125
  type QueryParameterValue = string | number | boolean | null;
98
- /** Typed scalar parameters with optional fallback values. */
99
- type QueryParameter = { [Type in QueryValueType]: {
126
+ /** Typed scalar or datetime-range parameters with optional fallback values. */
127
+ type QueryParameter = {
128
+ type: 'dateTimeRange';
129
+ nullable?: false;
130
+ /** Absolute defaults may use canonical UTC ISO strings (including milliseconds) for static manifests. Snapshots hydrate them into Dates. */
131
+ defaultValue?: { [Bound in keyof DateTimeRange]: DateTimeRange[Bound] | string; };
132
+ } | { [Type in QueryValueType]: {
100
133
  type: Type;
101
134
  nullable?: false;
102
135
  defaultValue?: QueryValues[Type];
@@ -106,7 +139,9 @@ type QueryParameter = { [Type in QueryValueType]: {
106
139
  defaultValue?: QueryValues[Type] | null;
107
140
  }; }[QueryValueType];
108
141
  /** Callers may omit values supplied by host context or declaration defaults. */
109
- type QueryInputParameters<Params extends Readonly<Record<string, QueryParameter>>> = { [Name in keyof Params]?: QueryValue<Params[Name]>; };
142
+ type QueryInputParameters<Params extends Readonly<Record<string, QueryParameter>>> = { [Name in keyof Params]?: Params[Name] extends {
143
+ type: 'dateTimeRange';
144
+ } ? DateTimeRange : Params[Name] extends QueryField ? QueryValue<Params[Name]> : never; };
110
145
  type QueryDefinition = {
111
146
  statement: string;
112
147
  params: Readonly<Record<string, QueryParameter>>;
@@ -115,7 +150,10 @@ type QueryDefinition = {
115
150
  type QueryDefinitions = Readonly<Record<string, QueryDefinition>>;
116
151
  type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
117
152
  type KnownRecord<RecordType> = '__proto__' extends keyof RecordType ? never : string extends keyof RecordType ? never : Exclude<keyof RecordType, string> extends never ? true extends IsUnion<RecordType> ? never : RecordType : never;
118
- type CheckedField<Field extends QueryField> = true extends IsUnion<Field> ? never : true extends IsUnion<Field['type']> ? never : 'nullable' extends keyof Field ? Field extends {
153
+ type CheckedField<Field extends {
154
+ type: string;
155
+ nullable?: boolean;
156
+ }> = true extends IsUnion<Field> ? never : true extends IsUnion<Field['type']> ? never : 'nullable' extends keyof Field ? Field extends {
119
157
  nullable: infer Nullable;
120
158
  } ? boolean extends Nullable ? never : Field : never : Field;
121
159
  type CheckedParameters<Params extends Readonly<Record<string, QueryParameter>>> = KnownRecord<Params> & { [Name in keyof Params]: CheckedField<Params[Name]> & ('defaultValue' extends keyof Params[Name] ? undefined extends Params[Name]['defaultValue'] ? never : Params[Name] : Params[Name]); };
@@ -126,7 +164,12 @@ type CheckedQueries<Queries extends QueryDefinitions> = KnownRecord<Queries> & (
126
164
  params: CheckedParameters<Queries[Name]['params']>;
127
165
  projections: CheckedProjections<Queries[Name]['projections']>;
128
166
  }; };
129
- type FrozenField<Field extends QueryField> = Field extends unknown ? Readonly<Field> : never;
167
+ type FrozenField<Field extends {
168
+ type: string;
169
+ nullable?: boolean;
170
+ }> = Field extends {
171
+ type: 'dateTimeRange';
172
+ } ? Readonly<{ [Key in keyof Field]: Key extends 'defaultValue' ? DateTimeRange : Field[Key]; }> : Field extends unknown ? Readonly<Field> : never;
130
173
  type QuerySnapshot<Queries extends QueryDefinitions> = { readonly [Name in keyof Queries]: {
131
174
  readonly statement: Queries[Name]['statement'];
132
175
  readonly params: { readonly [Param in keyof Queries[Name]['params']]: FrozenField<Queries[Name]['params'][Param]>; };
@@ -135,27 +178,72 @@ type QuerySnapshot<Queries extends QueryDefinitions> = { readonly [Name in keyof
135
178
  /** Parameters are scalar SQL values, never identifiers or SQL fragments. */
136
179
  type QueryParameters = Readonly<Record<string, QueryParameterValue>>;
137
180
  //#endregion
138
- //#region src/core/date-range.d.ts
139
- /** ISO calendar dates; the app operation defines timezone and inclusive bounds. */
140
- type DateRange = {
141
- start: string;
142
- end: string;
143
- };
144
- type DatePresetId = 'day' | 'last-3' | 'last-7' | 'last-14' | 'last-30' | 'last-90' | 'this-week' | 'previous-week' | 'this-month' | 'previous-month';
145
- type DatePreset = {
146
- id: DatePresetId;
181
+ //#region src/core/date-time-variable.d.ts
182
+ /** A picker suggestion. Text ranges use the same natural-language parser as typed input. */
183
+ type DateTimeRangePreset = {
184
+ /** Menu label, also shown when this preset matches the selected range. */
147
185
  label: string;
148
- range: DateRange;
186
+ range: DateTimeRange | string;
187
+ /** Optional compact badge, for example "15m". */
188
+ shortcut?: string;
149
189
  };
150
- declare function inclusiveDays(range: DateRange): number;
151
- declare function withinBounds(range: DateRange, minDate?: string, maxDate?: string, maxRangeDays?: number): boolean;
152
- /** Only offer ranges the app says it can query. Dates and range lengths are inclusive. */
153
- declare function availableDatePresets({ minDate, maxDate, maxRangeDays, timeZone }: {
154
- minDate?: string;
155
- maxDate?: string;
190
+ /** Monitoring offers minute/hour windows; analytics offers longer periods and to-date windows. Spread either menu to add custom presets. */
191
+ declare const dateTimeRangePresets: {
192
+ readonly monitoring: readonly DateTimeRangePreset[];
193
+ readonly analytics: readonly DateTimeRangePreset[];
194
+ };
195
+ type DateTimeRangeVariableOptions = {
196
+ key: string;
197
+ label?: string;
198
+ /** Enable the previous-period reporting workflow. Requires a shared contract. */
199
+ allowComparison?: false;
200
+ /** Relative defaults such as "7d" stay relative. */
201
+ defaultValue: DateTimeRange | string;
202
+ /** Client limit for determinate durations; the backend must validate timezone-dependent ranges. */
203
+ maxRangeDays?: number;
204
+ /** Shared reporting coverage, timezone, duration limits, and comparison policy. */
205
+ contract?: DateRangeContract;
206
+ /** Suggestions in display order. Omit for defaults; [] retains calendar and text entry.
207
+ * Invalid or over-limit suggestions are omitted; typed input is not restricted to the menu.
208
+ */
209
+ presets?: readonly DateTimeRangePreset[];
210
+ history?: HistoryMode;
211
+ presentation?: VariablePresentation;
212
+ };
213
+ type DateTimeRangeVariable = AppVariable<DateTimeRange, 'dateTimeRange'> & {
214
+ parse: (value: unknown) => DateTimeRange;
156
215
  maxRangeDays?: number;
157
- timeZone?: string;
158
- }): DatePreset[];
216
+ /** Shared reporting coverage, timezone, duration limits, and comparison policy. */
217
+ contract?: DateRangeContract;
218
+ presets?: readonly DateTimeRangePreset[];
219
+ };
220
+ type DateTimeRangeComparisonSelection = {
221
+ range: DateTimeRange;
222
+ comparison?: 'previous';
223
+ };
224
+ /** An execution snapshot with the relative selection retained for URL and displayed-scope matching. */
225
+ type DateTimeRangeComparisonRequest = DateTimeRangeRequest & {
226
+ selection: DateTimeRangeComparisonSelection;
227
+ reference: string;
228
+ };
229
+ type DateTimeRangeComparisonVariableOptions = Omit<DateTimeRangeVariableOptions, 'allowComparison' | 'contract'> & {
230
+ allowComparison: true;
231
+ contract: DateRangeContract;
232
+ };
233
+ type DateTimeRangeComparisonVariable = AppVariable<DateTimeRangeComparisonSelection, 'dateTimeRangeComparison'> & {
234
+ contract: DateRangeContract;
235
+ maxRangeDays?: number;
236
+ presets?: readonly DateTimeRangePreset[];
237
+ input: (selection: DateTimeRangeComparisonSelection, now?: Date) => DateTimeRangeComparisonRequest;
238
+ parseInput: (value: unknown) => DateTimeRangeComparisonRequest;
239
+ previous: (selection: DateTimeRangeComparisonSelection) => DateTimeRangeRequest['comparison'];
240
+ };
241
+ /** One declaration drives the picker, URL state, and operation input.
242
+ * With comparison enabled, use input(defaultValue) for operation checks and variableInput()
243
+ * to validate request snapshots. Query the resulting range and optional comparison bounds.
244
+ */
245
+ declare function dateTimeRangeVariable(options: DateTimeRangeComparisonVariableOptions): DateTimeRangeComparisonVariable;
246
+ declare function dateTimeRangeVariable(options: DateTimeRangeVariableOptions): DateTimeRangeVariable;
159
247
  //#endregion
160
248
  //#region src/core/dimension-source.d.ts
161
249
  declare const dimensionSource: unique symbol;
@@ -165,10 +253,9 @@ type SourceDimensionVariable<Value extends DimensionValue> = DimensionSelectionV
165
253
  readonly operation: string;
166
254
  };
167
255
  };
168
- /** Validate named variable values at the operation boundary. Date inputs belong to the base parser. */
169
- declare function variableInput<Input extends object, const Variables extends VariableCollection>(parse: (value: unknown) => Input, variables: Variables & { [Key in keyof Variables]: Variables[Key] extends {
170
- kind: 'dateRange';
171
- } ? never : Variables[Key]; }): (value: unknown) => Input & AppVariableValues<Variables>;
256
+ type ParsedVariableValues<Variables extends VariableCollection> = { [Key in keyof Variables]: Variables[Key] extends DateTimeRangeComparisonVariable ? DateTimeRangeComparisonRequest : AppVariableValues<Variables>[Key]; };
257
+ /** Validate named variable values at the operation boundary. */
258
+ declare function variableInput<Input extends object, const Variables extends VariableCollection>(parse: (value: unknown) => Input, variables: Variables): (value: unknown) => Input & ParsedVariableValues<Variables>;
172
259
  type DimensionSourceConfig<Type extends 'string' | 'number'> = DimensionSettings & {
173
260
  allowMissing?: false;
174
261
  valueType: Type;
@@ -281,7 +368,7 @@ type AppVariable<Value, Kind extends string = string> = {
281
368
  valid: (value: Value) => boolean;
282
369
  same: (left: Value, right: Value) => boolean;
283
370
  };
284
- type VariableCollection = Record<string, SearchVariable | ChoiceVariable<any> | MultiChoiceVariable | DateRangeVariable | DimensionVariable<any> | FacetVariable<any, any, string, unknown> | SourceDimensionVariable<any> | NumberFilter | BooleanFilter>;
371
+ type VariableCollection = Record<string, SearchVariable | ChoiceVariable<any> | MultiChoiceVariable | DateTimeRangeVariable | DateTimeRangeComparisonVariable | DimensionVariable<any> | FacetVariable<any, any, string, unknown> | SourceDimensionVariable<any> | NumberFilter | BooleanFilter>;
285
372
  type AppVariableValues<Variables> = { [Key in keyof Variables]: Variables[Key] extends DimensionSelectionVariable<infer Value> ? DimensionSelection<Value> : Variables[Key] extends AppVariable<infer Value, string> ? Value : never; };
286
373
  /** Keep conditional declarations narrowed so every dependency has one contract. */
287
374
  type CheckedVariableDeclarations<Variables extends VariableCollection> = true extends IsUnion<Variables> ? never : string extends keyof Variables ? Variables : '__proto__' extends keyof Variables ? never : { [Name in keyof Variables]: true extends IsUnion<Variables[Name]> ? never : Variables[Name]; };
@@ -334,46 +421,6 @@ declare function multiChoiceVariable<const Options extends readonly ChoiceOption
334
421
  }): MultiChoiceVariable & {
335
422
  presentation?: Presentation;
336
423
  };
337
- type DateRangeSelection = {
338
- kind: 'preset';
339
- id: DatePresetId;
340
- comparison?: 'previous';
341
- } | {
342
- kind: 'dates';
343
- start: string;
344
- end: string;
345
- comparison?: 'previous';
346
- };
347
- type DateRangeVariableOptions = {
348
- label?: string;
349
- /** URL key for a relative preset; explicit dates use start/end for period, otherwise key-prefixed fields. */
350
- key: string;
351
- defaultValue: DateRangeSelection & {
352
- comparison?: never;
353
- };
354
- contract: DateRangeContract;
355
- history?: HistoryMode;
356
- /** Opt into a URL-backed comparison with the preceding equal-length range. */
357
- comparison?: boolean;
358
- presentation?: VariablePresentation;
359
- };
360
- type DateRangeVariable = AppVariable<DateRangeSelection, 'dateRange'> & {
361
- kind: 'dateRange';
362
- supportsComparison: boolean;
363
- input: (selection: DateRangeSelection) => DateRangeRequest;
364
- describeInput: (input: DateRangeRequest) => string;
365
- bounds: () => {
366
- minDate?: string;
367
- maxDate: string;
368
- maxRangeDays: number;
369
- timeZone: string;
370
- };
371
- resolve: (selection: DateRangeSelection) => DateRange;
372
- previous: (selection: DateRangeSelection) => DateRange | null;
373
- comparisonRange: (selection: DateRangeSelection) => DateRange | null;
374
- };
375
- /** A date variable keeps relative presets relative and validates exact dates against source coverage. */
376
- declare function dateRangeVariable({ key, label, defaultValue, contract, history, comparison, presentation }: DateRangeVariableOptions): DateRangeVariable;
377
424
  //#endregion
378
425
  //#region src/core/facets.d.ts
379
426
  /** Executable facet sources are attached only by the typed hooks factory. */
@@ -462,12 +509,6 @@ declare function dimensionPredicate<T extends DimensionValue, const Columns exte
462
509
  //#region src/authoring/contract.d.ts
463
510
  declare function parseEmptyInput(value: unknown): Record<string, never>;
464
511
  declare function parseTrue(value: unknown): true;
465
- type DateRangeRequest = {
466
- range: DateRange;
467
- comparison: DateRange | null;
468
- };
469
- /** The immediately preceding, equally long set of calendar days. */
470
- declare function previousDateRange({ start, end }: DateRange): DateRange;
471
512
  type ReportingPeriod = {
472
513
  kind: 'rolling';
473
514
  amount: number;
@@ -484,34 +525,32 @@ type DateRangeContractOptions = {
484
525
  maxDate?: string | (() => string);
485
526
  maxRangeDays: number;
486
527
  timeZone: string;
528
+ /** Defaults to complete days through yesterday in the reporting timezone. Set false to include today. */
487
529
  completeDays?: boolean;
488
530
  };
489
- /** One source policy for the server parser, URL variable, and displayed reporting period. */
490
- declare function defineDateRangeContract(options: DateRangeContractOptions): {
491
- request: (value: unknown, compare?: boolean) => DateRangeRequest;
492
- parseRequest: (value: unknown) => DateRangeRequest;
493
- bounds: () => {
531
+ /** One source policy for datetime picker validation and operation requests. */
532
+ declare function defineDateRangeContract({ minDate, maxDate, maxRangeDays, timeZone, completeDays }: DateRangeContractOptions): {
533
+ datetime: {
534
+ timeZone: string;
535
+ bounds: (now?: Date) => {
536
+ minDate: string | undefined;
537
+ maxDate: string;
538
+ maxRangeDays: number;
539
+ timeZone: string;
540
+ };
541
+ parse: (value: unknown, now?: Date) => DateTimeRange;
542
+ resolve: (value: unknown, now?: Date) => DateTimeRangeRequest['range'];
543
+ comparison: (value: unknown, now?: Date) => DateTimeRangeRequest['comparison'];
544
+ request(value: unknown, compare?: boolean, now?: Date): DateTimeRangeRequest;
545
+ };
546
+ bounds: (now?: Date) => {
494
547
  minDate: string | undefined;
495
548
  maxDate: string;
496
549
  maxRangeDays: number;
497
550
  timeZone: string;
498
551
  };
499
- parse(value: unknown): DateRange;
500
- period: ({ start, end }: DateRange) => ReportingPeriod;
501
- comparison: (input: DateRange) => DateRange | null;
502
- describeInput: (input: DateRange) => string;
503
- view: {
504
- period: ({ start, end }: DateRange) => ReportingPeriod;
505
- describeInput: (input: DateRange) => string;
506
- };
507
552
  };
508
553
  type DateRangeContract = ReturnType<typeof defineDateRangeContract>;
509
- /** Validate calendar dates and a bounded inclusive range on the server. */
510
- declare function parseDateRangeInput(value: unknown, { minDate, maxDate, maxRangeDays }: {
511
- minDate?: string;
512
- maxDate?: string;
513
- maxRangeDays: number;
514
- }): DateRange;
515
554
  /** Accepts numeric strings from DuckDB; rejects negative, fractional, and unsafe integers. */
516
555
  declare function parseCount(value: unknown): number;
517
556
  declare function parseLabel(value: unknown, maxLength?: number): string;
@@ -546,175 +585,5 @@ declare function connectionCheck<const Queries extends QueryDefinitions & {
546
585
  connection: QueryDefinitions[string];
547
586
  }>(queries: CheckedQueries<Queries>): ConnectionOperation;
548
587
  //#endregion
549
- //#region src/core/messages.d.ts
550
- type MessageContext = {
551
- signal: AbortSignal;
552
- };
553
- type RoutedMessage = {
554
- route: string;
555
- payload: unknown;
556
- };
557
- type MessageDispatcher = (message: unknown, context: MessageContext) => Promise<unknown>;
558
- type MessageTransport = (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
559
- type MessageRoute<Input, Output> = {
560
- input: (value: unknown) => Input;
561
- output: (value: unknown, input: Input) => Output;
562
- };
563
- type MessageRoutes = Record<string, {
564
- input: (value: unknown) => unknown;
565
- output: (value: unknown, input: never) => unknown;
566
- }>;
567
- type MessageInput<Route extends MessageRoutes[string]> = ReturnType<Route['input']>;
568
- type MessageHandlers<Routes extends MessageRoutes> = { [Name in keyof Routes]: (payload: MessageInput<Routes[Name]>, context: MessageContext) => ReturnType<Routes[Name]['output']> | Promise<ReturnType<Routes[Name]['output']>>; };
569
- declare const errorBrand: unique symbol;
570
- /** Only these deliberate, public failures cross the message boundary. Other errors stay private. */
571
- declare class MessageRoutingError extends Error {
572
- readonly code: string;
573
- readonly requestId?: string | undefined;
574
- readonly [errorBrand] = true;
575
- static [Symbol.hasInstance](value: unknown): boolean;
576
- constructor(code: string, message: string, requestId?: string | undefined,
577
- /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */
578
- options?: ErrorOptions);
579
- }
580
- declare function defineMessageRoute<Input, Output>(route: MessageRoute<Input, Output>): MessageRoute<Input, Output>;
581
- /** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */
582
- declare function createMessageRouter<const Routes extends MessageRoutes>(routes: Routes, handlers: MessageHandlers<NoInfer<Routes>>): {
583
- dispatch: (value: unknown, context: MessageContext) => Promise<unknown>;
584
- };
585
- type DataQueryRoute<Operations extends OperationContracts> = MessageRoute<DataQueryInput<Operations>, TransportResponse> & {
586
- operations: Operations | undefined;
587
- };
588
- type MessageOutput<Route extends MessageRoutes[string], Input> = Route extends DataQueryRoute<infer Operations> ? Input extends {
589
- operation: infer Name extends keyof Operations;
590
- } ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>> : never : ReturnType<Route['output']>;
591
- /** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */
592
- declare function defineDataQueryRoute<Operations extends OperationContracts = OperationContracts>(operations?: Operations): DataQueryRoute<Operations>;
593
- declare const navigationUpdateRoute: MessageRoute<NavigationUpdate, null>;
594
- type SqlQueryInput = {
595
- statement: string;
596
- limit: number;
597
- params?: QueryParameters;
598
- };
599
- /** SQL delivery for browser-owned operations. Hosts must enforce backend access and resource limits. */
600
- declare const sqlQueryRoute: MessageRoute<SqlQueryInput, QueryResult>;
601
- declare const dataAppRoutes: {
602
- 'data:query': DataQueryRoute<OperationContracts>;
603
- 'navigation:update': MessageRoute<NavigationUpdate, null>;
604
- };
605
- //#endregion
606
- //#region src/core/annotations.d.ts
607
- type DataAppAnnotationDraft = {
608
- id: string;
609
- target: {
610
- id: string;
611
- label: string;
612
- kind: 'widget' | 'element' | 'app';
613
- text: string;
614
- queryNames: string[];
615
- glossaryIds: string[];
616
- };
617
- context: {
618
- search: string;
619
- hash: string;
620
- displayedInput?: unknown;
621
- /** Normalized position within the selected target, stable across scrolling/resizing. */
622
- anchor?: {
623
- x: number;
624
- y: number;
625
- };
626
- cursor?: {
627
- x: number;
628
- y: number;
629
- };
630
- /** Normalized custom selection rectangle within the iframe document. */
631
- region?: {
632
- x: number;
633
- y: number;
634
- width: number;
635
- height: number;
636
- };
637
- screenshot?: {
638
- mimeType: 'image/png';
639
- dataUrl: string;
640
- width: number;
641
- height: number;
642
- };
643
- view?: string;
644
- viewport: {
645
- width: number;
646
- height: number;
647
- };
648
- rect: {
649
- x: number;
650
- y: number;
651
- width: number;
652
- height: number;
653
- };
654
- };
655
- comment: string;
656
- };
657
- type DataAppAnnotationPresentation = {
658
- enabled: boolean;
659
- /** When provided, the host owns the mode and renders the annotation trigger. */
660
- active?: boolean;
661
- pinsVisible?: boolean;
662
- showHint?: boolean;
663
- readOnly?: boolean;
664
- targets?: {
665
- id: string;
666
- targetId: string;
667
- number: number;
668
- comment?: string;
669
- anchor?: {
670
- x: number;
671
- y: number;
672
- };
673
- region?: {
674
- x: number;
675
- y: number;
676
- width: number;
677
- height: number;
678
- };
679
- }[];
680
- selectedAnnotationId?: string;
681
- selectedTargetId?: string;
682
- selectionId?: string;
683
- /** Confirmed host click outside the iframe; occurredAt is epoch milliseconds. */
684
- dismissal?: {
685
- id: string;
686
- occurredAt: number;
687
- };
688
- };
689
- /** Reconstruct at the boundary; discard extra fields and bound the entire JSON payload. */
690
- declare function parseDataAppAnnotationDraft(value: unknown): DataAppAnnotationDraft;
691
- declare const annotationDraftRoute: MessageRoute<DataAppAnnotationDraft, null>;
692
- declare const annotationEditorStateRoute: MessageRoute<{
693
- hasUnsavedChanges: boolean;
694
- }, null>;
695
- /** Request host-owned batch submission without transferring ownership of drafts. */
696
- declare const annotationSendRoute: MessageRoute<null, null>;
697
- declare const annotationUpdateRoute: MessageRoute<{
698
- id: string;
699
- comment: string;
700
- }, null>;
701
- /** A controlled shell acknowledges local exits (for example Escape). */
702
- declare const annotationModeRoute: MessageRoute<{
703
- active: boolean;
704
- }, null>;
705
- //#endregion
706
- //#region src/core/contract.d.ts
707
- declare const sourceErrorBrand: unique symbol;
708
- declare class DataSourceError extends Error {
709
- readonly reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable';
710
- readonly status?: number | undefined;
711
- readonly [sourceErrorBrand] = true;
712
- queryName?: string;
713
- static [Symbol.hasInstance](value: unknown): boolean;
714
- constructor(reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable', status?: number | undefined,
715
- /** `cause` stays on the server or host for logs; responses carry only the reason. */
716
- options?: ErrorOptions);
717
- }
718
- //#endregion
719
- export { createDimensionFilter as $, QueryDefinitions as $t, DateRangeContractOptions as A, BooleanSelection as At, parseDateRangeInput as B, DimensionSourceQueryName as Bt, dataAppRoutes as C, multiChoiceVariable as Ct, sqlQueryRoute as D, HistoryMode as Dt, navigationUpdateRoute as E, AppLocation as Et, connectionCheck as F, numberFilter as Ft, DimensionFilterOptions as G, DatePresetId as Gt, parseLabel as H, dimensionSource as Ht, defineDateRangeContract as I, numberOperatorLabels as It, DimensionOption as J, inclusiveDays as Jt, DimensionFilterSettings as K, DateRange as Kt, defineOperation as L, parseBooleanSelection as Lt, OperationDefinition as M, NumberOperator as Mt, RegisteredQuery as N, NumberSelection as Nt, ConnectionOperation as O, NavigationUpdate as Ot, ReportingPeriod as P, booleanFilter as Pt, DimensionVariable as Q, KnownRecord as Qt, defineQueryNames as R, parseNumberSelection as Rt, createMessageRouter as S, defineAppVariables as St, defineMessageRoute as T, validateChoiceOptions as Tt, parseTrue as U, variableInput as Ut, parseEmptyInput as V, SourceDimensionVariable as Vt, previousDateRange as W, DatePreset as Wt, DimensionSelectionVariable as X, CheckedQueries as Xt, DimensionSelection as Y, withinBounds as Yt, DimensionValue as Z, IsUnion as Zt, MessageRoutes as _, OutputOf as _n, SearchVariable as _t, annotationEditorStateRoute as a, QueryRow as an, FacetVariable as at, RoutedMessage as b, choiceVariable as bt, annotationUpdateRoute as c, DataOperation as cn, AppVariableValues as ct, MessageContext as d, DataQueryInput as dn, ChoiceOption as dt, QueryField as en, dimensionFilter as et, MessageDispatcher as f, DisclosedQuery as fn, ChoiceVariable as ft, MessageRoute as g, OperationContracts as gn, MultiChoiceVariable as gt, MessageOutput as h, OperationContext as hn, DateRangeVariableOptions as ht, annotationDraftRoute as i, QueryProjections as in, parseFacetOptions as it, DateRangeRequest as j, NumberFilter as jt, DateRangeContract as k, BooleanFilter as kt, parseDataAppAnnotationDraft as l, DataOperations as ln, CheckedFacetContexts as lt, MessageInput as m, Lakehouse as mn, DateRangeVariable as mt, DataAppAnnotationDraft as n, QueryParameterValue as nn, dimensionPredicate as nt, annotationModeRoute as o, QuerySnapshot as on, facetSource as ot, MessageHandlers as p, InputOf as pn, DateRangeSelection as pt, DimensionMember as q, availableDatePresets as qt, DataAppAnnotationPresentation as r, QueryParameters as rn, parseDimensionSelection as rt, annotationSendRoute as s, QueryValueType as sn, AppVariable as st, DataSourceError as t, QueryParameter as tn, dimensionMemberKey as tt, DataQueryRoute as u, DataQueryBody as un, CheckedVariableDeclarations as ut, MessageRoutingError as v, QueryResult as vn, VariableCollection as vt, defineDataQueryRoute as w, searchVariable as wt, SqlQueryInput as x, dateRangeVariable as xt, MessageTransport as y, TransportResponse as yn, VariablePresentation as yt, parseCount as z, DimensionSourceConfig as zt };
588
+ export { NumberSelection as $, facetSource as A, QuerySnapshot as At, VariablePresentation as B, OperationContracts as Bt, createDimensionFilter as C, QueryDefinitions as Ct, parseDimensionSelection as D, QueryParameters as Dt, dimensionPredicate as E, QueryParameterValue as Et, ChoiceOption as F, DataQueryInput as Ft, validateChoiceOptions as G, DateTimeRangeRequest as Gt, defineAppVariables as H, QueryResult as Ht, ChoiceVariable as I, DisclosedQuery as It, NavigationUpdate as J, AppLocation as K, MultiChoiceVariable as L, InputOf as Lt, AppVariableValues as M, DataOperation as Mt, CheckedFacetContexts as N, DataOperations as Nt, parseFacetOptions as O, QueryProjections as Ot, CheckedVariableDeclarations as P, DataQueryBody as Pt, NumberOperator as Q, SearchVariable as R, Lakehouse as Rt, DimensionVariable as S, MAX_QUERY_ROWS as St, dimensionMemberKey as T, QueryParameter as Tt, multiChoiceVariable as U, TransportResponse as Ut, choiceVariable as V, OutputOf as Vt, searchVariable as W, DateTimeRangeContract as Wt, BooleanSelection as X, BooleanFilter as Y, NumberFilter as Z, DimensionMember as _, dateTimeRangePresets as _t, RegisteredQuery as a, DimensionSourceConfig as at, DimensionSelectionVariable as b, IsUnion as bt, defineDateRangeContract as c, dimensionSource as ct, parseCount as d, DateTimeRangeComparisonSelection as dt, booleanFilter as et, parseEmptyInput as f, DateTimeRangeComparisonVariable as ft, DimensionFilterSettings as g, DateTimeRangeVariableOptions as gt, DimensionFilterOptions as h, DateTimeRangeVariable as ht, OperationDefinition as i, parseNumberSelection as it, AppVariable as j, QueryValueType as jt, FacetVariable as k, QueryRow as kt, defineOperation as l, variableInput as lt, parseTrue as m, DateTimeRangePreset as mt, DateRangeContract as n, numberOperatorLabels as nt, ReportingPeriod as o, DimensionSourceQueryName as ot, parseLabel as p, DateTimeRangeComparisonVariableOptions as pt, HistoryMode as q, DateRangeContractOptions as r, parseBooleanSelection as rt, connectionCheck as s, SourceDimensionVariable as st, ConnectionOperation as t, numberFilter as tt, defineQueryNames as u, DateTimeRangeComparisonRequest as ut, DimensionOption as v, dateTimeRangeVariable as vt, dimensionFilter as w, QueryField as wt, DimensionValue as x, KnownRecord as xt, DimensionSelection as y, CheckedQueries as yt, VariableCollection as z, OperationContext as zt };
720
589
  //# sourceMappingURL=contract.d.ts.map