@altertable/data-app 0.77.0 → 0.79.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 (70) hide show
  1. package/AGENTS.md +3 -0
  2. package/CONTRIBUTING.md +5 -1
  3. package/REFERENCE.md +70 -180
  4. package/dist/chunks/contract-BTG-BUwW.js +1589 -0
  5. package/dist/chunks/contract-BTG-BUwW.js.map +1 -0
  6. package/dist/chunks/data-client-C4Pay-UE.js +122 -0
  7. package/dist/chunks/data-client-C4Pay-UE.js.map +1 -0
  8. package/dist/chunks/{date-time-range-value-CnlTr1U1.js → date-time-range-value-D-XfqVTT.js} +21 -24
  9. package/dist/chunks/date-time-range-value-D-XfqVTT.js.map +1 -0
  10. package/dist/chunks/{diagnostics-Dyj-rUsY.js → diagnostics-BwpM9wGn.js} +240 -63
  11. package/dist/chunks/diagnostics-BwpM9wGn.js.map +1 -0
  12. package/dist/chunks/record-Cr4Uk1K3.js +9 -0
  13. package/dist/chunks/record-Cr4Uk1K3.js.map +1 -0
  14. package/dist/client/index.js +4 -101
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/core/appearance.js +3 -5
  17. package/dist/core/appearance.js.map +1 -1
  18. package/dist/core/config.js +12 -3
  19. package/dist/core/config.js.map +1 -1
  20. package/dist/core/contract.js +3 -4
  21. package/dist/core/format.js +1 -1
  22. package/dist/internal.js +63 -11
  23. package/dist/internal.js.map +1 -1
  24. package/dist/types/chunks/contract.d.ts +260 -20
  25. package/dist/types/chunks/data-client.d.ts +46 -0
  26. package/dist/types/chunks/date-time-range-value.d.ts +28 -2
  27. package/dist/types/chunks/index.d.ts +65 -80
  28. package/dist/types/client/index.d.ts +4 -3
  29. package/dist/types/core/config.d.ts +13 -4
  30. package/dist/types/core/contract.d.ts +3 -5
  31. package/dist/types/core/format.d.ts +1 -2
  32. package/dist/types/index.d.ts +4 -4
  33. package/dist/types/internal.d.ts +25 -6
  34. package/docs/app-authoring.md +160 -72
  35. package/docs/client.md +14 -53
  36. package/docs/contract.md +47 -26
  37. package/docs/data-context.md +11 -11
  38. package/docs/diagnostics.md +16 -23
  39. package/docs/embed.md +60 -25
  40. package/docs/filters.md +39 -65
  41. package/docs/formatting-and-appearance.md +2 -5
  42. package/docs/hosted-apps.md +11 -11
  43. package/docs/layout.md +21 -0
  44. package/docs/local-data-apps.md +10 -7
  45. package/docs/react-embed.md +44 -2
  46. package/docs/react.md +2 -5
  47. package/docs/server-bun.md +8 -5
  48. package/docs/stories-and-export.md +5 -6
  49. package/docs/styling.md +2 -1
  50. package/docs/ui.md +37 -10
  51. package/docs/views.md +18 -19
  52. package/docs/widgets.md +10 -11
  53. package/docs/worker.md +1 -1
  54. package/package.json +1 -5
  55. package/dist/chunks/contract-BQsFReRp.js +0 -780
  56. package/dist/chunks/contract-BQsFReRp.js.map +0 -1
  57. package/dist/chunks/contract-VhY9V9wd.js +0 -806
  58. package/dist/chunks/contract-VhY9V9wd.js.map +0 -1
  59. package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +0 -1
  60. package/dist/chunks/diagnostics-Dyj-rUsY.js.map +0 -1
  61. package/dist/chunks/operation-BVRM-A5Y.js +0 -134
  62. package/dist/chunks/operation-BVRM-A5Y.js.map +0 -1
  63. package/dist/chunks/request-body-H1qPmmTN.js +0 -50
  64. package/dist/chunks/request-body-H1qPmmTN.js.map +0 -1
  65. package/dist/server/index.js +0 -90
  66. package/dist/server/index.js.map +0 -1
  67. package/dist/types/chunks/contract2.d.ts +0 -221
  68. package/dist/types/chunks/date-time-range.d.ts +0 -29
  69. package/dist/types/server/index.d.ts +0 -17
  70. package/docs/server.md +0 -41
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../src/core/config.ts"],"sourcesContent":["/**\n * App configuration shared by browser and server.\n * @module @altertable/data-app\n */\nimport {\n defineOperation,\n type DefinedOperation,\n type FilterOperationDefinition,\n type InputOperationDefinition,\n type WithFilterInput,\n} from '../authoring/contract.ts';\nimport type { FilterCollection } from './app-filters.ts';\nimport type { AppearanceOptions } from './appearance.ts';\nimport {\n bindDimensionSource,\n type DimensionSourceConfig,\n type DimensionSourceQueryName,\n type SourceDimensionFilter,\n} from './dimension-source.ts';\nimport type { FilterInput } from './operation-filters.ts';\nimport {\n snapshotQueries,\n type QueryDefinitions,\n type CheckedQueries,\n type QuerySnapshot,\n} from './queries.ts';\nexport type {\n QueryDefinitions,\n QueryParameterValue,\n QueryParameter,\n QueryValueType,\n QueryField,\n QueryProjections,\n QueryRow,\n} from './queries.ts';\n\nexport type DataAppConfig<Queries extends QueryDefinitions = QueryDefinitions> =\n {\n title: string;\n /** Display labels; scope does not grant data access. */\n scope: { organization: string; environment: string };\n /** Explain what the app helps readers explore. */\n description: string;\n /** Omit to use the standard appearance. */\n appearance?: AppearanceOptions;\n /** Shared date display defaults. Reporting views and individual fields may override the time zone. */\n dateFormatting?: { locale?: string; timeZone?: string };\n /** Named SQL statements with typed parameters and result projections. */\n queries: Queries;\n };\n\n/** An app declaration with operations bound to its query registry. */\nexport type DataAppDefinition<\n Queries extends QueryDefinitions = QueryDefinitions,\n> = Readonly<Omit<DataAppConfig<Queries>, 'queries'>> & {\n readonly queries: QuerySnapshot<Queries>;\n defineDimension<const Type extends 'string' | 'number'>(\n config: DimensionSourceConfig<Type> & {\n source: { query: DimensionSourceQueryName<Queries, NoInfer<Type>> };\n }\n ): SourceDimensionFilter<{ string: string; number: number }[Type]>;\n /** Parse a destination's own input, such as a record id, and list valid `checks`.\n * Declare `filters` too when it reads the displayed scope. */\n defineOperation<Input, Output, const Filters extends FilterCollection = {}>(\n operation: InputOperationDefinition<Input, Output, Queries, Filters>\n ): DefinedOperation<\n WithFilterInput<Filters, Input>,\n Output,\n Queries,\n keyof Filters extends never ? undefined : Filters\n >;\n /** Declare the filters the operation reads; its input, checks, and views derive from them. */\n defineOperation<\n const Filters extends FilterCollection = {},\n Output = unknown,\n >(\n operation: FilterOperationDefinition<Filters, Output, Queries>\n ): DefinedOperation<FilterInput<Filters>, Output, Queries, Filters>;\n};\n\n/**\n * Define the app's query source of truth while preserving exact query and parameter names.\n * Use `dataApp.defineOperation()` to bind operations to these queries. Pass the app once\n * to `mountDataApp({ app: dataApp, component })` or `<DataAppProvider app={dataApp}>`.\n * The app owns an immutable snapshot of its registry; later input mutations do not change it.\n * This declaration does not execute queries or mount UI. Static apps use `queries: {}`.\n *\n * Declare the app once at module scope using the named import from `@altertable/data-app`.\n * Import aliases are allowed. Prefer a `const` initializer; top-level variable\n * initializers, default exports, and standalone calls are supported.\n * Use literal objects, arrays, strings (including templates without interpolation),\n * finite signed numbers, booleans, and null. Parentheses, `as`, and `satisfies` are\n * allowed. Keep executable composition outside the call; omit spreads, computed keys,\n * references, and callbacks. Extraction reads literals without executing app code.\n * TypeScript and runtime query rules own configuration validation.\n *\n * Scalar placeholders pass to the backend. Datetime-range bound references ($period.from/to)\n * expand to DuckDB timestamp expressions while the range is bound as JSON.\n * Declare each parameter's type and optional defaultValue.\n * Values are scalars or declared datetime ranges, never SQL fragments or identifiers.\n * Host queryParams supply protected values; callers cannot override them.\n */\nexport function defineDataApp<const Queries extends QueryDefinitions>(\n config: DataAppConfig<Queries> & { queries: CheckedQueries<Queries> }\n): DataAppDefinition<Queries> {\n const queries = snapshotQueries<Queries>(config.queries);\n return Object.freeze({\n ...config,\n queries,\n defineDimension<const Type extends 'string' | 'number'>(\n config: DimensionSourceConfig<Type> & {\n source: { query: DimensionSourceQueryName<Queries, NoInfer<Type>> };\n }\n ) {\n return bindDimensionSource<Type>(config, queries);\n },\n defineOperation(operation: object): any {\n return defineOperation({\n ...operation,\n queries: queries as unknown as CheckedQueries<Queries>,\n } as never);\n },\n });\n}\n\nexport function dataAppTitle(\n config: Pick<DataAppConfig, 'title' | 'scope'>\n): string {\n return `${config.title} • ${config.scope.organization}/${config.scope.environment} • Altertable app`;\n}\n\nexport type {\n DateTimeRange,\n AbsoluteOrRelativeDateTime,\n RelativeDateTime,\n RelativeAnchor,\n RelativeOffset,\n RelativeUnit,\n} from './date-time-range.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,SAAgB,cACd,QAC4B;CAC5B,MAAM,UAAU,gBAAyB,OAAO,OAAO;CACvD,OAAO,OAAO,OAAO;EACnB,GAAG;EACH;EACA,gBACE,QAGA;GACA,OAAO,oBAA0B,QAAQ,OAAO;EAClD;EACA,gBAAgB,WAAwB;GACtC,OAAO,gBAAgB;IACrB,GAAG;IACM;GACX,CAAU;EACZ;CACF,CAAC;AACH;AAEA,SAAgB,aACd,QACQ;CACR,OAAO,GAAG,OAAO,MAAM,KAAK,OAAO,MAAM,aAAa,GAAG,OAAO,MAAM,YAAY;AACpF"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../src/core/config.ts"],"sourcesContent":["/**\n * App configuration shared by browser and server.\n * @module @altertable/data-app\n */\nimport {\n defineOperation,\n type DefinedOperation,\n type FilterOperationDefinition,\n type InputOperationDefinition,\n type WithFilterInput,\n} from '../authoring/contract.ts';\nimport { createDataClient, type DataClient } from '../client/data-client.ts';\nimport type { FilterCollection } from './app-filters.ts';\nimport type { AppearanceOptions } from './appearance.ts';\nimport {\n bindDimensionSource,\n type DimensionSourceConfig,\n type DimensionSourceQueryName,\n type SourceDimensionFilter,\n} from './dimension-source.ts';\nimport type { FilterInput } from './operation-filters.ts';\nimport type { DataOperations } from './operation-types.ts';\nimport {\n snapshotQueries,\n type QueryDefinitions,\n type CheckedQueries,\n type QuerySnapshot,\n} from './queries.ts';\nexport type {\n QueryDefinitions,\n QueryParameterValue,\n QueryParameter,\n QueryValueType,\n QueryField,\n QueryProjections,\n QueryRow,\n} from './queries.ts';\n\nexport type DataAppConfig<Queries extends QueryDefinitions = QueryDefinitions> =\n {\n title: string;\n /** Display labels; scope does not grant data access. */\n scope: { organization: string; environment: string };\n /** Explain what the app helps readers explore. */\n description: string;\n /** Omit to use the standard appearance. */\n appearance?: AppearanceOptions;\n /** Shared date display defaults. Reporting views and individual fields may override the time zone. */\n dateFormatting?: { locale?: string; timeZone?: string };\n /** Named SQL statements with typed parameters and result projections. */\n queries: Queries;\n };\n\nexport type DataAppOperationRegistry<Operations extends DataOperations> =\n Operations & {\n /** Run operations in the browser using its installed query bridge. */\n createDataClient(): DataClient<Operations>;\n };\n\n/** An app declaration with operations bound to its query registry. */\nexport type DataAppDefinition<\n Queries extends QueryDefinitions = QueryDefinitions,\n> = Readonly<Omit<DataAppConfig<Queries>, 'queries'>> & {\n readonly queries: QuerySnapshot<Queries>;\n /** Every registered query name, keyed by itself. Pass it to `createDataContext()`,\n * then cite the queries behind each glossary entry. */\n readonly queryNames: { readonly [Name in keyof Queries & string]: Name };\n defineDimension<const Type extends 'string' | 'number'>(\n config: DimensionSourceConfig<Type> & {\n source: { query: DimensionSourceQueryName<Queries, NoInfer<Type>> };\n }\n ): SourceDimensionFilter<{ string: string; number: number }[Type]>;\n /** Parse a destination's own input, such as a record id, and list valid `checks`.\n * Declare `filters` too when it reads the displayed scope. */\n defineOperation<Input, Output, const Filters extends FilterCollection = {}>(\n operation: InputOperationDefinition<Input, Output, Queries, Filters>\n ): DefinedOperation<\n WithFilterInput<Filters, Input>,\n Output,\n Queries,\n keyof Filters extends never ? undefined : Filters\n >;\n /** Declare the filters the operation reads; its input, checks, and views derive from them. */\n defineOperation<\n const Filters extends FilterCollection = {},\n Output = unknown,\n >(\n operation: FilterOperationDefinition<Filters, Output, Queries>\n ): DefinedOperation<FilterInput<Filters>, Output, Queries, Filters>;\n /** Bind a named registry to these queries and derive its client and filters. */\n defineOperations<const Operations extends DataOperations>(\n operations: Operations\n ): DataAppOperationRegistry<Operations>;\n};\n\n/**\n * Define the app's query source of truth while preserving exact query and parameter names.\n * Use `dataApp.defineOperation()` to bind operations to these queries. Pass the app once\n * to `mountDataApp({ app: dataApp, component })` or `<DataAppProvider app={dataApp}>`.\n * The app owns an immutable snapshot of its registry; later input mutations do not change it.\n * This declaration does not execute queries or mount UI. Static apps use `queries: {}`.\n *\n * Declare the app once at module scope using the named import from `@altertable/data-app`.\n * Import aliases are allowed. Prefer a `const` initializer; top-level variable\n * initializers, default exports, and standalone calls are supported.\n * Use literal objects, arrays, strings (including templates without interpolation),\n * finite signed numbers, booleans, and null. Parentheses, `as`, and `satisfies` are\n * allowed. Keep executable composition outside the call; omit spreads, computed keys,\n * references, and callbacks. Extraction reads literals without executing app code.\n * TypeScript and runtime query rules own configuration validation.\n *\n * Statements use DuckDB SQL and bound parameters without SDK-only SQL syntax.\n * Declare each parameter's type and optional defaultValue.\n * Values are scalars or declared datetime ranges, never SQL fragments or identifiers.\n * Host queryParams supply protected values; callers cannot override them.\n */\nexport function defineDataApp<const Queries extends QueryDefinitions>(\n config: DataAppConfig<Queries> & { queries: CheckedQueries<Queries> }\n): DataAppDefinition<Queries> {\n const queries = snapshotQueries<Queries>(config.queries);\n return Object.freeze({\n ...config,\n queries,\n queryNames: Object.freeze(\n Object.fromEntries(Object.keys(queries).map(name => [name, name]))\n ),\n defineDimension<const Type extends 'string' | 'number'>(\n config: DimensionSourceConfig<Type> & {\n source: { query: DimensionSourceQueryName<Queries, NoInfer<Type>> };\n }\n ) {\n return bindDimensionSource<Type>(config, queries);\n },\n defineOperation(operation: object): any {\n return defineOperation({\n ...operation,\n queries: queries as unknown as CheckedQueries<Queries>,\n } as never);\n },\n defineOperations(operations: DataOperations) {\n if (Object.hasOwn(operations, 'createDataClient'))\n throw new Error('Operation name createDataClient is reserved.');\n const registry = {\n ...operations,\n } as DataAppOperationRegistry<DataOperations>;\n Object.setPrototypeOf(registry, {\n createDataClient() {\n return (\n createDataClient as (options: object) => DataClient<DataOperations>\n )({\n operations: registry,\n });\n },\n });\n return Object.freeze(registry);\n },\n }) as unknown as DataAppDefinition<Queries>;\n}\n\nexport function dataAppTitle(\n config: Pick<DataAppConfig, 'title' | 'scope'>\n): string {\n return `${config.title} • ${config.scope.organization}/${config.scope.environment} • Altertable app`;\n}\n\nexport type {\n DateTimeRange,\n AbsoluteOrRelativeDateTime,\n RelativeDateTime,\n RelativeAnchor,\n RelativeOffset,\n RelativeUnit,\n} from './date-time-range.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,SAAgB,cACd,QAC4B;CAC5B,MAAM,UAAU,gBAAyB,OAAO,OAAO;CACvD,OAAO,OAAO,OAAO;EACnB,GAAG;EACH;EACA,YAAY,OAAO,OACjB,OAAO,YAAY,OAAO,KAAK,OAAO,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CACnE;EACA,gBACE,QAGA;GACA,OAAO,oBAA0B,QAAQ,OAAO;EAClD;EACA,gBAAgB,WAAwB;GACtC,OAAO,gBAAgB;IACrB,GAAG;IACM;GACX,CAAU;EACZ;EACA,iBAAiB,YAA4B;GAC3C,IAAI,OAAO,OAAO,YAAY,kBAAkB,GAC9C,MAAM,IAAI,MAAM,8CAA8C;GAChE,MAAM,WAAW,EACf,GAAG,WACL;GACA,OAAO,eAAe,UAAU,EAC9B,mBAAmB;IACjB,OACE,iBACA,EACA,YAAY,SACd,CAAC;GACH,EACF,CAAC;GACD,OAAO,OAAO,OAAO,QAAQ;EAC/B;CACF,CAAC;AACH;AAEA,SAAgB,aACd,QACQ;CACR,OAAO,GAAG,OAAO,MAAM,KAAK,OAAO,MAAM,aAAa,GAAG,OAAO,MAAM,YAAY;AACpF"}
@@ -1,4 +1,3 @@
1
- import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "../chunks/date-time-range-value-CnlTr1U1.js";
2
- import { C as dateTimeRangeSql, D as dimensionPredicate, O as parseDimensionSelection, T as dimensionFilter, a as parseLabel, f as displayChoice, i as parseCount, k as parseFacetOptions, m as searchFilter, n as defineOperation, o as parseTrue, p as multiChoiceFilter, r as defineQueryNames, t as connectionCheck, u as choiceFilter } from "../chunks/contract-BQsFReRp.js";
3
- import { D as parseBooleanSelection, O as parseNumberSelection, S as facetFilter, T as numberFilter, _ as navigationUpdateRoute, a as annotationDraftRoute, b as dateTimeRangeFilter, c as annotationSendRoute, d as parseDataAppAnnotationDraft, f as MessageRoutingError, g as defineMessageRoute, h as defineDataQueryRoute, i as resolveExternalLinkTarget, l as annotationUpdateRoute, m as dataAppRoutes, n as openExternalLinkRoute, o as annotationEditorStateRoute, p as createMessageRouter, r as parseExternalUrl, s as annotationModeRoute, t as DataSourceError, v as sqlQueryRoute, w as booleanFilter, x as dateTimeRangePresets } from "../chunks/contract-VhY9V9wd.js";
4
- export { DataSourceError, MessageRoutingError, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, choiceFilter, connectionCheck, createMessageRouter, dataAppRoutes, dateTimeRangeFilter, dateTimeRangePresets, dateTimeRangeSql, defineDataQueryRoute, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, displayChoice, facetFilter, formatDateTimeBound, formatDateTimeRange, multiChoiceFilter, navigationUpdateRoute, numberFilter, openExternalLinkRoute, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, resolveDateTimeRange, resolveExternalLinkTarget, searchFilter, serializeDateTimeRange, sqlQueryRoute };
1
+ import { a as resolveDateTimeRange, i as parseDateTimeRange, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, t as formatDateTimeBound } from "../chunks/date-time-range-value-D-XfqVTT.js";
2
+ import { A as resolvedDateTimeRangeParams, C as parseCount, D as dateTimeRangePresets, E as dateTimeRangeFilter, G as searchFilter, I as parseBooleanSelection, L as parseNumberSelection, N as booleanFilter, O as queryDateTimeRangeParams, P as numberFilter, S as defineQueryNames, T as parseTrue, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, _ as navigationUpdateRoute, a as annotationDraftRoute, at as parseDimensionSelection, b as connectionCheck, c as annotationSendRoute, d as parseDataAppAnnotationDraft, f as MessageRoutingError, g as defineMessageRoute, h as defineDataOperationRoute, i as resolveExternalLinkTarget, it as dimensionPredicate, j as facetFilter, k as dateTimeRangeSql, l as annotationUpdateRoute, m as dataAppRoutes, n as openExternalLinkRoute, nt as dimensionFilter, o as annotationEditorStateRoute, ot as parseFacetOptions, p as createMessageRouter, r as parseExternalUrl, s as annotationModeRoute, t as DataSourceError, v as registeredQueryRoute, w as parseLabel, x as defineOperation } from "../chunks/contract-BTG-BUwW.js";
3
+ export { DataSourceError, MessageRoutingError, annotationDraftRoute, annotationEditorStateRoute, annotationModeRoute, annotationSendRoute, annotationUpdateRoute, booleanFilter, choiceFilter, connectionCheck, createMessageRouter, dataAppRoutes, dateTimeRangeFilter, dateTimeRangePresets, dateTimeRangeSql, defineDataOperationRoute, defineMessageRoute, defineOperation, defineQueryNames, dimensionFilter, dimensionPredicate, displayChoice, facetFilter, formatDateTimeBound, formatDateTimeRange, multiChoiceFilter, navigationUpdateRoute, numberFilter, openExternalLinkRoute, parseBooleanSelection, parseCount, parseDataAppAnnotationDraft, parseDateTimeBound, parseDateTimeRange, parseDimensionSelection, parseExternalUrl, parseFacetOptions, parseLabel, parseNumberSelection, parseTrue, queryDateTimeRangeParams, registeredQueryRoute, resolveDateTimeRange, resolveExternalLinkTarget, resolvedDateTimeRangeParams, searchFilter, serializeDateTimeRange };
@@ -1,4 +1,4 @@
1
- import { c as parseDateTimeRangeInput, n as formatDateTimeRange } from "../chunks/date-time-range-value-CnlTr1U1.js";
1
+ import { c as parseDateTimeRangeInput, n as formatDateTimeRange } from "../chunks/date-time-range-value-D-XfqVTT.js";
2
2
  //#region src/core/date-format.ts
