@altertable/data-app 0.75.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 (38) hide show
  1. package/README.md +56 -9
  2. package/REFERENCE.md +25 -79
  3. package/dist/chunks/{contract-B3s0ybE2.js → contract-DsyRYgN_.js} +6 -83
  4. package/dist/chunks/contract-DsyRYgN_.js.map +1 -0
  5. package/dist/chunks/{contract-DcPjfm0R.js → contract-kNFYPHRK.js} +3 -3
  6. package/dist/chunks/{contract-DcPjfm0R.js.map → contract-kNFYPHRK.js.map} +1 -1
  7. package/dist/chunks/{format-5hMYUWk3.js → date-time-range-value-TE8KCsfV.js} +2 -147
  8. package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +1 -0
  9. package/dist/chunks/{diagnostics-DVwQ5PDK.js → diagnostics-DhCqGklq.js} +2 -2
  10. package/dist/chunks/{diagnostics-DVwQ5PDK.js.map → diagnostics-DhCqGklq.js.map} +1 -1
  11. package/dist/chunks/{operation-CGuN7Zcb.js → operation-7tiT4cpJ.js} +3 -3
  12. package/dist/chunks/{operation-CGuN7Zcb.js.map → operation-7tiT4cpJ.js.map} +1 -1
  13. package/dist/client/index.js +4 -4
  14. package/dist/core/config.js +1 -1
  15. package/dist/core/contract.js +4 -4
  16. package/dist/core/format.js +149 -1
  17. package/dist/core/format.js.map +1 -0
  18. package/dist/internal.js +6 -190
  19. package/dist/internal.js.map +1 -1
  20. package/dist/server/index.js +3 -3
  21. package/dist/types/chunks/contract.d.ts +6 -295
  22. package/dist/types/chunks/contract2.d.ts +207 -0
  23. package/dist/types/chunks/date-time-range-value.d.ts +2 -28
  24. package/dist/types/chunks/date-time-range.d.ts +29 -0
  25. package/dist/types/chunks/index.d.ts +2 -1
  26. package/dist/types/client/index.d.ts +1 -1
  27. package/dist/types/core/config.d.ts +2 -2
  28. package/dist/types/core/contract.d.ts +5 -3
  29. package/dist/types/core/format.d.ts +2 -1
  30. package/dist/types/index.d.ts +2 -2
  31. package/dist/types/internal.d.ts +6 -4
  32. package/dist/types/server/index.d.ts +1 -1
  33. package/docs/contract.md +3 -2
  34. package/docs/ui.md +1 -1
  35. package/docs/variables.md +22 -11
  36. package/package.json +16 -5
  37. package/dist/chunks/contract-B3s0ybE2.js.map +0 -1
  38. package/dist/chunks/format-5hMYUWk3.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { c as DateTimeRange, p as ResolvedDateTimeRange } from "./date-time-range-value.js";
1
+ import { n as DateTimeRange, s as ResolvedDateTimeRange } from "./date-time-range.js";
2
2
  //#region src/core/date-time-range-contract.d.ts
3
3
  /** Resolved UTC-rebased bounds for one execution, optionally with the preceding equal-length interval. */
4
4
  type DateTimeRangeRequest = {
@@ -178,28 +178,6 @@ type QuerySnapshot<Queries extends QueryDefinitions> = { readonly [Name in keyof
178
178
  /** Parameters are scalar SQL values, never identifiers or SQL fragments. */
179
179
  type QueryParameters = Readonly<Record<string, QueryParameterValue>>;
180
180
  //#endregion
181
- //#region src/core/date-range.d.ts
182
- /** ISO calendar dates; the app operation defines timezone and inclusive bounds. */
183
- type DateRange = {
184
- start: string;
185
- end: string;
186
- };
187
- type DatePresetId = 'day' | 'last-3' | 'last-7' | 'last-14' | 'last-30' | 'last-90' | 'this-week' | 'previous-week' | 'this-month' | 'previous-month';
188
- type DatePreset = {
189
- id: DatePresetId;
190
- label: string;
191
- range: DateRange;
192
- };
193
- declare function inclusiveDays(range: DateRange): number;
194
- declare function withinBounds(range: DateRange, minDate?: string, maxDate?: string, maxRangeDays?: number): boolean;
195
- /** Only offer ranges the app says it can query. Dates and range lengths are inclusive. */
196
- declare function availableDatePresets({ minDate, maxDate, maxRangeDays, timeZone }: {
197
- minDate?: string;
198
- maxDate?: string;
199
- maxRangeDays?: number;
200
- timeZone?: string;
201
- }): DatePreset[];
202
- //#endregion
203
181
  //#region src/core/date-time-variable.d.ts
204
182
  /** A picker suggestion. Text ranges use the same natural-language parser as typed input. */
205
183
  type DateTimeRangePreset = {
@@ -276,10 +254,8 @@ type SourceDimensionVariable<Value extends DimensionValue> = DimensionSelectionV
276
254
  };
277
255
  };
278
256
  type ParsedVariableValues<Variables extends VariableCollection> = { [Key in keyof Variables]: Variables[Key] extends DateTimeRangeComparisonVariable ? DateTimeRangeComparisonRequest : AppVariableValues<Variables>[Key]; };
279
- /** Validate named variable values at the operation boundary. Date inputs belong to the base parser. */
280
- declare function variableInput<Input extends object, const Variables extends VariableCollection>(parse: (value: unknown) => Input, variables: Variables & { [Key in keyof Variables]: Variables[Key] extends {
281
- kind: 'dateRange';
282
- } ? never : Variables[Key]; }): (value: unknown) => Input & ParsedVariableValues<Variables>;
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>;
283
259
  type DimensionSourceConfig<Type extends 'string' | 'number'> = DimensionSettings & {
284
260
  allowMissing?: false;
285
261
  valueType: Type;
@@ -392,7 +368,7 @@ type AppVariable<Value, Kind extends string = string> = {
392
368
  valid: (value: Value) => boolean;
393
369
  same: (left: Value, right: Value) => boolean;
394
370
  };
395
- type VariableCollection = Record<string, SearchVariable | ChoiceVariable<any> | MultiChoiceVariable | DateRangeVariable | DateTimeRangeVariable | DateTimeRangeComparisonVariable | 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>;
396
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; };
397
373
  /** Keep conditional declarations narrowed so every dependency has one contract. */
398
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]; };
@@ -445,46 +421,6 @@ declare function multiChoiceVariable<const Options extends readonly ChoiceOption
445
421
  }): MultiChoiceVariable & {
446
422
  presentation?: Presentation;
447
423
  };
