@altertable/data-app 0.68.0 → 0.70.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 (203) hide show
  1. package/AGENTS.md +10 -0
  2. package/CONTRIBUTING.md +27 -1
  3. package/README.md +18 -21
  4. package/THIRD_PARTY_NOTICES +18 -0
  5. package/dist/chunks/index-22d576sn.js +153 -0
  6. package/dist/chunks/index-22d576sn.js.map +11 -0
  7. package/dist/chunks/index-2ajhmsc4.js +355 -0
  8. package/dist/chunks/index-2ajhmsc4.js.map +13 -0
  9. package/dist/chunks/{index-ktmvs916.js → index-58kks6a8.js} +37 -21
  10. package/dist/chunks/index-58kks6a8.js.map +13 -0
  11. package/dist/chunks/{index-23dktynd.js → index-7q99hf1z.js} +19 -12
  12. package/dist/chunks/index-7q99hf1z.js.map +10 -0
  13. package/dist/chunks/{index-mt93ff2b.js → index-9zqbrv2z.js} +7 -3
  14. package/dist/chunks/index-9zqbrv2z.js.map +10 -0
  15. package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
  16. package/dist/chunks/index-cv36cyna.js.map +10 -0
  17. package/dist/chunks/{index-ag0cgnvq.js → index-q1w84fv9.js} +178 -31
  18. package/dist/chunks/index-q1w84fv9.js.map +15 -0
  19. package/dist/chunks/{index-qd5xgx6y.js → index-rew95tbg.js} +89 -21
  20. package/dist/chunks/index-rew95tbg.js.map +13 -0
  21. package/dist/chunks/{index-gvers8jw.js → index-vtpygsbq.js} +5651 -2711
  22. package/dist/chunks/index-vtpygsbq.js.map +126 -0
  23. package/dist/chunks/{index-x69p7cv7.js → index-wjt6cavj.js} +6 -4
  24. package/dist/chunks/index-wjt6cavj.js.map +10 -0
  25. package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
  26. package/dist/chunks/index-wss3gd3h.js.map +13 -0
  27. package/dist/chunks/{index-ev2b5aaf.js → index-xzb7sx6g.js} +4 -4
  28. package/dist/client/index.js +6 -6
  29. package/dist/core/appearance.js +1 -1
  30. package/dist/core/config.js +3 -3
  31. package/dist/core/contract.js +7 -7
  32. package/dist/core/contract.js.map +1 -1
  33. package/dist/core/format.js +10 -2
  34. package/dist/core/format.js.map +1 -1
  35. package/dist/embed/index.js +26 -25
  36. package/dist/embed/index.js.map +4 -4
  37. package/dist/index.js +3 -3
  38. package/dist/local.js +200 -145
  39. package/dist/local.js.map +10 -7
  40. package/dist/preview.js +1456 -0
  41. package/dist/preview.js.map +17 -0
  42. package/dist/react/embed/index.js +1 -1
  43. package/dist/react/index.js +500 -401
  44. package/dist/react/index.js.map +10 -13
  45. package/dist/react/ui/index.js +1851 -1476
  46. package/dist/react/ui/index.js.map +24 -21
  47. package/dist/server.js +102 -58
  48. package/dist/server.js.map +9 -6
  49. package/dist/types/client/data-client.d.ts +21 -10
  50. package/dist/types/client/download.d.ts +5 -0
  51. package/dist/types/client/iframe.d.ts +4 -2
  52. package/dist/types/client/logger.d.ts +10 -2
  53. package/dist/types/core/annotations.d.ts +5 -0
  54. package/dist/types/core/appearance.d.ts +2 -0
  55. package/dist/types/core/bridge-endpoint.d.ts +2 -2
  56. package/dist/types/core/bridge.d.ts +22 -0
  57. package/dist/types/core/config.d.ts +25 -17
  58. package/dist/types/core/contract.d.ts +26 -14
  59. package/dist/types/core/date-format.d.ts +24 -0
  60. package/dist/types/core/dimension-source.d.ts +64 -0
  61. package/dist/types/core/dimension.d.ts +33 -24
  62. package/dist/types/core/facets.d.ts +13 -0
  63. package/dist/types/core/filters.d.ts +4 -3
  64. package/dist/types/core/format.d.ts +5 -3
  65. package/dist/types/core/keys.d.ts +2 -0
  66. package/dist/types/core/messages.d.ts +3 -1
  67. package/dist/types/core/operation-types.d.ts +12 -11
  68. package/dist/types/core/queries.d.ts +75 -7
  69. package/dist/types/core/time-interval.d.ts +96 -0
  70. package/dist/types/core/variables.d.ts +49 -14
  71. package/dist/types/embed/host.d.ts +4 -4
  72. package/dist/types/embed/sql.d.ts +1 -1
  73. package/dist/types/index.d.ts +1 -1
  74. package/dist/types/react/actions.d.ts +53 -0
  75. package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
  76. package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
  77. package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
  78. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
  79. package/dist/types/react/bindings.d.ts +62 -3
  80. package/dist/types/react/date-formatting.d.ts +12 -0
  81. package/dist/types/react/details.d.ts +46 -0
  82. package/dist/types/react/exploration.d.ts +44 -0
  83. package/dist/types/react/hooks.d.ts +82 -43
  84. package/dist/types/react/index.d.ts +10 -2
  85. package/dist/types/react/search-suggestions.d.ts +8 -0
  86. package/dist/types/react/style-contract.d.ts +1 -5
  87. package/dist/types/react/ui/AboutData.d.ts +9 -4
  88. package/dist/types/react/ui/AreaChart.d.ts +2 -2
  89. package/dist/types/react/ui/BarChart.d.ts +2 -2
  90. package/dist/types/react/ui/Button.d.ts +2 -1
  91. package/dist/types/react/ui/ChartLegend.d.ts +3 -2
  92. package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
  93. package/dist/types/react/ui/ComposedChartLegend.d.ts +2 -1
  94. package/dist/types/react/ui/DataApp.d.ts +8 -4
  95. package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
  96. package/dist/types/react/ui/DataTable.d.ts +6 -4
  97. package/dist/types/react/ui/DataWidget.d.ts +7 -0
  98. package/dist/types/react/ui/DateDisplay.d.ts +9 -0
  99. package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
  100. package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
  101. package/dist/types/react/ui/DimensionPicker.d.ts +5 -3
  102. package/dist/types/react/ui/EmptyState.d.ts +1 -1
  103. package/dist/types/react/ui/ExplorationActionControl.d.ts +60 -0
  104. package/dist/types/react/ui/GradientScroll.d.ts +8 -0
  105. package/dist/types/react/ui/Grid.d.ts +1 -1
  106. package/dist/types/react/ui/InspectionProvider.d.ts +2 -2
  107. package/dist/types/react/ui/LineChart.d.ts +2 -2
  108. package/dist/types/react/ui/Menu.d.ts +3 -2
  109. package/dist/types/react/ui/MetricWidget.d.ts +4 -0
  110. package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
  111. package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
  112. package/dist/types/react/ui/PickerField.d.ts +23 -0
  113. package/dist/types/react/ui/PieChart.d.ts +2 -2
  114. package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
  115. package/dist/types/react/ui/RequestHint.d.ts +2 -2
  116. package/dist/types/react/ui/SearchField.d.ts +3 -1
  117. package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
  118. package/dist/types/react/ui/SectionHeading.d.ts +8 -0
  119. package/dist/types/react/ui/Select.d.ts +9 -1
  120. package/dist/types/react/ui/Sheet.d.ts +4 -2
  121. package/dist/types/react/ui/TableWidget.d.ts +8 -0
  122. package/dist/types/react/ui/Tabs.d.ts +4 -3
  123. package/dist/types/react/ui/TrendChart.d.ts +3 -3
  124. package/dist/types/react/ui/VariableBar.d.ts +1 -1
  125. package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
  126. package/dist/types/react/ui/chart-data.d.ts +8 -6
  127. package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
  128. package/dist/types/react/ui/chart-interaction.d.ts +27 -0
  129. package/dist/types/react/ui/chart-primitives.d.ts +4 -4
  130. package/dist/types/react/ui/chart-time.d.ts +19 -0
  131. package/dist/types/react/ui/chartColor.d.ts +1 -1
  132. package/dist/types/react/ui/icons.d.ts +5 -1
  133. package/dist/types/react/ui/index.d.ts +10 -4
  134. package/dist/types/react/ui/metric-comparison.d.ts +2 -2
  135. package/dist/types/react/ui/metric.d.ts +2 -2
  136. package/dist/types/react/ui/presentation.d.ts +2 -0
  137. package/dist/types/react/ui/searchItems.d.ts +2 -0
  138. package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +2 -0
  139. package/dist/types/react/ui/variables.d.ts +1 -1
  140. package/dist/types/react/view-control-bar.d.ts +18 -0
  141. package/dist/types/react/view-controls.d.ts +3 -2
  142. package/dist/types/react/view-runtime.d.ts +8 -3
  143. package/dist/types/react/view.d.ts +28 -7
  144. package/dist/types/react/widgets.d.ts +22 -11
  145. package/dist/types/server/local.d.ts +3 -1
  146. package/dist/types/server/preview/host.d.ts +1 -0
  147. package/dist/types/server/preview/index.d.ts +16 -0
  148. package/dist/types/server/reload-channel.d.ts +6 -0
  149. package/dist/types/server/request-body.d.ts +4 -0
  150. package/dist/worker.js +1 -1
  151. package/docs/app-authoring.md +27 -12
  152. package/docs/client.md +6 -7
  153. package/docs/composition.md +84 -0
  154. package/docs/contract.md +45 -26
  155. package/docs/data-context.md +2 -0
  156. package/docs/embed.md +11 -3
  157. package/docs/formatting-and-appearance.md +36 -5
  158. package/docs/layout.md +31 -8
  159. package/docs/react-embed.md +4 -4
  160. package/docs/react.md +1 -1
  161. package/docs/server-bun.md +25 -0
  162. package/docs/server.md +2 -2
  163. package/docs/styling.md +10 -27
  164. package/docs/ui.md +32 -18
  165. package/docs/variables.md +174 -25
  166. package/docs/views.md +60 -29
  167. package/docs/widgets.md +131 -26
  168. package/examples/starter-data-app/index.tsx +10 -23
  169. package/examples/starter-local-data-app/.bun-version +1 -0
  170. package/examples/starter-local-data-app/.node-version +1 -0
  171. package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
  172. package/examples/starter-local-data-app/.oxlintrc.json +33 -0
  173. package/examples/starter-local-data-app/AGENTS.md +22 -0
  174. package/examples/starter-local-data-app/README.md +54 -0
  175. package/examples/starter-local-data-app/app.ts +28 -0
  176. package/examples/starter-local-data-app/bunfig.toml +2 -0
  177. package/examples/starter-local-data-app/package.json +33 -0
  178. package/examples/starter-local-data-app/src/App.tsx +8 -0
  179. package/examples/starter-local-data-app/src/assets.d.ts +1 -0
  180. package/examples/starter-local-data-app/src/data-context.ts +21 -0
  181. package/examples/starter-local-data-app/src/favicon.svg +13 -0
  182. package/examples/starter-local-data-app/src/index.html +14 -0
  183. package/examples/starter-local-data-app/src/main.tsx +7 -0
  184. package/examples/starter-local-data-app/src/operations.ts +6 -0
  185. package/examples/starter-local-data-app/src/server.ts +6 -0
  186. package/examples/starter-local-data-app/tsconfig.json +21 -0
  187. package/package.json +13 -3
  188. package/dist/chunks/index-23dktynd.js.map +0 -10
  189. package/dist/chunks/index-ag0cgnvq.js.map +0 -13
  190. package/dist/chunks/index-dq7b35fn.js +0 -307
  191. package/dist/chunks/index-dq7b35fn.js.map +0 -13
  192. package/dist/chunks/index-f5cnbrjz.js.map +0 -13
  193. package/dist/chunks/index-gvers8jw.js.map +0 -109
  194. package/dist/chunks/index-ktmvs916.js.map +0 -13
  195. package/dist/chunks/index-m6n8ctfc.js.map +0 -10
  196. package/dist/chunks/index-mev09s5v.js +0 -77
  197. package/dist/chunks/index-mev09s5v.js.map +0 -10
  198. package/dist/chunks/index-mt93ff2b.js.map +0 -10
  199. package/dist/chunks/index-qd5xgx6y.js.map +0 -13
  200. package/dist/chunks/index-x69p7cv7.js.map +0 -10
  201. package/dist/types/react/shellStyles.d.ts +0 -3
  202. package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
  203. /package/dist/chunks/{index-ev2b5aaf.js.map → index-xzb7sx6g.js.map} +0 -0