3
3
  const calendarDate = /^\d{4}-\d{2}-\d{2}$/;
4
4
  const timestamp = /^(\d{4}-\d{2}-\d{2})T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,9})?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
package/dist/internal.js CHANGED
@@ -1,9 +1,6 @@
1
- import { a as resolveDateTimeRange, i as parseDateTimeRange, l as invariant, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, s as fixedUnitMilliseconds, t as formatDateTimeBound } from "./chunks/date-time-range-value-CnlTr1U1.js";
2
- import { A as KEY_SEPARATOR, E as dimensionMemberKey, b as MAX_QUERY_ROWS, c as dateFilterName, d as defineAppFilters, f as displayChoice, h as validateChoiceOptions, l as resolveFilterInput, m as searchFilter, p as multiChoiceFilter, s as combineOperationFilters, u as choiceFilter, v as dimensionSource, w as createDimensionFilter } from "./chunks/contract-BQsFReRp.js";
3
- import { C as facetSource, E as numberOperatorLabels, b as dateTimeRangeFilter, x as dateTimeRangePresets } from "./chunks/contract-VhY9V9wd.js";
4
- import { n as toDataOperationFailure } from "./chunks/operation-BVRM-A5Y.js";
5
- import { a as localFrameBridge, d as MAX_PENDING, f as PARENT_PARAM, g as randomUuid, h as parseAppDiagnosticReport, l as isDataAppPresentation, m as validId, p as REQUEST_TIMEOUT_MS, u as createBridgeEndpoint } from "./chunks/diagnostics-Dyj-rUsY.js";
6
- import { n as readRequestBody, t as RequestBodyTooLargeError } from "./chunks/request-body-H1qPmmTN.js";
1
+ import { a as resolveDateTimeRange, i as parseDateTimeRange, l as invariant, n as formatDateTimeRange, o as serializeDateTimeRange, r as parseDateTimeBound, s as fixedUnitMilliseconds, t as formatDateTimeBound } from "./chunks/date-time-range-value-D-XfqVTT.js";
2
+ import { B as resolveFilterInput, D as dateTimeRangePresets, E as dateTimeRangeFilter, F as numberOperatorLabels, G as searchFilter, H as defineAppFilters, K as validateChoiceOptions, M as facetSource, Q as REGISTERED_QUERY_ID_PATTERN, R as combineOperationFilters, U as displayChoice, V as choiceFilter, W as multiChoiceFilter, Y as dimensionSource, Z as MAX_QUERY_ROWS, et as unsupportedParameterReference, rt as dimensionMemberKey, st as KEY_SEPARATOR, tt as createDimensionFilter, z as dateFilterName } from "./chunks/contract-BTG-BUwW.js";
3
+ import { _ as toDataOperationFailure, a as localFrameBridge, c as isDataAppPresentation, d as PARENT_PARAM, f as REQUEST_TIMEOUT_MS, h as randomUuid, l as createBridgeEndpoint, m as parseAppDiagnosticReport, p as validId, u as MAX_PENDING } from "./chunks/diagnostics-BwpM9wGn.js";
7
4
  //#region src/client/download.ts