448
- type DateRangeSelection = {
449
- kind: 'preset';
450
- id: DatePresetId;
451
- comparison?: 'previous';
452
- } | {
453
- kind: 'dates';
454
- start: string;
455
- end: string;
456
- comparison?: 'previous';
457
- };
458
- type DateRangeVariableOptions = {
459
- label?: string;
460
- /** URL key for a relative preset; explicit dates use start/end for period, otherwise key-prefixed fields. */
461
- key: string;
462
- defaultValue: DateRangeSelection & {
463
- comparison?: never;
464
- };
465
- contract: DateRangeContract;
466
- history?: HistoryMode;
467
- /** Opt into a URL-backed comparison with the preceding equal-length range. */
468
- comparison?: boolean;
469
- presentation?: VariablePresentation;
470
- };
471
- type DateRangeVariable = AppVariable<DateRangeSelection, 'dateRange'> & {
472
- kind: 'dateRange';
473
- supportsComparison: boolean;
474
- input: (selection: DateRangeSelection) => DateRangeRequest;
475
- describeInput: (input: DateRangeRequest) => string;
476
- bounds: () => {
477
- minDate?: string;
478
- maxDate: string;
479
- maxRangeDays: number;
480
- timeZone: string;
481
- };
482
- resolve: (selection: DateRangeSelection) => DateRange;
483
- previous: (selection: DateRangeSelection) => DateRange | null;
484
- comparisonRange: (selection: DateRangeSelection) => DateRange | null;
485
- };
486
- /** A date variable keeps relative presets relative and validates exact dates against source coverage. */
487
- declare function dateRangeVariable({ key, label, defaultValue, contract, history, comparison, presentation }: DateRangeVariableOptions): DateRangeVariable;
488
424
  //#endregion
489
425
  //#region src/core/facets.d.ts
490
426
  /** Executable facet sources are attached only by the typed hooks factory. */
