@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.
- package/AGENTS.md +10 -0
- package/CONTRIBUTING.md +27 -1
- package/README.md +18 -21
- package/THIRD_PARTY_NOTICES +18 -0
- package/dist/chunks/index-22d576sn.js +153 -0
- package/dist/chunks/index-22d576sn.js.map +11 -0
- package/dist/chunks/index-2ajhmsc4.js +355 -0
- package/dist/chunks/index-2ajhmsc4.js.map +13 -0
- package/dist/chunks/{index-ktmvs916.js → index-58kks6a8.js} +37 -21
- package/dist/chunks/index-58kks6a8.js.map +13 -0
- package/dist/chunks/{index-23dktynd.js → index-7q99hf1z.js} +19 -12
- package/dist/chunks/index-7q99hf1z.js.map +10 -0
- package/dist/chunks/{index-mt93ff2b.js → index-9zqbrv2z.js} +7 -3
- package/dist/chunks/index-9zqbrv2z.js.map +10 -0
- package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
- package/dist/chunks/index-cv36cyna.js.map +10 -0
- package/dist/chunks/{index-ag0cgnvq.js → index-q1w84fv9.js} +178 -31
- package/dist/chunks/index-q1w84fv9.js.map +15 -0
- package/dist/chunks/{index-qd5xgx6y.js → index-rew95tbg.js} +89 -21
- package/dist/chunks/index-rew95tbg.js.map +13 -0
- package/dist/chunks/{index-gvers8jw.js → index-vtpygsbq.js} +5651 -2711
- package/dist/chunks/index-vtpygsbq.js.map +126 -0
- package/dist/chunks/{index-x69p7cv7.js → index-wjt6cavj.js} +6 -4
- package/dist/chunks/index-wjt6cavj.js.map +10 -0
- package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
- package/dist/chunks/index-wss3gd3h.js.map +13 -0
- package/dist/chunks/{index-ev2b5aaf.js → index-xzb7sx6g.js} +4 -4
- package/dist/client/index.js +6 -6
- package/dist/core/appearance.js +1 -1
- package/dist/core/config.js +3 -3
- package/dist/core/contract.js +7 -7
- package/dist/core/contract.js.map +1 -1
- package/dist/core/format.js +10 -2
- package/dist/core/format.js.map +1 -1
- package/dist/embed/index.js +26 -25
- package/dist/embed/index.js.map +4 -4
- package/dist/index.js +3 -3
- package/dist/local.js +200 -145
- package/dist/local.js.map +10 -7
- package/dist/preview.js +1456 -0
- package/dist/preview.js.map +17 -0
- package/dist/react/embed/index.js +1 -1
- package/dist/react/index.js +500 -401
- package/dist/react/index.js.map +10 -13
- package/dist/react/ui/index.js +1851 -1476
- package/dist/react/ui/index.js.map +24 -21
- package/dist/server.js +102 -58
- package/dist/server.js.map +9 -6
- package/dist/types/client/data-client.d.ts +21 -10
- package/dist/types/client/download.d.ts +5 -0
- package/dist/types/client/iframe.d.ts +4 -2
- package/dist/types/client/logger.d.ts +10 -2
- package/dist/types/core/annotations.d.ts +5 -0
- package/dist/types/core/appearance.d.ts +2 -0
- package/dist/types/core/bridge-endpoint.d.ts +2 -2
- package/dist/types/core/bridge.d.ts +22 -0
- package/dist/types/core/config.d.ts +25 -17
- package/dist/types/core/contract.d.ts +26 -14
- package/dist/types/core/date-format.d.ts +24 -0
- package/dist/types/core/dimension-source.d.ts +64 -0
- package/dist/types/core/dimension.d.ts +33 -24
- package/dist/types/core/facets.d.ts +13 -0
- package/dist/types/core/filters.d.ts +4 -3
- package/dist/types/core/format.d.ts +5 -3
- package/dist/types/core/keys.d.ts +2 -0
- package/dist/types/core/messages.d.ts +3 -1
- package/dist/types/core/operation-types.d.ts +12 -11
- package/dist/types/core/queries.d.ts +75 -7
- package/dist/types/core/time-interval.d.ts +96 -0
- package/dist/types/core/variables.d.ts +49 -14
- package/dist/types/embed/host.d.ts +4 -4
- package/dist/types/embed/sql.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/actions.d.ts +53 -0
- package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
- package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
- package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
- package/dist/types/react/bindings.d.ts +62 -3
- package/dist/types/react/date-formatting.d.ts +12 -0
- package/dist/types/react/details.d.ts +46 -0
- package/dist/types/react/exploration.d.ts +44 -0
- package/dist/types/react/hooks.d.ts +82 -43
- package/dist/types/react/index.d.ts +10 -2
- package/dist/types/react/search-suggestions.d.ts +8 -0
- package/dist/types/react/style-contract.d.ts +1 -5
- package/dist/types/react/ui/AboutData.d.ts +9 -4
- package/dist/types/react/ui/AreaChart.d.ts +2 -2
- package/dist/types/react/ui/BarChart.d.ts +2 -2
- package/dist/types/react/ui/Button.d.ts +2 -1
- package/dist/types/react/ui/ChartLegend.d.ts +3 -2
- package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
- package/dist/types/react/ui/ComposedChartLegend.d.ts +2 -1
- package/dist/types/react/ui/DataApp.d.ts +8 -4
- package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
- package/dist/types/react/ui/DataTable.d.ts +6 -4
- package/dist/types/react/ui/DataWidget.d.ts +7 -0
- package/dist/types/react/ui/DateDisplay.d.ts +9 -0
- package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
- package/dist/types/react/ui/DimensionPicker.d.ts +5 -3
- package/dist/types/react/ui/EmptyState.d.ts +1 -1
- package/dist/types/react/ui/ExplorationActionControl.d.ts +60 -0
- package/dist/types/react/ui/GradientScroll.d.ts +8 -0
- package/dist/types/react/ui/Grid.d.ts +1 -1
- package/dist/types/react/ui/InspectionProvider.d.ts +2 -2
- package/dist/types/react/ui/LineChart.d.ts +2 -2
- package/dist/types/react/ui/Menu.d.ts +3 -2
- package/dist/types/react/ui/MetricWidget.d.ts +4 -0
- package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
- package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
- package/dist/types/react/ui/PickerField.d.ts +23 -0
- package/dist/types/react/ui/PieChart.d.ts +2 -2
- package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
- package/dist/types/react/ui/RequestHint.d.ts +2 -2
- package/dist/types/react/ui/SearchField.d.ts +3 -1
- package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
- package/dist/types/react/ui/SectionHeading.d.ts +8 -0
- package/dist/types/react/ui/Select.d.ts +9 -1
- package/dist/types/react/ui/Sheet.d.ts +4 -2
- package/dist/types/react/ui/TableWidget.d.ts +8 -0
- package/dist/types/react/ui/Tabs.d.ts +4 -3
- package/dist/types/react/ui/TrendChart.d.ts +3 -3
- package/dist/types/react/ui/VariableBar.d.ts +1 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
- package/dist/types/react/ui/chart-data.d.ts +8 -6
- package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
- package/dist/types/react/ui/chart-interaction.d.ts +27 -0
- package/dist/types/react/ui/chart-primitives.d.ts +4 -4
- package/dist/types/react/ui/chart-time.d.ts +19 -0
- package/dist/types/react/ui/chartColor.d.ts +1 -1
- package/dist/types/react/ui/icons.d.ts +5 -1
- package/dist/types/react/ui/index.d.ts +10 -4
- package/dist/types/react/ui/metric-comparison.d.ts +2 -2
- package/dist/types/react/ui/metric.d.ts +2 -2
- package/dist/types/react/ui/presentation.d.ts +2 -0
- package/dist/types/react/ui/searchItems.d.ts +2 -0
- package/dist/types/react/ui/use-chart-scroll-to-end.d.ts +2 -0
- package/dist/types/react/ui/variables.d.ts +1 -1
- package/dist/types/react/view-control-bar.d.ts +18 -0
- package/dist/types/react/view-controls.d.ts +3 -2
- package/dist/types/react/view-runtime.d.ts +8 -3
- package/dist/types/react/view.d.ts +28 -7
- package/dist/types/react/widgets.d.ts +22 -11
- package/dist/types/server/local.d.ts +3 -1
- package/dist/types/server/preview/host.d.ts +1 -0
- package/dist/types/server/preview/index.d.ts +16 -0
- package/dist/types/server/reload-channel.d.ts +6 -0
- package/dist/types/server/request-body.d.ts +4 -0
- package/dist/worker.js +1 -1
- package/docs/app-authoring.md +27 -12
- package/docs/client.md +6 -7
- package/docs/composition.md +84 -0
- package/docs/contract.md +45 -26
- package/docs/data-context.md +2 -0
- package/docs/embed.md +11 -3
- package/docs/formatting-and-appearance.md +36 -5
- package/docs/layout.md +31 -8
- package/docs/react-embed.md +4 -4
- package/docs/react.md +1 -1
- package/docs/server-bun.md +25 -0
- package/docs/server.md +2 -2
- package/docs/styling.md +10 -27
- package/docs/ui.md +32 -18
- package/docs/variables.md +174 -25
- package/docs/views.md +60 -29
- package/docs/widgets.md +131 -26
- package/examples/starter-data-app/index.tsx +10 -23
- package/examples/starter-local-data-app/.bun-version +1 -0
- package/examples/starter-local-data-app/.node-version +1 -0
- package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
- package/examples/starter-local-data-app/.oxlintrc.json +33 -0
- package/examples/starter-local-data-app/AGENTS.md +22 -0
- package/examples/starter-local-data-app/README.md +54 -0
- package/examples/starter-local-data-app/app.ts +28 -0
- package/examples/starter-local-data-app/bunfig.toml +2 -0
- package/examples/starter-local-data-app/package.json +33 -0
- package/examples/starter-local-data-app/src/App.tsx +8 -0
- package/examples/starter-local-data-app/src/assets.d.ts +1 -0
- package/examples/starter-local-data-app/src/data-context.ts +21 -0
- package/examples/starter-local-data-app/src/favicon.svg +13 -0
- package/examples/starter-local-data-app/src/index.html +14 -0
- package/examples/starter-local-data-app/src/main.tsx +7 -0
- package/examples/starter-local-data-app/src/operations.ts +6 -0
- package/examples/starter-local-data-app/src/server.ts +6 -0
- package/examples/starter-local-data-app/tsconfig.json +21 -0
- package/package.json +13 -3
- package/dist/chunks/index-23dktynd.js.map +0 -10
- package/dist/chunks/index-ag0cgnvq.js.map +0 -13
- package/dist/chunks/index-dq7b35fn.js +0 -307
- package/dist/chunks/index-dq7b35fn.js.map +0 -13
- package/dist/chunks/index-f5cnbrjz.js.map +0 -13
- package/dist/chunks/index-gvers8jw.js.map +0 -109
- package/dist/chunks/index-ktmvs916.js.map +0 -13
- package/dist/chunks/index-m6n8ctfc.js.map +0 -10
- package/dist/chunks/index-mev09s5v.js +0 -77
- package/dist/chunks/index-mev09s5v.js.map +0 -10
- package/dist/chunks/index-mt93ff2b.js.map +0 -10
- package/dist/chunks/index-qd5xgx6y.js.map +0 -13
- package/dist/chunks/index-x69p7cv7.js.map +0 -10
- package/dist/types/react/shellStyles.d.ts +0 -3
- package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
- /package/dist/chunks/{index-ev2b5aaf.js.map → index-xzb7sx6g.js.map} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DimensionMembershipError,
|
|
2
3
|
DataSourceError2
|
|
3
|
-
} from "./index-
|
|
4
|
+
} from "./index-q1w84fv9.js";
|
|
4
5
|
|
|
5
6
|
// src/core/operation.ts
|
|
6
7
|
async function executeDataOperation(operation, value, {
|
|
@@ -29,7 +30,7 @@ async function executeDataOperation(operation, value, {
|
|
|
29
30
|
queryParams
|
|
30
31
|
});
|
|
31
32
|
const body = {
|
|
32
|
-
data:
|
|
33
|
+
data: output,
|
|
33
34
|
requestId,
|
|
34
35
|
queriedAt: new Date().toISOString(),
|
|
35
36
|
queryIds: execution.queryIds,
|
|
@@ -51,6 +52,7 @@ function createOperationLakehouse(operation, source, signal, operationName) {
|
|
|
51
52
|
const queries = [];
|
|
52
53
|
const lakehouse = {
|
|
53
54
|
async queryAll(statement, options) {
|
|
55
|
+
signal.throwIfAborted();
|
|
54
56
|
if (!Number.isInteger(options.limit) || options.limit < 1)
|
|
55
57
|
throw new Error("Query needs a positive row limit.");
|
|
56
58
|
if (operation.queryNames && !Object.values(operation.queryNames).includes(options.name ?? ""))
|
|
@@ -124,7 +126,7 @@ var sourceErrorMessages = {
|
|
|
124
126
|
unavailable: "The lakehouse is unavailable. Check the connection and retry."
|
|
125
127
|
};
|
|
126
128
|
function toDataOperationFailure(error, aborted = false) {
|
|
127
|
-
if (error instanceof OperationInputError)
|
|
129
|
+
if (error instanceof OperationInputError || error instanceof DimensionMembershipError)
|
|
128
130
|
return {
|
|
129
131
|
status: 400,
|
|
130
132
|
code: "invalid_input",
|
|
@@ -146,4 +148,4 @@ function toDataOperationFailure(error, aborted = false) {
|
|
|
146
148
|
|
|
147
149
|
export { executeDataOperation, toDataOperationFailure };
|
|
148
150
|
|
|
149
|
-
//# debugId=
|
|
151
|
+
//# debugId=856CD69BA374A36264756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/operation.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { DimensionMembershipError } from '@/src/core/dimension-source';\nimport { DataSourceError } from '@/src/core/contract';\nimport type {\n DataOperations,\n DisclosedQuery,\n Lakehouse,\n OperationContext,\n DataQueryBody,\n} from '@/src/core/operation-types';\n\ntype Operation = DataOperations[string];\ntype OperationExecutionOptions = {\n operationName: string;\n lakehouse: Lakehouse;\n signal: AbortSignal;\n requestId: string;\n queryParams?: OperationContext['queryParams'];\n};\n\n/** Shared operation execution. Adapters own authorization, delivery, and public errors. */\nexport async function executeDataOperation(\n operation: Operation,\n value: unknown,\n {\n operationName,\n lakehouse,\n signal: requestSignal,\n requestId,\n queryParams,\n }: OperationExecutionOptions\n) {\n requestSignal.throwIfAborted();\n let input: unknown;\n try {\n input = operation.input(value);\n } catch {\n throw new OperationInputError();\n }\n\n const signal = AbortSignal.any([\n requestSignal,\n AbortSignal.timeout(operation.policy.maxDurationMs),\n ]);\n const execution = createOperationLakehouse(\n operation,\n lakehouse,\n signal,\n operationName\n );\n try {\n const output = await runOperation(operation, input, {\n lakehouse: execution.lakehouse,\n signal,\n queryParams,\n });\n const body: DataQueryBody<unknown> = {\n data: output,\n requestId,\n queriedAt: new Date().toISOString(),\n queryIds: execution.queryIds,\n queries: execution.queries,\n };\n const serializedBody = JSON.stringify(body);\n const responseBytes = new TextEncoder().encode(serializedBody).byteLength;\n if (responseBytes > (operation.policy.maxResponseBytes ?? 1_000_000))\n throw new Error('Response exceeds byte limit.');\n\n return { body, serializedBody };\n } catch (error) {\n if (signal.aborted && !(error instanceof DataSourceError))\n throw new OperationTimeoutError();\n throw error;\n }\n}\n\n/** Query evidence follows statement invocation order; query IDs retain completion order. */\nfunction createOperationLakehouse(\n operation: Operation,\n source: Lakehouse,\n signal: AbortSignal,\n operationName: string\n) {\n const queryIds: string[] = [];\n const queries: DisclosedQuery[] = [];\n const lakehouse: Lakehouse = {\n async queryAll(statement, options) {\n signal.throwIfAborted();\n if (!Number.isInteger(options.limit) || options.limit < 1)\n throw new Error('Query needs a positive row limit.');\n if (\n operation.queryNames &&\n !Object.values(operation.queryNames).includes(options.name ?? '')\n )\n throw new Error(\n `Query name is not registered for operation ${operationName}.`\n );\n const query: DisclosedQuery = {\n name: options.name ?? `Query ${queries.length + 1}`,\n statement,\n ...(options.params === undefined ? {} : { params: options.params }),\n };\n queries.push(query);\n const limit = Math.min(options.limit, operation.policy.maxQueryRows);\n let result;\n try {\n result = await source.queryAll(statement, {\n limit,\n ...(options.params === undefined ? {} : { params: options.params }),\n signal: AbortSignal.any([signal, options.signal]),\n });\n } catch (error) {\n if (error instanceof DataSourceError) error.queryName = query.name;\n throw error;\n }\n if (result.rows.length > limit)\n throw new Error('Result exceeds row limit.');\n if (result.queryId) {\n query.queryId = result.queryId;\n queryIds.push(result.queryId);\n }\n\n return result;\n },\n };\n\n return { lakehouse, queries, queryIds };\n}\n\n/** Settle cancellation even when operation code or its lakehouse ignores the signal. */\nasync function runOperation(\n operation: Operation,\n input: unknown,\n { lakehouse, signal, queryParams }: OperationContext\n) {\n let abort: (() => void) | undefined;\n try {\n signal.throwIfAborted();\n const cancelled = new Promise<never>((_, reject) => {\n function rejectAborted() {\n reject(new Error('Request aborted.'));\n }\n abort = rejectAborted;\n signal.addEventListener('abort', rejectAborted, { once: true });\n if (signal.aborted) rejectAborted();\n });\n\n return await Promise.race([\n cancelled,\n Promise.resolve().then(() => {\n signal.throwIfAborted();\n\n return operation.run(\n { lakehouse, signal, queryParams },\n input as never\n );\n }),\n ]);\n } finally {\n if (abort) signal.removeEventListener('abort', abort);\n }\n}\n\nclass OperationTimeoutError extends Error {}\n\nclass OperationInputError extends Error {}\n\nconst sourceErrorMessages = {\n unauthorized:\n 'This app could not authenticate its data connection. Contact the app owner.',\n forbidden:\n 'This app cannot access the requested data. Contact the app owner.',\n rate_limited: 'The lakehouse is busy. Wait a moment and retry.',\n query_rejected:\n \"A lakehouse query was rejected. Check the app's data operation.\",\n unavailable: 'The lakehouse is unavailable. Check the connection and retry.',\n};\n\nexport function toDataOperationFailure(error: unknown, aborted = false) {\n if (\n error instanceof OperationInputError ||\n error instanceof DimensionMembershipError\n )\n return {\n status: 400,\n code: 'invalid_input',\n message: \"Check this operation's inputs.\",\n };\n if (error instanceof DataSourceError)\n return {\n status: error.reason === 'rate_limited' ? 429 : 502,\n code: `source_${error.reason}`,\n message: sourceErrorMessages[error.reason],\n };\n const timedOut = aborted || error instanceof OperationTimeoutError;\n return {\n status: timedOut ? 504 : 502,\n code: timedOut ? 'timeout' : 'query_failed',\n message: timedOut\n ? 'The data request timed out.'\n : 'The data request failed.',\n };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;AAoBA,eAAsB,oBAAoB,CACxC,WACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,GAEF;AAAA,EACA,cAAc,eAAe;AAAA,EAC7B,IAAI;AAAA,EACJ,IAAI;AAAA,IACF,QAAQ,UAAU,MAAM,KAAK;AAAA,IAC7B,MAAM;AAAA,IACN,MAAM,IAAI;AAAA;AAAA,EAGZ,MAAM,SAAS,YAAY,IAAI;AAAA,IAC7B;AAAA,IACA,YAAY,QAAQ,UAAU,OAAO,aAAa;AAAA,EACpD,CAAC;AAAA,EACD,MAAM,YAAY,yBAChB,WACA,WACA,QACA,aACF;AAAA,EACA,IAAI;AAAA,IACF,MAAM,SAAS,MAAM,aAAa,WAAW,OAAO;AA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ACD;AAAA,IACH,CAAC;AAAA,YACD;AAAA,IACA,IAAI;AAAA,MAAO,OAAO,oBAAoB,SAAS,KAAK;AAAA;AAAA;AAAA;AAIxD,MAAM,8BAA8B,MAAM;AAAC;AAAA;AAE3C,MAAM,4BAA4B,MAAM;AAAC;AAEzC,IAAM,sBAAsB;AAAA,EAC1B,cACE;AAAA,EACF,WACE;AAAA,EACF,cAAc;AAAA,EACd,gBACE;AAAA,EACF,aAAa;AACf;AAEO,SAAS,sBAAsB,CAAC,OAAgB,UAAU,OAAO;AAAA,EACtE,IACE,iBAAiB,uBACjB,iBAAiB;AAAA,IAEjB,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF,IAAI,iBAAiB;AAAA,IACnB,OAAO;AAAA,MACL,QAAQ,MAAM,WAAW,iBAAiB,MAAM;AAAA,MAChD,MAAM,UAAU,MAAM;AAAA,MACtB,SAAS,oBAAoB,MAAM;AAAA,IACrC;AAAA,EACF,MAAM,WAAW,WAAW,iBAAiB;AAAA,EAC7C,OAAO;AAAA,IACL,QAAQ,WAAW,MAAM;AAAA,IACzB,MAAM,WAAW,YAAY;AAAA,IAC7B,SAAS,WACL,gCACA;AAAA,EACN;AAAA;",
|
|
8
|
+
"debugId": "856CD69BA374A36264756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -159,6 +159,24 @@ var bridgeProtocol = {
|
|
|
159
159
|
})
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
|
+
function bridgeMessageMetadata(message) {
|
|
163
|
+
const metadata = { type: message.type };
|
|
164
|
+
if ("id" in message)
|
|
165
|
+
metadata.id = message.id;
|
|
166
|
+
if (message.type === "bridge:request") {
|
|
167
|
+
metadata.route = message.route;
|
|
168
|
+
const payload = message.payload;
|
|
169
|
+
if (message.route === "data:query" && payload && typeof payload === "object" && "operation" in payload && typeof payload.operation === "string")
|
|
170
|
+
metadata.operation = payload.operation.slice(0, 256);
|
|
171
|
+
}
|
|
172
|
+
if (message.type === "bridge:error")
|
|
173
|
+
metadata.error = {
|
|
174
|
+
code: message.code,
|
|
175
|
+
message: message.message,
|
|
176
|
+
...message.requestId === undefined ? {} : { requestId: message.requestId }
|
|
177
|
+
};
|
|
178
|
+
return metadata;
|
|
179
|
+
}
|
|
162
180
|
var byWire = new Map;
|
|
163
181
|
for (const name of Object.keys(bridgeProtocol.events)) {
|
|
164
182
|
const wire = bridgeProtocol.events[name].wire;
|
|
@@ -218,6 +236,13 @@ function createBridgeEndpoint({
|
|
|
218
236
|
handlers
|
|
219
237
|
}) {
|
|
220
238
|
let disposed = false;
|
|
239
|
+
function drop(reason, type) {
|
|
240
|
+
diagnostic?.({
|
|
241
|
+
direction: "drop",
|
|
242
|
+
reason,
|
|
243
|
+
...typeof type === "string" ? { type: type.slice(0, 64) } : {}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
221
246
|
function send(name, payload) {
|
|
222
247
|
if (disposed)
|
|
223
248
|
throw new Error("The bridge endpoint has closed.");
|
|
@@ -234,7 +259,7 @@ function createBridgeEndpoint({
|
|
|
234
259
|
});
|
|
235
260
|
if (!message || opaque && !validId(current.token))
|
|
236
261
|
throw new Error("The bridge is not ready to send this event.");
|
|
237
|
-
diagnostic?.("send",
|
|
262
|
+
diagnostic?.({ direction: "send", ...bridgeMessageMetadata(message) });
|
|
238
263
|
if (disposed)
|
|
239
264
|
return;
|
|
240
265
|
post(message);
|
|
@@ -244,32 +269,37 @@ function createBridgeEndpoint({
|
|
|
244
269
|
if (disposed || !peer || event.origin !== origin || event.source !== peer)
|
|
245
270
|
return;
|
|
246
271
|
const envelope = parseBridgeEnvelope(event.data);
|
|
247
|
-
if (!envelope)
|
|
272
|
+
if (!envelope) {
|
|
273
|
+
const data = event.data;
|
|
274
|
+
if (data && typeof data === "object" && "channel" in data && data.channel === bridgeProtocol.channel)
|
|
275
|
+
drop("invalid_envelope", "type" in data ? data.type : undefined);
|
|
248
276
|
return;
|
|
277
|
+
}
|
|
249
278
|
const current = context();
|
|
250
279
|
const connecting = role === "app" && envelope.type === bridgeProtocol.events.connect.wire;
|
|
251
280
|
if (opaque && (connecting ? !validId(envelope.token) : !current.token || envelope.token !== current.token))
|
|
252
|
-
return;
|
|
281
|
+
return drop("token_mismatch", envelope.type);
|
|
253
282
|
const name = bridgeEventName(envelope.type);
|
|
254
283
|
if (!name)
|
|
255
|
-
return;
|
|
284
|
+
return drop("unexpected_type", envelope.type);
|
|
256
285
|
const definition = bridgeProtocol.events[name];
|
|
257
286
|
if (definition.from === role)
|
|
258
|
-
return;
|
|
287
|
+
return drop("unexpected_type", envelope.type);
|
|
259
288
|
if (definition.session === "establish") {
|
|
260
289
|
if (envelope.documentId !== current.documentId || envelope.sessionId === undefined)
|
|
261
|
-
return;
|
|
290
|
+
return drop("session_mismatch", envelope.type);
|
|
262
291
|
} else if (definition.session === "current") {
|
|
263
292
|
if (!current.sessionId || envelope.sessionId !== current.sessionId || envelope.documentId !== current.documentId)
|
|
264
|
-
return;
|
|
293
|
+
return drop("session_mismatch", envelope.type);
|
|
265
294
|
}
|
|
266
295
|
const message = parseBridgePayload(envelope, definition);
|
|
267
296
|
if (!message) {
|
|
297
|
+
drop("invalid_payload", envelope.type);
|
|
268
298
|
if (role === "host" && name === "request" && validId(envelope.id))
|
|
269
299
|
invalidRequest?.(envelope.id);
|
|
270
300
|
return;
|
|
271
301
|
}
|
|
272
|
-
diagnostic?.("receive",
|
|
302
|
+
diagnostic?.({ direction: "receive", ...bridgeMessageMetadata(message) });
|
|
273
303
|
if (disposed)
|
|
274
304
|
return;
|
|
275
305
|
const handler = handlers[name];
|
|
@@ -286,4 +316,4 @@ function createBridgeEndpoint({
|
|
|
286
316
|
|
|
287
317
|
export { randomUuid, PARENT_PARAM, MAX_PENDING, REQUEST_TIMEOUT_MS, validId, createBridgeEndpoint };
|
|
288
318
|
|
|
289
|
-
//# debugId=
|
|
319
|
+
//# debugId=4627681268E65F3B64756E2164756E21
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/uuid.ts", "../src/core/logger.ts", "../src/core/bridge.ts", "../src/core/bridge-endpoint.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/** Opaque documents can lack randomUUID even when cryptographic randomness is available. */\nexport function randomUuid(): string {\n if (typeof crypto.randomUUID === 'function') return crypto.randomUUID();\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = (bytes[6]! & 15) | 64;\n bytes[8] = (bytes[8]! & 63) | 128;\n const hex = Array.from(bytes, byte => byte.toString(16).padStart(2, '0'));\n return [\n hex.slice(0, 4),\n hex.slice(4, 6),\n hex.slice(6, 8),\n hex.slice(8, 10),\n hex.slice(10),\n ]\n .map(part => part.join(''))\n .join('-');\n}\n",
|
|
6
|
+
"/** Host-owned log sink; compatible with console and frontend createLogger(). */\nexport type DataAppLogger = {\n log: (...args: unknown[]) => void;\n info: (...args: unknown[]) => void;\n warn: (...args: unknown[]) => void;\n error: (...args: unknown[]) => void;\n};\n\nexport type LogEntry = {\n method: keyof DataAppLogger;\n args: unknown[];\n};\n\nexport function isLogEntry(value: unknown): value is LogEntry {\n if (!value || typeof value !== 'object') return false;\n const entry = value as Record<string, unknown>;\n return (\n (entry.method === 'log' ||\n entry.method === 'info' ||\n entry.method === 'warn' ||\n entry.method === 'error') &&\n Array.isArray(entry.args) &&\n entry.args.length <= 128\n );\n}\n",
|
|
7
|
+
"import { isLogEntry } from '@/src/core/logger';\n\n/** Data app delivery protocol. IDs identify a document, a shell session, and an individual call. */\nexport const BRIDGE = 'altertable:data-app';\nexport const PARENT_PARAM = '__altertable_parent';\n/** Bound pending requests in the client and host independently.\n * The host enforces its own limit because frames can send messages directly. */\nexport const MAX_PENDING = 128;\nexport const REQUEST_TIMEOUT_MS = 60_000;\nexport type { TransportResponse } from '@/src/core/operation-types';\n\nexport function validId(value: unknown): value is string {\n return typeof value === 'string' && /^[a-zA-Z0-9_-]{1,128}$/.test(value);\n}\n\ntype Fields = Record<string, unknown>;\nexport type BridgeRole = 'host' | 'app';\ntype SessionRule = 'none' | 'establish' | 'current';\n\nfunction event<\n const Wire extends string,\n const Role extends BridgeRole,\n const Session extends SessionRule,\n Payload,\n>({\n wire,\n from,\n session,\n parse,\n}: {\n wire: Wire;\n from: Role;\n session: Session;\n parse: (fields: Fields) => Payload;\n}) {\n return { wire, from, session, parse };\n}\n\nfunction id(fields: Fields) {\n if (!validId(fields.id)) throw new Error('Invalid request ID.');\n return fields.id;\n}\n\nfunction string(fields: Fields, key: string) {\n const value = fields[key];\n if (typeof value !== 'string') throw new Error(`Invalid ${key}.`);\n return value;\n}\n\nfunction empty() {\n return {};\n}\n\n/** Parsers project known fields; opaque values are validated by their owning route or adapter. */\nexport const bridgeProtocol = {\n channel: BRIDGE,\n version: 1,\n events: {\n connect: event({\n wire: 'bridge:connect',\n from: 'host',\n session: 'none',\n parse: empty,\n }),\n ready: event({\n wire: 'bridge:ready',\n from: 'app',\n session: 'none',\n parse: empty,\n }),\n initialize: event({\n wire: 'bridge:initialize',\n from: 'host',\n session: 'establish',\n parse: fields => ({ state: fields.state }),\n }),\n request: event({\n wire: 'bridge:request',\n from: 'app',\n session: 'current',\n parse: fields => {\n const route = string(fields, 'route');\n if (!route || route.length > 256)\n throw new Error('Invalid message route.');\n return { id: id(fields), route, payload: fields.payload };\n },\n }),\n result: event({\n wire: 'bridge:result',\n from: 'host',\n session: 'current',\n parse: fields => {\n if (!Object.hasOwn(fields, 'response'))\n throw new Error('Missing response.');\n return { id: id(fields), response: fields.response };\n },\n }),\n error: event({\n wire: 'bridge:error',\n from: 'host',\n session: 'current',\n parse: fields => {\n if (\n fields.requestId !== undefined &&\n typeof fields.requestId !== 'string'\n )\n throw new Error('Invalid requestId.');\n return {\n id: id(fields),\n code: string(fields, 'code'),\n message: string(fields, 'message'),\n ...(fields.requestId === undefined\n ? {}\n : { requestId: fields.requestId }),\n };\n },\n }),\n cancel: event({\n wire: 'bridge:cancel',\n from: 'app',\n session: 'current',\n parse: fields => ({ id: id(fields) }),\n }),\n disconnect: event({\n wire: 'bridge:disconnect',\n from: 'app',\n session: 'current',\n parse: empty,\n }),\n scriptLoad: event({\n wire: 'script:load',\n from: 'host',\n session: 'current',\n parse: fields => ({ javascript: string(fields, 'javascript') }),\n }),\n stateUpdate: event({\n wire: 'state:update',\n from: 'host',\n session: 'current',\n parse: fields => ({ state: fields.state }),\n }),\n runtimeLog: event({\n wire: 'runtime:log',\n from: 'app',\n session: 'current',\n parse: fields => {\n if (!isLogEntry(fields.payload)) throw new Error('Invalid log entry.');\n return { payload: fields.payload };\n },\n }),\n runtimeReady: event({\n wire: 'runtime:ready',\n from: 'app',\n session: 'current',\n parse: empty,\n }),\n runtimeError: event({\n wire: 'runtime:error',\n from: 'app',\n session: 'current',\n parse: empty,\n }),\n },\n} as const;\n\ntype Events = typeof bridgeProtocol.events;\nexport type BridgeEventName = keyof Events;\nexport type BridgePayload<Name extends BridgeEventName> = ReturnType<\n Events[Name]['parse']\n>;\nexport type BridgeEnvelope = {\n channel: typeof BRIDGE;\n version: typeof bridgeProtocol.version;\n documentId: string;\n sessionId?: string;\n token?: string;\n};\nexport type BridgeEventMessage<Name extends BridgeEventName> =\n Name extends BridgeEventName\n ? BridgeEnvelope & {\n type: Events[Name]['wire'];\n } & (Events[Name]['session'] extends 'none'\n ? {}\n : { sessionId: string }) &\n BridgePayload<Name>\n : never;\nexport type BridgeMessage = {\n [Name in BridgeEventName]: BridgeEventMessage<Name>;\n}[BridgeEventName];\nexport type BridgeEventsFrom<Role extends BridgeRole> = {\n [Name in BridgeEventName]: Events[Name]['from'] extends Role ? Name : never;\n}[BridgeEventName];\nexport type BridgeHandlers<Role extends BridgeRole> = {\n [Name in BridgeEventsFrom<Role extends 'host' ? 'app' : 'host'>]: (\n message: BridgeEventMessage<Name>\n ) => void;\n};\n\n/** Delivery metadata safe to log on either side; never payloads or session credentials. */\nexport type BridgeMessageMetadata = {\n type: BridgeMessage['type'];\n id?: string;\n route?: string;\n operation?: string;\n error?: { code: string; message: string; requestId?: string };\n};\n\nexport function bridgeMessageMetadata(\n message: BridgeMessage\n): BridgeMessageMetadata {\n const metadata: BridgeMessageMetadata = { type: message.type };\n if ('id' in message) metadata.id = message.id;\n if (message.type === 'bridge:request') {\n metadata.route = message.route;\n const payload = message.payload;\n if (\n message.route === 'data:query' &&\n payload &&\n typeof payload === 'object' &&\n 'operation' in payload &&\n typeof payload.operation === 'string'\n )\n metadata.operation = payload.operation.slice(0, 256);\n }\n if (message.type === 'bridge:error')\n metadata.error = {\n code: message.code,\n message: message.message,\n ...(message.requestId === undefined\n ? {}\n : { requestId: message.requestId }),\n };\n return metadata;\n}\n\n/** Why a message from the connected peer was ignored. Messages from other windows are not reported. */\nexport type BridgeDropReason =\n | 'invalid_envelope'\n | 'token_mismatch'\n | 'unexpected_type'\n | 'session_mismatch'\n | 'invalid_payload';\n\nexport type BridgeDiagnostic =\n | ({ direction: 'send' | 'receive' } & BridgeMessageMetadata)\n | { direction: 'drop'; type?: string; reason: BridgeDropReason };\n\nconst byWire = new Map<string, BridgeEventName>();\nfor (const name of Object.keys(bridgeProtocol.events) as BridgeEventName[]) {\n const wire = bridgeProtocol.events[name].wire;\n if (byWire.has(wire)) throw new Error(`Duplicate bridge event: ${wire}`);\n byWire.set(wire, name);\n}\n\nexport function bridgeEventName(wire: string) {\n return byWire.get(wire);\n}\n\n/** Envelope parsing precedes authentication; event-specific fields remain untrusted. */\nexport function parseBridgeEnvelope(\n value: unknown\n): (BridgeEnvelope & Fields & { type: string }) | undefined {\n if (!value || typeof value !== 'object') return;\n const fields = value as Fields;\n if (\n fields.channel !== BRIDGE ||\n fields.version !== bridgeProtocol.version ||\n typeof fields.type !== 'string' ||\n typeof fields.documentId !== 'string' ||\n !fields.documentId ||\n fields.documentId.length > 128 ||\n (fields.sessionId !== undefined && !validId(fields.sessionId)) ||\n (fields.token !== undefined && typeof fields.token !== 'string')\n )\n return;\n return fields as BridgeEnvelope & Fields & { type: string };\n}\n\n/** Project event fields after the caller has checked envelope eligibility. */\nexport function parseBridgePayload(\n envelope: NonNullable<ReturnType<typeof parseBridgeEnvelope>>,\n definition: Events[BridgeEventName]\n): BridgeMessage | undefined {\n try {\n return {\n channel: BRIDGE,\n version: bridgeProtocol.version,\n documentId: envelope.documentId,\n ...(envelope.sessionId === undefined\n ? {}\n : { sessionId: envelope.sessionId }),\n ...(envelope.token === undefined ? {} : { token: envelope.token }),\n type: definition.wire,\n ...definition.parse(envelope),\n } as BridgeMessage;\n } catch {\n return;\n }\n}\n\nexport function parseBridgeMessage(value: unknown): BridgeMessage | undefined {\n const envelope = parseBridgeEnvelope(value);\n if (!envelope) return;\n const name = bridgeEventName(envelope.type);\n if (!name) return;\n const definition = bridgeProtocol.events[name];\n if (definition.session !== 'none' && envelope.sessionId === undefined) return;\n return parseBridgePayload(envelope, definition);\n}\n",
|
|
8
|
+
"import {\n bridgeProtocol,\n bridgeEventName,\n bridgeMessageMetadata,\n parseBridgeEnvelope,\n parseBridgeMessage,\n parseBridgePayload,\n validId,\n type BridgeDiagnostic,\n type BridgeDropReason,\n type BridgeMessage,\n type BridgeRole,\n type BridgeEventsFrom,\n type BridgePayload,\n type BridgeEnvelope,\n type BridgeHandlers,\n} from '@/src/core/bridge';\n\ntype ConnectionContext = Pick<BridgeEnvelope, 'sessionId' | 'token'> & {\n documentId?: string;\n};\n\n/** The connection owns IDs and token rotation; callers can only supply event payloads. */\nexport function createBridgeEndpoint<const Role extends BridgeRole>({\n role,\n origin,\n source,\n opaque,\n context,\n post,\n diagnostic,\n invalidRequest,\n handlers,\n}: {\n role: Role;\n handlers: BridgeHandlers<NoInfer<Role>>;\n origin: string;\n source: () => MessageEventSource | null;\n opaque: boolean;\n context: () => ConnectionContext;\n post: (message: BridgeMessage) => void;\n diagnostic?: (event: BridgeDiagnostic) => void;\n invalidRequest?: (id: string) => void;\n}) {\n let disposed = false;\n\n function drop(reason: BridgeDropReason, type: unknown) {\n diagnostic?.({\n direction: 'drop',\n reason,\n ...(typeof type === 'string' ? { type: type.slice(0, 64) } : {}),\n });\n }\n\n function send<\n Name extends BridgeEventsFrom<Role>,\n const Payload extends BridgePayload<NoInfer<Name>>,\n >(\n name: Name,\n payload: Payload &\n Record<Exclude<keyof Payload, keyof BridgePayload<NoInfer<Name>>>, never>\n ) {\n if (disposed) throw new Error('The bridge endpoint has closed.');\n const definition = bridgeProtocol.events[name];\n const current = context();\n const message = parseBridgeMessage({\n ...payload,\n channel: bridgeProtocol.channel,\n version: bridgeProtocol.version,\n type: definition.wire,\n documentId: name === 'connect' ? 'host' : current.documentId,\n sessionId: current.sessionId,\n token: opaque ? current.token : undefined,\n });\n if (!message || (opaque && !validId(current.token)))\n throw new Error('The bridge is not ready to send this event.');\n diagnostic?.({ direction: 'send', ...bridgeMessageMetadata(message) });\n if (disposed) return;\n post(message);\n }\n\n function receive(event: MessageEvent) {\n const peer = source();\n if (disposed || !peer || event.origin !== origin || event.source !== peer)\n return;\n const envelope = parseBridgeEnvelope(event.data);\n if (!envelope) {\n const data: unknown = event.data;\n if (\n data &&\n typeof data === 'object' &&\n 'channel' in data &&\n data.channel === bridgeProtocol.channel\n )\n drop('invalid_envelope', 'type' in data ? data.type : undefined);\n return;\n }\n const current = context();\n // The app learns its opaque token from a trusted host connect message.\n const connecting =\n role === 'app' && envelope.type === bridgeProtocol.events.connect.wire;\n if (\n opaque &&\n (connecting\n ? !validId(envelope.token)\n : !current.token || envelope.token !== current.token)\n )\n return drop('token_mismatch', envelope.type);\n const name = bridgeEventName(envelope.type);\n if (!name) return drop('unexpected_type', envelope.type);\n const definition = bridgeProtocol.events[name];\n if (definition.from === role) return drop('unexpected_type', envelope.type);\n if (definition.session === 'establish') {\n if (\n envelope.documentId !== current.documentId ||\n envelope.sessionId === undefined\n )\n return drop('session_mismatch', envelope.type);\n } else if (definition.session === 'current') {\n if (\n !current.sessionId ||\n envelope.sessionId !== current.sessionId ||\n envelope.documentId !== current.documentId\n )\n return drop('session_mismatch', envelope.type);\n }\n const message = parseBridgePayload(envelope, definition);\n if (!message) {\n drop('invalid_payload', envelope.type);\n if (role === 'host' && name === 'request' && validId(envelope.id))\n invalidRequest?.(envelope.id);\n return;\n }\n diagnostic?.({ direction: 'receive', ...bridgeMessageMetadata(message) });\n if (disposed) return;\n // The catalog lookup correlates the key and parsed discriminated message.\n const handler = (handlers as Record<string, (message: unknown) => void>)[\n name\n ]!;\n handler(message);\n }\n\n return {\n send,\n receive,\n dispose() {\n disposed = true;\n },\n };\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";AACO,SAAS,UAAU,GAAW;AAAA,EACnC,IAAI,OAAO,OAAO,eAAe;AAAA,IAAY,OAAO,OAAO,WAAW;AAAA,EACtE,MAAM,QAAQ,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC;AAAA,EACvD,MAAM,KAAM,MAAM,KAAM,KAAM;AAAA,EAC9B,MAAM,KAAM,MAAM,KAAM,KAAM;AAAA,EAC9B,MAAM,MAAM,MAAM,KAAK,OAAO,UAAQ,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EACxE,OAAO;AAAA,IACL,IAAI,MAAM,GAAG,CAAC;AAAA,IACd,IAAI,MAAM,GAAG,CAAC;AAAA,IACd,IAAI,MAAM,GAAG,CAAC;AAAA,IACd,IAAI,MAAM,GAAG,EAAE;AAAA,IACf,IAAI,MAAM,EAAE;AAAA,EACd,EACG,IAAI,UAAQ,KAAK,KAAK,EAAE,CAAC,EACzB,KAAK,GAAG;AAAA;;;ACFN,SAAS,UAAU,CAAC,OAAmC;AAAA,EAC5D,IAAI,CAAC,SAAS,OAAO,UAAU;AAAA,IAAU,OAAO;AAAA,EAChD,MAAM,QAAQ;AAAA,EACd,QACG,MAAM,WAAW,SAChB,MAAM,WAAW,UACjB,MAAM,WAAW,UACjB,MAAM,WAAW,YACnB,MAAM,QAAQ,M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mB,UAAU,UAAU;AAAA,IACvD,IAAI,CAAC,SAAS;AAAA,MACZ,KAAK,mBAAmB,SAAS,IAAI;AAAA,MACrC,IAAI,SAAS,UAAU,SAAS,aAAa,QAAQ,SAAS,EAAE;AAAA,QAC9D,iBAAiB,SAAS,EAAE;AAAA,MAC9B;AAAA,IACF;AAAA,IACA,aAAa,EAAE,WAAW,cAAc,sBAAsB,OAAO,EAAE,CAAC;AAAA,IACxE,IAAI;AAAA,MAAU;AAAA,IAEd,MAAM,UAAW,SACf;AAAA,IAEF,QAAQ,OAAO;AAAA;AAAA,EAGjB,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO,GAAG;AAAA,MACR,WAAW;AAAA;AAAA,EAEf;AAAA;",
|
|
11
|
+
"debugId": "4627681268E65F3B64756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -2,21 +2,21 @@ import {
|
|
|
2
2
|
createMessageClient2,
|
|
3
3
|
localFrameBridge,
|
|
4
4
|
getDataAppTransport2
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-58kks6a8.js";
|
|
6
6
|
import {
|
|
7
7
|
PARENT_PARAM
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-wss3gd3h.js";
|
|
9
9
|
import {
|
|
10
10
|
annotationDraftRoute2,
|
|
11
11
|
annotationEditorStateRoute2,
|
|
12
12
|
annotationSendRoute2,
|
|
13
13
|
annotationUpdateRoute2,
|
|
14
14
|
annotationModeRoute2
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-q1w84fv9.js";
|
|
16
16
|
import {
|
|
17
17
|
validLocation,
|
|
18
18
|
navigationUpdateRoute2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-rew95tbg.js";
|
|
20
20
|
|
|
21
21
|
// src/client/location.ts
|
|
22
22
|
function createAppLocation(frame, virtual, publish) {
|
package/dist/client/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import"../chunks/index-
|
|
2
|
-
import"../chunks/index-
|
|
1
|
+
import"../chunks/index-22d576sn.js";
|
|
2
|
+
import"../chunks/index-q1w84fv9.js";
|
|
3
3
|
import {
|
|
4
4
|
createDataClient2
|
|
5
|
-
} from "../chunks/index-
|
|
6
|
-
import"../chunks/index-
|
|
5
|
+
} from "../chunks/index-7q99hf1z.js";
|
|
6
|
+
import"../chunks/index-wjt6cavj.js";
|
|
7
7
|
import {
|
|
8
8
|
createDataAppNavigation2,
|
|
9
9
|
getDataAppNavigation2,
|
|
10
10
|
createAnnotationClient2
|
|
11
|
-
} from "../chunks/index-
|
|
11
|
+
} from "../chunks/index-xzb7sx6g.js";
|
|
12
12
|
import {
|
|
13
13
|
DataAppError2,
|
|
14
14
|
createHttpTransport2,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createIframeTransport2,
|
|
17
17
|
installDataAppTransport2,
|
|
18
18
|
getDataAppTransport2
|
|
19
|
-
} from "../chunks/index-
|
|
19
|
+
} from "../chunks/index-58kks6a8.js";
|
|
20
20
|
export {
|
|
21
21
|
DataAppError2 as DataAppError,
|
|
22
22
|
createAnnotationClient2 as createAnnotationClient,
|
package/dist/core/appearance.js
CHANGED
package/dist/core/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineDataApp2,
|
|
3
3
|
dataAppTitle2
|
|
4
|
-
} from "../chunks/index-
|
|
5
|
-
import"../chunks/index-
|
|
6
|
-
import"../chunks/index-
|
|
4
|
+
} from "../chunks/index-9zqbrv2z.js";
|
|
5
|
+
import"../chunks/index-q1w84fv9.js";
|
|
6
|
+
import"../chunks/index-22d576sn.js";
|
|
7
7
|
export {
|
|
8
8
|
dataAppTitle2 as dataAppTitle,
|
|
9
9
|
defineDataApp2 as defineDataApp
|
package/dist/core/contract.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
parseDimensionSelection2,
|
|
4
4
|
parseFacetOptions2,
|
|
5
5
|
dimensionPredicate2,
|
|
6
|
+
variableInput2,
|
|
6
7
|
parseDataAppAnnotationDraft2,
|
|
7
8
|
annotationDraftRoute2,
|
|
8
9
|
annotationEditorStateRoute2,
|
|
@@ -20,12 +21,11 @@ import {
|
|
|
20
21
|
parseDateRangeInput2,
|
|
21
22
|
parseCount2,
|
|
22
23
|
parseLabel2,
|
|
23
|
-
rowsAsRecords2,
|
|
24
24
|
defineQueryNames2,
|
|
25
25
|
DataSourceError2,
|
|
26
26
|
defineOperation2,
|
|
27
27
|
connectionCheck2
|
|
28
|
-
} from "../chunks/index-
|
|
28
|
+
} from "../chunks/index-q1w84fv9.js";
|
|
29
29
|
import {
|
|
30
30
|
MessageRoutingError2,
|
|
31
31
|
defineMessageRoute2,
|
|
@@ -34,8 +34,8 @@ import {
|
|
|
34
34
|
navigationUpdateRoute2,
|
|
35
35
|
sqlQueryRoute2,
|
|
36
36
|
dataAppRoutes2
|
|
37
|
-
} from "../chunks/index-
|
|
38
|
-
import"../chunks/index-
|
|
37
|
+
} from "../chunks/index-rew95tbg.js";
|
|
38
|
+
import"../chunks/index-22d576sn.js";
|
|
39
39
|
export {
|
|
40
40
|
DataSourceError2 as DataSourceError,
|
|
41
41
|
MessageRoutingError2 as MessageRoutingError,
|
|
@@ -68,8 +68,8 @@ export {
|
|
|
68
68
|
parseNumberSelection2 as parseNumberSelection,
|
|
69
69
|
parseTrue2 as parseTrue,
|
|
70
70
|
previousDateRange2 as previousDateRange,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
sqlQueryRoute2 as sqlQueryRoute,
|
|
72
|
+
variableInput2 as variableInput
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
//# debugId=
|
|
75
|
+
//# debugId=D41F60F6D172E51464756E2164756E21
|
package/dist/core/format.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
formatDate2,
|
|
3
|
+
parseDateTime2,
|
|
4
|
+
formatDateTime2,
|
|
5
|
+
formatTime2,
|
|
2
6
|
formatDateRange2,
|
|
3
7
|
formatMetric2,
|
|
4
8
|
formatNumber2,
|
|
5
9
|
formatCount2,
|
|
6
10
|
pluralize2,
|
|
7
11
|
formatPercent2
|
|
8
|
-
} from "../chunks/index-
|
|
12
|
+
} from "../chunks/index-22d576sn.js";
|
|
9
13
|
export {
|
|
10
14
|
formatCount2 as formatCount,
|
|
15
|
+
formatDate2 as formatDate,
|
|
11
16
|
formatDateRange2 as formatDateRange,
|
|
17
|
+
formatDateTime2 as formatDateTime,
|
|
12
18
|
formatMetric2 as formatMetric,
|
|
13
19
|
formatNumber2 as formatNumber,
|
|
14
20
|
formatPercent2 as formatPercent,
|
|
21
|
+
formatTime2 as formatTime,
|
|
22
|
+
parseDateTime2 as parseDateTime,
|
|
15
23
|
pluralize2 as pluralize
|
|
16
24
|
};
|
|
17
25
|
|
|
18
|
-
//# debugId=
|
|
26
|
+
//# debugId=02D73B3FB92AFA3964756E2164756E21
|
package/dist/core/format.js.map
CHANGED
package/dist/embed/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import"../chunks/index-
|
|
2
|
-
import"../chunks/index-
|
|
1
|
+
import"../chunks/index-22d576sn.js";
|
|
2
|
+
import"../chunks/index-q1w84fv9.js";
|
|
3
3
|
import {
|
|
4
4
|
attachDataAppBridge2
|
|
5
|
-
} from "../chunks/index-
|
|
5
|
+
} from "../chunks/index-2ajhmsc4.js";
|
|
6
6
|
import {
|
|
7
7
|
toDataOperationFailure
|
|
8
|
-
} from "../chunks/index-
|
|
8
|
+
} from "../chunks/index-wjt6cavj.js";
|
|
9
9
|
import {
|
|
10
10
|
createIframeTransport2,
|
|
11
11
|
installDataAppTransport2
|
|
12
|
-
} from "../chunks/index-
|
|
12
|
+
} from "../chunks/index-58kks6a8.js";
|
|
13
13
|
import {
|
|
14
14
|
randomUuid,
|
|
15
15
|
PARENT_PARAM
|
|
16
|
-
} from "../chunks/index-
|
|
16
|
+
} from "../chunks/index-wss3gd3h.js";
|
|
17
17
|
import {
|
|
18
18
|
MessageRoutingError2
|
|
19
|
-
} from "../chunks/index-
|
|
19
|
+
} from "../chunks/index-rew95tbg.js";
|
|
20
20
|
// src/embed/bootstrap.ts
|
|
21
21
|
function startDataAppBootstrap({
|
|
22
22
|
parentOrigin,
|
|
23
23
|
window: frame = window
|
|
24
24
|
}) {
|
|
25
25
|
let loaded;
|
|
26
|
-
let
|
|
26
|
+
let failure;
|
|
27
27
|
const bundleSource = `altertable-data-app-${randomUuid()}.js`;
|
|
28
28
|
const bridge = createIframeTransport2({
|
|
29
29
|
parentOrigin,
|
|
@@ -31,13 +31,12 @@ function startDataAppBootstrap({
|
|
|
31
31
|
mode: "bundle",
|
|
32
32
|
loadScript(javascript) {
|
|
33
33
|
if (loaded !== undefined) {
|
|
34
|
-
if (javascript
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
bridge.fail();
|
|
34
|
+
if (javascript !== loaded)
|
|
35
|
+
bridge.fail(new Error("This frame already evaluated a different app script."));
|
|
36
|
+
else if (failure)
|
|
37
|
+
bridge.fail(failure.cause);
|
|
38
|
+
else
|
|
39
|
+
bridge.ready();
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
loaded = javascript;
|
|
@@ -46,24 +45,24 @@ function startDataAppBootstrap({
|
|
|
46
45
|
script.textContent = `${javascript}
|
|
47
46
|
//# sourceURL=${bundleSource}`;
|
|
48
47
|
frame.document.body.append(script);
|
|
49
|
-
if (!
|
|
48
|
+
if (!failure)
|
|
50
49
|
bridge.ready();
|
|
51
|
-
} catch {
|
|
52
|
-
reportError();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
reportError(error);
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
|
-
function reportError() {
|
|
57
|
-
|
|
58
|
-
bridge.fail();
|
|
55
|
+
function reportError(error) {
|
|
56
|
+
failure = { cause: error };
|
|
57
|
+
bridge.fail(error);
|
|
59
58
|
}
|
|
60
59
|
function reportBundleError(event) {
|
|
61
60
|
if (event.filename === bundleSource)
|
|
62
|
-
reportError();
|
|
61
|
+
reportError(event.error ?? event.message);
|
|
63
62
|
}
|
|
64
63
|
function reportBundleRejection(event) {
|
|
65
64
|
if (event.reason instanceof Error && event.reason.stack?.includes(bundleSource))
|
|
66
|
-
reportError();
|
|
65
|
+
reportError(event.reason);
|
|
67
66
|
}
|
|
68
67
|
frame.addEventListener("error", reportBundleError);
|
|
69
68
|
frame.addEventListener("unhandledrejection", reportBundleRejection);
|
|
@@ -122,7 +121,9 @@ function createSqlQueryHandler(authorize) {
|
|
|
122
121
|
if (error instanceof MessageRoutingError2)
|
|
123
122
|
throw error;
|
|
124
123
|
const failure = toDataOperationFailure(error);
|
|
125
|
-
throw new MessageRoutingError2(failure.code, failure.message, requestId
|
|
124
|
+
throw new MessageRoutingError2(failure.code, failure.message, requestId, {
|
|
125
|
+
cause: error
|
|
126
|
+
});
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
return handleSqlQuery;
|
|
@@ -134,4 +135,4 @@ export {
|
|
|
134
135
|
startDataAppBootstrap
|
|
135
136
|
};
|
|
136
137
|
|
|
137
|
-
//# debugId=
|
|
138
|
+
//# debugId=F133D372B55FA32864756E2164756E21
|
package/dist/embed/index.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/embed/bootstrap.ts", "../src/embed/navigation.ts", "../src/embed/sql.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { randomUuid } from '@/src/core/uuid';\nimport {\n createIframeTransport,\n installDataAppTransport,\n} from '@/src/client/iframe';\n\n/** Run from a trusted bootstrap page in an allow-scripts-only iframe. CSP can prohibit network access. */\nexport function startDataAppBootstrap({\n parentOrigin,\n window: frame = window,\n}: {\n parentOrigin: string;\n window?: Window;\n}) {\n let loaded: string | undefined;\n let
|
|
5
|
+
"import { randomUuid } from '@/src/core/uuid';\nimport {\n createIframeTransport,\n installDataAppTransport,\n} from '@/src/client/iframe';\n\n/** Run from a trusted bootstrap page in an allow-scripts-only iframe. CSP can prohibit network access. */\nexport function startDataAppBootstrap({\n parentOrigin,\n window: frame = window,\n}: {\n parentOrigin: string;\n window?: Window;\n}) {\n let loaded: string | undefined;\n let failure: { cause: unknown } | undefined;\n const bundleSource = `altertable-data-app-${randomUuid()}.js`;\n const bridge = createIframeTransport({\n parentOrigin,\n window: frame,\n mode: 'bundle',\n loadScript(javascript) {\n if (loaded !== undefined) {\n if (javascript !== loaded)\n bridge.fail(\n new Error('This frame already evaluated a different app script.')\n );\n else if (failure) bridge.fail(failure.cause);\n else bridge.ready();\n\n return;\n }\n loaded = javascript;\n try {\n const script = frame.document.createElement('script');\n script.textContent = `${javascript}\\n//# sourceURL=${bundleSource}`;\n frame.document.body.append(script);\n if (!failure) bridge.ready();\n } catch (error) {\n reportError(error);\n }\n },\n });\n\n function reportError(error: unknown) {\n failure = { cause: error };\n bridge.fail(error);\n }\n\n function reportBundleError(event: ErrorEvent) {\n if (event.filename === bundleSource)\n reportError(event.error ?? event.message);\n }\n\n function reportBundleRejection(event: PromiseRejectionEvent) {\n if (\n event.reason instanceof Error &&\n event.reason.stack?.includes(bundleSource)\n )\n reportError(event.reason);\n }\n\n frame.addEventListener('error', reportBundleError);\n frame.addEventListener('unhandledrejection', reportBundleRejection);\n const uninstall = installDataAppTransport(bridge, frame);\n\n return () => {\n frame.removeEventListener('error', reportBundleError);\n frame.removeEventListener('unhandledrejection', reportBundleRejection);\n uninstall();\n };\n}\n",
|
|
6
6
|
"import { PARENT_PARAM } from '@/src/core/bridge';\nimport type { NavigationUpdate } from '@/src/core/messages';\n\n/** Override this handler for framework routers. Reserved host parameters survive app navigation. */\nexport function createNavigationHandler({\n window: host = window,\n reservedSearchParams = [],\n}: {\n window?: Window;\n reservedSearchParams?: readonly string[];\n} = {}) {\n function navigate(input: NavigationUpdate): null {\n const previous = new URL(host.location.href);\n const url = new URL(previous);\n url.search = input.search;\n url.searchParams.delete(PARENT_PARAM);\n for (const name of reservedSearchParams) {\n url.searchParams.delete(name);\n for (const value of previous.searchParams.getAll(name))\n url.searchParams.append(name, value);\n }\n url.hash = input.hash;\n if (url.href !== host.location.href)\n host.history[input.mode === 'push' ? 'pushState' : 'replaceState'](\n null,\n '',\n url\n );\n if (input.title !== undefined) host.document.title = input.title;\n\n return null;\n }\n\n return navigate;\n}\n",
|
|
7
|
-
"import { randomUuid } from '@/src/core/uuid';\nimport type { Lakehouse } from '@/src/core/contract';\nimport { toDataOperationFailure } from '@/src/core/operation';\nimport {\n MessageRoutingError,\n type MessageContext,\n type SqlQueryInput,\n} from '@/src/core/messages';\n\n/** Authorize every SQL request and supply a backend that independently enforces access and query limits. */\nexport function createSqlQueryHandler(\n authorize: (\n query: SqlQueryInput,\n context: MessageContext\n ) => Promise<Lakehouse>\n) {\n async function handleSqlQuery(input: SqlQueryInput, context: MessageContext) {\n const requestId = randomUuid();\n context.signal.throwIfAborted();\n let lakehouse: Lakehouse;\n try {\n lakehouse = await authorize(input, context);\n } catch {\n context.signal.throwIfAborted();\n throw new MessageRoutingError(\n 'forbidden',\n 'You cannot run this query.',\n requestId\n );\n }\n context.signal.throwIfAborted();\n try {\n return await lakehouse.queryAll(input.statement, {\n limit: input.limit,\n ...(input.params === undefined ? {} : { params: input.params }),\n signal: context.signal,\n });\n } catch (error) {\n context.signal.throwIfAborted();\n if (error instanceof MessageRoutingError) throw error;\n const failure = toDataOperationFailure(error);\n throw new MessageRoutingError(failure.code, failure.message, requestId);\n }\n }\n\n return handleSqlQuery;\n}\n"
|
|
7
|
+
"import { randomUuid } from '@/src/core/uuid';\nimport type { Lakehouse } from '@/src/core/contract';\nimport { toDataOperationFailure } from '@/src/core/operation';\nimport {\n MessageRoutingError,\n type MessageContext,\n type SqlQueryInput,\n} from '@/src/core/messages';\n\n/** Authorize every SQL request and supply a backend that independently enforces access and query limits. */\nexport function createSqlQueryHandler(\n authorize: (\n query: SqlQueryInput,\n context: MessageContext\n ) => Promise<Lakehouse>\n) {\n async function handleSqlQuery(input: SqlQueryInput, context: MessageContext) {\n const requestId = randomUuid();\n context.signal.throwIfAborted();\n let lakehouse: Lakehouse;\n try {\n lakehouse = await authorize(input, context);\n } catch {\n context.signal.throwIfAborted();\n throw new MessageRoutingError(\n 'forbidden',\n 'You cannot run this query.',\n requestId\n );\n }\n context.signal.throwIfAborted();\n try {\n return await lakehouse.queryAll(input.statement, {\n limit: input.limit,\n ...(input.params === undefined ? {} : { params: input.params }),\n signal: context.signal,\n });\n } catch (error) {\n context.signal.throwIfAborted();\n if (error instanceof MessageRoutingError) throw error;\n const failure = toDataOperationFailure(error);\n throw new MessageRoutingError(failure.code, failure.message, requestId, {\n cause: error,\n });\n }\n }\n\n return handleSqlQuery;\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAOO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,QAAQ,QAAQ;AAAA,GAIf;AAAA,EACD,IAAI;AAAA,EACJ,IAAI
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAOO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,QAAQ,QAAQ;AAAA,GAIf;AAAA,EACD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM,eAAe,uBAAuB,WAAW;AAAA,EACvD,MAAM,SAAS,uBAAsB;AAAA,IACnC;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU,CAAC,YAAY;AAAA,MACrB,IAAI,WAAW,WAAW;AAAA,QACxB,IAAI,eAAe;AAAA,UACjB,OAAO,KACL,IAAI,MAAM,sDAAsD,CAClE;AAAA,QACG,SAAI;AAAA,UAAS,OAAO,KAAK,QAAQ,KAAK;AAAA,QACtC;AAAA,iBAAO,MAAM;AAAA,QAElB;AAAA,MACF;AAAA,MACA,SA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AAAA;AAAA,EAIL,OAAO;AAAA;",
|
|
10
|
+
"debugId": "F133D372B55FA32864756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"./chunks/index-
|
|
2
|
-
import"./chunks/index-
|
|
1
|
+
import"./chunks/index-22d576sn.js";
|
|
2
|
+
import"./chunks/index-q1w84fv9.js";
|
|
3
3
|
import {
|
|
4
4
|
defineDataApp2,
|
|
5
5
|
dataAppTitle2
|
|
6
|
-
} from "./chunks/index-
|
|
6
|
+
} from "./chunks/index-9zqbrv2z.js";
|
|
7
7
|
export {
|
|
8
8
|
dataAppTitle2 as dataAppTitle,
|
|
9
9
|
defineDataApp2 as defineDataApp
|