8
5
  /** Start a browser download and release its temporary anchor and object URL. */
9
6
  function downloadBlob({ filename, blob }) {
@@ -42,6 +39,17 @@ function resolveDataView({ requestedInput, current, previous, pending, error, sa
42
39
  error
43
40
  } : { kind: "loading" };
44
41
  const currentInput = sameInput(shown.input, requestedInput);
42
+ if (isEmpty(shown.data)) {
43
+ if (error) return {
44
+ kind: "error",
45
+ error
46
+ };
47
+ if (pending || !currentInput) return { kind: "loading" };
48
+ return {
49
+ kind: "empty",
50
+ input: shown.input
51
+ };
52
+ }
45
53
  if (error) return {
46
54
  kind: "stale-error",
47
55
  data: shown.data,
@@ -57,16 +65,60 @@ function resolveDataView({ requestedInput, current, previous, pending, error, sa
57
65
  requestedInput,
58
66
  message: currentInput ? `Updating ${describe(requestedInput)}…` : `Showing ${describe(shown.input)} while loading ${describe(requestedInput)}…`
59
67
  };
60
- return isEmpty(shown.data) ? {
61
- kind: "empty",
62
- input: shown.input
63
- } : {
68
+ return {
64
69
  kind: "ready",
65
70
  data: shown.data,
66
71
  input: shown.input
67
72
  };
68
73
  }
69
74
  //#endregion
70
- export { KEY_SEPARATOR, MAX_PENDING, MAX_QUERY_ROWS, PARENT_PARAM, REQUEST_TIMEOUT_MS, RequestBodyTooLargeError, choiceFilter, combineOperationFilters, createBridgeEndpoint, createDimensionFilter, dateFilterName, dateTimeRangeFilter, dateTimeRangePresets, defineAppFilters, dimensionMemberKey, dimensionSource, displayChoice, displayedSnapshot, downloadBlob, facetSource, fixedUnitMilliseconds, formatDateTimeBound, formatDateTimeRange, invariant, isDataAppPresentation, localFrameBridge, multiChoiceFilter, numberOperatorLabels, parseAppDiagnosticReport, parseDateTimeBound, parseDateTimeRange, randomUuid, readRequestBody, resolveDataView, resolveDateTimeRange, resolveFilterInput, searchFilter, serializeDateTimeRange, toDataOperationFailure, validId, validateChoiceOptions };
75
+ //#region src/server/request-body.ts
76
+ var RequestBodyTooLargeError = class extends Error {};
77
+ /** Count encoded bytes before retaining chunks; cancellation also interrupts waiting reads. */
78
+ async function readRequestBody(request, maxBytes) {
79
+ const body = request.body;
80
+ if (!body) return "";
81
+ const reader = body.getReader();
82
+ const chunks = [];
83
+ let size = 0;
84
+ let abort;
85
+ function cancelReader() {
86
+ reader.cancel().catch(() => {});
87
+ }
88
+ try {
89
+ request.signal.throwIfAborted();
90
+ const cancelled = new Promise((_, reject) => {
91
+ function rejectAborted() {
92
+ reject(/* @__PURE__ */ new Error("Request aborted."));
93
+ cancelReader();
94
+ }
95
+ abort = rejectAborted;
96
+ request.signal.addEventListener("abort", rejectAborted, { once: true });
97
+ if (request.signal.aborted) rejectAborted();
98
+ });
99
+ while (true) {
100
+ const { done, value } = await Promise.race([reader.read(), cancelled]);
101
+ if (done) break;
102
+ size += value.byteLength;
103
+ if (size > maxBytes) {
104
+ cancelReader();
105
+ throw new RequestBodyTooLargeError();
106
+ }
107
+ chunks.push(value);
108
+ }
109
+ const bytes = new Uint8Array(size);
110
+ let offset = 0;
111
+ for (const chunk of chunks) {
112
+ bytes.set(chunk, offset);
113
+ offset += chunk.byteLength;
114
+ }
115
+ return new TextDecoder().decode(bytes);
116
+ } finally {
117
+ if (abort) request.signal.removeEventListener("abort", abort);
118
+ reader.releaseLock();
119
+ }
120
+ }
121
+ //#endregion
122
+ export { KEY_SEPARATOR, MAX_PENDING, MAX_QUERY_ROWS, PARENT_PARAM, REGISTERED_QUERY_ID_PATTERN, REQUEST_TIMEOUT_MS, RequestBodyTooLargeError, choiceFilter, combineOperationFilters, createBridgeEndpoint, createDimensionFilter, dateFilterName, dateTimeRangeFilter, dateTimeRangePresets, defineAppFilters, dimensionMemberKey, dimensionSource, displayChoice, displayedSnapshot, downloadBlob, facetSource, fixedUnitMilliseconds, formatDateTimeBound, formatDateTimeRange, invariant, isDataAppPresentation, localFrameBridge, multiChoiceFilter, numberOperatorLabels, parseAppDiagnosticReport, parseDateTimeBound, parseDateTimeRange, randomUuid, readRequestBody, resolveDataView, resolveDateTimeRange, resolveFilterInput, searchFilter, serializeDateTimeRange, toDataOperationFailure, unsupportedParameterReference, validId, validateChoiceOptions };
71
123
 
72
124
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","names":[],"sources":["../src/client/download.ts","../src/core/data-view.ts"],"sourcesContent":["/** Start a browser download and release its temporary anchor and object URL. */\nexport function downloadBlob({\n filename,\n blob,\n}: {\n filename: string;\n blob: Blob;\n}): void {\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n document.body.append(link);\n try {\n link.click();\n } finally {\n link.remove();\n setTimeout(() => URL.revokeObjectURL(url), 1000);\n }\n}\n","export type DataView<T, Input = unknown> =\n | { kind: 'loading' }\n | { kind: 'empty'; input: Input }\n | { kind: 'error'; error: Error }\n | { kind: 'ready'; data: T; input: Input }\n | {\n kind: 'updating';\n data: T;\n requestedInput: Input;\n displayedInput: Input;\n message: string;\n }\n | {\n kind: 'stale-error';\n data: T;\n requestedInput: Input;\n displayedInput: Input;\n error: Error;\n message: string;\n };\n\ntype DataSnapshot<Data, Input> = { data: Data; input: Input };\nexport type DisplayedSnapshot<Data, Input> = DataSnapshot<Data, Input> & {\n state: 'ready' | 'updating' | 'stale-error';\n};\n\n/** The result currently shown to the reader, including the input that produced it. */\nexport function displayedSnapshot<Data, Input>(\n view: DataView<Data, Input>\n): DisplayedSnapshot<Data, Input> | undefined {\n if (view.kind === 'ready')\n return { data: view.data, input: view.input, state: view.kind };\n if (view.kind === 'updating' || view.kind === 'stale-error')\n return { data: view.data, input: view.displayedInput, state: view.kind };\n\n return undefined;\n}\n\n/** Keep the requested input separate from the input that produced visible data. */\nexport function resolveDataView<Data, Input>({\n requestedInput,\n current,\n previous,\n pending,\n error,\n sameInput,\n describe,\n isEmpty,\n}: {\n requestedInput: Input;\n current?: DataSnapshot<Data, Input>;\n previous?: DataSnapshot<Data, Input>;\n pending: boolean;\n error?: Error;\n sameInput: (a: Input, b: Input) => boolean;\n describe: (input: Input) => string;\n isEmpty: (data: Data) => boolean;\n}): DataView<Data, Input> {\n const shown = current ?? previous;\n if (!shown) return error ? { kind: 'error', error } : { kind: 'loading' };\n const currentInput = sameInput(shown.input, requestedInput);\n if (error)\n return {\n kind: 'stale-error',\n data: shown.data,\n displayedInput: shown.input,\n requestedInput,\n error,\n message: currentInput\n ? `Couldn’t refresh. Showing the last result for ${describe(shown.input)}.`\n : `Couldn’t refresh. Showing ${describe(shown.input)} while ${describe(requestedInput)} is unavailable.`,\n };\n if (pending || !currentInput)\n return {\n kind: 'updating',\n data: shown.data,\n displayedInput: shown.input,\n requestedInput,\n message: currentInput\n ? `Updating ${describe(requestedInput)}…`\n : `Showing ${describe(shown.input)} while loading ${describe(requestedInput)}…`,\n };\n\n return isEmpty(shown.data)\n ? { kind: 'empty', input: shown.input }\n : { kind: 'ready', data: shown.data, input: shown.input };\n}\n"],"mappings":";;;;;;;;AACA,SAAgB,aAAa,EAC3B,UACA,QAIO;CACP,MAAM,MAAM,IAAI,gBAAgB,IAAI;CACpC,MAAM,OAAO,SAAS,cAAc,GAAG;CACvC,KAAK,OAAO;CACZ,KAAK,WAAW;CAChB,SAAS,KAAK,OAAO,IAAI;CACzB,IAAI;EACF,KAAK,MAAM;CACb,UAAU;EACR,KAAK,OAAO;EACZ,iBAAiB,IAAI,gBAAgB,GAAG,GAAG,GAAI;CACjD;AACF;;;;ACQA,SAAgB,kBACd,MAC4C;CAC5C,IAAI,KAAK,SAAS,SAChB,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO,KAAK;EAAO,OAAO,KAAK;CAAK;CAChE,IAAI,KAAK,SAAS,cAAc,KAAK,SAAS,eAC5C,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO,KAAK;EAAgB,OAAO,KAAK;CAAK;AAG3E;;AAGA,SAAgB,gBAA6B,EAC3C,gBACA,SACA,UACA,SACA,OACA,WACA,UACA,WAUwB;CACxB,MAAM,QAAQ,WAAW;CACzB,IAAI,CAAC,OAAO,OAAO,QAAQ;EAAE,MAAM;EAAS;CAAM,IAAI,EAAE,MAAM,UAAU;CACxE,MAAM,eAAe,UAAU,MAAM,OAAO,cAAc;CAC1D,IAAI,OACF,OAAO;EACL,MAAM;EACN,MAAM,MAAM;EACZ,gBAAgB,MAAM;EACtB;EACA;EACA,SAAS,eACL,iDAAiD,SAAS,MAAM,KAAK,EAAE,KACvE,6BAA6B,SAAS,MAAM,KAAK,EAAE,SAAS,SAAS,cAAc,EAAE;CAC3F;CACF,IAAI,WAAW,CAAC,cACd,OAAO;EACL,MAAM;EACN,MAAM,MAAM;EACZ,gBAAgB,MAAM;EACtB;EACA,SAAS,eACL,YAAY,SAAS,cAAc,EAAE,KACrC,WAAW,SAAS,MAAM,KAAK,EAAE,iBAAiB,SAAS,cAAc,EAAE;CACjF;CAEF,OAAO,QAAQ,MAAM,IAAI,IACrB;EAAE,MAAM;EAAS,OAAO,MAAM;CAAM,IACpC;EAAE,MAAM;EAAS,MAAM,MAAM;EAAM,OAAO,MAAM;CAAM;AAC5D"}
1
+ {"version":3,"file":"internal.js","names":[],"sources":["../src/client/download.ts","../src/core/data-view.ts","../src/server/request-body.ts"],"sourcesContent":["/** Start a browser download and release its temporary anchor and object URL. */\nexport function downloadBlob({\n filename,\n blob,\n}: {\n filename: string;\n blob: Blob;\n}): void {\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n document.body.append(link);\n try {\n link.click();\n } finally {\n link.remove();\n setTimeout(() => URL.revokeObjectURL(url), 1000);\n }\n}\n","export type DataView<T, Input = unknown> =\n | { kind: 'loading' }\n | { kind: 'empty'; input: Input }\n | { kind: 'error'; error: Error }\n | { kind: 'ready'; data: T; input: Input }\n | {\n kind: 'updating';\n data: T;\n requestedInput: Input;\n displayedInput: Input;\n message: string;\n }\n | {\n kind: 'stale-error';\n data: T;\n requestedInput: Input;\n displayedInput: Input;\n error: Error;\n message: string;\n };\n\ntype DataSnapshot<Data, Input> = { data: Data; input: Input };\nexport type DisplayedSnapshot<Data, Input> = DataSnapshot<Data, Input> & {\n state: 'ready' | 'updating' | 'stale-error';\n};\n\n/** The result currently shown to the reader, including the input that produced it. */\nexport function displayedSnapshot<Data, Input>(\n view: DataView<Data, Input>\n): DisplayedSnapshot<Data, Input> | undefined {\n if (view.kind === 'ready')\n return { data: view.data, input: view.input, state: view.kind };\n if (view.kind === 'updating' || view.kind === 'stale-error')\n return { data: view.data, input: view.displayedInput, state: view.kind };\n\n return undefined;\n}\n\n/** Keep the requested input separate from the input that produced visible data. */\nexport function resolveDataView<Data, Input>({\n requestedInput,\n current,\n previous,\n pending,\n error,\n sameInput,\n describe,\n isEmpty,\n}: {\n requestedInput: Input;\n current?: DataSnapshot<Data, Input>;\n previous?: DataSnapshot<Data, Input>;\n pending: boolean;\n error?: Error;\n sameInput: (a: Input, b: Input) => boolean;\n describe: (input: Input) => string;\n isEmpty: (data: Data) => boolean;\n}): DataView<Data, Input> {\n const shown = current ?? previous;\n if (!shown) return error ? { kind: 'error', error } : { kind: 'loading' };\n const currentInput = sameInput(shown.input, requestedInput);\n // Empty results have no displayed content to preserve during a request.\n if (isEmpty(shown.data)) {\n if (error) return { kind: 'error', error };\n if (pending || !currentInput) return { kind: 'loading' };\n return { kind: 'empty', input: shown.input };\n }\n if (error)\n return {\n kind: 'stale-error',\n data: shown.data,\n displayedInput: shown.input,\n requestedInput,\n error,\n message: currentInput\n ? `Couldn’t refresh. Showing the last result for ${describe(shown.input)}.`\n : `Couldn’t refresh. Showing ${describe(shown.input)} while ${describe(requestedInput)} is unavailable.`,\n };\n if (pending || !currentInput)\n return {\n kind: 'updating',\n data: shown.data,\n displayedInput: shown.input,\n requestedInput,\n message: currentInput\n ? `Updating ${describe(requestedInput)}…`\n : `Showing ${describe(shown.input)} while loading ${describe(requestedInput)}…`,\n };\n\n return { kind: 'ready', data: shown.data, input: shown.input };\n}\n","export class RequestBodyTooLargeError extends Error {}\n\n/** Count encoded bytes before retaining chunks; cancellation also interrupts waiting reads. */\nexport async function readRequestBody(\n request: Request,\n maxBytes: number\n): Promise<string> {\n const body = request.body;\n if (!body) return '';\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n let abort: (() => void) | undefined;\n\n function cancelReader() {\n // The source's cancel algorithm may never settle; the handler must still respond.\n void reader.cancel().catch(() => {});\n }\n\n try {\n request.signal.throwIfAborted();\n const cancelled = new Promise<never>((_, reject) => {\n function rejectAborted() {\n reject(new Error('Request aborted.'));\n cancelReader();\n }\n abort = rejectAborted;\n request.signal.addEventListener('abort', rejectAborted, { once: true });\n if (request.signal.aborted) rejectAborted();\n });\n while (true) {\n const { done, value } = await Promise.race([reader.read(), cancelled]);\n if (done) break;\n size += value.byteLength;\n if (size > maxBytes) {\n cancelReader();\n throw new RequestBodyTooLargeError();\n }\n chunks.push(value);\n }\n const bytes = new Uint8Array(size);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n\n return new TextDecoder().decode(bytes);\n } finally {\n if (abort) request.signal.removeEventListener('abort', abort);\n reader.releaseLock();\n }\n}\n"],"mappings":";;;;;AACA,SAAgB,aAAa,EAC3B,UACA,QAIO;CACP,MAAM,MAAM,IAAI,gBAAgB,IAAI;CACpC,MAAM,OAAO,SAAS,cAAc,GAAG;CACvC,KAAK,OAAO;CACZ,KAAK,WAAW;CAChB,SAAS,KAAK,OAAO,IAAI;CACzB,IAAI;EACF,KAAK,MAAM;CACb,UAAU;EACR,KAAK,OAAO;EACZ,iBAAiB,IAAI,gBAAgB,GAAG,GAAG,GAAI;CACjD;AACF;;;;ACQA,SAAgB,kBACd,MAC4C;CAC5C,IAAI,KAAK,SAAS,SAChB,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO,KAAK;EAAO,OAAO,KAAK;CAAK;CAChE,IAAI,KAAK,SAAS,cAAc,KAAK,SAAS,eAC5C,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO,KAAK;EAAgB,OAAO,KAAK;CAAK;AAG3E;;AAGA,SAAgB,gBAA6B,EAC3C,gBACA,SACA,UACA,SACA,OACA,WACA,UACA,WAUwB;CACxB,MAAM,QAAQ,WAAW;CACzB,IAAI,CAAC,OAAO,OAAO,QAAQ;EAAE,MAAM;EAAS;CAAM,IAAI,EAAE,MAAM,UAAU;CACxE,MAAM,eAAe,UAAU,MAAM,OAAO,cAAc;CAE1D,IAAI,QAAQ,MAAM,IAAI,GAAG;EACvB,IAAI,OAAO,OAAO;GAAE,MAAM;GAAS;EAAM;EACzC,IAAI,WAAW,CAAC,cAAc,OAAO,EAAE,MAAM,UAAU;EACvD,OAAO;GAAE,MAAM;GAAS,OAAO,MAAM;EAAM;CAC7C;CACA,IAAI,OACF,OAAO;EACL,MAAM;EACN,MAAM,MAAM;EACZ,gBAAgB,MAAM;EACtB;EACA;EACA,SAAS,eACL,iDAAiD,SAAS,MAAM,KAAK,EAAE,KACvE,6BAA6B,SAAS,MAAM,KAAK,EAAE,SAAS,SAAS,cAAc,EAAE;CAC3F;CACF,IAAI,WAAW,CAAC,cACd,OAAO;EACL,MAAM;EACN,MAAM,MAAM;EACZ,gBAAgB,MAAM;EACtB;EACA,SAAS,eACL,YAAY,SAAS,cAAc,EAAE,KACrC,WAAW,SAAS,MAAM,KAAK,EAAE,iBAAiB,SAAS,cAAc,EAAE;CACjF;CAEF,OAAO;EAAE,MAAM;EAAS,MAAM,MAAM;EAAM,OAAO,MAAM;CAAM;AAC/D;;;AC1FA,IAAa,2BAAb,cAA8C,MAAM,CAAC;;AAGrD,eAAsB,gBACpB,SACA,UACiB;CACjB,MAAM,OAAO,QAAQ;CACrB,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,SAAuB,CAAC;CAC9B,IAAI,OAAO;CACX,IAAI;CAEJ,SAAS,eAAe;EAEtB,OAAY,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;CACrC;CAEA,IAAI;EACF,QAAQ,OAAO,eAAe;EAC9B,MAAM,YAAY,IAAI,SAAgB,GAAG,WAAW;GAClD,SAAS,gBAAgB;IACvB,uBAAO,IAAI,MAAM,kBAAkB,CAAC;IACpC,aAAa;GACf;GACA,QAAQ;GACR,QAAQ,OAAO,iBAAiB,SAAS,eAAe,EAAE,MAAM,KAAK,CAAC;GACtE,IAAI,QAAQ,OAAO,SAAS,cAAc;EAC5C,CAAC;EACD,OAAO,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,MAAM,QAAQ,KAAK,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;GACrE,IAAI,MAAM;GACV,QAAQ,MAAM;GACd,IAAI,OAAO,UAAU;IACnB,aAAa;IACb,MAAM,IAAI,yBAAyB;GACrC;GACA,OAAO,KAAK,KAAK;EACnB;EACA,MAAM,QAAQ,IAAI,WAAW,IAAI;EACjC,IAAI,SAAS;EACb,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,IAAI,OAAO,MAAM;GACvB,UAAU,MAAM;EAClB;EAEA,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CACvC,UAAU;EACR,IAAI,OAAO,QAAQ,OAAO,oBAAoB,SAAS,KAAK;EAC5D,OAAO,YAAY;CACrB;AACF"}
@@ -1,10 +1,12 @@
1
- import { n as DateTimeRange, s as ResolvedDateTimeRange } from "./date-time-range.js";
1
+ import { c as DateTimeRange, p as ResolvedDateTimeRange } from "./date-time-range-value.js";
2
2
  //#region src/core/date-time-range-contract.d.ts
3
3
  /** What an operation receives for a date filter: resolved bounds, `from` inclusive and
4
4
  * `to` exclusive, and the same window one selected length earlier while the comparison is on. */
5
5
  type DateTimeRangeInput = {
6
6
  range: ResolvedDateTimeRange;
7
7
  comparison: ResolvedDateTimeRange | null;
8
+ /** Original selection, retained so relative bounds can be resolved when a query runs. */
9
+ selection?: DateTimeRangeSelection;
8
10
  };
9
11
  type DateTimeRangePolicyOptions = {
10
12
  minDate?: string;
@@ -98,9 +100,15 @@ type DateTimeRangeFilter<Comparable extends boolean = boolean> = AppFilter<DateT
98
100
  previous: (selection: DateTimeRangeSelection) => DateTimeRangeInput['comparison'];
99
101
  };
100
102
  /** One declaration drives the picker, URL state, and the input of operations that list it.
101
- * Operations receive `{ range, comparison }`: `from` inclusive, `to` exclusive.
103
+ * Operations receive resolved bounds and the original selection: `from` inclusive, `to` exclusive.
102
104
  */
103
105
  declare function dateTimeRangeFilter<Comparison extends DateTimeRangeComparison | undefined = undefined>(options: DateTimeRangeFilterOptions<Comparison>): DateTimeRangeFilter<undefined extends Comparison ? false : true>;
106
+ /** Bind one date selection immediately before dispatching a query. Both periods share one clock. */
107
+ declare function queryDateTimeRangeParams<const Prefix extends string>(filter: Pick<DateTimeRangeFilter, 'request'>, input: DateTimeRangeInput, prefix: Prefix, now?: Date): {
108
+ current: Record<`${Prefix}_from` | `${Prefix}_to`, string>;
109
+ comparison: Record<`${Prefix}_from` | `${Prefix}_to`, string> | null;
110
+ combined: Record<`${Prefix}_from` | `${Prefix}_to`, string>;
111
+ };
104
112
  //#endregion
105
113
  //#region src/core/facets.d.ts
106
114
  declare const facetSource: unique symbol;
@@ -189,6 +197,7 @@ declare function dimensionPredicate<T extends DimensionValue, const Columns exte
189
197
  //#endregion
190
198
  //#region src/core/queries.d.ts
191
199
  declare const MAX_QUERY_ROWS = 10000;
200
+ declare const REGISTERED_QUERY_ID_PATTERN: RegExp;
192
201
  type QueryValues = {
193
202
  string: string;
194
203
  number: number;
@@ -208,11 +217,9 @@ type QueryValue<Field extends QueryField> = QueryValues[Field['type']] | (Field
208
217
  type QueryRow<Projections extends QueryProjections> = { -readonly [Name in keyof Projections]: QueryValue<Projections[Name]>; };
209
218
  type QueryParameterValue = string | number | boolean | null;
210
219
  /** Typed scalar, datetime-range, or dimension parameters with optional fallback values.
211
- * Reference a range's bounds as `$name.from` (inclusive) and `$name.to` (exclusive),
212
- * and a dimension selection as `$name.matches(column)`. */
220
+ * Structured values bind as JSON; statements use DuckDB SQL to read their fields. */
213
221
  type QueryParameter = {
214
- /** A dimension filter's `DimensionSelection`; `$name.matches(column)` is true
215
- * for the rows it keeps, including missing-value and exclusion semantics. */
222
+ /** A dimension filter's `DimensionSelection`, bound as validated JSON. */
216
223
  type: 'dimension';
217
224
  valueType: 'string' | 'number';
218
225
  nullable?: false;
@@ -247,7 +254,7 @@ type QueryDefinition = {
247
254
  };
248
255
  type QueryDefinitions = Readonly<Record<string, QueryDefinition>>;
249
256
  type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
250
- 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;
257
+ type KnownRecord<RecordType> = string extends keyof RecordType ? never : Exclude<keyof RecordType, string> extends never ? true extends IsUnion<RecordType> ? never : RecordType : never;
251
258
  type CheckedField<Field extends {
252
259
  type: string;
253
260
  nullable?: boolean;
@@ -305,23 +312,30 @@ type DisclosedQuery = {
305
312
  params?: QueryParameters;
306
313
  queryId?: string;
307
314
  };
308
- /** Query interface supplied by a server adapter or an authorized iframe bridge. */
309
- type Lakehouse = {
310
- queryAll(statement: string, options: {
311
- limit: number;
312
- signal: AbortSignal;
315
+ type QueryOptions = {
316
+ limit: number;
317
+ signal: AbortSignal;
318
+ params?: QueryParameters;
319
+ };
320
+ /** SQL execution supplied by a local server adapter. */
321
+ type SqlLakehouse = {
322
+ queryAll(statement: string, options: QueryOptions & {
313
323
  name?: string;
314
- params?: QueryParameters;
315
324
  }): Promise<QueryResult>;
316
325
  };
326
+ /** Registered query execution supplied by an authorized hosted bridge. */
327
+ type HostedLakehouse = {
328
+ queryAllById(queryId: string, options: QueryOptions): Promise<QueryResult>;
329
+ };
330
+ type Lakehouse = SqlLakehouse | HostedLakehouse;
317
331
  type OperationContext = {
318
- lakehouse: Lakehouse;
332
+ lakehouse: SqlLakehouse;
319
333
  signal: AbortSignal;
320
334
  queryParams?: QueryParameters;
321
335
  };
322
336
  /**
323
- * The input parser runs in the operation executor's runtime: server for HTTP apps, browser for
324
- * bundle apps. Browser validation does not replace backend authorization or query limits.
337
+ * The input parser runs in the browser. Browser validation does not replace
338
+ * backend authorization or query limits.
325
339
  * Registered queries decode rows from their declared projections; `run` derives the operation's data.
326
340
  */
327
341
  type DataOperation<Input, Output> = {
@@ -352,7 +366,7 @@ type DataQueryBody<Output> = {
352
366
  queryIds: string[];
353
367
  queries?: DisclosedQuery[];
354
368
  };
355
- /** Delivery envelope shared by HTTP and iframe transports. */
369
+ /** Delivery envelope for typed message routes. */
356
370
  type TransportResponse<Body = unknown> = {
357
371
  status: number;
358
372
  body: Body;
@@ -483,7 +497,7 @@ type AppFilter<Value, Kind extends string = string> = {
483
497
  type FilterCollection = Record<string, SearchFilter | ChoiceFilter<any> | MultiChoiceFilter | DateTimeRangeFilter | DimensionFilter<any> | FacetFilter<any, string> | SourceDimensionFilter<any> | NumberFilter | BooleanFilter>;
484
498
  type FilterValues<Collection> = { [Key in keyof Collection]: Collection[Key] extends DimensionSelectionFilter<infer Value> ? DimensionSelection<Value> : Collection[Key] extends AppFilter<infer Value, string> ? Value : never; };
485
499
  /** Keep conditional declarations narrowed so every dependency has one contract. */
486
- type CheckedFilterDeclarations<Collection extends FilterCollection> = true extends IsUnion<Collection> ? never : string extends keyof Collection ? Collection : '__proto__' extends keyof Collection ? never : { [Name in keyof Collection]: true extends IsUnion<Collection[Name]> ? never : Collection[Name]; };
500
+ type CheckedFilterDeclarations<Collection extends FilterCollection> = true extends IsUnion<Collection> ? never : string extends keyof Collection ? Collection : { [Name in keyof Collection]: true extends IsUnion<Collection[Name]> ? never : Collection[Name]; };
487
501
  /** Name filters once in the app. URL keys must be unique across its controls. */
488
502
  declare function defineAppFilters<const Collection extends FilterCollection>(filters: Collection): Collection;
489
503
  type ScalarFilterOptions = {
@@ -556,6 +570,33 @@ declare function resolveFilterInput<Filters extends FilterCollection>(filters: F
556
570
  /** Every operation in an app shares one filter per name and one owner per URL key. */
557
571
  declare function combineOperationFilters(operations: Readonly<Record<string, FilterCollection>>): FilterCollection;
558
572
  //#endregion
573
+ //#region src/core/facet-filter.d.ts
574
+ type FacetFilterOptions<Value extends DimensionValue, Operation extends string> = DimensionFilterSettings<Value> & {
575
+ /** The registered operation that returns this dimension's options. */
576
+ options: Operation;
577
+ };
578
+ /** Options load from `options`, an operation returning `DimensionOption[]`; the
579
+ * client checks that it is registered. Validate selections like any dimension. */
580
+ declare function facetFilter<const Operation extends string>(config: FacetFilterOptions<string, Operation> & {
581
+ valueType: 'string';
582
+ }): FacetFilter<string, Operation>;
583
+ declare function facetFilter<const Operation extends string>(config: FacetFilterOptions<number, Operation> & {
584
+ valueType: 'number';
585
+ }): FacetFilter<number, Operation>;
586
+ //#endregion
587
+ //#region src/core/date-time-range-sql.d.ts
588
+ /** Bind a resolved filter range as timestamp strings for literal DuckDB SQL.
589
+ * Dates carry reporting-zone wall-clock fields in UTC; omit `Z` for TIMESTAMP casts. */
590
+ declare function resolvedDateTimeRangeParams<const Prefix extends string>(range: ResolvedDateTimeRange, prefix: Prefix): Record<`${Prefix}_from` | `${Prefix}_to`, string>;
591
+ /** DuckDB timestamp expressions using the query session's timezone for relative anchors.
592
+ * Absolute fields remain UTC-rebased TIMESTAMP values. Start is inclusive, end exclusive.
593
+ */
594
+ declare function dateTimeRangeSql(range: DateTimeRange, parameter?: string): {
595
+ from: string;
596
+ to: string;
597
+ params: Record<string, string>;
598
+ };
599
+ //#endregion
559
600
  //#region src/authoring/contract.d.ts
560
601
  declare function parseTrue(value: unknown): true;
561
602
  type ReportingPeriod = {
@@ -584,7 +625,12 @@ type RegisteredQuery<Queries extends QueryDefinitions> = <Name extends keyof Que
584
625
  type OperationRun<Input, Output, Queries extends QueryDefinitions> = (context: Pick<OperationContext, 'signal'> & {
585
626
  query: RegisteredQuery<NoInfer<Queries>>;
586
627
  }, input: Input) => Promise<Output>;
587
- type OperationPolicy = DataOperation<unknown, unknown>['policy'];
628
+ type ResolvedOperationPolicy = DataOperation<unknown, unknown>['policy'];
629
+ /** Limits for one operation. `maxQueryRows` caps each query. */
630
+ type OperationPolicy = Omit<ResolvedOperationPolicy, 'maxDurationMs'> & {
631
+ /** @default 15000 */
632
+ maxDurationMs?: number;
633
+ };
588
634
  /** An operation that reads app filters. Its input has one field per filter, validated by
589
635
  * the filters themselves; views derive their filters, scope, and period from it. */
590
636
  type FilterOperationDefinition<Filters extends FilterCollection, Output, Queries extends QueryDefinitions> = {
@@ -634,5 +680,199 @@ declare function connectionCheck<const Queries extends QueryDefinitions & {
634
680
  connection: QueryDefinitions[string];
635
681
  }>(queries: CheckedQueries<Queries>): ConnectionOperation;
636
682
  //#endregion
637
- export { DataQueryInput as $, multiChoiceFilter as A, dimensionFilter as At, NumberSelection as B, DateTimeRangePreset as Bt, FilterPresentation as C, DimensionFilterSettings as Ct, choiceFilter as D, DimensionSelectionFilter as Dt, SearchFilter as E, DimensionSelection as Et, NavigationUpdate as F, FacetFilter as Ft, parseNumberSelection as G, DateTimeRangeInput as Gt, numberFilter as H, DateTimeRangeSelection as Ht, BooleanFilter as I, facetSource as It, SourceDimensionFilter as J, DimensionSourceConfig as K, DateTimeRangePolicy as Kt, BooleanSelection as L, DateTimeRangeComparison as Lt, validateChoiceOptions as M, dimensionPredicate as Mt, AppLocation as N, parseDimensionSelection as Nt, defineAppFilters as O, DimensionValue as Ot, HistoryMode as P, parseFacetOptions as Pt, DataQueryBody as Q, NumberFilter as R, DateTimeRangeFilter as Rt, FilterCollection as S, DimensionFilterOptions as St, MultiChoiceFilter as T, DimensionOption as Tt, numberOperatorLabels as U, dateTimeRangeFilter as Ut, booleanFilter as V, DateTimeRangeRequest as Vt, parseBooleanSelection as W, dateTimeRangePresets as Wt, DataOperation as X, dimensionSource as Y, DataOperations as Z, resolveFilterInput as _, QueryProjections as _t, RegisteredQuery as a, OutputOf as at, ChoiceFilter as b, QueryValueType as bt, connectionCheck as c, CheckedQueries as ct, parseCount as d, MAX_QUERY_ROWS as dt, DisclosedQuery as et, parseLabel as f, QueryDefinitions as ft, dateFilterName as g, QueryParameters as gt, combineOperationFilters as h, QueryParameterValue as ht, InputOperationDefinition as i, OperationContracts as it, searchFilter as j, dimensionMemberKey as jt, displayChoice as k, createDimensionFilter as kt, defineOperation as l, IsUnion as lt, FilterInput as m, QueryParameter as mt, DefinedOperation as n, Lakehouse as nt, ReportingPeriod as o, QueryResult as ot, parseTrue as p, QueryField as pt, DimensionSourceQueryName as q, FilterOperationDefinition as r, OperationContext as rt, WithFilterInput as s, TransportResponse as st, ConnectionOperation as t, InputOf as tt, defineQueryNames as u, KnownRecord as ut, AppFilter as v, QueryRow as vt, FilterValues as w, DimensionMember as wt, ChoiceOption as x, DimensionFilter as xt, CheckedFilterDeclarations as y, QuerySnapshot as yt, NumberOperator as z, DateTimeRangeFilterOptions as zt };
683
+ //#region src/core/messages.d.ts
684
+ type MessageContext = {
685
+ signal: AbortSignal;
686
+ };
687
+ type RoutedMessage = {
688
+ route: string;
689
+ payload: unknown;
690
+ };
691
+ type MessageDispatcher = (message: unknown, context: MessageContext) => Promise<unknown>;
692
+ type MessageTransport = (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
693
+ type MessageRoute<Input, Output> = {
694
+ input: (value: unknown) => Input;
695
+ output: (value: unknown, input: Input) => Output;
696
+ };
697
+ type MessageRoutes = Record<string, {
698
+ input: (value: unknown) => unknown;
699
+ output: (value: unknown, input: never) => unknown;
700
+ }>;
701
+ type MessageInput<Route extends MessageRoutes[string]> = ReturnType<Route['input']>;
702
+ type MessageHandlers<Routes extends MessageRoutes> = { [Name in keyof Routes]: (payload: MessageInput<Routes[Name]>, context: MessageContext) => ReturnType<Routes[Name]['output']> | Promise<ReturnType<Routes[Name]['output']>>; };
703
+ declare const errorBrand: unique symbol;
704
+ /** Only these deliberate, public failures cross the message boundary. Other errors stay private. */
705
+ declare class MessageRoutingError extends Error {
706
+ readonly code: string;
707
+ readonly requestId?: string | undefined;
708
+ readonly [errorBrand] = true;
709
+ static [Symbol.hasInstance](value: unknown): boolean;
710
+ constructor(code: string, message: string, requestId?: string | undefined,
711
+ /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */
712
+ options?: ErrorOptions);
713
+ }
714
+ declare function defineMessageRoute<Input, Output>(route: MessageRoute<Input, Output>): MessageRoute<Input, Output>;
715
+ /** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */
716
+ declare function createMessageRouter<const Routes extends MessageRoutes>(routes: Routes, handlers: MessageHandlers<NoInfer<Routes>>): {
717
+ dispatch: (value: unknown, context: MessageContext) => Promise<unknown>;
718
+ };
719
+ type DataOperationRoute<Operations extends OperationContracts> = MessageRoute<DataQueryInput<Operations>, TransportResponse> & {
720
+ operations: Operations | undefined;
721
+ };
722
+ type MessageOutput<Route extends MessageRoutes[string], Input> = Route extends DataOperationRoute<infer Operations> ? Input extends {
723
+ operation: infer Name extends keyof Operations;
724
+ } ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>> : never : ReturnType<Route['output']>;
725
+ /** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */
726
+ declare function defineDataOperationRoute<Operations extends OperationContracts = OperationContracts>(operations?: Operations): DataOperationRoute<Operations>;
727
+ declare const navigationUpdateRoute: MessageRoute<NavigationUpdate, null>;
728
+ type RegisteredQueryInput = {
729
+ queryId: string;
730
+ limit: number;
731
+ params?: QueryParameters;
732
+ };
733
+ /** Run a SQL query already registered by the app's defineDataApp manifest. */
734
+ declare const registeredQueryRoute: MessageRoute<RegisteredQueryInput, QueryResult>;
735
+ declare const dataAppRoutes: {
736
+ 'data:query': MessageRoute<RegisteredQueryInput, QueryResult>;
737
+ 'navigation:update': MessageRoute<NavigationUpdate, null>;
738
+ };
739
+ //#endregion
740
+ //#region src/core/annotations.d.ts
741
+ type DataAppAnnotationDraft = {
742
+ id: string;
743
+ target: {
744
+ id: string;
745
+ label: string;
746
+ kind: 'widget' | 'element' | 'app';
747
+ text: string;
748
+ queryNames: string[];
749
+ glossaryIds: string[];
750
+ };
751
+ context: {
752
+ search: string;
753
+ hash: string;
754
+ displayedInput?: unknown;
755
+ /** Normalized position within the selected target, stable across scrolling/resizing. */
756
+ anchor?: {
757
+ x: number;
758
+ y: number;
759
+ };
760
+ cursor?: {
761
+ x: number;
762
+ y: number;
763
+ };
764
+ /** Normalized custom selection rectangle within the iframe document. */
765
+ region?: {
766
+ x: number;
767
+ y: number;
768
+ width: number;
769
+ height: number;
770
+ };
771
+ screenshot?: {
772
+ mimeType: 'image/png';
773
+ dataUrl: string;
774
+ width: number;
775
+ height: number;
776
+ };
777
+ view?: string;
778
+ viewport: {
779
+ width: number;
780
+ height: number;
781
+ };
782
+ rect: {
783
+ x: number;
784
+ y: number;
785
+ width: number;
786
+ height: number;
787
+ };
788
+ };
789
+ comment: string;
790
+ };
791
+ type DataAppAnnotationPresentation = {
792
+ enabled: boolean;
793
+ /** When provided, the host owns the mode and renders the annotation trigger.
794
+ * Without an in-frame toolbar, as on embedded surfaces, the host always owns it; omitted means inactive. */
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 { dateFilterName as $, QueryParameter as $t, dataAppRoutes as A, dateTimeRangePresets as An, DimensionSourceQueryName as At, ReportingPeriod as B, Lakehouse as Bt, MessageRoute as C, DateTimeRangeComparison as Cn, NumberSelection as Ct, RegisteredQueryInput as D, DateTimeRangeRequest as Dn, parseBooleanSelection as Dt, MessageTransport as E, DateTimeRangePreset as En, numberOperatorLabels as Et, ConnectionOperation as F, DataQueryBody as Ft, parseCount as G, SqlLakehouse as Gt, connectionCheck as H, OperationContracts as Ht, DefinedOperation as I, DataQueryInput as It, dateTimeRangeSql as J, IsUnion as Jt, parseLabel as K, TransportResponse as Kt, FilterOperationDefinition as L, DisclosedQuery as Lt, defineMessageRoute as M, DateTimeRangeInput as Mn, dimensionSource as Mt, navigationUpdateRoute as N, DateTimeRangePolicy as Nn, DataOperation as Nt, RoutedMessage as O, DateTimeRangeSelection as On, parseNumberSelection as Ot, registeredQueryRoute as P, DataOperations as Pt, combineOperationFilters as Q, QueryField as Qt, InputOperationDefinition as R, HostedLakehouse as Rt, MessageOutput as S, facetSource as Sn, NumberOperator as St, MessageRoutingError as T, DateTimeRangeFilterOptions as Tn, numberFilter as Tt, defineOperation as U, OutputOf as Ut, WithFilterInput as V, OperationContext as Vt, defineQueryNames as W, QueryResult as Wt, facetFilter as X, MAX_QUERY_ROWS as Xt, resolvedDateTimeRangeParams as Y, KnownRecord as Yt, FilterInput as Z, QueryDefinitions as Zt, DataOperationRoute as _, dimensionMemberKey as _n, HistoryMode as _t, OpenExternalLink as a, QueryValueType as an, FilterCollection as at, MessageHandlers as b, parseFacetOptions as bn, BooleanSelection as bt, resolveExternalLinkTarget as c, DimensionFilterOptions as cn, MultiChoiceFilter as ct, annotationDraftRoute as d, DimensionOption as dn, defineAppFilters as dt, QueryParameterValue as en, resolveFilterInput as et, annotationEditorStateRoute as f, DimensionSelection as fn, displayChoice as ft, parseDataAppAnnotationDraft as g, dimensionFilter as gn, AppLocation as gt, annotationUpdateRoute as h, createDimensionFilter as hn, validateChoiceOptions as ht, ExternalLinkTarget as i, QuerySnapshot as in, ChoiceOption as it, defineDataOperationRoute as j, queryDateTimeRangeParams as jn, SourceDimensionFilter as jt, createMessageRouter as k, dateTimeRangeFilter as kn, DimensionSourceConfig as kt, DataAppAnnotationDraft as l, DimensionFilterSettings as ln, SearchFilter as lt, annotationSendRoute as m, DimensionValue as mn, searchFilter as mt, ExternalLinkModifiers as n, QueryProjections as nn, CheckedFilterDeclarations as nt, openExternalLinkRoute as o, REGISTERED_QUERY_ID_PATTERN as on, FilterPresentation as ot, annotationModeRoute as p, DimensionSelectionFilter as pn, multiChoiceFilter as pt, parseTrue as q, CheckedQueries as qt, ExternalLinkResult as r, QueryRow as rn, ChoiceFilter as rt, parseExternalUrl as s, DimensionFilter as sn, FilterValues as st, DataSourceError as t, QueryParameters as tn, AppFilter as tt, DataAppAnnotationPresentation as u, DimensionMember as un, choiceFilter as ut, MessageContext as v, dimensionPredicate as vn, NavigationUpdate as vt, MessageRoutes as w, DateTimeRangeFilter as wn, booleanFilter as wt, MessageInput as x, FacetFilter as xn, NumberFilter as xt, MessageDispatcher as y, parseDimensionSelection as yn, BooleanFilter as yt, RegisteredQuery as z, InputOf as zt };
638
878
  //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { Bt as Lakehouse, Ft as DataQueryBody, Jt as IsUnion, Pt as DataOperations, Ut as OutputOf, Yt as KnownRecord, at as FilterCollection, dn as DimensionOption, xn as FacetFilter, zt as InputOf } from "./contract.js";
2
+ //#region src/client/data-client.d.ts
3
+ /**
4
+ * Parsed operation data and query evidence.
5
+ */
6
+ type DataResponse<Output, Input = unknown> = DataQueryBody<Output> & {
7
+ /** The exact browser input that produced this response. */
8
+ input: Input;
9
+ };
10
+ /** The filters each operation reads, for operations that read any. */
11
+ type OperationFilters<Operations extends DataOperations> = { readonly [Name in keyof Operations as Operations[Name] extends {
12
+ filters: infer Filters extends FilterCollection;
13
+ } ? keyof Filters extends never ? never : Name : never]: Operations[Name] extends {
14
+ filters: infer Filters;
15
+ } ? Filters : never; };
16
+ declare const clientContract: unique symbol;
17
+ type DataClient<Operations extends DataOperations> = {
18
+ /** Preserve the operation registry when passing clients through helpers. */
19
+ readonly [clientContract]: (operations: Operations) => Operations;
20
+ /** Each operation's filters; views derive their inputs and controls from them. */
21
+ readonly filters: Readonly<Record<string, FilterCollection>>;
22
+ query<Name extends keyof Operations & string>(this: void, name: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown), input: InputOf<Operations[NoInfer<Name>]>, options?: {
23
+ signal?: AbortSignal;
24
+ }): Promise<DataResponse<OutputOf<Operations[Name]>, InputOf<Operations[Name]>>>;
25
+ };
26
+ /** Distribute over conditional filter members so each possible facet is checked. */
27
+ type UncheckedFacet<Operations extends DataOperations, Filter, Key> = Filter extends FacetFilter<infer Value, infer Source> ? Source extends keyof Operations ? OutputOf<Operations[Source]> extends readonly DimensionOption<Value>[] ? never : Key : Key : never;
28
+ /** The filter names whose facet options are missing or mistyped. Only known names:
29
+ * a typed contract may widen `filters` with an index signature. */
30
+ type UncheckedFacetNames<Operations extends DataOperations, Filters> = { [Key in keyof Filters as string extends Key ? never : Key]: UncheckedFacet<Operations, Filters[Key], Key>; } extends (infer Checked) ? Checked[keyof Checked] : never;
31
+ /** Every facet filter loads its options from a registered operation returning them. */
32
+ type CheckedFacets<Operations extends DataOperations> = { [Name in keyof Operations]: Operations[Name] extends {
33
+ filters: infer Filters;
34
+ } ? UncheckedFacetNames<Operations, Filters> : never; }[keyof Operations] extends never ? unknown : {
35
+ 'Facet filter options must name a registered operation returning DimensionOption[]': never;
36
+ };
37
+ /** Execute declared operations in the browser against registered query IDs. */
38
+ type DataClientOptions<Operations extends DataOperations> = (KnownRecord<Operations> extends never ? never : true extends { [Name in keyof Operations]: IsUnion<Operations[Name]>; }[keyof Operations] ? never : unknown) & {
39
+ operations: Operations;
40
+ lakehouse?: Lakehouse;
41
+ } & CheckedFacets<Operations>;
42
+ /** Create a browser operation client. */
43
+ declare function createDataClient<Operations extends DataOperations>(options: DataClientOptions<Operations>): DataClient<Operations>;
44
+ //#endregion
45
+ export { createDataClient as a, OperationFilters as i, DataClientOptions as n, DataResponse as r, DataClient as t };
46
+ //# sourceMappingURL=data-client.d.ts.map