@altertable/data-app 0.72.0 → 0.74.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 +5 -61
- package/CONTRIBUTING.md +130 -181
- package/README.md +3 -4
- package/REFERENCE.md +35 -345
- package/dist/chunks/contract-BeLPJwlO.js +558 -0
- package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
- package/dist/chunks/contract-Di8SP74I.js +462 -0
- package/dist/chunks/contract-Di8SP74I.js.map +1 -0
- package/dist/chunks/diagnostics-BTZSlNtW.js +967 -0
- package/dist/chunks/diagnostics-BTZSlNtW.js.map +1 -0
- package/dist/chunks/format-BdFlv_xa.js +148 -0
- package/dist/chunks/format-BdFlv_xa.js.map +1 -0
- package/dist/chunks/operation-CSM9UmO3.js +134 -0
- package/dist/chunks/operation-CSM9UmO3.js.map +1 -0
- package/dist/chunks/request-body-H1qPmmTN.js +50 -0
- package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
- package/dist/client/index.js +273 -285
- package/dist/client/index.js.map +1 -13
- package/dist/core/appearance.js +171 -162
- package/dist/core/appearance.js.map +1 -10
- package/dist/core/config.js +49 -11
- package/dist/core/config.js.map +1 -9
- package/dist/core/contract.js +3 -73
- package/dist/core/format.js +1 -26
- package/dist/index.js +1 -12
- package/dist/internal.js +352 -397
- package/dist/internal.js.map +1 -15
- package/dist/server/index.js +85 -97
- package/dist/server/index.js.map +1 -10
- package/dist/types/chunks/appearance.d.ts +45 -0
- package/dist/types/chunks/contract.d.ts +720 -0
- package/dist/types/chunks/index.d.ts +240 -0
- package/dist/types/client/index.d.ts +3 -13
- package/dist/types/core/appearance.d.ts +2 -42
- package/dist/types/core/config.d.ts +36 -39
- package/dist/types/core/contract.d.ts +2 -114
- package/dist/types/core/format.d.ts +44 -17
- package/dist/types/index.d.ts +3 -3
- package/dist/types/internal.d.ts +312 -22
- package/dist/types/server/index.d.ts +15 -4
- package/docs/app-authoring.md +77 -128
- package/docs/client.md +29 -63
- package/docs/composition.md +44 -75
- package/docs/contract.md +60 -100
- package/docs/data-context.md +35 -61
- package/docs/diagnostics.md +45 -0
- package/docs/embed.md +86 -55
- package/docs/formatting-and-appearance.md +17 -38
- package/docs/hosted-apps.md +7 -14
- package/docs/layout.md +30 -47
- package/docs/local-data-apps.md +7 -7
- package/docs/react-embed.md +20 -26
- package/docs/react.md +10 -27
- package/docs/server-bun.md +2 -27
- package/docs/server.md +6 -12
- package/docs/stories-and-export.md +38 -40
- package/docs/styling.md +14 -22
- package/docs/ui-quality.md +5 -5
- package/docs/ui.md +93 -70
- package/docs/variables.md +142 -254
- package/docs/views.md +85 -116
- package/docs/widgets.md +100 -153
- package/docs/worker.md +15 -27
- package/package.json +3 -2
- package/dist/chunks/index-5a27erdg.js +0 -54
- package/dist/chunks/index-5a27erdg.js.map +0 -10
- package/dist/chunks/index-9yxr7nmm.js +0 -742
- package/dist/chunks/index-9yxr7nmm.js.map +0 -17
- package/dist/chunks/index-j5q5n3ra.js +0 -151
- package/dist/chunks/index-j5q5n3ra.js.map +0 -10
- package/dist/chunks/index-q75zm3a7.js +0 -153
- package/dist/chunks/index-q75zm3a7.js.map +0 -11
- package/dist/chunks/index-vhaec7m5.js +0 -30
- package/dist/chunks/index-vhaec7m5.js.map +0 -10
- package/dist/chunks/index-zp78caex.js +0 -1047
- package/dist/chunks/index-zp78caex.js.map +0 -19
- package/dist/core/contract.js.map +0 -9
- package/dist/core/format.js.map +0 -9
- package/dist/index.js.map +0 -9
- package/dist/types/client/annotations.d.ts +0 -27
- package/dist/types/client/data-client.d.ts +0 -43
- package/dist/types/client/download.d.ts +0 -5
- package/dist/types/client/iframe.d.ts +0 -59
- package/dist/types/client/location.d.ts +0 -13
- package/dist/types/client/logger.d.ts +0 -14
- package/dist/types/client/messages.d.ts +0 -7
- package/dist/types/client/navigation.d.ts +0 -15
- package/dist/types/client/transport.d.ts +0 -15
- package/dist/types/core/annotations.d.ts +0 -99
- package/dist/types/core/bridge-endpoint.d.ts +0 -21
- package/dist/types/core/bridge.d.ts +0 -172
- package/dist/types/core/data-view.d.ts +0 -46
- package/dist/types/core/date-format.d.ts +0 -24
- package/dist/types/core/date-range.d.ts +0 -20
- package/dist/types/core/dimension-source.d.ts +0 -64
- package/dist/types/core/dimension.d.ts +0 -71
- package/dist/types/core/facets.d.ts +0 -13
- package/dist/types/core/filters.d.ts +0 -45
- package/dist/types/core/invariant.d.ts +0 -2
- package/dist/types/core/keys.d.ts +0 -2
- package/dist/types/core/logger.d.ts +0 -12
- package/dist/types/core/messages.d.ts +0 -62
- package/dist/types/core/navigation.d.ts +0 -11
- package/dist/types/core/operation-types.d.ts +0 -80
- package/dist/types/core/operation.d.ts +0 -20
- package/dist/types/core/presentation.d.ts +0 -9
- package/dist/types/core/queries.d.ts +0 -84
- package/dist/types/core/reading.d.ts +0 -17
- package/dist/types/core/uuid.d.ts +0 -2
- package/dist/types/core/variables.d.ts +0 -133
- package/dist/types/server/handler.d.ts +0 -13
- package/dist/types/server/request-body.d.ts +0 -4
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** App-owned URL state shared by controls, frame adapters, and host navigation. */
|
|
2
|
-
export type AppLocation = {
|
|
3
|
-
search: string;
|
|
4
|
-
hash: string;
|
|
5
|
-
};
|
|
6
|
-
export type HistoryMode = 'push' | 'replace';
|
|
7
|
-
export type NavigationUpdate = AppLocation & {
|
|
8
|
-
mode: HistoryMode;
|
|
9
|
-
title?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function validLocation(value: unknown): value is AppLocation;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/** Shared operation, query, and response contracts; independent of delivery adapters. */
|
|
2
|
-
import { type QueryParameters } from './queries.js';
|
|
3
|
-
export type OperationContracts = Record<string, {
|
|
4
|
-
input: (value: unknown) => unknown;
|
|
5
|
-
}>;
|
|
6
|
-
export type InputOf<T> = T extends {
|
|
7
|
-
input: (value: unknown) => infer Input;
|
|
8
|
-
} ? Input : never;
|
|
9
|
-
/** An operation's data is what its `run` resolves to. */
|
|
10
|
-
export type OutputOf<T> = T extends {
|
|
11
|
-
run: (...args: never[]) => Promise<infer Output>;
|
|
12
|
-
} ? Output : unknown;
|
|
13
|
-
/** Lakehouse results contain positional unknown cells; registered queries supply decoded records. */
|
|
14
|
-
export type QueryResult<Row = unknown[]> = {
|
|
15
|
-
columns: {
|
|
16
|
-
name: string;
|
|
17
|
-
type?: string;
|
|
18
|
-
}[];
|
|
19
|
-
rows: Row[];
|
|
20
|
-
queryId?: string;
|
|
21
|
-
};
|
|
22
|
-
/** One registered statement an operation ran, with its parameter values. */
|
|
23
|
-
export type DisclosedQuery = {
|
|
24
|
-
name: string;
|
|
25
|
-
statement: string;
|
|
26
|
-
params?: QueryParameters;
|
|
27
|
-
queryId?: string;
|
|
28
|
-
};
|
|
29
|
-
/** Query interface supplied by a server adapter or an authorized iframe bridge. */
|
|
30
|
-
export type Lakehouse = {
|
|
31
|
-
queryAll(statement: string, options: {
|
|
32
|
-
limit: number;
|
|
33
|
-
signal: AbortSignal;
|
|
34
|
-
name?: string;
|
|
35
|
-
params?: QueryParameters;
|
|
36
|
-
}): Promise<QueryResult>;
|
|
37
|
-
};
|
|
38
|
-
export type OperationContext = {
|
|
39
|
-
lakehouse: Lakehouse;
|
|
40
|
-
signal: AbortSignal;
|
|
41
|
-
queryParams?: QueryParameters;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* The input parser runs in the operation executor's runtime: server for HTTP apps, browser for
|
|
45
|
-
* bundle apps. Browser validation does not replace backend authorization or query limits.
|
|
46
|
-
* Registered queries decode rows from their declared projections; `run` derives the operation's data.
|
|
47
|
-
*/
|
|
48
|
-
export type DataOperation<Input, Output> = {
|
|
49
|
-
input: (value: unknown) => Input;
|
|
50
|
-
run: (context: OperationContext, input: Input) => Promise<Output>;
|
|
51
|
-
checks: readonly [Input, ...Input[]];
|
|
52
|
-
queryNames?: Readonly<Record<string, string>>;
|
|
53
|
-
policy: {
|
|
54
|
-
maxQueryRows: number;
|
|
55
|
-
maxDurationMs: number;
|
|
56
|
-
maxResponseBytes?: number;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/** Heterogeneous registry: inputs vary per operation, so checks retain unknown values. */
|
|
60
|
-
export type DataOperations = Record<string, OperationContracts[string] & Omit<DataOperation<never, unknown>, 'input' | 'checks'> & {
|
|
61
|
-
checks: readonly [unknown, ...unknown[]];
|
|
62
|
-
}>;
|
|
63
|
-
export type DataQueryInput<Operations extends OperationContracts> = {
|
|
64
|
-
[Name in keyof Operations & string]: {
|
|
65
|
-
operation: Name;
|
|
66
|
-
input: InputOf<Operations[Name]>;
|
|
67
|
-
};
|
|
68
|
-
}[keyof Operations & string];
|
|
69
|
-
export type DataQueryBody<Output> = {
|
|
70
|
-
data: Output;
|
|
71
|
-
requestId: string;
|
|
72
|
-
queriedAt: string;
|
|
73
|
-
queryIds: string[];
|
|
74
|
-
queries?: DisclosedQuery[];
|
|
75
|
-
};
|
|
76
|
-
/** Delivery envelope shared by HTTP and iframe transports. */
|
|
77
|
-
export type TransportResponse<Body = unknown> = {
|
|
78
|
-
status: number;
|
|
79
|
-
body: Body;
|
|
80
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DataOperations, Lakehouse, OperationContext, DataQueryBody } from './operation-types.js';
|
|
2
|
-
type Operation = DataOperations[string];
|
|
3
|
-
type OperationExecutionOptions = {
|
|
4
|
-
operationName: string;
|
|
5
|
-
lakehouse: Lakehouse;
|
|
6
|
-
signal: AbortSignal;
|
|
7
|
-
requestId: string;
|
|
8
|
-
queryParams?: OperationContext['queryParams'];
|
|
9
|
-
};
|
|
10
|
-
/** Shared operation execution. Adapters own authorization, delivery, and public errors. */
|
|
11
|
-
export declare function executeDataOperation(operation: Operation, value: unknown, { operationName, lakehouse, signal: requestSignal, requestId, queryParams, }: OperationExecutionOptions): Promise<{
|
|
12
|
-
body: DataQueryBody<unknown>;
|
|
13
|
-
serializedBody: string;
|
|
14
|
-
}>;
|
|
15
|
-
export declare function toDataOperationFailure(error: unknown, aborted?: boolean): {
|
|
16
|
-
status: number;
|
|
17
|
-
code: string;
|
|
18
|
-
message: string;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type DataAppAnnotationPresentation } from './annotations.js';
|
|
2
|
-
import { type Theme } from './appearance.js';
|
|
3
|
-
/** Presentation owned by the parent shell, delivered only over a trusted bridge. */
|
|
4
|
-
export type DataAppPresentation = {
|
|
5
|
-
surface: 'embedded' | 'standalone';
|
|
6
|
-
theme: Theme;
|
|
7
|
-
annotations?: DataAppAnnotationPresentation;
|
|
8
|
-
};
|
|
9
|
-
export declare function isDataAppPresentation(value: unknown): value is DataAppPresentation;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { QueryResult } from './operation-types.js';
|
|
2
|
-
type QueryValues = {
|
|
3
|
-
string: string;
|
|
4
|
-
number: number;
|
|
5
|
-
boolean: boolean;
|
|
6
|
-
null: null;
|
|
7
|
-
};
|
|
8
|
-
/** Primitive values after decoding, independent of SQL storage types. */
|
|
9
|
-
export type QueryValueType = keyof QueryValues;
|
|
10
|
-
export type QueryField = {
|
|
11
|
-
type: QueryValueType;
|
|
12
|
-
nullable?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type QueryProjections = Readonly<Record<string, QueryField>>;
|
|
15
|
-
type QueryValue<Field extends QueryField> = QueryValues[Field['type']] | (Field extends {
|
|
16
|
-
nullable: true;
|
|
17
|
-
} ? null : never);
|
|
18
|
-
export type QueryRow<Projections extends QueryProjections> = {
|
|
19
|
-
-readonly [Name in keyof Projections]: QueryValue<Projections[Name]>;
|
|
20
|
-
};
|
|
21
|
-
export type QueryParameterValue = string | number | boolean | null;
|
|
22
|
-
/** Typed scalar parameters with optional fallback values. */
|
|
23
|
-
export type QueryParameter = {
|
|
24
|
-
[Type in QueryValueType]: {
|
|
25
|
-
type: Type;
|
|
26
|
-
nullable?: false;
|
|
27
|
-
defaultValue?: QueryValues[Type];
|
|
28
|
-
} | {
|
|
29
|
-
type: Type;
|
|
30
|
-
nullable: true;
|
|
31
|
-
defaultValue?: QueryValues[Type] | null;
|
|
32
|
-
};
|
|
33
|
-
}[QueryValueType];
|
|
34
|
-
/** Callers may omit values supplied by host context or declaration defaults. */
|
|
35
|
-
export type QueryInputParameters<Params extends Readonly<Record<string, QueryParameter>>> = {
|
|
36
|
-
[Name in keyof Params]?: QueryValue<Params[Name]>;
|
|
37
|
-
};
|
|
38
|
-
type QueryDefinition = {
|
|
39
|
-
statement: string;
|
|
40
|
-
params: Readonly<Record<string, QueryParameter>>;
|
|
41
|
-
projections: QueryProjections;
|
|
42
|
-
};
|
|
43
|
-
export type QueryDefinitions = Readonly<Record<string, QueryDefinition>>;
|
|
44
|
-
export type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
|
|
45
|
-
export type KnownRecord<RecordType> = '__proto__' extends keyof RecordType ? never : string extends keyof RecordType ? never : Exclude<keyof RecordType, string> extends never ? true extends IsUnion<RecordType> ? never : RecordType : never;
|
|
46
|
-
type CheckedField<Field extends QueryField> = true extends IsUnion<Field> ? never : true extends IsUnion<Field['type']> ? never : 'nullable' extends keyof Field ? Field extends {
|
|
47
|
-
nullable: infer Nullable;
|
|
48
|
-
} ? boolean extends Nullable ? never : Field : never : Field;
|
|
49
|
-
type CheckedParameters<Params extends Readonly<Record<string, QueryParameter>>> = KnownRecord<Params> & {
|
|
50
|
-
[Name in keyof Params]: CheckedField<Params[Name]> & ('defaultValue' extends keyof Params[Name] ? undefined extends Params[Name]['defaultValue'] ? never : Params[Name] : Params[Name]);
|
|
51
|
-
};
|
|
52
|
-
type CheckedProjections<Projections extends QueryProjections> = KnownRecord<Projections> & (keyof Projections extends never ? never : '' extends keyof Projections ? never : {
|
|
53
|
-
[Name in keyof Projections]: CheckedField<Projections[Name]>;
|
|
54
|
-
});
|
|
55
|
-
/** Author declarations preserve finite names, fixed types, and one parameter map. */
|
|
56
|
-
export type CheckedQueries<Queries extends QueryDefinitions> = KnownRecord<Queries> & ('' extends keyof Queries ? never : unknown) & {
|
|
57
|
-
[Name in keyof Queries]: KnownRecord<Queries[Name]> & {
|
|
58
|
-
statement: Queries[Name]['statement'] extends '' ? never : Queries[Name]['statement'];
|
|
59
|
-
params: CheckedParameters<Queries[Name]['params']>;
|
|
60
|
-
projections: CheckedProjections<Queries[Name]['projections']>;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
type FrozenField<Field extends QueryField> = Field extends unknown ? Readonly<Field> : never;
|
|
64
|
-
export type QuerySnapshot<Queries extends QueryDefinitions> = {
|
|
65
|
-
readonly [Name in keyof Queries]: {
|
|
66
|
-
readonly statement: Queries[Name]['statement'];
|
|
67
|
-
readonly params: {
|
|
68
|
-
readonly [Param in keyof Queries[Name]['params']]: FrozenField<Queries[Name]['params'][Param]>;
|
|
69
|
-
};
|
|
70
|
-
readonly projections: {
|
|
71
|
-
readonly [Field in keyof Queries[Name]['projections']]: FrozenField<Queries[Name]['projections'][Field]>;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
/** Parameters are scalar SQL values, never identifiers or SQL fragments. */
|
|
76
|
-
export type QueryParameters = Readonly<Record<string, QueryParameterValue>>;
|
|
77
|
-
export declare function isQueryParameters(value: unknown): value is QueryParameters;
|
|
78
|
-
/** Snapshot the query's SQL, parameter defaults, and decoded result contract. */
|
|
79
|
-
export declare function snapshotQueries<const Queries extends QueryDefinitions>(definitions: Queries): QuerySnapshot<Queries>;
|
|
80
|
-
/** Decode each returned cell once, matching aliases independently of result order. */
|
|
81
|
-
export declare function decodeQueryResult<Projections extends QueryProjections>(result: QueryResult, projections: Projections): QueryResult<QueryRow<Projections>>;
|
|
82
|
-
/** Host context supplies protected values; callers and defaults fill the remaining parameters. */
|
|
83
|
-
export declare function resolveQueryParameters(declarations: Readonly<Record<string, QueryParameter>>, values: Partial<QueryParameters>, context: QueryParameters): QueryParameters;
|
|
84
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type DateRangeRequest } from './contract.js';
|
|
2
|
-
export type DataReading<Value> = {
|
|
3
|
-
loading: true;
|
|
4
|
-
value?: never;
|
|
5
|
-
} | {
|
|
6
|
-
loading: false;
|
|
7
|
-
value: Value;
|
|
8
|
-
};
|
|
9
|
-
/** Zero is measured data. null or omitted means no previous measurement.
|
|
10
|
-
* Comparison activation belongs to the reading's period, not these values. */
|
|
11
|
-
export type MetricValues = {
|
|
12
|
-
current: number;
|
|
13
|
-
previous?: number | null;
|
|
14
|
-
};
|
|
15
|
-
export type MetricReading = DataReading<MetricValues & {
|
|
16
|
-
period?: DateRangeRequest;
|
|
17
|
-
}>;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { IsUnion } from './queries.js';
|
|
2
|
-
import { facetSource, type FacetVariable } from './facets.js';
|
|
3
|
-
import type { SourceDimensionVariable } from './dimension-source.js';
|
|
4
|
-
import { type DatePresetId, type DateRange } from './date-range.js';
|
|
5
|
-
import type { DateRangeContract, DateRangeRequest } from './contract.js';
|
|
6
|
-
import type { DimensionSelection, DimensionVariable, DimensionSelectionVariable } from './dimension.js';
|
|
7
|
-
import type { NumberFilter, BooleanFilter } from './filters.js';
|
|
8
|
-
import type { HistoryMode } from './navigation.js';
|
|
9
|
-
export type { HistoryMode } from './navigation.js';
|
|
10
|
-
export type VariablePresentation = {
|
|
11
|
-
/** Scope changes the included data; display changes its presentation. Defaults to scope. */
|
|
12
|
-
group?: 'scope' | 'display';
|
|
13
|
-
/** Widget controls render beside their visualization instead of in the toolbar.
|
|
14
|
-
* Scope filters remain available in the Filters sheet and active summaries. */
|
|
15
|
-
control?: 'toolbar' | 'widget';
|
|
16
|
-
/** Secondary scope controls live in the Filters sheet with compact pickers when active; secondary display options follow primary options. Defaults to primary. */
|
|
17
|
-
prominence?: 'primary' | 'secondary';
|
|
18
|
-
};
|
|
19
|
-
/** An app-owned value with one URL representation. Controls never parse or write routes. */
|
|
20
|
-
export type AppVariable<Value, Kind extends string = string> = {
|
|
21
|
-
kind: Kind;
|
|
22
|
-
label?: string;
|
|
23
|
-
presentation?: VariablePresentation;
|
|
24
|
-
urlKeys: readonly string[];
|
|
25
|
-
defaultValue: Value;
|
|
26
|
-
/** Unrestricted value, when this variable represents a filter. */
|
|
27
|
-
clearValue?: Value;
|
|
28
|
-
describe?: (value: Value) => string;
|
|
29
|
-
history: HistoryMode;
|
|
30
|
-
read: (params: URLSearchParams) => Value;
|
|
31
|
-
write: (value: Value) => Record<string, string | null>;
|
|
32
|
-
valid: (value: Value) => boolean;
|
|
33
|
-
same: (left: Value, right: Value) => boolean;
|
|
34
|
-
};
|
|
35
|
-
export type VariableCollection = Record<string, SearchVariable | ChoiceVariable<any> | MultiChoiceVariable | DateRangeVariable | DimensionVariable<any> | FacetVariable<any, any, string, unknown> | SourceDimensionVariable<any> | NumberFilter | BooleanFilter>;
|
|
36
|
-
export type AppVariableValues<Variables> = {
|
|
37
|
-
[Key in keyof Variables]: Variables[Key] extends DimensionSelectionVariable<infer Value> ? DimensionSelection<Value> : Variables[Key] extends AppVariable<infer Value, string> ? Value : never;
|
|
38
|
-
};
|
|
39
|
-
/** Keep conditional declarations narrowed so every dependency has one contract. */
|
|
40
|
-
export type CheckedVariableDeclarations<Variables extends VariableCollection> = true extends IsUnion<Variables> ? never : string extends keyof Variables ? Variables : '__proto__' extends keyof Variables ? never : {
|
|
41
|
-
[Name in keyof Variables]: true extends IsUnion<Variables[Name]> ? never : Variables[Name];
|
|
42
|
-
};
|
|
43
|
-
/** Every facet dependency must be present with a compatible variable declaration. */
|
|
44
|
-
export type CheckedFacetContexts<Variables extends VariableCollection> = CheckedVariableDeclarations<Variables> & (string extends keyof Variables ? Extract<Variables[keyof Variables], {
|
|
45
|
-
[facetSource]: unknown;
|
|
46
|
-
}> extends never ? Variables : never : {
|
|
47
|
-
[Name in keyof Variables]: Variables[Name] extends {
|
|
48
|
-
[facetSource]: {
|
|
49
|
-
context: infer Context;
|
|
50
|
-
};
|
|
51
|
-
} ? string extends keyof Context ? never : Variables extends Context ? Variables[Name] : never : Variables[Name];
|
|
52
|
-
});
|
|
53
|
-
/** Name variables once in the app. URL keys must be unique across its controls. */
|
|
54
|
-
export declare function defineAppVariables<const Variables extends VariableCollection>(variables: Variables): Variables;
|
|
55
|
-
type ScalarVariableOptions = {
|
|
56
|
-
label?: string;
|
|
57
|
-
key: string;
|
|
58
|
-
defaultValue?: string;
|
|
59
|
-
history?: HistoryMode;
|
|
60
|
-
presentation?: VariablePresentation;
|
|
61
|
-
};
|
|
62
|
-
export type SearchVariable = AppVariable<string, 'search'>;
|
|
63
|
-
export type ChoiceOption = {
|
|
64
|
-
id: string;
|
|
65
|
-
label: string;
|
|
66
|
-
description?: string;
|
|
67
|
-
};
|
|
68
|
-
export type ChoiceVariable<Value extends string = string> = AppVariable<Value, 'choice'> & {
|
|
69
|
-
options: readonly ChoiceOption[];
|
|
70
|
-
};
|
|
71
|
-
export type MultiChoiceVariable = AppVariable<readonly string[], 'multiChoice'> & {
|
|
72
|
-
options: readonly ChoiceOption[];
|
|
73
|
-
maxSelected: number;
|
|
74
|
-
};
|
|
75
|
-
/** Search query state; typing replaces history by default. */
|
|
76
|
-
export declare function searchVariable({ key, label, defaultValue, history, }: Omit<ScalarVariableOptions, 'presentation'>): SearchVariable;
|
|
77
|
-
/** Validate labeled choices before controls or URL state consume them. */
|
|
78
|
-
export declare function validateChoiceOptions(options: readonly ChoiceOption[]): void;
|
|
79
|
-
export declare function choiceVariable<const Options extends readonly ChoiceOption[], const Presentation extends VariablePresentation | undefined = undefined>({ key, label, defaultValue, options, history, presentation, }: Omit<ScalarVariableOptions, 'presentation'> & {
|
|
80
|
-
presentation?: Presentation;
|
|
81
|
-
defaultValue: NoInfer<Options[number]['id']>;
|
|
82
|
-
options: Options & (Options extends readonly [] ? never : unknown);
|
|
83
|
-
}): ChoiceVariable<Options[number]['id']> & {
|
|
84
|
-
presentation?: Presentation;
|
|
85
|
-
};
|
|
86
|
-
export declare function multiChoiceVariable<const Options extends readonly ChoiceOption[], const Presentation extends VariablePresentation | undefined = undefined>({ key, label, defaultValue, options, maxSelected, history, presentation, }: Omit<ScalarVariableOptions, 'defaultValue' | 'presentation'> & {
|
|
87
|
-
presentation?: Presentation;
|
|
88
|
-
defaultValue?: readonly NoInfer<Options[number]['id']>[];
|
|
89
|
-
options: Options & (Options extends readonly [] ? never : unknown);
|
|
90
|
-
maxSelected?: number;
|
|
91
|
-
}): MultiChoiceVariable & {
|
|
92
|
-
presentation?: Presentation;
|
|
93
|
-
};
|
|
94
|
-
export type DateRangeSelection = {
|
|
95
|
-
kind: 'preset';
|
|
96
|
-
id: DatePresetId;
|
|
97
|
-
comparison?: 'previous';
|
|
98
|
-
} | {
|
|
99
|
-
kind: 'dates';
|
|
100
|
-
start: string;
|
|
101
|
-
end: string;
|
|
102
|
-
comparison?: 'previous';
|
|
103
|
-
};
|
|
104
|
-
export type DateRangeVariableOptions = {
|
|
105
|
-
label?: string;
|
|
106
|
-
/** URL key for a relative preset; explicit dates use start/end for period, otherwise key-prefixed fields. */
|
|
107
|
-
key: string;
|
|
108
|
-
defaultValue: DateRangeSelection & {
|
|
109
|
-
comparison?: never;
|
|
110
|
-
};
|
|
111
|
-
contract: DateRangeContract;
|
|
112
|
-
history?: HistoryMode;
|
|
113
|
-
/** Opt into a URL-backed comparison with the preceding equal-length range. */
|
|
114
|
-
comparison?: boolean;
|
|
115
|
-
presentation?: VariablePresentation;
|
|
116
|
-
};
|
|
117
|
-
export type DateRangeVariable = AppVariable<DateRangeSelection, 'dateRange'> & {
|
|
118
|
-
kind: 'dateRange';
|
|
119
|
-
supportsComparison: boolean;
|
|
120
|
-
input: (selection: DateRangeSelection) => DateRangeRequest;
|
|
121
|
-
describeInput: (input: DateRangeRequest) => string;
|
|
122
|
-
bounds: () => {
|
|
123
|
-
minDate?: string;
|
|
124
|
-
maxDate: string;
|
|
125
|
-
maxRangeDays: number;
|
|
126
|
-
timeZone: string;
|
|
127
|
-
};
|
|
128
|
-
resolve: (selection: DateRangeSelection) => DateRange;
|
|
129
|
-
previous: (selection: DateRangeSelection) => DateRange | null;
|
|
130
|
-
comparisonRange: (selection: DateRangeSelection) => DateRange | null;
|
|
131
|
-
};
|
|
132
|
-
/** A date variable keeps relative presets relative and validates exact dates against source coverage. */
|
|
133
|
-
export declare function dateRangeVariable({ key, label, defaultValue, contract, history, comparison, presentation, }: DateRangeVariableOptions): DateRangeVariable;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type DataOperations, type Lakehouse, type QueryParameters } from '../core/contract.js';
|
|
2
|
-
/** Authorization result for one viewer request. A hosted adapter must scope its lakehouse client. */
|
|
3
|
-
export type RequestAccess = {
|
|
4
|
-
lakehouse: Lakehouse;
|
|
5
|
-
/** Trusted values shared across queries; each query uses only its declared keys. */
|
|
6
|
-
queryParams?: QueryParameters;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Execute named operations on the server. The app supplies operations and viewer authorization.
|
|
10
|
-
* JSON, Origin, and Fetch Metadata checks reject cross-site browser POSTs; they do not
|
|
11
|
-
* authenticate another local process. Query evidence accompanies every result.
|
|
12
|
-
*/
|
|
13
|
-
export declare function createDataHandler(operations: DataOperations, authorize: (request: Request, operation: string) => Promise<RequestAccess>): (request: Request) => Promise<Response>;
|