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