@@ -1,32 +1,38 @@
1
+ import {
2
+ withDimensionSelectors
3
+ } from "./index-q1w84fv9.js";
1
4
  import {
2
5
  executeDataOperation,
3
6
  toDataOperationFailure
4
- } from "./index-x69p7cv7.js";
7
+ } from "./index-wjt6cavj.js";
5
8
  import {
6
9
  DataAppError2,
7
10
  createHttpTransport2,
8
11
  localFrameBridge,
9
12
  getDataAppTransport2
10
- } from "./index-ktmvs916.js";
13
+ } from "./index-58kks6a8.js";
11
14
  import {
12
15
  randomUuid
13
- } from "./index-f5cnbrjz.js";
16
+ } from "./index-wss3gd3h.js";
14
17
  import {
15
18
  MessageRoutingError2,
16
19
  defineDataQueryRoute2
17
- } from "./index-qd5xgx6y.js";
20
+ } from "./index-rew95tbg.js";
18
21
 
19
22
  // src/client/data-client.ts
23
+ function typedClient(implementation) {
24
+ return implementation;
25
+ }
20
26
  var dataQueryRoute = defineDataQueryRoute2();
21
27
  function createDataClient2(options = {}) {
22
28
  if (options.operations)
23
29
  return createOperationClient({
24
- operations: options.operations,
30
+ operations: withDimensionSelectors(options.operations),
25
31
  lakehouse: options.lakehouse
26
32
  });
27
33
  const http = createHttpTransport2(options);
28
34
  const useHttp = options.endpoint !== undefined || options.fetch !== undefined;
29
- return {
35
+ return typedClient({
30
36
  async query(name, input, { signal } = {}) {
31
37
  const transport = options.transport ?? (useHttp ? http : localFrameBridge()?.transport ?? http);
32
38
  const response = await transport(name, input, signal);
@@ -43,20 +49,21 @@ function createDataClient2(options = {}) {
43
49
  }
44
50
  return { ...body, input };
45
51
  }
46
- };
52
+ });
47
53
  }