@@ -570,25 +506,9 @@ declare function parseFacetOptions<T extends DimensionValue>(value: unknown, fil
570
506
  /** Central SQL literal encoding for transports without bound parameters. Column is an allowlisted identifier. */
571
507
  declare function dimensionPredicate<T extends DimensionValue, const Columns extends readonly string[]>(column: Columns[number], selection: DimensionSelection<T>, allowedColumns: Columns): string;
572
508
  //#endregion
573
- //#region src/core/date-time-range-sql.d.ts
574
- /** DuckDB timestamp expressions using the query session's timezone for relative anchors.
575
- * Absolute fields remain UTC-rebased TIMESTAMP values. Start is inclusive, end exclusive.
576
- */
577
- declare function dateTimeRangeSql(range: DateTimeRange, parameter?: string): {
578
- from: string;
579
- to: string;
580
- params: Record<string, string>;
581
- };
582
- //#endregion
583
509
  //#region src/authoring/contract.d.ts
584
510
  declare function parseEmptyInput(value: unknown): Record<string, never>;
585
511
  declare function parseTrue(value: unknown): true;
586
- type DateRangeRequest = {
587
- range: DateRange;
588
- comparison: DateRange | null;
589
- };
590
- /** The immediately preceding, equally long set of calendar days. */
591
- declare function previousDateRange({ start, end }: DateRange): DateRange;
592
512
  type ReportingPeriod = {
593
513
  kind: 'rolling';
594
514
  amount: number;
@@ -608,7 +528,7 @@ type DateRangeContractOptions = {
608
528
  /** Defaults to complete days through yesterday in the reporting timezone. Set false to include today. */
609
529
  completeDays?: boolean;
610
530
  };
611
- /** One source policy for the server parser, URL variable, and displayed reporting period. */
531
+ /** One source policy for datetime picker validation and operation requests. */
612
532
  declare function defineDateRangeContract({ minDate, maxDate, maxRangeDays, timeZone, completeDays }: DateRangeContractOptions): {
613
533
  datetime: {
614
534
  timeZone: string;
@@ -623,30 +543,14 @@ declare function defineDateRangeContract({ minDate, maxDate, maxRangeDays, timeZ
623
543
  comparison: (value: unknown, now?: Date) => DateTimeRangeRequest['comparison'];
624
544
  request(value: unknown, compare?: boolean, now?: Date): DateTimeRangeRequest;
625
545
  };
626
- request: (value: unknown, compare?: boolean) => DateRangeRequest;
627
- parseRequest: (value: unknown) => DateRangeRequest;
628
546
  bounds: (now?: Date) => {
629
547
  minDate: string | undefined;
630
548
  maxDate: string;
631
549
  maxRangeDays: number;
632
550
  timeZone: string;
633
551
  };
634
- parse(value: unknown): DateRange;
635
- period: ({ start, end }: DateRange) => ReportingPeriod;
636
- comparison: (input: DateRange) => DateRange | null;
637
- describeInput: (input: DateRange) => string;
638
- view: {
639
- period: ({ start, end }: DateRange) => ReportingPeriod;
640
- describeInput: (input: DateRange) => string;
641
- };
642
552
  };
643
553
  type DateRangeContract = ReturnType<typeof defineDateRangeContract>;
644
- /** Validate calendar dates and a bounded inclusive range on the server. */
645
- declare function parseDateRangeInput(value: unknown, { minDate, maxDate, maxRangeDays }: {
646
- minDate?: string;
647
- maxDate?: string;
648
- maxRangeDays: number;
649
- }): DateRange;
650
554
  /** Accepts numeric strings from DuckDB; rejects negative, fractional, and unsafe integers. */
651
555
  declare function parseCount(value: unknown): number;
652
556
  declare function parseLabel(value: unknown, maxLength?: number): string;
@@ -681,198 +585,5 @@ declare function connectionCheck<const Queries extends QueryDefinitions & {
681
585
  connection: QueryDefinitions[string];
682
586
  }>(queries: CheckedQueries<Queries>): ConnectionOperation;
683
587
  //#endregion
684
- //#region src/core/messages.d.ts
685
- type MessageContext = {
686
- signal: AbortSignal;
687
- };
688
- type RoutedMessage = {
689
- route: string;
690
- payload: unknown;
691
- };
692
- type MessageDispatcher = (message: unknown, context: MessageContext) => Promise<unknown>;
693
- type MessageTransport = (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
694
- type MessageRoute<Input, Output> = {
695
- input: (value: unknown) => Input;
696
- output: (value: unknown, input: Input) => Output;
697
- };
698
- type MessageRoutes = Record<string, {
699
- input: (value: unknown) => unknown;
700
- output: (value: unknown, input: never) => unknown;
701
- }>;
702
- type MessageInput<Route extends MessageRoutes[string]> = ReturnType<Route['input']>;
703
- type MessageHandlers<Routes extends MessageRoutes> = { [Name in keyof Routes]: (payload: MessageInput<Routes[Name]>, context: MessageContext) => ReturnType<Routes[Name]['output']> | Promise<ReturnType<Routes[Name]['output']>>; };
704
- declare const errorBrand: unique symbol;
705
- /** Only these deliberate, public failures cross the message boundary. Other errors stay private. */
706
- declare class MessageRoutingError extends Error {
707
- readonly code: string;
708
- readonly requestId?: string | undefined;
709
- readonly [errorBrand] = true;
710
- static [Symbol.hasInstance](value: unknown): boolean;
711
- constructor(code: string, message: string, requestId?: string | undefined,
712
- /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */
713
- options?: ErrorOptions);
714
- }
715
- declare function defineMessageRoute<Input, Output>(route: MessageRoute<Input, Output>): MessageRoute<Input, Output>;
716
- /** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */
717
- declare function createMessageRouter<const Routes extends MessageRoutes>(routes: Routes, handlers: MessageHandlers<NoInfer<Routes>>): {
718
- dispatch: (value: unknown, context: MessageContext) => Promise<unknown>;
719
- };
720
- type DataQueryRoute<Operations extends OperationContracts> = MessageRoute<DataQueryInput<Operations>, TransportResponse> & {
721
- operations: Operations | undefined;
722
- };
723
- type MessageOutput<Route extends MessageRoutes[string], Input> = Route extends DataQueryRoute<infer Operations> ? Input extends {
724
- operation: infer Name extends keyof Operations;
725
- } ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>> : never : ReturnType<Route['output']>;
726
- /** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */
727
- declare function defineDataQueryRoute<Operations extends OperationContracts = OperationContracts>(operations?: Operations): DataQueryRoute<Operations>;
728
- declare const navigationUpdateRoute: MessageRoute<NavigationUpdate, null>;
729
- type SqlQueryInput = {
730
- statement: string;
731
- limit: number;
732
- params?: QueryParameters;
733
- };
734
- /** SQL delivery for browser-owned operations. Hosts must enforce backend access and resource limits. */
735
- declare const sqlQueryRoute: MessageRoute<SqlQueryInput, QueryResult>;
736
- declare const dataAppRoutes: {
737
- 'data:query': DataQueryRoute<OperationContracts>;
738
- 'navigation:update': MessageRoute<NavigationUpdate, null>;
739
- };
740
- //#endregion
741
- //#region src/core/annotations.d.ts
742
- type DataAppAnnotationDraft = {
743
- id: string;
744
- target: {
745
- id: string;
746
- label: string;
747
- kind: 'widget' | 'element' | 'app';
748
- text: string;
749
- queryNames: string[];
750
- glossaryIds: string[];
751
- };
752
- context: {
753
- search: string;
754
- hash: string;
755
- displayedInput?: unknown;
756
- /** Normalized position within the selected target, stable across scrolling/resizing. */
757
- anchor?: {
758
- x: number;
759
- y: number;
760
- };
761
- cursor?: {
762
- x: number;
763
- y: number;
764
- };
765
- /** Normalized custom selection rectangle within the iframe document. */
766
- region?: {
767
- x: number;
768
- y: number;
769
- width: number;
770
- height: number;
771
- };
772
- screenshot?: {
773
- mimeType: 'image/png';
774
- dataUrl: string;
775
- width: number;
776
- height: number;
777
- };
778
- view?: string;
779
- viewport: {
780
- width: number;
781
- height: number;
782
- };
783
- rect: {
784
- x: number;
785
- y: number;
786
- width: number;
787
- height: number;
788
- };
789
- };
790
- comment: string;
791
- };
792
- type DataAppAnnotationPresentation = {
793
- enabled: boolean;
794
- /** When provided, the host owns the mode and renders the annotation trigger. */
795
- active?: boolean;
796
- pinsVisible?: boolean;
797
- showHint?: boolean;
798
- readOnly?: boolean;
799
- targets?: {
800
- id: string;
801
- targetId: string;
802
- number: number;
803
- comment?: string;
804
- anchor?: {
805
- x: number;
806
- y: number;
807
- };
808
- region?: {
809
- x: number;
810
- y: number;
811
- width: number;
812
- height: number;
813
- };
814
- }[];
815
- selectedAnnotationId?: string;
816
- selectedTargetId?: string;
817
- selectionId?: string;
818
- /** Confirmed host click outside the iframe; occurredAt is epoch milliseconds. */
819
- dismissal?: {
820
- id: string;
821
- occurredAt: number;
822
- };
823
- };
824
- /** Reconstruct at the boundary; discard extra fields and bound the entire JSON payload. */
825
- declare function parseDataAppAnnotationDraft(value: unknown): DataAppAnnotationDraft;
826
- declare const annotationDraftRoute: MessageRoute<DataAppAnnotationDraft, null>;
827
- declare const annotationEditorStateRoute: MessageRoute<{
828
- hasUnsavedChanges: boolean;
829
- }, null>;
830
- /** Request host-owned batch submission without transferring ownership of drafts. */
831
- declare const annotationSendRoute: MessageRoute<null, null>;
832
- declare const annotationUpdateRoute: MessageRoute<{
833
- id: string;
834
- comment: string;
835
- }, null>;
836
- /** A controlled shell acknowledges local exits (for example Escape). */
837
- declare const annotationModeRoute: MessageRoute<{
838
- active: boolean;
839
- }, null>;
840
- //#endregion
841
- //#region src/core/external-link.d.ts
842
- /** Absolute HTTPS destinations only; URLs must not contain embedded credentials. */
843
- declare function parseExternalUrl(value: unknown): string;
844
- type ExternalLinkTarget = 'tab' | 'window';
845
- type ExternalLinkModifiers = {
846
- shiftKey: boolean;
847
- metaKey: boolean;
848
- ctrlKey: boolean;
849
- };
850
- type OpenExternalLink = {
851
- url: string;
852
- } & ({
853
- target?: ExternalLinkTarget;
854
- } | {
855
- target: 'event';
856
- keys: ExternalLinkModifiers;
857
- });
858
- type ExternalLinkResult = 'opened' | 'cancelled' | 'ignored';
859
- /** Shift takes precedence over Ctrl/Cmd; an unmodified event requests no navigation. */
860
- declare function resolveExternalLinkTarget(input: OpenExternalLink): ExternalLinkTarget | null;
861
- /** Opt-in host route. Validation does not replace the host's destination policy. */
862
- declare const openExternalLinkRoute: MessageRoute<OpenExternalLink, ExternalLinkResult>;
863
- //#endregion
864
- //#region src/core/contract.d.ts
865
- declare const sourceErrorBrand: unique symbol;
866
- declare class DataSourceError extends Error {
867
- readonly reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable';
868
- readonly status?: number | undefined;
869
- readonly [sourceErrorBrand] = true;
870
- queryName?: string;
871
- static [Symbol.hasInstance](value: unknown): boolean;
872
- constructor(reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable', status?: number | undefined,
873
- /** `cause` stays on the server or host for logs; responses carry only the reason. */
874
- options?: ErrorOptions);
875
- }
876
- //#endregion
877
- export { DimensionFilterOptions as $, DateTimeRangeComparisonSelection as $t, dataAppRoutes as A, DisclosedQuery as An, defineAppVariables as At, RegisteredQuery as B, NumberOperator as Bt, MessageRoute as C, QueryRow as Cn, DateRangeVariableOptions as Ct, RoutedMessage as D, DataOperations as Dn, VariablePresentation as Dt, MessageTransport as E, DataOperation as En, VariableCollection as Et, ConnectionOperation as F, OutputOf as Fn, HistoryMode as Ft, defineQueryNames as G, parseBooleanSelection as Gt, connectionCheck as H, booleanFilter as Ht, DateRangeContract as I, QueryResult as In, NavigationUpdate as It, parseEmptyInput as J, DimensionSourceQueryName as Jt, parseCount as K, parseNumberSelection as Kt, DateRangeContractOptions as L, TransportResponse as Ln, BooleanFilter as Lt, defineMessageRoute as M, Lakehouse as Mn, searchVariable as Mt, navigationUpdateRoute as N, OperationContext as Nn, validateChoiceOptions as Nt, SqlQueryInput as O, DataQueryBody as On, choiceVariable as Ot, sqlQueryRoute as P, OperationContracts as Pn, AppLocation as Pt, dateTimeRangeSql as Q, DateTimeRangeComparisonRequest as Qt, DateRangeRequest as R, DateTimeRangeContract as Rn, BooleanSelection as Rt, MessageOutput as S, QueryProjections as Sn, DateRangeVariable as St, MessageRoutingError as T, QueryValueType as Tn, SearchVariable as Tt, defineDateRangeContract as U, numberFilter as Ut, ReportingPeriod as V, NumberSelection as Vt, defineOperation as W, numberOperatorLabels as Wt, parseTrue as X, dimensionSource as Xt, parseLabel as Y, SourceDimensionVariable as Yt, previousDateRange as Z, variableInput as Zt, DataQueryRoute as _, QueryDefinitions as _n, CheckedFacetContexts as _t, OpenExternalLink as a, dateTimeRangePresets as an, DimensionValue as at, MessageHandlers as b, QueryParameterValue as bn, ChoiceVariable as bt, resolveExternalLinkTarget as c, DatePresetId as cn, dimensionFilter as ct, annotationDraftRoute as d, inclusiveDays as dn, parseDimensionSelection as dt, DateTimeRangeComparisonVariable as en, DimensionFilterSettings as et, annotationEditorStateRoute as f, withinBounds as fn, parseFacetOptions as ft, parseDataAppAnnotationDraft as g, MAX_QUERY_ROWS as gn, AppVariableValues as gt, annotationUpdateRoute as h, KnownRecord as hn, AppVariable as ht, ExternalLinkTarget as i, DateTimeRangeVariableOptions as in, DimensionSelectionVariable as it, defineDataQueryRoute as j, InputOf as jn, multiChoiceVariable as jt, createMessageRouter as k, DataQueryInput as kn, dateRangeVariable as kt, DataAppAnnotationDraft as l, DateRange as ln, dimensionMemberKey as lt, annotationSendRoute as m, IsUnion as mn, facetSource as mt, ExternalLinkModifiers as n, DateTimeRangePreset as nn, DimensionOption as nt, openExternalLinkRoute as o, dateTimeRangeVariable as on, DimensionVariable as ot, annotationModeRoute as p, CheckedQueries as pn, FacetVariable as pt, parseDateRangeInput as q, DimensionSourceConfig as qt, ExternalLinkResult as r, DateTimeRangeVariable as rn, DimensionSelection as rt, parseExternalUrl as s, DatePreset as sn, createDimensionFilter as st, DataSourceError as t, DateTimeRangeComparisonVariableOptions as tn, DimensionMember as tt, DataAppAnnotationPresentation as u, availableDatePresets as un, dimensionPredicate as ut, MessageContext as v, QueryField as vn, CheckedVariableDeclarations as vt, MessageRoutes as w, QuerySnapshot as wn, MultiChoiceVariable as wt, MessageInput as x, QueryParameters as xn, DateRangeSelection as xt, MessageDispatcher as y, QueryParameter as yn, ChoiceOption as yt, OperationDefinition as z, DateTimeRangeRequest as zn, NumberFilter 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 };
878
589
  //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1,207 @@
1
+ import { n as DateTimeRange } from "./date-time-range.js";
2
+ import { Bt as OperationContracts, Dt as QueryParameters, Ft as DataQueryInput, Ht as QueryResult, J as NavigationUpdate, Pt as DataQueryBody, Ut as TransportResponse, Vt as OutputOf } from "./contract.js";
3
+ //#region src/core/date-time-range-sql.d.ts
4
+ /** DuckDB timestamp expressions using the query session's timezone for relative anchors.
5
+ * Absolute fields remain UTC-rebased TIMESTAMP values. Start is inclusive, end exclusive.
6
+ */
7
+ declare function dateTimeRangeSql(range: DateTimeRange, parameter?: string): {
8
+ from: string;
9
+ to: string;
10
+ params: Record<string, string>;
11
+ };
12
+ //#endregion
13
+ //#region src/core/messages.d.ts
14
+ type MessageContext = {
15
+ signal: AbortSignal;
16
+ };
17
+ type RoutedMessage = {
18
+ route: string;
19
+ payload: unknown;
20
+ };
21
+ type MessageDispatcher = (message: unknown, context: MessageContext) => Promise<unknown>;
22
+ type MessageTransport = (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
23
+ type MessageRoute<Input, Output> = {
24
+ input: (value: unknown) => Input;
25
+ output: (value: unknown, input: Input) => Output;
26
+ };
27
+ type MessageRoutes = Record<string, {
28
+ input: (value: unknown) => unknown;
29
+ output: (value: unknown, input: never) => unknown;
30
+ }>;
31
+ type MessageInput<Route extends MessageRoutes[string]> = ReturnType<Route['input']>;
32
+ type MessageHandlers<Routes extends MessageRoutes> = { [Name in keyof Routes]: (payload: MessageInput<Routes[Name]>, context: MessageContext) => ReturnType<Routes[Name]['output']> | Promise<ReturnType<Routes[Name]['output']>>; };
33
+ declare const errorBrand: unique symbol;
34
+ /** Only these deliberate, public failures cross the message boundary. Other errors stay private. */
35
+ declare class MessageRoutingError extends Error {
36
+ readonly code: string;
37
+ readonly requestId?: string | undefined;
38
+ readonly [errorBrand] = true;
39
+ static [Symbol.hasInstance](value: unknown): boolean;
40
+ constructor(code: string, message: string, requestId?: string | undefined,
41
+ /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */
42
+ options?: ErrorOptions);
43
+ }
44
+ declare function defineMessageRoute<Input, Output>(route: MessageRoute<Input, Output>): MessageRoute<Input, Output>;
45
+ /** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */
46
+ declare function createMessageRouter<const Routes extends MessageRoutes>(routes: Routes, handlers: MessageHandlers<NoInfer<Routes>>): {
47
+ dispatch: (value: unknown, context: MessageContext) => Promise<unknown>;
48
+ };
49
+ type DataQueryRoute<Operations extends OperationContracts> = MessageRoute<DataQueryInput<Operations>, TransportResponse> & {
50
+ operations: Operations | undefined;
51
+ };
52
+ type MessageOutput<Route extends MessageRoutes[string], Input> = Route extends DataQueryRoute<infer Operations> ? Input extends {
53
+ operation: infer Name extends keyof Operations;
54
+ } ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>> : never : ReturnType<Route['output']>;
55
+ /** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */
56
+ declare function defineDataQueryRoute<Operations extends OperationContracts = OperationContracts>(operations?: Operations): DataQueryRoute<Operations>;
57
+ declare const navigationUpdateRoute: MessageRoute<NavigationUpdate, null>;
58
+ type SqlQueryInput = {
59
+ statement: string;
60
+ limit: number;
61
+ params?: QueryParameters;
62
+ };
63
+ /** SQL delivery for browser-owned operations. Hosts must enforce backend access and resource limits. */
64
+ declare const sqlQueryRoute: MessageRoute<SqlQueryInput, QueryResult>;
65
+ declare const dataAppRoutes: {
66
+ 'data:query': DataQueryRoute<OperationContracts>;
67
+ 'navigation:update': MessageRoute<NavigationUpdate, null>;
68
+ };
69
+ //#endregion
70
+ //#region src/core/annotations.d.ts
71
+ type DataAppAnnotationDraft = {
72
+ id: string;
73
+ target: {
74
+ id: string;
75
+ label: string;
76
+ kind: 'widget' | 'element' | 'app';
77
+ text: string;
78
+ queryNames: string[];
79
+ glossaryIds: string[];
80
+ };
81
+ context: {
82
+ search: string;
83
+ hash: string;
84
+ displayedInput?: unknown;
85
+ /** Normalized position within the selected target, stable across scrolling/resizing. */
86
+ anchor?: {
87
+ x: number;
88
+ y: number;
89
+ };
90
+ cursor?: {
91
+ x: number;
92
+ y: number;
93
+ };
94
+ /** Normalized custom selection rectangle within the iframe document. */
95
+ region?: {
96
+ x: number;
97
+ y: number;
98
+ width: number;
99
+ height: number;
100
+ };
101
+ screenshot?: {
102
+ mimeType: 'image/png';
103
+ dataUrl: string;
104
+ width: number;
105
+ height: number;
106
+ };
107
+ view?: string;
108
+ viewport: {
109
+ width: number;
110
+ height: number;
111
+ };
112
+ rect: {
113
+ x: number;
114
+ y: number;
115
+ width: number;
116
+ height: number;
117
+ };
118
+ };
119
+ comment: string;
120
+ };
121
+ type DataAppAnnotationPresentation = {
122
+ enabled: boolean;
123
+ /** When provided, the host owns the mode and renders the annotation trigger. */
124
+ active?: boolean;
125
+ pinsVisible?: boolean;
126
+ showHint?: boolean;
127
+ readOnly?: boolean;
128
+ targets?: {
129
+ id: string;
130
+ targetId: string;
131
+ number: number;
132
+ comment?: string;
133
+ anchor?: {
134
+ x: number;
135
+ y: number;
136
+ };
137
+ region?: {
138
+ x: number;
139
+ y: number;
140
+ width: number;
141
+ height: number;
142
+ };
143
+ }[];
144
+ selectedAnnotationId?: string;
145
+ selectedTargetId?: string;
146
+ selectionId?: string;
147
+ /** Confirmed host click outside the iframe; occurredAt is epoch milliseconds. */
148
+ dismissal?: {
149
+ id: string;
150
+ occurredAt: number;
151
+ };
152
+ };
153
+ /** Reconstruct at the boundary; discard extra fields and bound the entire JSON payload. */
154
+ declare function parseDataAppAnnotationDraft(value: unknown): DataAppAnnotationDraft;
155
+ declare const annotationDraftRoute: MessageRoute<DataAppAnnotationDraft, null>;
156
+ declare const annotationEditorStateRoute: MessageRoute<{
157
+ hasUnsavedChanges: boolean;
158
+ }, null>;
159
+ /** Request host-owned batch submission without transferring ownership of drafts. */
160
+ declare const annotationSendRoute: MessageRoute<null, null>;
161
+ declare const annotationUpdateRoute: MessageRoute<{
162
+ id: string;
163
+ comment: string;
164
+ }, null>;
165
+ /** A controlled shell acknowledges local exits (for example Escape). */
166
+ declare const annotationModeRoute: MessageRoute<{
167
+ active: boolean;
168
+ }, null>;
169
+ //#endregion
170
+ //#region src/core/external-link.d.ts
171
+ /** Absolute HTTPS destinations only; URLs must not contain embedded credentials. */
172
+ declare function parseExternalUrl(value: unknown): string;
173
+ type ExternalLinkTarget = 'tab' | 'window';
174
+ type ExternalLinkModifiers = {
175
+ shiftKey: boolean;
176
+ metaKey: boolean;
177
+ ctrlKey: boolean;
178
+ };
179
+ type OpenExternalLink = {
180
+ url: string;
181
+ } & ({
182
+ target?: ExternalLinkTarget;
183
+ } | {
184
+ target: 'event';
185
+ keys: ExternalLinkModifiers;
186
+ });
187
+ type ExternalLinkResult = 'opened' | 'cancelled' | 'ignored';
188
+ /** Shift takes precedence over Ctrl/Cmd; an unmodified event requests no navigation. */
189
+ declare function resolveExternalLinkTarget(input: OpenExternalLink): ExternalLinkTarget | null;
190
+ /** Opt-in host route. Validation does not replace the host's destination policy. */
191
+ declare const openExternalLinkRoute: MessageRoute<OpenExternalLink, ExternalLinkResult>;
192
+ //#endregion
193
+ //#region src/core/contract.d.ts
194
+ declare const sourceErrorBrand: unique symbol;
195
+ declare class DataSourceError extends Error {
196
+ readonly reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable';
197
+ readonly status?: number | undefined;
198
+ readonly [sourceErrorBrand] = true;
199
+ queryName?: string;
200
+ static [Symbol.hasInstance](value: unknown): boolean;
201
+ constructor(reason: 'unauthorized' | 'forbidden' | 'rate_limited' | 'query_rejected' | 'unavailable', status?: number | undefined,
202
+ /** `cause` stays on the server or host for logs; responses carry only the reason. */
203
+ options?: ErrorOptions);
204
+ }
205
+ //#endregion
206
+ export { dataAppRoutes as A, MessageRoute as C, RoutedMessage as D, MessageTransport as E, dateTimeRangeSql as F, defineMessageRoute as M, navigationUpdateRoute as N, SqlQueryInput as O, sqlQueryRoute as P, MessageOutput as S, MessageRoutingError as T, DataQueryRoute as _, OpenExternalLink as a, MessageHandlers as b, resolveExternalLinkTarget as c, annotationDraftRoute as d, annotationEditorStateRoute as f, parseDataAppAnnotationDraft as g, annotationUpdateRoute as h, ExternalLinkTarget as i, defineDataQueryRoute as j, createMessageRouter as k, DataAppAnnotationDraft as l, annotationSendRoute as m, ExternalLinkModifiers as n, openExternalLinkRoute as o, annotationModeRoute as p, ExternalLinkResult as r, parseExternalUrl as s, DataSourceError as t, DataAppAnnotationPresentation as u, MessageContext as v, MessageRoutes as w, MessageInput as x, MessageDispatcher as y };
207
+ //# sourceMappingURL=contract2.d.ts.map
@@ -1,30 +1,4 @@
1
- //#region src/core/date-time-range.d.ts
2
- /** Frontend-compatible range values. Absolute dates encode wall-clock fields as UTC,
3
- * not instants converted from a reporting timezone. The backend interprets that zone.
4
- */
5
- type AbsoluteOrRelativeDateTime = Date | RelativeDateTime;
6
- type DateTimeRange = {
7
- /** Inclusive start; null or omitted means unbounded. */
8
- from?: AbsoluteOrRelativeDateTime | null;
9
- /** Exclusive end; null or omitted means now. */
10
- to?: AbsoluteOrRelativeDateTime | null;
11
- };
12
- type RelativeDateTime = {
13
- anchor: RelativeAnchor;
14
- offset: RelativeOffset[];
15
- };
16
- type RelativeOffset = {
17
- amount: number;
18
- unit: RelativeUnit;
19
- };
20
- type RelativeAnchor = 'RELATIVE_ANCHOR_NOW' | 'RELATIVE_ANCHOR_START_OF_TODAY' | 'RELATIVE_ANCHOR_START_OF_YESTERDAY' | 'RELATIVE_ANCHOR_START_OF_TOMORROW' | 'RELATIVE_ANCHOR_START_OF_WEEK' | 'RELATIVE_ANCHOR_START_OF_MONTH' | 'RELATIVE_ANCHOR_START_OF_YEAR';
21
- type RelativeUnit = 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
22
- /** Bounded, resolved wall-clock dates encoded in UTC, with an exclusive end. */
23
- type ResolvedDateTimeRange = {
24
- from: Date;
25
- to: Date;
26
- };
27
- //#endregion
1
+ import { n as DateTimeRange, t as AbsoluteOrRelativeDateTime } from "./date-time-range.js";
28
2
  //#region src/core/date-time-range-value.d.ts
29
3
  /** Validate and restore UTC-rebased dates from JSON, without resolving relative bounds. */
30
4
  declare function parseDateTimeRange(value: unknown, { maxRangeDays }?: {
@@ -42,5 +16,5 @@ declare function formatDateTimeRange(value: DateTimeRange): string;
42
16
  /** Parse one bound without resolving relative anchors or offsets. */
43
17
  declare function parseDateTimeBound(text: string): AbsoluteOrRelativeDateTime | null;
44
18
  //#endregion
45
- export { resolveDateTimeRange as a, DateTimeRange as c, RelativeOffset as d, RelativeUnit as f, parseDateTimeRange as i, RelativeAnchor as l, formatDateTimeRange as n, serializeDateTimeRange as o, ResolvedDateTimeRange as p, parseDateTimeBound as r, AbsoluteOrRelativeDateTime as s, formatDateTimeBound as t, RelativeDateTime as u };
19
+ export { resolveDateTimeRange as a, parseDateTimeRange as i, formatDateTimeRange as n, serializeDateTimeRange as o, parseDateTimeBound as r, formatDateTimeBound as t };
46
20
  //# sourceMappingURL=date-time-range-value.d.ts.map
@@ -0,0 +1,29 @@
1
+ //#region src/core/date-time-range.d.ts
2
+ /** Frontend-compatible range values. Absolute dates encode wall-clock fields as UTC,
3
+ * not instants converted from a reporting timezone. The backend interprets that zone.
4
+ */
5
+ type AbsoluteOrRelativeDateTime = Date | RelativeDateTime;
6
+ type DateTimeRange = {
7
+ /** Inclusive start; null or omitted means unbounded. */
8
+ from?: AbsoluteOrRelativeDateTime | null;
9
+ /** Exclusive end; null or omitted means now. */
10
+ to?: AbsoluteOrRelativeDateTime | null;
11
+ };
12
+ type RelativeDateTime = {
13
+ anchor: RelativeAnchor;
14
+ offset: RelativeOffset[];
15
+ };
16
+ type RelativeOffset = {
17
+ amount: number;
18
+ unit: RelativeUnit;
19
+ };
20
+ type RelativeAnchor = 'RELATIVE_ANCHOR_NOW' | 'RELATIVE_ANCHOR_START_OF_TODAY' | 'RELATIVE_ANCHOR_START_OF_YESTERDAY' | 'RELATIVE_ANCHOR_START_OF_TOMORROW' | 'RELATIVE_ANCHOR_START_OF_WEEK' | 'RELATIVE_ANCHOR_START_OF_MONTH' | 'RELATIVE_ANCHOR_START_OF_YEAR';
21
+ type RelativeUnit = 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
22
+ /** Bounded, resolved wall-clock dates encoded in UTC, with an exclusive end. */
23
+ type ResolvedDateTimeRange = {
24
+ from: Date;
25
+ to: Date;
26
+ };
27
+ //#endregion
28
+ export { RelativeOffset as a, RelativeDateTime as i, DateTimeRange as n, RelativeUnit as o, RelativeAnchor as r, ResolvedDateTimeRange as s, AbsoluteOrRelativeDateTime as t };
29
+ //# sourceMappingURL=date-time-range.d.ts.map
@@ -1,4 +1,5 @@
1
- import { D as RoutedMessage, Dn as DataOperations, E as MessageTransport, Fn as OutputOf, Ft as HistoryMode, In as QueryResult, Ln as TransportResponse, Mn as Lakehouse, On as DataQueryBody, Pt as AppLocation, S as MessageOutput, hn as KnownRecord, jn as InputOf, l as DataAppAnnotationDraft, mn as IsUnion, n as ExternalLinkModifiers, r as ExternalLinkResult, w as MessageRoutes, x as MessageInput, xn as QueryParameters } from "./contract.js";
1
+ import { Dt as QueryParameters, Ht as QueryResult, K as AppLocation, Lt as InputOf, Nt as DataOperations, Pt as DataQueryBody, Rt as Lakehouse, Ut as TransportResponse, Vt as OutputOf, bt as IsUnion, q as HistoryMode, xt as KnownRecord } from "./contract.js";
2
+ import { D as RoutedMessage, E as MessageTransport, S as MessageOutput, l as DataAppAnnotationDraft, n as ExternalLinkModifiers, r as ExternalLinkResult, w as MessageRoutes, x as MessageInput } from "./contract2.js";
2
3
  //#region src/core/logger.d.ts
3
4
  /** Host-owned log sink; compatible with console and frontend createLogger(). */
4
5
  type DataAppLogger = {
@@ -1,3 +1,3 @@
1
- import { Fn as OutputOf, Pt as AppLocation, jn as InputOf } from "../chunks/contract.js";
1
+ import { K as AppLocation, Lt as InputOf, Vt as OutputOf } from "../chunks/contract.js";
2
2
  import { C as DataAppError, E as DataAppLogger, S as createDataClient, T as createHttpTransport, a as AppDiagnosticReport, b as DataClientOptions, c as createAnnotationClient, d as createDataAppNavigation, f as getDataAppNavigation, g as installDataAppTransport, h as getDataAppTransport, i as appDiagnostics, l as createMessageClient, m as createIframeTransport, n as navigateNewWindow, o as AppFailure, p as IframeTransport, r as navigateNewWindowOrTab, t as navigateNewTab, u as DataAppNavigation, v as DataAppLocation, w as DataTransport, x as DataResponse, y as DataClient } from "../chunks/index.js";
3
3
  export { type AppDiagnosticReport, type AppFailure, type AppLocation, DataAppError, type DataAppLocation, type DataAppLogger, type DataAppNavigation, type DataClient, type DataClientOptions, type DataResponse, type DataTransport, type IframeTransport, type InputOf, type OutputOf, appDiagnostics, createAnnotationClient, createDataAppNavigation, createDataClient, createHttpTransport, createIframeTransport, createMessageClient, getDataAppNavigation, getDataAppTransport, installDataAppTransport, navigateNewTab, navigateNewWindow, navigateNewWindowOrTab };