48
54
  function createOperationClient(options) {
49
- return {
55
+ const operations = Object.freeze({ ...options.operations });
56
+ return typedClient({
50
57
  async query(name, input, { signal } = {}) {
51
58
  signal?.throwIfAborted();
52
59
  const requestId = randomUuid();
53
- if (!Object.hasOwn(options.operations, name))
60
+ if (!Object.hasOwn(operations, name))
54
61
  throw new DataAppError2("Unknown data operation.", "not_found", requestId);
55
62
  const lakehouse = options.lakehouse ?? (typeof window === "undefined" ? undefined : getDataAppTransport2()?.lakehouse);
56
63
  if (!lakehouse)
57
64
  throw new DataAppError2("An authorized SQL bridge must be installed first.", "bridge_unavailable", requestId);
58
65
  try {
59
- const { body } = await executeDataOperation(options.operations[name], input, {
66
+ const { body } = await executeDataOperation(operations[name], input, {
60
67
  lakehouse,
61
68
  signal: signal ?? new AbortController().signal,
62
69
  requestId,
@@ -72,9 +79,9 @@ function createOperationClient(options) {
72
79
  throw new DataAppError2(failure.message, failure.code, requestId);
73
80
  }
74
81
  }
75
- };
82
+ });
76
83
  }
77
84
 
78
85
  export { createDataClient2 };
79
86
 
80
- //# debugId=F1FFBCC98547BBCD64756E2164756E21
87
+ //# debugId=76C2F64CBB98B04F64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/client/data-client.ts"],
4
+ "sourcesContent": [
5
+ "import type { IsUnion, KnownRecord } from '@/src/core/queries';\nimport { withDimensionSelectors } from '@/src/core/dimension-source';\nimport { randomUuid } from '@/src/core/uuid';\nimport { createHttpTransport, DataAppError } from '@/src/client/transport';\nimport { getDataAppTransport, localFrameBridge } from '@/src/client/iframe';\nimport {\n executeDataOperation,\n toDataOperationFailure,\n} from '@/src/core/operation';\nimport type { DataOperations, Lakehouse } from '@/src/core/contract';\nimport { defineDataQueryRoute, MessageRoutingError } from '@/src/core/messages';\nimport type { DataTransport } from '@/src/client/transport';\nimport type {\n DataQueryBody,\n InputOf,\n OutputOf,\n} from '@/src/core/operation-types';\nexport type { InputOf, OutputOf } from '@/src/core/operation-types';\n\n/**\n * Parsed operation data and query evidence.\n */\nexport type DataResponse<Output, Input = unknown> = DataQueryBody<Output> & {\n /** The exact browser input that produced this response. */\n input: Input;\n};\n\ndeclare const clientContract: unique symbol;\nexport type DataClient<Operations extends DataOperations> = {\n /** Preserve the operation registry when passing clients through helpers. */\n readonly [clientContract]: (operations: Operations) => Operations;\n query<Name extends keyof Operations & string>(\n this: void,\n name: Name & (true extends IsUnion<NoInfer<Name>> ? never : unknown),\n input: InputOf<Operations[NoInfer<Name>]>,\n options?: { signal?: AbortSignal }\n ): Promise<\n DataResponse<OutputOf<Operations[Name]>, InputOf<Operations[Name]>>\n >;\n};\n\n/** The factory is the only place that grants a client its invariant contract witness. */\nfunction typedClient<Operations extends DataOperations>(\n implementation: Pick<DataClient<Operations>, 'query'>\n): DataClient<Operations> {\n return implementation as DataClient<Operations>;\n}\n\ntype TransportOptions = {\n operations?: never;\n lakehouse?: never;\n transport?: DataTransport;\n endpoint?: string;\n fetch?: typeof fetch;\n};\n/** Browser operations and named-operation delivery are mutually exclusive. */\nexport type DataClientOptions<Operations extends DataOperations> =\n (KnownRecord<Operations> extends never\n ? never\n : true extends {\n [Name in keyof Operations]: IsUnion<Operations[Name]>;\n }[keyof Operations]\n ? never\n : unknown) &\n (\n | {\n operations: Operations;\n lakehouse?: Lakehouse;\n transport?: never;\n endpoint?: never;\n fetch?: never;\n }\n | TransportOptions\n );\n\nconst dataQueryRoute = defineDataQueryRoute();\n\n/** Named HTTP operations, or browser-owned operations executed through an authorized SQL bridge. */\nexport function createDataClient<Operations extends DataOperations>(\n options: DataClientOptions<Operations>\n): DataClient<Operations>;\n/** Named clients derive data from the declared operations' run return types. */\nexport function createDataClient<Operations extends DataOperations>(\n ...args: DataClientOptions<Operations> extends never ? [options: never] : []\n): DataClient<Operations>;\n/** Without an operation contract, external operation data remains unknown. */\nexport function createDataClient(\n options?: TransportOptions\n): DataClient<DataOperations>;\nexport function createDataClient<Operations extends DataOperations>(\n options: DataClientOptions<Operations> | TransportOptions = {}\n): DataClient<Operations> {\n if (options.operations)\n return createOperationClient({\n operations: withDimensionSelectors(options.operations),\n lakehouse: options.lakehouse,\n });\n const http = createHttpTransport(options);\n const useHttp = options.endpoint !== undefined || options.fetch !== undefined;\n\n return typedClient<Operations>({\n async query(name, input, { signal } = {}) {\n const transport =\n options.transport ??\n (useHttp ? http : (localFrameBridge()?.transport ?? http));\n const response = await transport(name, input, signal);\n const ok = response.status >= 200 && response.status < 300;\n let body: Omit<DataResponse<OutputOf<Operations[typeof name]>>, 'input'>;\n try {\n // The envelope is validated here; the shared operation contract owns data.\n body = dataQueryRoute.output(response, { operation: name, input })\n .body as typeof body;\n } catch (error) {\n if (signal?.aborted) throw error;\n if (error instanceof MessageRoutingError)\n throw new DataAppError(error.message, error.code, error.requestId);\n throw new DataAppError(\n ok ? 'The data response was invalid.' : 'Could not load data.',\n ok ? 'invalid_response' : 'request_failed'\n );\n }\n\n return { ...body, input };\n },\n });\n}\n\nfunction createOperationClient<Operations extends DataOperations>(options: {\n operations: Operations;\n lakehouse?: Lakehouse;\n}): DataClient<Operations> {\n const operations = Object.freeze({ ...options.operations });\n return typedClient<Operations>({\n async query(name, input, { signal } = {}) {\n signal?.throwIfAborted();\n const requestId = randomUuid();\n if (!Object.hasOwn(operations, name))\n throw new DataAppError(\n 'Unknown data operation.',\n 'not_found',\n requestId\n );\n const lakehouse =\n options.lakehouse ??\n (typeof window === 'undefined'\n ? undefined\n : getDataAppTransport()?.lakehouse);\n if (!lakehouse)\n throw new DataAppError(\n 'An authorized SQL bridge must be installed first.',\n 'bridge_unavailable',\n requestId\n );\n\n try {\n const { body } = await executeDataOperation(operations[name]!, input, {\n lakehouse,\n signal: signal ?? new AbortController().signal,\n requestId,\n operationName: name,\n });\n\n return { ...body, input } as DataResponse<\n OutputOf<Operations[typeof name]>,\n InputOf<Operations[typeof name]>\n >;\n } catch (error) {\n if (signal?.aborted) throw signal.reason;\n if (error instanceof DataAppError) throw error;\n const failure = toDataOperationFailure(error);\n throw new DataAppError(failure.message, failure.code, requestId);\n }\n },\n });\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAS,WAA8C,CACrD,gBACwB;AAAA,EACxB,OAAO;AAAA;AA8BT,IAAM,iBAAiB,sBAAqB;AAcrC,SAAS,iBAAmD,CACjE,UAA4D,CAAC,GACrC;AAAA,EACxB,IAAI,QAAQ;AAAA,IACV,OAAO,sBAAsB;AAAA,MAC3B,YAAY,uBAAuB,QAAQ,UAAU;AAAA,MACrD,WAAW,QAAQ;AAAA,IACrB,CAAC;AAAA,EACH,MAAM,OAAO,qBAAoB,OAAO;AAAA,EACxC,MAAM,UAAU,QAAQ,aAAa,aAAa,QAAQ,UAAU;AAAA,EAEpE,OAAO,YAAwB;AAAA,SACvB,MAAK,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG;AAAA,MACxC,MAAM,YACJ,QAAQ,cACP,UAAU,OAAQ,iBAAiB,GAAG,aAAa;AAAA,MACtD,MAAM,WAAW,MAAM,UAAU,MAAM,OAAO,MAAM;AAAA,MACpD,MAAM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AAAA,UAAc,MAAM;AAAA,QACzC,MAAM,UAAU,uBAAuB,KAAK;AAAA,QAC5C,MAAM,IAAI,cAAa,QAAQ,SAAS,QAAQ,MAAM,SAAS;AAAA;AAAA;AAAA,EAGrE,CAAC;AAAA;",
8
+ "debugId": "76C2F64CBB98B04F64756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,9 +1,10 @@
1
1
  import {
2
+ bindDimensionSource,
2
3
  defineOperation2
3
- } from "./index-ag0cgnvq.js";
4
+ } from "./index-q1w84fv9.js";
4
5
  import {
5
6
  snapshotQueries
6
- } from "./index-qd5xgx6y.js";
7
+ } from "./index-rew95tbg.js";
7
8
 
8
9
  // src/core/config.ts
9
10
  function defineDataApp2(config) {
@@ -11,6 +12,9 @@ function defineDataApp2(config) {
11
12
  return Object.freeze({
12
13
  ...config,
13
14
  queries,
15
+ defineDimension(config) {
16
+ return bindDimensionSource(config, queries);
17
+ },
14
18
  defineOperation(operation) {
15
19
  return defineOperation2({
16
20
  ...operation,
@@ -25,4 +29,4 @@ function dataAppTitle2(config) {
25
29
 
26
30
  export { defineDataApp2, dataAppTitle2 };
27
31
 
28
- //# debugId=BF0300C757D4413D64756E2164756E21
32
+ //# debugId=9AF8FB40EDEC910964756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/core/config.ts"],
4
+ "sourcesContent": [
5
+ "import {\n bindDimensionSource,\n type DimensionSourceConfig,\n type DimensionSourceQueryName,\n type SourceDimensionVariable,\n} from '@/src/core/dimension-source';\n/**\n * App configuration shared by browser and server.\n * @module @altertable/data-app\n */\nimport { defineOperation, type OperationDefinition } from '@/src/core/contract';\nimport type { AppearanceOptions } from '@/src/core/appearance';\nimport {\n snapshotQueries,\n type QueryDefinitions,\n type CheckedQueries,\n type QuerySnapshot,\n} from '@/src/core/queries';\nexport type {\n QueryDefinitions,\n QueryParameterValue,\n QueryParameter,\n QueryValueType,\n QueryField,\n QueryProjections,\n QueryRow,\n} from '@/src/core/queries';\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 ): SourceDimensionVariable<{ string: string; number: number }[Type]>;\n defineOperation<Input, Output>(\n operation: OperationDefinition<Input, Output, Queries>\n ): ReturnType<typeof defineOperation<Input, Output, Queries>>;\n};\n\n/**\n * Define the app's query source of truth while preserving exact query and parameter names.\n * Use `app.defineOperation()` to bind operations to these queries. Pass the app once\n * to `mountDataApp({ app, component })` or `<DataAppProvider app={app}>`.\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 exactly one module-level const initialized with `defineDataApp({ ... })` in the app's\n * declaration source. For the future backend extractor, the argument is read before bundling\n * by resolving the named `defineDataApp` import from `@altertable/data-app`, including aliases.\n * Variable name is arbitrary;\n * export only for imports by other modules. The argument must be a direct object literal\n * containing schema-valid objects, arrays, strings (including templates without interpolation),\n * finite signed numbers, booleans, and null. No spreads, computed keys, references, calls,\n * or callbacks inside it. Extraction must validate data without evaluating app code.\n * TypeScript checks the shape, not AST syntax. Keep executable composition outside the call.\n *\n * SQL passes unchanged to the backend, which interprets placeholders such as `$orgId`.\n * Declare each parameter's type and optional defaultValue.\n * Values are finite numbers, strings, booleans, or null, 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<Input, Output>(\n operation: OperationDefinition<Input, Output, Queries>\n ) {\n return defineOperation<Input, Output, Queries>({\n ...operation,\n queries: queries as unknown as CheckedQueries<Queries>,\n });\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"
6
+ ],
7
+ "mappings": ";;;;;;;;;AAgFO,SAAS,cAAqD,CACnE,QAC4B;AAAA,EAC5B,MAAM,UAAU,gBAAyB,OAAO,OAAO;AAAA,EACvD,OAAO,OAAO,OAAO;AAAA,OAChB;AAAA,IACH;AAAA,IACA,eAAuD,CACrD,QAGA;AAAA,MACA,OAAO,oBAA0B,QAAQ,OAAO;AAAA;AAAA,IAElD,eAA8B,CAC5B,WACA;AAAA,MACA,OAAO,iBAAwC;AAAA,WAC1C;AAAA,QACH;AAAA,MACF,CAAC;AAAA;AAAA,EAEL,CAAC;AAAA;AAGI,SAAS,aAAY,CAC1B,QACQ;AAAA,EACR,OAAO,GAAG,OAAO,WAAW,OAAO,MAAM,gBAAgB,OAAO,MAAM;AAAA;",
8
+ "debugId": "9AF8FB40EDEC910964756E2164756E21",
9
+ "names": []
10
+ }
@@ -2,8 +2,8 @@
2
2
  var defaults = {
3
3
  theme: "light",
4
4
  baseColor: "neutral",
5
- accentColor: "#405d47",
6
- darkAccentColor: "#a6c4ad",
5
+ accentColor: "#202124",
6
+ darkAccentColor: "#f2f3f4",
7
7
  chartColors: [
8
8
  "#285fc0",
9
9
  "#a95319",
@@ -102,7 +102,7 @@ function applyAppearance2(value) {
102
102
  "--atbl-input-font": fontStack(settings.typography.body),
103
103
  "--atbl-input-font-heading": fontStack(settings.typography.heading),
104
104
  "--atbl-input-accent": settings.accentColor,
105
- "--atbl-input-dark-accent": settings.darkAccentColor ?? "",
105
+ "--atbl-input-dark-accent": settings.darkAccentColor ?? `color-mix(in srgb, ${settings.accentColor} 50%, white)`,
106
106
  "--atbl-input-on-accent": ""
107
107
  };
108
108
  const chartColors = settings.chartColors.length ? settings.chartColors : defaults.chartColors;
@@ -177,4 +177,4 @@ function createThemeController2(initialTheme = "light") {
177
177
 
178
178
  export { parseAppearance2, normalizeAppearance2, applyAppearance2, createThemeController2 };
179
179
 
180
- //# debugId=312AAB5702AE519564756E2164756E21
180
+ //# debugId=FEC902AF3AD81A9464756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/core/appearance.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Brand settings; parsing is portable, while theme application requires the browser.\n * @module @altertable/data-app/appearance\n */\nexport type Theme = 'light' | 'dark';\nexport type ThemePreference = Theme | 'system';\n\nexport type AppearanceSettings = {\n theme: ThemePreference;\n /** Palette for surfaces, text, and borders; independent of the accent. */\n baseColor: 'neutral' | 'slate' | 'warm';\n /** Emphasis color for checked controls and selected dates; options use the base palette. */\n accentColor: string;\n darkAccentColor?: string;\n chartColors: string[];\n density: 'compact' | 'comfortable' | 'spacious';\n cornerRadius: 'none' | 'small' | 'medium' | 'large';\n elevation: 'flat' | 'subtle' | 'raised';\n typography: { body: string; heading: string };\n};\n\n/** App-authored overrides; omitted fields use the package defaults. */\nexport type AppearanceOptions = Partial<\n Omit<AppearanceSettings, 'typography'>\n> & { typography?: Partial<AppearanceSettings['typography']> };\n\nexport type ThemeController = {\n getTheme: () => ThemePreference;\n setTheme: (theme: ThemePreference) => void;\n subscribe: (listener: () => void) => () => void;\n};\n\nconst defaults: AppearanceSettings = {\n theme: 'light',\n baseColor: 'neutral',\n accentColor: '#202124',\n darkAccentColor: '#f2f3f4',\n chartColors: [\n '#285fc0',\n '#a95319',\n '#147862',\n '#7243aa',\n '#aa3958',\n '#475569',\n ],\n density: 'comfortable',\n cornerRadius: 'medium',\n elevation: 'subtle',\n typography: { body: 'system', heading: 'system' },\n};\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction oneOf<T extends string>(\n value: unknown,\n options: readonly T[]\n): value is T {\n return typeof value === 'string' && options.includes(value as T);\n}\n\nfunction color(value: unknown): value is string {\n return typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value);\n}\n\nfunction font(value: unknown): value is string {\n return (\n typeof value === 'string' &&\n value.length > 0 &&\n value.length <= 120 &&\n !/[;{}()]/.test(value)\n );\n}\n\n/** Preserve supported external settings and use defaults for invalid fields. */\nexport function parseAppearance(value: unknown): AppearanceSettings {\n if (!record(value)) return normalizeAppearance();\n const typography = record(value.typography) ? value.typography : {};\n\n return normalizeAppearance({\n theme: oneOf(value.theme, ['light', 'dark', 'system'])\n ? value.theme\n : undefined,\n baseColor: oneOf(value.baseColor, ['neutral', 'slate', 'warm'])\n ? value.baseColor\n : undefined,\n accentColor: color(value.accentColor) ? value.accentColor : undefined,\n darkAccentColor: color(value.darkAccentColor)\n ? value.darkAccentColor\n : undefined,\n chartColors:\n Array.isArray(value.chartColors) &&\n value.chartColors.length >= 1 &&\n value.chartColors.length <= 8 &&\n value.chartColors.every(color)\n ? value.chartColors\n : undefined,\n density: oneOf(value.density, ['compact', 'comfortable', 'spacious'])\n ? value.density\n : undefined,\n cornerRadius: oneOf(value.cornerRadius, [\n 'none',\n 'small',\n 'medium',\n 'large',\n ])\n ? value.cornerRadius\n : undefined,\n elevation: oneOf(value.elevation, ['flat', 'subtle', 'raised'])\n ? value.elevation\n : undefined,\n typography: {\n body: font(typography.body) ? typography.body : undefined,\n heading: font(typography.heading) ? typography.heading : undefined,\n },\n });\n}\n\n/** Resolve typed app settings without repeating authoring checks at runtime. */\nexport function normalizeAppearance(\n value: AppearanceOptions = {}\n): AppearanceSettings {\n return {\n theme: value.theme ?? defaults.theme,\n baseColor: value.baseColor ?? defaults.baseColor,\n accentColor: value.accentColor ?? defaults.accentColor,\n density: value.density ?? defaults.density,\n cornerRadius: value.cornerRadius ?? defaults.cornerRadius,\n elevation: value.elevation ?? defaults.elevation,\n darkAccentColor:\n value.darkAccentColor ??\n (value.accentColor === undefined ? defaults.darkAccentColor : undefined),\n chartColors: [...(value.chartColors ?? defaults.chartColors)],\n typography: {\n body: value.typography?.body ?? defaults.typography.body,\n heading: value.typography?.heading ?? defaults.typography.heading,\n },\n };\n}\n\nfunction fontStack(family: string): string {\n return family === 'system'\n ? \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, ui-sans-serif, sans-serif\"\n : `${JSON.stringify(family)}, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, ui-sans-serif, sans-serif`;\n}\n\n/** Choose a foreground after the browser resolves the configured CSS color. */\nfunction accentForeground(settings: AppearanceSettings, dark: boolean): string {\n const accent =\n getComputedStyle(document.documentElement).getPropertyValue(\n '--atbl-accent'\n ) ||\n (dark\n ? (settings.darkAccentColor ??\n `color-mix(in srgb, ${settings.accentColor} 50%, white)`)\n : settings.accentColor);\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = 1;\n const context = canvas.getContext('2d')!;\n context.fillStyle = accent;\n context.fillRect(0, 0, 1, 1);\n const channels = [...context.getImageData(0, 0, 1, 1).data]\n .slice(0, 3)\n .map(value => {\n const channel = value / 255;\n return channel <= 0.04045\n ? channel / 12.92\n : ((channel + 0.055) / 1.055) ** 2.4;\n });\n const luminance =\n channels[0]! * 0.2126 + channels[1]! * 0.7152 + channels[2]! * 0.0722;\n return (luminance + 0.05) / 0.05 > 1.05 / (luminance + 0.05)\n ? '#000000'\n : '#ffffff';\n}\n\n/**\n * Select document-owned appearance presets and brand inputs. Public CSS tokens remain\n * overridable in stylesheets. Cleanup restores the previous document appearance.\n */\nexport function applyAppearance(value?: AppearanceOptions): () => void {\n const settings = normalizeAppearance(value);\n const root = document.documentElement;\n const preference = window.matchMedia('(prefers-color-scheme: dark)');\n const attributes: Record<string, string> = {\n 'data-atbl-appearance': '',\n 'data-atbl-base-color': settings.baseColor,\n 'data-atbl-density': settings.density,\n 'data-atbl-radius': settings.cornerRadius,\n 'data-atbl-elevation': settings.elevation,\n 'data-atbl-theme': '',\n };\n const inputs: Record<string, string> = {\n '--atbl-input-font': fontStack(settings.typography.body),\n '--atbl-input-font-heading': fontStack(settings.typography.heading),\n '--atbl-input-accent': settings.accentColor,\n '--atbl-input-dark-accent':\n settings.darkAccentColor ??\n `color-mix(in srgb, ${settings.accentColor} 50%, white)`,\n '--atbl-input-on-accent': '',\n };\n const chartColors = settings.chartColors.length\n ? settings.chartColors\n : defaults.chartColors;\n // Every categorical slot is defined, including after shrinking a custom palette.\n for (let index = 0; index < 8; index++)\n inputs[`--atbl-input-chart-${index + 1}`] =\n chartColors[index % chartColors.length]!;\n\n const previousAttributes = Object.keys(attributes).map(\n name => [name, root.getAttribute(name)] as const\n );\n const previousInputs = Object.keys(inputs).map(\n name =>\n [\n name,\n root.style.getPropertyValue(name),\n root.style.getPropertyPriority(name),\n ] as const\n );\n for (const [name, token] of Object.entries(inputs)) {\n if (token) root.style.setProperty(name, token);\n else root.style.removeProperty(name);\n }\n for (const [name, attribute] of Object.entries(attributes))\n root.setAttribute(name, attribute);\n\n function applyTheme(): void {\n const dark =\n settings.theme === 'dark' ||\n (settings.theme === 'system' && preference.matches);\n root.setAttribute('data-atbl-theme', dark ? 'dark' : 'light');\n root.style.setProperty(\n '--atbl-input-on-accent',\n accentForeground(settings, dark)\n );\n }\n applyTheme();\n if (settings.theme === 'system')\n preference.addEventListener('change', applyTheme);\n\n return () => {\n preference.removeEventListener('change', applyTheme);\n for (const [name, attribute] of previousAttributes) {\n if (attribute === null) root.removeAttribute(name);\n else root.setAttribute(name, attribute);\n }\n for (const [name, token, priority] of previousInputs) {\n if (token) root.style.setProperty(name, token, priority);\n else root.style.removeProperty(name);\n }\n };\n}\n\n/** Persist a viewer theme preference. Applying appearance belongs to the UI owner. */\nexport function createThemeController(\n initialTheme: ThemePreference = 'light'\n): ThemeController {\n const storageKey = 'altertable.data-app.theme';\n let theme = initialTheme;\n try {\n const saved = window.localStorage.getItem(storageKey);\n if (oneOf(saved, ['light', 'dark', 'system'])) theme = saved;\n } catch {\n // Storage can be unavailable in private browsing or embedded contexts.\n }\n const listeners = new Set<() => void>();\n\n return {\n getTheme() {\n return theme;\n },\n setTheme(nextTheme) {\n if (nextTheme === theme) return;\n theme = nextTheme;\n try {\n window.localStorage.setItem(storageKey, theme);\n } catch {\n // The selection still applies to this page.\n }\n listeners.forEach(listener => listener());\n },\n subscribe(listener) {\n listeners.add(listener);\n\n return () => listeners.delete(listener);\n },\n };\n}\n"
6
+ ],
7
+ "mappings": ";AAgCA,IAAM,WAA+B;AAAA,EACnC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAS;AAAA,EACT,cAAc;AAAA,EACd,WAAW;AAAA,EACX,YAAY,EAAE,MAAM,UAAU,SAAS,SAAS;AAClD;AAEA,SAAS,MAAM,CAAC,OAAkD;AAAA,EAChE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA;AAG5E,SAAS,KAAuB,CAC9B,OACA,SACY;AAAA,EACZ,OAAO,OAAO,UAAU,YAAY,QAAQ,SAAS,KAAU;AAAA;AAGjE,SAAS,KAAK,CAAC,OAAiC;AAAA,EAC9C,OAAO,O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,cAAc;AAAA,QAAO;AAAA,MACzB,QAAQ;AAAA,MACR,IAAI;AAAA,QACF,OAAO,aAAa,QAAQ,YAAY,KAAK;AAAA,QAC7C,MAAM;AAAA,MAGR,UAAU,QAAQ,cAAY,SAAS,CAAC;AAAA;AAAA,IAE1C,SAAS,CAAC,UAAU;AAAA,MAClB,UAAU,IAAI,QAAQ;AAAA,MAEtB,OAAO,MAAM,UAAU,OAAO,QAAQ;AAAA;AAAA,EAE1C;AAAA;",
8
+ "debugId": "FEC902AF3AD81A9464756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,22 +1,26 @@
1
1
  import {
2
2
  formatDateRange2
3
- } from "./index-mev09s5v.js";
3
+ } from "./index-22d576sn.js";
4
4
  import {
5
5
  invariant,
6
6
  snapshotQueries,
7
+ decodeQueryResult,
7
8
  resolveQueryParameters,
8
9
  defineMessageRoute2
9
- } from "./index-qd5xgx6y.js";
10
+ } from "./index-rew95tbg.js";
10
11
 
11
- // src/core/contract.ts
12
- import { parseDate, today } from "@internationalized/date";
12
+ // src/core/keys.ts
13
+ var KEY_SEPARATOR = ":";
13
14
 
14
15
  // src/core/dimension.ts
15
16
  var allSelection = { kind: "all" };
16
17
  function dimensionMemberKey(member) {
17
- return member.kind === "missing" ? "missing" : `value:${typeof member.value}:${member.value}`;
18
+ return member.kind === "missing" ? "missing" : ["value", typeof member.value, member.value].join(KEY_SEPARATOR);
18
19
  }
19
20
  function dimensionFilter2(config) {
21
+ return { ...createDimensionFilter(config), optionsSource: "fixed" };
22
+ }
23
+ function createDimensionFilter(config, dynamic = false) {
20
24
  const { key, label, selectionMode, valueType } = config;
21
25
  const options = config.options ?? [];
22
26
  const optionKeys = options.map((option) => dimensionMemberKey({ kind: "value", value: option.value }));
@@ -28,11 +32,13 @@ function dimensionFilter2(config) {
28
32
  const allowMissing = config.allowMissing ?? false;
29
33
  const defaultValue = allSelection;
30
34
  function validMember(member) {
35
+ if (!member || typeof member !== "object")
36
+ return false;
31
37
  if (member.kind === "missing")
32
38
  return allowMissing;
33
39
  if (member.kind !== "value" || typeof member.value !== valueType)
34
40
  return false;
35
- if (!config.facet)
41
+ if (!dynamic)
36
42
  return allowed.has(dimensionMemberKey(member));
37
43
  return typeof member.value === "number" ? Number.isFinite(member.value) : member.value.length <= 100;
38
44
  }
@@ -43,8 +49,10 @@ function dimensionFilter2(config) {
43
49
  return true;
44
50
  if (value.kind !== "include" && !(config.allowExclusion && value.kind === "exclude") || !Array.isArray(value.members) || !value.members.length || value.members.length > maxSelected)
45
51
  return false;
52
+ if (!value.members.every(validMember))
53
+ return false;
46
54
  const ids = value.members.map(dimensionMemberKey);
47
- return new Set(ids).size === ids.length && value.members.every(validMember);
55
+ return new Set(ids).size === ids.length;
48
56
  }
49
57
  function encode(value) {
50
58
  return value.kind === "all" ? null : JSON.stringify({
@@ -73,11 +81,12 @@ function dimensionFilter2(config) {
73
81
  }
74
82
  return {
75
83
  kind: "dimension",
84
+ optionsSource: dynamic ? "query" : "fixed",
85
+ presentation: config.presentation,
76
86
  label,
77
87
  valueType,
78
88
  selectionMode,
79
89
  options,
80
- facet: config.facet,
81
90
  allowMissing,
82
91
  allowExclusion: config.allowExclusion ?? false,
83
92
  maxSelected,
@@ -95,8 +104,8 @@ function dimensionFilter2(config) {
95
104
  write(value) {
96
105
  return { [key]: encode(value) };
97
106
  },
98
- describe(value) {
99
- return value.kind === "all" ? `All ${label.toLocaleLowerCase()}` : `${value.kind === "exclude" ? "Exclude: " : ""}${value.members.map((member) => member.kind === "missing" ? "Missing" : options.find((option) => option.value === member.value)?.label ?? String(member.value)).join(", ")}`;
107
+ describe(value, suppliedOptions = options) {
108
+ return value.kind === "all" ? `All ${label.toLocaleLowerCase()}` : `${value.kind === "exclude" ? "Exclude: " : ""}${value.members.map((member) => member.kind === "missing" ? "Missing" : suppliedOptions.find((option) => option.value === member.value)?.label ?? String(member.value)).join(", ")}`;
100
109
  }
101
110
  };
102
111
  }
@@ -146,6 +155,143 @@ function dimensionPredicate2(column, selection, allowedColumns) {
146
155
  const predicate = `(${clauses.join(" OR ")})`;
147
156
  return selection.kind === "exclude" ? missing ? `NOT ${predicate}` : `(${column} IS NULL OR NOT ${predicate})` : predicate;
148
157
  }
158
+
159
+ // src/core/dimension-source.ts
160
+ var dimensionSource = Symbol("data-app.dimensionSource");
161
+ var sources = new WeakMap;
162
+ var parserVariables = new WeakMap;
163
+ var selectorsKey = Symbol.for("@altertable/data-app/dimension-selectors");
164
+ var ownerKey = Symbol.for("@altertable/data-app/dimension-selector-owner");
165
+ var invalidMemberKey = Symbol.for("@altertable/data-app/dimension-member-error");
166
+
167
+ class DimensionMembershipError extends Error {
168
+ [invalidMemberKey] = true;
169
+ static [Symbol.hasInstance](value) {
170
+ return value instanceof Error && value[invalidMemberKey] === true;
171
+ }
172
+ }
173
+ function variableInput2(parse, variables) {
174
+ const previous = parserVariables.get(parse) ?? {};
175
+ const definitions = { ...variables };
176
+ for (const [name, variable] of Object.entries(definitions))
177
+ invariant(!previous[name] || previous[name] === variable, `Variable input ${name} is already declared.`);
178
+ function parser(value) {
179
+ invariant(value && typeof value === "object" && !Array.isArray(value), "Expected variable input.");
180
+ const input = parse(value);
181
+ invariant(input && typeof input === "object" && !Array.isArray(input), "Expected parsed input object.");
182
+ const values = {};
183
+ for (const [name, variable] of Object.entries(definitions)) {
184
+ const selected = value[name];
185
+ invariant(variable.valid(selected), `Invalid ${variable.label ?? name}.`);
186
+ values[name] = selected;
187
+ }
188
+ return { ...input, ...values };
189
+ }
190
+ parserVariables.set(parser, {
191
+ ...previous,
192
+ ...definitions
193
+ });
194
+ return parser;
195
+ }
196
+ function bindDimensionSource(config, queries) {
197
+ invariant(!config.allowMissing, "Source dimensions require concrete members.");
198
+ const query = queries[config.source.query];
199
+ invariant(query && Object.hasOwn(query.params, "member"), "Dimension sources must declare member.");
200
+ const member = query.params.member;
201
+ const { value, label, count } = query.projections;
202
+ invariant(member.type === config.valueType && member.nullable === true && value?.type === config.valueType && value.nullable !== true && label?.type === "string" && label.nullable !== true && (!count || count.type === "number" && count.nullable !== true), "Dimension sources require a matching nullable member and concrete value, label, and count projections.");
203
+ const operation = `__dimension:${config.key}`;
204
+ const variable = Object.assign(createDimensionFilter({
205
+ ...config,
206
+ valueType: config.valueType,
207
+ options: []
208
+ }, true), {
209
+ optionsSource: "query",
210
+ [dimensionSource]: Object.freeze({ operation })
211
+ });
212
+ sources.set(variable, { query: config.source.query, queries });
213
+ return variable;
214
+ }
215
+ async function loadOptions(variable, member, query) {
216
+ const source = sources.get(variable);
217
+ const result = await query(source.query, { member }, { limit: member === null ? 200 : 2 });
218
+ const names = result.columns.map((column) => column.name);
219
+ invariant(new Set(names).size === names.length && names.includes("value") && names.includes("label"), "Dimension source must return value and label.");
220
+ const options = parseFacetOptions2(result.rows, variable);
221
+ if (member !== null && (options.length !== 1 || options[0].value !== member))
222
+ throw new DimensionMembershipError(`Invalid ${variable.label} member.`);
223
+ return options;
224
+ }
225
+ async function validateVariableInput(parser, input, query) {
226
+ for (const [name, variable] of Object.entries(parserVariables.get(parser) ?? {})) {
227
+ if (variable.kind !== "dimension" || !sources.has(variable))
228
+ continue;
229
+ const selection = input[name];
230
+ if (selection.kind === "all")
231
+ continue;
232
+ for (const member of selection.members)
233
+ if (member.kind === "value")
234
+ await loadOptions(variable, member.value, query);
235
+ }
236
+ }
237
+ function attachDimensionSelectors(operation, queries) {
238
+ const selectors = {};
239
+ for (const variable of Object.values(parserVariables.get(operation.input) ?? {})) {
240
+ if (variable.kind !== "dimension" || !(dimensionSource in variable))
241
+ continue;
242
+ const source = sources.get(variable);
243
+ if (!source)
244
+ continue;
245
+ invariant(JSON.stringify(source.queries[source.query]) === JSON.stringify(queries[source.query]), "Dimension sources must belong to the operation query registry.");
246
+ const name = variable[dimensionSource].operation;
247
+ invariant(!selectors[name] || selectors[name][ownerKey] === variable, "Dimension source keys must be unique across the app.");
248
+ selectors[name] = {
249
+ input(value) {
250
+ invariant(value && typeof value === "object", "Invalid dimension request.");
251
+ const member = value.member;
252
+ invariant(member === null || variable.valid({
253
+ kind: "include",
254
+ members: [{ kind: "value", value: member }]
255
+ }), "Invalid requested member.");
256
+ return { member };
257
+ },
258
+ checks: [{ member: null }],
259
+ policy: {
260
+ maxDurationMs: 15000,
261
+ maxQueryRows: 200,
262
+ maxResponseBytes: 1e6
263
+ },
264
+ queryNames: { [source.query]: source.query },
265
+ async run(context, input) {
266
+ return loadOptions(variable, input.member, async (name, params, options) => {
267
+ const definition = queries[name];
268
+ const result = await context.lakehouse.queryAll(definition.statement, {
269
+ name,
270
+ params: resolveQueryParameters(definition.params, params, context.queryParams ?? {}),
271
+ limit: options.limit,
272
+ signal: context.signal
273
+ });
274
+ return decodeQueryResult(result, definition.projections);
275
+ });
276
+ }
277
+ };
278
+ Object.defineProperty(selectors[name], ownerKey, { value: variable });
279
+ }
280
+ Object.defineProperty(operation, selectorsKey, { value: selectors });
281
+ }
282
+ function withDimensionSelectors(operations) {
283
+ const expanded = { ...operations };
284
+ for (const operation of Object.values(operations))
285
+ for (const [name, selector] of Object.entries(operation[selectorsKey] ?? {})) {
286
+ invariant(!Object.hasOwn(operations, name), "Reserved dimension operation name.");
287
+ invariant(!expanded[name] || expanded[name][ownerKey] === selector[ownerKey], "Dimension source keys must be unique across the app.");
288
+ expanded[name] ??= selector;
289
+ }
290
+ return expanded;
291
+ }
292
+
293
+ // src/core/contract.ts
294
+ import { parseDate, today } from "@internationalized/date";
149
295
  // src/core/annotations.ts
150
296
  function object(value) {
151
297
  if (!value || typeof value !== "object" || Array.isArray(value))
@@ -327,7 +473,7 @@ function isAnnotationPresentation(value) {
327
473
  if (!value || typeof value !== "object")
328
474
  return false;
329
475
  const input = value;
330
- return typeof input.enabled === "boolean" && (input.active === undefined || typeof input.active === "boolean") && (input.pinsVisible === undefined || typeof input.pinsVisible === "boolean") && (input.showHint === undefined || typeof input.showHint === "boolean") && (input.readOnly === undefined || typeof input.readOnly === "boolean") && (input.selectedAnnotationId === undefined || typeof input.selectedAnnotationId === "string" && input.selectedAnnotationId.length <= 128) && (input.selectionId === undefined || typeof input.selectionId === "string" && input.selectionId.length <= 128) && (input.selectedTargetId === undefined || typeof input.selectedTargetId === "string" && input.selectedTargetId.length <= 128) && (input.targets === undefined || Array.isArray(input.targets) && input.targets.length <= 50 && input.targets.every((target) => target && typeof target.id === "string" && target.id.length <= 128 && typeof target.targetId === "string" && target.targetId.length <= 128 && Number.isSafeInteger(target.number) && target.number > 0 && (target.anchor === undefined || typeof target.anchor.x === "number" && Number.isFinite(target.anchor.x) && target.anchor.x >= 0 && target.anchor.x <= 1 && typeof target.anchor.y === "number" && Number.isFinite(target.anchor.y) && target.anchor.y >= 0 && target.anchor.y <= 1) && (target.region === undefined || typeof target.region === "object" && target.region !== null && ["x", "y", "width", "height"].every((key) => {
476
+ return typeof input.enabled === "boolean" && (input.active === undefined || typeof input.active === "boolean") && (input.pinsVisible === undefined || typeof input.pinsVisible === "boolean") && (input.showHint === undefined || typeof input.showHint === "boolean") && (input.readOnly === undefined || typeof input.readOnly === "boolean") && (input.selectedAnnotationId === undefined || typeof input.selectedAnnotationId === "string" && input.selectedAnnotationId.length <= 128) && (input.dismissal === undefined || input.dismissal !== null && typeof input.dismissal === "object" && typeof input.dismissal.id === "string" && input.dismissal.id.length <= 128 && typeof input.dismissal.occurredAt === "number" && Number.isFinite(input.dismissal.occurredAt)) && (input.selectionId === undefined || typeof input.selectionId === "string" && input.selectionId.length <= 128) && (input.selectedTargetId === undefined || typeof input.selectedTargetId === "string" && input.selectedTargetId.length <= 128) && (input.targets === undefined || Array.isArray(input.targets) && input.targets.length <= 50 && input.targets.every((target) => target && typeof target.id === "string" && target.id.length <= 128 && typeof target.targetId === "string" && target.targetId.length <= 128 && Number.isSafeInteger(target.number) && target.number > 0 && (target.anchor === undefined || typeof target.anchor.x === "number" && Number.isFinite(target.anchor.x) && target.anchor.x >= 0 && target.anchor.x <= 1 && typeof target.anchor.y === "number" && Number.isFinite(target.anchor.y) && target.anchor.y >= 0 && target.anchor.y <= 1) && (target.region === undefined || typeof target.region === "object" && target.region !== null && ["x", "y", "width", "height"].every((key) => {
331
477
  const value = target.region[key];
332
478
  return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
333
479
  }) && target.region.width > 0 && target.region.height > 0 && target.region.x + target.region.width <= 1.000001 && target.region.y + target.region.height <= 1.000001) && (target.comment === undefined || typeof target.comment === "string" && target.comment.length <= 2000)));
@@ -348,7 +494,8 @@ function numberFilter2({
348
494
  min,
349
495
  max,
350
496
  defaultValue = all,
351
- history = "push"
497
+ history = "push",
498
+ presentation
352
499
  }) {
353
500
  invariant(!!key.trim(), "Numeric filter requires a URL key.");
354
501
  invariant((min === undefined || Number.isFinite(min)) && (max === undefined || Number.isFinite(max)) && (min === undefined || max === undefined || min <= max), "Invalid numeric filter bounds.");
@@ -374,6 +521,7 @@ function numberFilter2({
374
521
  invariant(valid(defaultValue), `Invalid default for ${label}.`);
375
522
  return {
376
523
  kind: "numberFilter",
524
+ presentation,
377
525
  label,
378
526
  min,
379
527
  max,
@@ -410,7 +558,8 @@ function booleanFilter2({
410
558
  key,
411
559
  label,
412
560
  defaultValue = all,
413
- history = "push"
561
+ history = "push",
562
+ presentation
414
563
  }) {
415
564
  invariant(!!key.trim(), "Boolean filter requires a URL key.");
416
565
  function valid(value) {
@@ -422,6 +571,7 @@ function booleanFilter2({
422
571
  invariant(valid(defaultValue), `Invalid default for ${label}.`);
423
572
  return {
424
573
  kind: "booleanFilter",
574
+ presentation,
425
575
  label,
426
576
  defaultValue,
427
577
  clearValue: all,
@@ -565,14 +715,6 @@ function parseLabel2(value, maxLength = 100) {
565
715
  invariant(typeof value === "string" && !!value && value.length <= maxLength, "Invalid label in query result.");
566
716
  return value;
567
717
  }
568
- function rowsAsRecords2(result, requiredColumns) {
569
- const names = result.columns.map((column) => column.name);
570
- invariant(new Set(names).size === names.length && requiredColumns.every((name) => names.includes(name)), "Query result columns do not match the expected shape.");
571
- return result.rows.map((row) => {
572
- invariant(row.length === names.length, "Query result row has the wrong width.");
573
- return Object.fromEntries(names.map((name, index) => [name, row[index]]));
574
- });
575
- }
576
718
  function defineQueryNames2(names) {
577
719
  const values = Object.values(names);
578
720
  invariant(values.every((name) => !!name.trim()) && new Set(values).size === values.length, "Query names must be nonempty and unique.");
@@ -588,8 +730,8 @@ class DataSourceError2 extends Error {
588
730
  static [Symbol.hasInstance](value) {
589
731
  return value instanceof Error && value[sourceErrorBrand] === true;
590
732
  }
591
- constructor(reason, status) {
592
- super(`Data source ${reason}${status ? ` (${status})` : ""}.`);
733
+ constructor(reason, status, options) {
734
+ super(`Data source ${reason}${status ? ` (${status})` : ""}.`, options);
593
735
  this.reason = reason;
594
736
  this.status = status;
595
737
  this.name = "DataSourceError";
@@ -601,30 +743,35 @@ function defineOperation2(operation) {
601
743
  const queryNames = Object.fromEntries(Object.keys(queries).map((name) => [name, name]));
602
744
  for (const input of operation.checks)
603
745
  operation.input(input);
604
- return {
746
+ const defined = {
605
747
  ...operation,
606
748
  queryNames,
607
- run(context, input) {
608
- function query(name, values = {}, options) {
749
+ async run(context, input) {
750
+ async function query(name, values = {}, options) {
609
751
  invariant(Object.hasOwn(queries, name), `Unknown query name: ${name}.`);
610
752
  const definition = queries[name];
611
753
  const params = resolveQueryParameters(definition.params, values, context.queryParams ?? {});
612
- return context.lakehouse.queryAll(definition.statement, {
754
+ const result = await context.lakehouse.queryAll(definition.statement, {
613
755
  name,
614
756
  params,
615
757
  limit: options?.limit ?? operation.policy.maxQueryRows,
616
758
  signal: context.signal
617
759
  });
760
+ return decodeQueryResult(result, definition.projections);
618
761
  }
762
+ await validateVariableInput(operation.input, input, query);
763
+ context.signal.throwIfAborted();
619
764
  return operation.run({ signal: context.signal, query }, input);
620
765
  }
621
766
  };
767
+ attachDimensionSelectors(defined, queries);
768
+ return defined;
622
769
  }
623
770
  function connectionCheck2(queries) {
771
+ const connection = queries.connection;
624
772
  return defineOperation2({
625
- queries,
773
+ queries: { connection },
626
774
  input: parseEmptyInput2,
627
- output: parseTrue2,
628
775
  checks: [{}],
629
776
  policy: { maxQueryRows: 1, maxDurationMs: 15000 },
630
777
  async run({ query }) {
@@ -634,6 +781,6 @@ function connectionCheck2(queries) {
634
781
  });
635
782
  }
636
783
 
637
- export { dimensionMemberKey, dimensionFilter2, parseDimensionSelection2, parseFacetOptions2, dimensionPredicate2, parseDataAppAnnotationDraft2, annotationDraftRoute2, annotationEditorStateRoute2, annotationSendRoute2, annotationUpdateRoute2, annotationModeRoute2, isAnnotationPresentation, numberOperatorLabels, numberFilter2, booleanFilter2, parseNumberSelection2, parseBooleanSelection2, parseEmptyInput2, parseTrue2, previousDateRange2, defineDateRangeContract2, parseDateRangeInput2, parseCount2, parseLabel2, rowsAsRecords2, defineQueryNames2, DataSourceError2, defineOperation2, connectionCheck2 };
784
+ export { KEY_SEPARATOR, dimensionMemberKey, dimensionFilter2, createDimensionFilter, parseDimensionSelection2, parseFacetOptions2, dimensionPredicate2, dimensionSource, DimensionMembershipError, variableInput2, bindDimensionSource, withDimensionSelectors, parseDataAppAnnotationDraft2, annotationDraftRoute2, annotationEditorStateRoute2, annotationSendRoute2, annotationUpdateRoute2, annotationModeRoute2, isAnnotationPresentation, numberOperatorLabels, numberFilter2, booleanFilter2, parseNumberSelection2, parseBooleanSelection2, parseEmptyInput2, parseTrue2, previousDateRange2, defineDateRangeContract2, parseDateRangeInput2, parseCount2, parseLabel2, defineQueryNames2, DataSourceError2, defineOperation2, connectionCheck2 };
638
785
 
639
- //# debugId=87015EDE1552300964756E2164756E21
786
+ //# debugId=4386C0918DAC7C1B64756E2164756E21