@altertable/data-app 0.76.0 → 0.77.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/REFERENCE.md +365 -257
- package/dist/chunks/{contract-DsyRYgN_.js → contract-BQsFReRp.js} +323 -169
- package/dist/chunks/contract-BQsFReRp.js.map +1 -0
- package/dist/chunks/{contract-kNFYPHRK.js → contract-VhY9V9wd.js} +184 -91
- package/dist/chunks/contract-VhY9V9wd.js.map +1 -0
- package/dist/chunks/{date-time-range-value-TE8KCsfV.js → date-time-range-value-CnlTr1U1.js} +8 -8
- package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +1 -0
- package/dist/chunks/{diagnostics-DhCqGklq.js → diagnostics-Dyj-rUsY.js} +2 -2
- package/dist/chunks/{diagnostics-DhCqGklq.js.map → diagnostics-Dyj-rUsY.js.map} +1 -1
- package/dist/chunks/{operation-7tiT4cpJ.js → operation-BVRM-A5Y.js} +3 -3
- package/dist/chunks/{operation-7tiT4cpJ.js.map → operation-BVRM-A5Y.js.map} +1 -1
- package/dist/client/index.js +65 -50
- package/dist/client/index.js.map +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.js +4 -4
- package/dist/core/format.js +1 -1
- package/dist/internal.js +6 -124
- package/dist/internal.js.map +1 -1
- package/dist/server/index.js +3 -3
- package/dist/types/chunks/contract.d.ts +358 -309
- package/dist/types/chunks/contract2.d.ts +16 -2
- package/dist/types/chunks/index.d.ts +32 -5
- package/dist/types/client/index.d.ts +3 -3
- package/dist/types/core/config.d.ts +7 -3
- package/dist/types/core/contract.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal.d.ts +5 -5
- package/dist/types/server/index.d.ts +1 -1
- package/docs/app-authoring.md +15 -10
- package/docs/client.md +12 -7
- package/docs/contract.md +33 -51
- package/docs/data-context.md +9 -5
- package/docs/filters.md +295 -0
- package/docs/hosted-apps.md +4 -3
- package/docs/layout.md +24 -18
- package/docs/stories-and-export.md +19 -10
- package/docs/ui.md +6 -5
- package/docs/views.md +62 -26
- package/docs/widgets.md +38 -14
- package/package.json +1 -1
- package/dist/chunks/contract-DsyRYgN_.js.map +0 -1
- package/dist/chunks/contract-kNFYPHRK.js.map +0 -1
- package/dist/chunks/date-time-range-value-TE8KCsfV.js.map +0 -1
- package/docs/variables.md +0 -280
|
@@ -1,107 +1,191 @@
|
|
|
1
1
|
import { n as DateTimeRange, s as ResolvedDateTimeRange } from "./date-time-range.js";
|
|
2
2
|
//#region src/core/date-time-range-contract.d.ts
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/** What an operation receives for a date filter: resolved bounds, `from` inclusive and
|
|
4
|
+
* `to` exclusive, and the same window one selected length earlier while the comparison is on. */
|
|
5
|
+
type DateTimeRangeInput = {
|
|
5
6
|
range: ResolvedDateTimeRange;
|
|
6
7
|
comparison: ResolvedDateTimeRange | null;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type DateTimeRangePolicyOptions = {
|
|
10
|
+
minDate?: string;
|
|
11
|
+
maxDate?: string | (() => string);
|
|
12
|
+
maxRangeDays?: number;
|
|
13
|
+
timeZone: string;
|
|
14
|
+
completeDays?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** A date filter's coverage, duration limit, and reporting time zone. Parsing preserves relative values. */
|
|
17
|
+
type DateTimeRangePolicy = ReturnType<typeof createDateTimeRangePolicy>;
|
|
18
|
+
declare function createDateTimeRangePolicy({ minDate, maxDate: sourceMaxDate, maxRangeDays, timeZone, completeDays }: DateTimeRangePolicyOptions): {
|
|
11
19
|
timeZone: string;
|
|
12
20
|
bounds: (now?: Date) => {
|
|
13
21
|
minDate: string | undefined;
|
|
14
22
|
maxDate: string;
|
|
15
|
-
maxRangeDays: number;
|
|
23
|
+
maxRangeDays: number | undefined;
|
|
16
24
|
timeZone: string;
|
|
17
25
|
};
|
|
18
26
|
/** Validate coverage and duration while preserving symbolic relative bounds. */
|
|
19
27
|
parse: (value: unknown, now?: Date) => DateTimeRange;
|
|
20
28
|
/** Resolve to UTC-rebased bounds using reporting-zone wall-clock fields, then validate policy. */
|
|
21
|
-
resolve: (value: unknown, now?: Date) =>
|
|
22
|
-
/** Return the
|
|
23
|
-
comparison: (value: unknown, now?: Date) =>
|
|
24
|
-
/**
|
|
25
|
-
|
|
29
|
+
resolve: (value: unknown, now?: Date) => ResolvedDateTimeRange;
|
|
30
|
+
/** Return the comparison window, or null when source coverage excludes it. */
|
|
31
|
+
comparison: (value: unknown, now?: Date) => ResolvedDateTimeRange | null;
|
|
32
|
+
/** End a resolved range at the reference time when it runs past it. */
|
|
33
|
+
endAtNow: (range: ResolvedDateTimeRange, now?: Date) => ResolvedDateTimeRange;
|
|
34
|
+
/** Resolve both periods against one reference instant, ending the range at now. */
|
|
35
|
+
request(value: unknown, compare?: boolean, now?: Date): DateTimeRangeInput;
|
|
26
36
|
};
|
|
27
37
|
//#endregion
|
|
28
|
-
//#region src/core/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type OutputOf<T> = T extends {
|
|
37
|
-
run: (...args: never[]) => Promise<infer Output>;
|
|
38
|
-
} ? Output : unknown;
|
|
39
|
-
/** Lakehouse results contain positional unknown cells; registered queries supply decoded records. */
|
|
40
|
-
type QueryResult<Row = unknown[]> = {
|
|
41
|
-
columns: {
|
|
42
|
-
name: string;
|
|
43
|
-
type?: string;
|
|
44
|
-
}[];
|
|
45
|
-
rows: Row[];
|
|
46
|
-
queryId?: string;
|
|
38
|
+
//#region src/core/date-time-filter.d.ts
|
|
39
|
+
/** A picker suggestion. Text ranges use the same natural-language parser as typed input. */
|
|
40
|
+
type DateTimeRangePreset = {
|
|
41
|
+
/** Menu label, also shown when this preset matches the selected range. */
|
|
42
|
+
label: string;
|
|
43
|
+
range: DateTimeRange | string;
|
|
44
|
+
/** Optional compact badge, for example "15m". */
|
|
45
|
+
shortcut?: string;
|
|
47
46
|
};
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
params?: QueryParameters;
|
|
53
|
-
queryId?: string;
|
|
47
|
+
/** Monitoring offers minute/hour windows; analytics offers longer periods and to-date windows. Spread either menu to add custom presets. */
|
|
48
|
+
declare const dateTimeRangePresets: {
|
|
49
|
+
readonly monitoring: readonly DateTimeRangePreset[];
|
|
50
|
+
readonly analytics: readonly DateTimeRangePreset[];
|
|
54
51
|
};
|
|
55
|
-
/**
|
|
56
|
-
type
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
/** Offer the previous-period comparison, with its toggle starting off or on. */
|
|
53
|
+
type DateTimeRangeComparison = 'off' | 'on';
|
|
54
|
+
type DateTimeRangeFilterOptions<Comparison extends DateTimeRangeComparison | undefined = undefined> = {
|
|
55
|
+
key: string;
|
|
56
|
+
label?: string;
|
|
57
|
+
/** Range text such as "7d" stays relative; `{ from, to }` is absolute. */
|
|
58
|
+
defaultValue: DateTimeRange | string;
|
|
59
|
+
/** Reporting zone for relative ranges, calendar days, and labels. Defaults to UTC. */
|
|
60
|
+
timeZone?: string;
|
|
61
|
+
/** Longest selectable range. */
|
|
62
|
+
maxRangeDays?: number;
|
|
63
|
+
/** First date with data, as YYYY-MM-DD. */
|
|
64
|
+
minDate?: string;
|
|
65
|
+
/** Last date with data, as YYYY-MM-DD. */
|
|
66
|
+
maxDate?: string | (() => string);
|
|
67
|
+
/** End coverage yesterday, for sources that load whole days. */
|
|
68
|
+
completeDays?: boolean;
|
|
69
|
+
/** Offer the previous-period comparison. Omit for none. */
|
|
70
|
+
comparison?: Comparison;
|
|
71
|
+
/** Suggestions in display order. Omit for defaults; [] retains calendar and text entry.
|
|
72
|
+
* Invalid or over-limit suggestions are omitted; typed input is not restricted to the menu.
|
|
73
|
+
*/
|
|
74
|
+
presets?: readonly DateTimeRangePreset[];
|
|
75
|
+
history?: HistoryMode;
|
|
76
|
+
presentation?: FilterPresentation;
|
|
63
77
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
/** The picker's URL state: the selected range, relative or absolute, and the comparison toggle. */
|
|
79
|
+
type DateTimeRangeSelection = {
|
|
80
|
+
range: DateTimeRange;
|
|
81
|
+
comparison?: 'previous';
|
|
68
82
|
};
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
/** Sent from the browser: the resolved input plus the selection and reference time it came from. */
|
|
84
|
+
type DateTimeRangeRequest = DateTimeRangeInput & {
|
|
85
|
+
selection: DateTimeRangeSelection;
|
|
86
|
+
reference: string;
|
|
87
|
+
};
|
|
88
|
+
type DateTimeRangeFilter<Comparable extends boolean = boolean> = AppFilter<DateTimeRangeSelection, 'dateTimeRange'> & {
|
|
89
|
+
/** Whether readers can turn on the previous-period comparison. */
|
|
90
|
+
comparable: Comparable;
|
|
91
|
+
policy: DateTimeRangePolicy;
|
|
92
|
+
maxRangeDays?: number;
|
|
93
|
+
presets?: readonly DateTimeRangePreset[];
|
|
94
|
+
/** Resolve a selection against one reference time. */
|
|
95
|
+
request: (selection: DateTimeRangeSelection, now?: Date) => DateTimeRangeRequest;
|
|
96
|
+
/** Validate untrusted input against coverage and return what the operation receives. */
|
|
97
|
+
parseInput: (value: unknown) => DateTimeRangeInput;
|
|
98
|
+
previous: (selection: DateTimeRangeSelection) => DateTimeRangeInput['comparison'];
|
|
99
|
+
};
|
|
100
|
+
/** One declaration drives the picker, URL state, and the input of operations that list it.
|
|
101
|
+
* Operations receive `{ range, comparison }`: `from` inclusive, `to` exclusive.
|
|
73
102
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
103
|
+
declare function dateTimeRangeFilter<Comparison extends DateTimeRangeComparison | undefined = undefined>(options: DateTimeRangeFilterOptions<Comparison>): DateTimeRangeFilter<undefined extends Comparison ? false : true>;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/core/facets.d.ts
|
|
106
|
+
declare const facetSource: unique symbol;
|
|
107
|
+
/** A dimension whose options come from an operation. The options follow that
|
|
108
|
+
* operation's own filters, so selecting a period narrows the choices. */
|
|
109
|
+
type FacetFilter<Value extends DimensionValue = DimensionValue, Operation extends string = string> = DimensionSelectionFilter<Value> & {
|
|
110
|
+
readonly optionsSource: 'query';
|
|
111
|
+
readonly [facetSource]: {
|
|
112
|
+
readonly operation: Operation;
|
|
83
113
|
};
|
|
84
114
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
type DataQueryBody<Output> = {
|
|
94
|
-
data: Output;
|
|
95
|
-
requestId: string;
|
|
96
|
-
queriedAt: string;
|
|
97
|
-
queryIds: string[];
|
|
98
|
-
queries?: DisclosedQuery[];
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/core/dimension.d.ts
|
|
117
|
+
type DimensionValue = string | number;
|
|
118
|
+
type DimensionMember<T extends DimensionValue = DimensionValue> = {
|
|
119
|
+
kind: 'value';
|
|
120
|
+
value: T;
|
|
121
|
+
} | {
|
|
122
|
+
kind: 'missing';
|
|
99
123
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
type DimensionSelection<T extends DimensionValue = DimensionValue> = {
|
|
125
|
+
kind: 'all';
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'include' | 'exclude';
|
|
128
|
+
members: readonly DimensionMember<T>[];
|
|
104
129
|
};
|
|
130
|
+
type DimensionOption<T extends DimensionValue = DimensionValue> = {
|
|
131
|
+
value: T;
|
|
132
|
+
label: string;
|
|
133
|
+
count?: number;
|
|
134
|
+
};
|
|
135
|
+
type DimensionSelectionFilter<T extends DimensionValue = DimensionValue> = AppFilter<DimensionSelection<T>, 'dimension'> & {
|
|
136
|
+
readonly optionsSource: 'fixed' | 'query';
|
|
137
|
+
label: string;
|
|
138
|
+
selectionMode: 'single' | 'multiple';
|
|
139
|
+
readonly valueType: T extends number ? 'number' : 'string';
|
|
140
|
+
allowMissing: boolean;
|
|
141
|
+
allowExclusion: boolean;
|
|
142
|
+
maxSelected: number;
|
|
143
|
+
options: readonly DimensionOption<T>[];
|
|
144
|
+
describe: (selection: DimensionSelection<T>, options?: readonly DimensionOption<T>[]) => string;
|
|
145
|
+
};
|
|
146
|
+
/** A fixed-option dimension retains its distinction from query-backed facets. */
|
|
147
|
+
type DimensionFilter<T extends DimensionValue = DimensionValue> = DimensionSelectionFilter<T> & {
|
|
148
|
+
readonly optionsSource: 'fixed';
|
|
149
|
+
readonly [facetSource]?: never;
|
|
150
|
+
};
|
|
151
|
+
declare function dimensionMemberKey(member: DimensionMember): string;
|
|
152
|
+
type DimensionSettings = {
|
|
153
|
+
key: string;
|
|
154
|
+
label: string;
|
|
155
|
+
allowMissing?: boolean;
|
|
156
|
+
allowExclusion?: boolean;
|
|
157
|
+
history?: HistoryMode;
|
|
158
|
+
presentation?: FilterPresentation;
|
|
159
|
+
} & ({
|
|
160
|
+
selectionMode: 'single';
|
|
161
|
+
maxSelected?: 1;
|
|
162
|
+
} | {
|
|
163
|
+
selectionMode: 'multiple';
|
|
164
|
+
maxSelected?: number;
|
|
165
|
+
});
|
|
166
|
+
type DimensionFilterSettings<T extends DimensionValue> = DimensionSettings & {
|
|
167
|
+
valueType: T extends number ? 'number' : 'string';
|
|
168
|
+
/** The selection before readers change it, such as paid orders only. Clearing
|
|
169
|
+
* filters still returns to every member. Defaults to `{ kind: 'all' }`. */
|
|
170
|
+
defaultValue?: DimensionSelection<NoInfer<T>>;
|
|
171
|
+
};
|
|
172
|
+
type DimensionFilterOptions<T extends DimensionValue> = DimensionFilterSettings<T> & {
|
|
173
|
+
options: readonly DimensionOption<T>[];
|
|
174
|
+
facet?: never;
|
|
175
|
+
};
|
|
176
|
+
/** A bounded categorical filter with app-owned fixed options. */
|
|
177
|
+
declare function dimensionFilter<const T extends string>(config: DimensionFilterOptions<T>): DimensionFilter<T>;
|
|
178
|
+
declare function dimensionFilter<const T extends number>(config: DimensionFilterOptions<T>): DimensionFilter<T>;
|
|
179
|
+
/** Shared fixed-option and query-backed selection behavior. */
|
|
180
|
+
declare function createDimensionFilter<const T extends DimensionValue>(config: DimensionFilterSettings<T> & {
|
|
181
|
+
options: readonly DimensionOption<T>[];
|
|
182
|
+
}, dynamic?: boolean): DimensionSelectionFilter<T>;
|
|
183
|
+
/** Server-side parser; call from the operation input parser before building SQL. */
|
|
184
|
+
declare function parseDimensionSelection<T extends DimensionValue>(value: unknown, filter: DimensionSelectionFilter<T>): DimensionSelection<T>;
|
|
185
|
+
/** Validate bounded facet results before showing them in a picker. */
|
|
186
|
+
declare function parseFacetOptions<T extends DimensionValue>(value: unknown, filter: DimensionSelectionFilter<T>): DimensionOption<T>[];
|
|
187
|
+
/** Central SQL literal encoding for transports without bound parameters. Column is an allowlisted identifier. */
|
|
188
|
+
declare function dimensionPredicate<T extends DimensionValue, const Columns extends readonly string[]>(column: Columns[number], selection: DimensionSelection<T>, allowedColumns: Columns): string;
|
|
105
189
|
//#endregion
|
|
106
190
|
//#region src/core/queries.d.ts
|
|
107
191
|
declare const MAX_QUERY_ROWS = 10000;
|
|
@@ -123,8 +207,17 @@ type QueryValue<Field extends QueryField> = QueryValues[Field['type']] | (Field
|
|
|
123
207
|
} ? null : never);
|
|
124
208
|
type QueryRow<Projections extends QueryProjections> = { -readonly [Name in keyof Projections]: QueryValue<Projections[Name]>; };
|
|
125
209
|
type QueryParameterValue = string | number | boolean | null;
|
|
126
|
-
/** Typed scalar
|
|
210
|
+
/** Typed scalar, datetime-range, or dimension parameters with optional fallback values.
|
|
211
|
+
* Reference a range's bounds as `$name.from` (inclusive) and `$name.to` (exclusive),
|
|
212
|
+
* and a dimension selection as `$name.matches(column)`. */
|
|
127
213
|
type QueryParameter = {
|
|
214
|
+
/** A dimension filter's `DimensionSelection`; `$name.matches(column)` is true
|
|
215
|
+
* for the rows it keeps, including missing-value and exclusion semantics. */
|
|
216
|
+
type: 'dimension';
|
|
217
|
+
valueType: 'string' | 'number';
|
|
218
|
+
nullable?: false;
|
|
219
|
+
defaultValue?: never;
|
|
220
|
+
} | {
|
|
128
221
|
type: 'dateTimeRange';
|
|
129
222
|
nullable?: false;
|
|
130
223
|
/** Absolute defaults may use canonical UTC ISO strings (including milliseconds) for static manifests. Snapshots hydrate them into Dates. */
|
|
@@ -141,7 +234,12 @@ type QueryParameter = {
|
|
|
141
234
|
/** Callers may omit values supplied by host context or declaration defaults. */
|
|
142
235
|
type QueryInputParameters<Params extends Readonly<Record<string, QueryParameter>>> = { [Name in keyof Params]?: Params[Name] extends {
|
|
143
236
|
type: 'dateTimeRange';
|
|
144
|
-
} ? DateTimeRange : Params[Name] extends
|
|
237
|
+
} ? DateTimeRange : Params[Name] extends {
|
|
238
|
+
type: 'dimension';
|
|
239
|
+
valueType: 'number';
|
|
240
|
+
} ? DimensionSelection<number> : Params[Name] extends {
|
|
241
|
+
type: 'dimension';
|
|
242
|
+
} ? DimensionSelection<string> : Params[Name] extends QueryField ? QueryValue<Params[Name]> : never; };
|
|
145
243
|
type QueryDefinition = {
|
|
146
244
|
statement: string;
|
|
147
245
|
params: Readonly<Record<string, QueryParameter>>;
|
|
@@ -168,6 +266,8 @@ type FrozenField<Field extends {
|
|
|
168
266
|
type: string;
|
|
169
267
|
nullable?: boolean;
|
|
170
268
|
}> = Field extends {
|
|
269
|
+
type: 'dimension';
|
|
270
|
+
} ? Readonly<Field> : Field extends {
|
|
171
271
|
type: 'dateTimeRange';
|
|
172
272
|
} ? Readonly<{ [Key in keyof Field]: Key extends 'defaultValue' ? DateTimeRange : Field[Key]; }> : Field extends unknown ? Readonly<Field> : never;
|
|
173
273
|
type QuerySnapshot<Queries extends QueryDefinitions> = { readonly [Name in keyof Queries]: {
|
|
@@ -178,84 +278,94 @@ type QuerySnapshot<Queries extends QueryDefinitions> = { readonly [Name in keyof
|
|
|
178
278
|
/** Parameters are scalar SQL values, never identifiers or SQL fragments. */
|
|
179
279
|
type QueryParameters = Readonly<Record<string, QueryParameterValue>>;
|
|
180
280
|
//#endregion
|
|
181
|
-
//#region src/core/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
281
|
+
//#region src/core/operation-types.d.ts
|
|
282
|
+
type OperationContracts = Record<string, {
|
|
283
|
+
input: (value: unknown) => unknown;
|
|
284
|
+
}>;
|
|
285
|
+
type InputOf<T> = T extends {
|
|
286
|
+
input: (value: unknown) => infer Input;
|
|
287
|
+
} ? Input : never;
|
|
288
|
+
/** An operation's data is what its `run` resolves to. */
|
|
289
|
+
type OutputOf<T> = T extends {
|
|
290
|
+
run: (...args: never[]) => Promise<infer Output>;
|
|
291
|
+
} ? Output : unknown;
|
|
292
|
+
/** Lakehouse results contain positional unknown cells; registered queries supply decoded records. */
|
|
293
|
+
type QueryResult<Row = unknown[]> = {
|
|
294
|
+
columns: {
|
|
295
|
+
name: string;
|
|
296
|
+
type?: string;
|
|
297
|
+
}[];
|
|
298
|
+
rows: Row[];
|
|
299
|
+
queryId?: string;
|
|
194
300
|
};
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
defaultValue: DateTimeRange | string;
|
|
202
|
-
/** Client limit for determinate durations; the backend must validate timezone-dependent ranges. */
|
|
203
|
-
maxRangeDays?: number;
|
|
204
|
-
/** Shared reporting coverage, timezone, duration limits, and comparison policy. */
|
|
205
|
-
contract?: DateRangeContract;
|
|
206
|
-
/** Suggestions in display order. Omit for defaults; [] retains calendar and text entry.
|
|
207
|
-
* Invalid or over-limit suggestions are omitted; typed input is not restricted to the menu.
|
|
208
|
-
*/
|
|
209
|
-
presets?: readonly DateTimeRangePreset[];
|
|
210
|
-
history?: HistoryMode;
|
|
211
|
-
presentation?: VariablePresentation;
|
|
301
|
+
/** One registered statement an operation ran, with its parameter values. */
|
|
302
|
+
type DisclosedQuery = {
|
|
303
|
+
name: string;
|
|
304
|
+
statement: string;
|
|
305
|
+
params?: QueryParameters;
|
|
306
|
+
queryId?: string;
|
|
212
307
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
308
|
+
/** Query interface supplied by a server adapter or an authorized iframe bridge. */
|
|
309
|
+
type Lakehouse = {
|
|
310
|
+
queryAll(statement: string, options: {
|
|
311
|
+
limit: number;
|
|
312
|
+
signal: AbortSignal;
|
|
313
|
+
name?: string;
|
|
314
|
+
params?: QueryParameters;
|
|
315
|
+
}): Promise<QueryResult>;
|
|
219
316
|
};
|
|
220
|
-
type
|
|
221
|
-
|
|
222
|
-
|
|
317
|
+
type OperationContext = {
|
|
318
|
+
lakehouse: Lakehouse;
|
|
319
|
+
signal: AbortSignal;
|
|
320
|
+
queryParams?: QueryParameters;
|
|
223
321
|
};
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
322
|
+
/**
|
|
323
|
+
* The input parser runs in the operation executor's runtime: server for HTTP apps, browser for
|
|
324
|
+
* bundle apps. Browser validation does not replace backend authorization or query limits.
|
|
325
|
+
* Registered queries decode rows from their declared projections; `run` derives the operation's data.
|
|
326
|
+
*/
|
|
327
|
+
type DataOperation<Input, Output> = {
|
|
328
|
+
/** The app filters the operation reads; its input has one field per filter. */
|
|
329
|
+
filters?: Readonly<FilterCollection>;
|
|
330
|
+
input: (value: unknown) => Input;
|
|
331
|
+
run: (context: OperationContext, input: Input) => Promise<Output>;
|
|
332
|
+
checks: readonly [Input, ...Input[]];
|
|
333
|
+
queryNames?: Readonly<Record<string, string>>;
|
|
334
|
+
policy: {
|
|
335
|
+
maxQueryRows: number;
|
|
336
|
+
maxDurationMs: number;
|
|
337
|
+
maxResponseBytes?: number;
|
|
338
|
+
};
|
|
228
339
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
340
|
+
/** Heterogeneous registry: inputs vary per operation, so checks retain unknown values. */
|
|
341
|
+
type DataOperations = Record<string, OperationContracts[string] & Omit<DataOperation<never, unknown>, 'input' | 'checks'> & {
|
|
342
|
+
checks: readonly [unknown, ...unknown[]];
|
|
343
|
+
}>;
|
|
344
|
+
type DataQueryInput<Operations extends OperationContracts> = { [Name in keyof Operations & string]: {
|
|
345
|
+
operation: Name;
|
|
346
|
+
input: InputOf<Operations[Name]>;
|
|
347
|
+
}; }[keyof Operations & string];
|
|
348
|
+
type DataQueryBody<Output> = {
|
|
349
|
+
data: Output;
|
|
350
|
+
requestId: string;
|
|
351
|
+
queriedAt: string;
|
|
352
|
+
queryIds: string[];
|
|
353
|
+
queries?: DisclosedQuery[];
|
|
232
354
|
};
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
input: (selection: DateTimeRangeComparisonSelection, now?: Date) => DateTimeRangeComparisonRequest;
|
|
238
|
-
parseInput: (value: unknown) => DateTimeRangeComparisonRequest;
|
|
239
|
-
previous: (selection: DateTimeRangeComparisonSelection) => DateTimeRangeRequest['comparison'];
|
|
355
|
+
/** Delivery envelope shared by HTTP and iframe transports. */
|
|
356
|
+
type TransportResponse<Body = unknown> = {
|
|
357
|
+
status: number;
|
|
358
|
+
body: Body;
|
|
240
359
|
};
|
|
241
|
-
/** One declaration drives the picker, URL state, and operation input.
|
|
242
|
-
* With comparison enabled, use input(defaultValue) for operation checks and variableInput()
|
|
243
|
-
* to validate request snapshots. Query the resulting range and optional comparison bounds.
|
|
244
|
-
*/
|
|
245
|
-
declare function dateTimeRangeVariable(options: DateTimeRangeComparisonVariableOptions): DateTimeRangeComparisonVariable;
|
|
246
|
-
declare function dateTimeRangeVariable(options: DateTimeRangeVariableOptions): DateTimeRangeVariable;
|
|
247
360
|
//#endregion
|
|
248
361
|
//#region src/core/dimension-source.d.ts
|
|
249
362
|
declare const dimensionSource: unique symbol;
|
|
250
|
-
type
|
|
363
|
+
type SourceDimensionFilter<Value extends DimensionValue> = DimensionSelectionFilter<Value> & {
|
|
251
364
|
readonly optionsSource: 'query';
|
|
252
365
|
readonly [dimensionSource]: {
|
|
253
366
|
readonly operation: string;
|
|
254
367
|
};
|
|
255
368
|
};
|
|
256
|
-
type ParsedVariableValues<Variables extends VariableCollection> = { [Key in keyof Variables]: Variables[Key] extends DateTimeRangeComparisonVariable ? DateTimeRangeComparisonRequest : AppVariableValues<Variables>[Key]; };
|
|
257
|
-
/** Validate named variable values at the operation boundary. */
|
|
258
|
-
declare function variableInput<Input extends object, const Variables extends VariableCollection>(parse: (value: unknown) => Input, variables: Variables): (value: unknown) => Input & ParsedVariableValues<Variables>;
|
|
259
369
|
type DimensionSourceConfig<Type extends 'string' | 'number'> = DimensionSettings & {
|
|
260
370
|
allowMissing?: false;
|
|
261
371
|
valueType: Type;
|
|
@@ -304,12 +414,12 @@ type BooleanSelection = {
|
|
|
304
414
|
kind: 'is';
|
|
305
415
|
value: boolean;
|
|
306
416
|
};
|
|
307
|
-
type NumberFilter =
|
|
417
|
+
type NumberFilter = AppFilter<NumberSelection, 'numberFilter'> & {
|
|
308
418
|
label: string;
|
|
309
419
|
min?: number;
|
|
310
420
|
max?: number;
|
|
311
421
|
};
|
|
312
|
-
type BooleanFilter =
|
|
422
|
+
type BooleanFilter = AppFilter<BooleanSelection, 'booleanFilter'> & {
|
|
313
423
|
label: string;
|
|
314
424
|
};
|
|
315
425
|
type FilterOptions<Value> = {
|
|
@@ -317,7 +427,7 @@ type FilterOptions<Value> = {
|
|
|
317
427
|
label: string;
|
|
318
428
|
defaultValue?: Value;
|
|
319
429
|
history?: HistoryMode;
|
|
320
|
-
presentation?:
|
|
430
|
+
presentation?: FilterPresentation;
|
|
321
431
|
};
|
|
322
432
|
declare const numberOperatorLabels: Record<NumberOperator, string>;
|
|
323
433
|
/** Exact numeric predicates; range bounds are inclusive and may be open-ended. */
|
|
@@ -342,10 +452,9 @@ type NavigationUpdate = AppLocation & {
|
|
|
342
452
|
title?: string;
|
|
343
453
|
};
|
|
344
454
|
//#endregion
|
|
345
|
-
//#region src/core/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
group?: 'scope' | 'display';
|
|
455
|
+
//#region src/core/app-filters.d.ts
|
|
456
|
+
/** Where a filter's or display option's control renders. */
|
|
457
|
+
type FilterPresentation = {
|
|
349
458
|
/** Widget controls render beside their visualization instead of in the toolbar.
|
|
350
459
|
* Scope filters remain available in the Filters sheet and active summaries. */
|
|
351
460
|
control?: 'toolbar' | 'widget';
|
|
@@ -353,13 +462,16 @@ type VariablePresentation = {
|
|
|
353
462
|
prominence?: 'primary' | 'secondary';
|
|
354
463
|
};
|
|
355
464
|
/** An app-owned value with one URL representation. Controls never parse or write routes. */
|
|
356
|
-
type
|
|
465
|
+
type AppFilter<Value, Kind extends string = string> = {
|
|
357
466
|
kind: Kind;
|
|
358
467
|
label?: string;
|
|
359
|
-
|
|
468
|
+
/** Display options (`displayChoice()`) change how results are shown, not which data is included. */
|
|
469
|
+
presentation?: FilterPresentation & {
|
|
470
|
+
group?: 'scope' | 'display';
|
|
471
|
+
};
|
|
360
472
|
urlKeys: readonly string[];
|
|
361
473
|
defaultValue: Value;
|
|
362
|
-
/** Unrestricted value, when this
|
|
474
|
+
/** Unrestricted value, when this filter can be cleared. */
|
|
363
475
|
clearValue?: Value;
|
|
364
476
|
describe?: (value: Value) => string;
|
|
365
477
|
history: HistoryMode;
|
|
@@ -368,146 +480,83 @@ type AppVariable<Value, Kind extends string = string> = {
|
|
|
368
480
|
valid: (value: Value) => boolean;
|
|
369
481
|
same: (left: Value, right: Value) => boolean;
|
|
370
482
|
};
|
|
371
|
-
type
|
|
372
|
-
type
|
|
483
|
+
type FilterCollection = Record<string, SearchFilter | ChoiceFilter<any> | MultiChoiceFilter | DateTimeRangeFilter | DimensionFilter<any> | FacetFilter<any, string> | SourceDimensionFilter<any> | NumberFilter | BooleanFilter>;
|
|
484
|
+
type FilterValues<Collection> = { [Key in keyof Collection]: Collection[Key] extends DimensionSelectionFilter<infer Value> ? DimensionSelection<Value> : Collection[Key] extends AppFilter<infer Value, string> ? Value : never; };
|
|
373
485
|
/** Keep conditional declarations narrowed so every dependency has one contract. */
|
|
374
|
-
type
|
|
375
|
-
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}> extends never ? Variables : never : { [Name in keyof Variables]: Variables[Name] extends {
|
|
379
|
-
[facetSource]: {
|
|
380
|
-
context: infer Context;
|
|
381
|
-
};
|
|
382
|
-
} ? string extends keyof Context ? never : Variables extends Context ? Variables[Name] : never : Variables[Name]; });
|
|
383
|
-
/** Name variables once in the app. URL keys must be unique across its controls. */
|
|
384
|
-
declare function defineAppVariables<const Variables extends VariableCollection>(variables: Variables): Variables;
|
|
385
|
-
type ScalarVariableOptions = {
|
|
486
|
+
type CheckedFilterDeclarations<Collection extends FilterCollection> = true extends IsUnion<Collection> ? never : string extends keyof Collection ? Collection : '__proto__' extends keyof Collection ? never : { [Name in keyof Collection]: true extends IsUnion<Collection[Name]> ? never : Collection[Name]; };
|
|
487
|
+
/** Name filters once in the app. URL keys must be unique across its controls. */
|
|
488
|
+
declare function defineAppFilters<const Collection extends FilterCollection>(filters: Collection): Collection;
|
|
489
|
+
type ScalarFilterOptions = {
|
|
386
490
|
label?: string;
|
|
387
491
|
key: string;
|
|
388
492
|
defaultValue?: string;
|
|
389
493
|
history?: HistoryMode;
|
|
390
|
-
presentation?:
|
|
494
|
+
presentation?: FilterPresentation;
|
|
391
495
|
};
|
|
392
|
-
type
|
|
496
|
+
type SearchFilter = AppFilter<string, 'search'>;
|
|
393
497
|
type ChoiceOption = {
|
|
394
498
|
id: string;
|
|
395
499
|
label: string;
|
|
396
500
|
description?: string;
|
|
397
501
|
};
|
|
398
|
-
type
|
|
502
|
+
type ChoiceFilter<Value extends string = string> = AppFilter<Value, 'choice'> & {
|
|
399
503
|
options: readonly ChoiceOption[];
|
|
400
504
|
};
|
|
401
|
-
type
|
|
505
|
+
type MultiChoiceFilter = AppFilter<readonly string[], 'multiChoice'> & {
|
|
402
506
|
options: readonly ChoiceOption[];
|
|
403
507
|
maxSelected: number;
|
|
404
508
|
};
|
|
405
|
-
/** Search query state; typing replaces history by default.
|
|
406
|
-
|
|
509
|
+
/** Search query state; typing replaces history by default. Operations reject text
|
|
510
|
+
* longer than `maxLength` (200 by default). */
|
|
511
|
+
declare function searchFilter({ key, label, defaultValue, history, maxLength }: Omit<ScalarFilterOptions, 'presentation'> & {
|
|
512
|
+
maxLength?: number;
|
|
513
|
+
}): SearchFilter;
|
|
407
514
|
/** Validate labeled choices before controls or URL state consume them. */
|
|
408
515
|
declare function validateChoiceOptions(options: readonly ChoiceOption[]): void;
|
|
409
|
-
|
|
410
|
-
presentation?: Presentation;
|
|
516
|
+
type ChoiceOptions<Options extends readonly ChoiceOption[]> = Omit<ScalarFilterOptions, 'defaultValue'> & {
|
|
411
517
|
defaultValue: NoInfer<Options[number]['id']>;
|
|
412
518
|
options: Options & (Options extends readonly [] ? never : unknown);
|
|
413
|
-
}): ChoiceVariable<Options[number]['id']> & {
|
|
414
|
-
presentation?: Presentation;
|
|
415
519
|
};
|
|
416
|
-
|
|
417
|
-
|
|
520
|
+
/** One choice that narrows the included data. */
|
|
521
|
+
declare function choiceFilter<const Options extends readonly ChoiceOption[]>(options: ChoiceOptions<Options>): ChoiceFilter<Options[number]['id']>;
|
|
522
|
+
/** One choice that changes how results are shown, such as a chart breakdown or sort order.
|
|
523
|
+
* Clearing filters keeps it; pass `view.breakdown(name)` to render it beside its chart. */
|
|
524
|
+
declare function displayChoice<const Options extends readonly ChoiceOption[]>(options: ChoiceOptions<Options>): ChoiceFilter<Options[number]['id']> & {
|
|
525
|
+
presentation: {
|
|
526
|
+
group: 'display';
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
declare function multiChoiceFilter<const Options extends readonly ChoiceOption[]>({ key, label, defaultValue, options, maxSelected, history, presentation }: Omit<ScalarFilterOptions, 'defaultValue'> & {
|
|
418
530
|
defaultValue?: readonly NoInfer<Options[number]['id']>[];
|
|
419
531
|
options: Options & (Options extends readonly [] ? never : unknown);
|
|
420
532
|
maxSelected?: number;
|
|
421
|
-
}):
|
|
422
|
-
presentation?: Presentation;
|
|
423
|
-
};
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/core/facets.d.ts
|
|
426
|
-
/** Executable facet sources are attached only by the typed hooks factory. */
|
|
427
|
-
declare const facetSource: unique symbol;
|
|
428
|
-
type FacetSourceDefinition<Context extends VariableCollection = VariableCollection, Name extends string = string, Input = unknown> = {
|
|
429
|
-
readonly context: Context;
|
|
430
|
-
readonly operation: Name;
|
|
431
|
-
readonly input: (values: Record<string, unknown>) => Input;
|
|
432
|
-
};
|
|
433
|
-
type FacetVariable<Value extends DimensionValue, Context extends VariableCollection, Name extends string, Input> = DimensionSelectionVariable<Value> & {
|
|
434
|
-
readonly optionsSource: 'query';
|
|
435
|
-
readonly [facetSource]: FacetSourceDefinition<Context, Name, Input>;
|
|
436
|
-
};
|
|
533
|
+
}): MultiChoiceFilter;
|
|
437
534
|
//#endregion
|
|
438
|
-
//#region src/core/
|
|
439
|
-
|
|
440
|
-
type
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
type
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
readonly valueType: T extends number ? 'number' : 'string';
|
|
462
|
-
allowMissing: boolean;
|
|
463
|
-
allowExclusion: boolean;
|
|
464
|
-
maxSelected: number;
|
|
465
|
-
options: readonly DimensionOption<T>[];
|
|
466
|
-
describe: (selection: DimensionSelection<T>, options?: readonly DimensionOption<T>[]) => string;
|
|
467
|
-
};
|
|
468
|
-
/** A fixed-option dimension retains its distinction from query-backed facets. */
|
|
469
|
-
type DimensionVariable<T extends DimensionValue = DimensionValue> = DimensionSelectionVariable<T> & {
|
|
470
|
-
readonly optionsSource: 'fixed';
|
|
471
|
-
readonly [facetSource]?: never;
|
|
472
|
-
};
|
|
473
|
-
declare function dimensionMemberKey(member: DimensionMember): string;
|
|
474
|
-
type DimensionSettings = {
|
|
475
|
-
key: string;
|
|
476
|
-
label: string;
|
|
477
|
-
allowMissing?: boolean;
|
|
478
|
-
allowExclusion?: boolean;
|
|
479
|
-
history?: HistoryMode;
|
|
480
|
-
presentation?: VariablePresentation;
|
|
481
|
-
} & ({
|
|
482
|
-
selectionMode: 'single';
|
|
483
|
-
maxSelected?: 1;
|
|
484
|
-
} | {
|
|
485
|
-
selectionMode: 'multiple';
|
|
486
|
-
maxSelected?: number;
|
|
487
|
-
});
|
|
488
|
-
type DimensionFilterSettings<T extends DimensionValue> = DimensionSettings & {
|
|
489
|
-
valueType: T extends number ? 'number' : 'string';
|
|
490
|
-
};
|
|
491
|
-
type DimensionFilterOptions<T extends DimensionValue> = DimensionFilterSettings<T> & {
|
|
492
|
-
options: readonly DimensionOption<T>[];
|
|
493
|
-
facet?: never;
|
|
494
|
-
};
|
|
495
|
-
/** A bounded categorical filter with app-owned fixed options. */
|
|
496
|
-
declare function dimensionFilter<const T extends string>(config: DimensionFilterOptions<T>): DimensionVariable<T>;
|
|
497
|
-
declare function dimensionFilter<const T extends number>(config: DimensionFilterOptions<T>): DimensionVariable<T>;
|
|
498
|
-
/** Shared fixed-option and query-backed selection behavior. */
|
|
499
|
-
declare function createDimensionFilter<const T extends DimensionValue>(config: DimensionFilterSettings<T> & {
|
|
500
|
-
options: readonly DimensionOption<T>[];
|
|
501
|
-
}, dynamic?: boolean): DimensionSelectionVariable<T>;
|
|
502
|
-
/** Server-side parser; call from the operation input parser before building SQL. */
|
|
503
|
-
declare function parseDimensionSelection<T extends DimensionValue>(value: unknown, filter: DimensionSelectionVariable<T>): DimensionSelection<T>;
|
|
504
|
-
/** Validate bounded facet results before showing them in a picker. */
|
|
505
|
-
declare function parseFacetOptions<T extends DimensionValue>(value: unknown, filter: DimensionSelectionVariable<T>): DimensionOption<T>[];
|
|
506
|
-
/** Central SQL literal encoding for transports without bound parameters. Column is an allowlisted identifier. */
|
|
507
|
-
declare function dimensionPredicate<T extends DimensionValue, const Columns extends readonly string[]>(column: Columns[number], selection: DimensionSelection<T>, allowedColumns: Columns): string;
|
|
535
|
+
//#region src/core/operation-filters.d.ts
|
|
536
|
+
/** The value an operation receives for one filter: date filters arrive resolved. */
|
|
537
|
+
type FilterInputValue<Filter> = Filter extends DateTimeRangeFilter ? DateTimeRangeInput : FilterValues<{
|
|
538
|
+
value: Filter;
|
|
539
|
+
}>['value'];
|
|
540
|
+
/** An operation's input: one flat field per declared filter. */
|
|
541
|
+
type FilterInput<Filters extends FilterCollection> = keyof Filters extends never ? Record<string, never> : { [Name in keyof Filters]: FilterInputValue<Filters[Name]>; };
|
|
542
|
+
/** Exactly the date filters, so a view knows which one sets its reporting period. */
|
|
543
|
+
type DateFilterNames<Filters extends FilterCollection> = { [Name in keyof Filters]: Filters[Name] extends DateTimeRangeFilter ? Name : never; }[keyof Filters];
|
|
544
|
+
/** Filters are a literal record of known names, and at most one is a date filter:
|
|
545
|
+
* it sets the view's reporting period. */
|
|
546
|
+
type CheckedOperationFilters<Filters extends FilterCollection> = Filters & (string extends keyof Filters ? {
|
|
547
|
+
'Declare the filters an operation reads as an object literal': never;
|
|
548
|
+
} : unknown) & ([DateFilterNames<Filters>] extends [never] ? unknown : true extends IsUnion<DateFilterNames<Filters>> ? {
|
|
549
|
+
'An operation reads at most one date filter': never;
|
|
550
|
+
} : unknown);
|
|
551
|
+
/** The name of the operation's date filter, which sets its reporting period. */
|
|
552
|
+
declare function dateFilterName(filters: FilterCollection): string | undefined;
|
|
553
|
+
/** Resolve URL selections to the request the browser sends. Relative date ranges
|
|
554
|
+
* resolve against one reference time so the range and its comparison agree. */
|
|
555
|
+
declare function resolveFilterInput<Filters extends FilterCollection>(filters: Filters, values: FilterValues<Filters>, reference?: Date): FilterInput<Filters>;
|
|
556
|
+
/** Every operation in an app shares one filter per name and one owner per URL key. */
|
|
557
|
+
declare function combineOperationFilters(operations: Readonly<Record<string, FilterCollection>>): FilterCollection;
|
|
508
558
|
//#endregion
|
|
509
559
|
//#region src/authoring/contract.d.ts
|
|
510
|
-
declare function parseEmptyInput(value: unknown): Record<string, never>;
|
|
511
560
|
declare function parseTrue(value: unknown): true;
|
|
512
561
|
type ReportingPeriod = {
|
|
513
562
|
kind: 'rolling';
|
|
@@ -520,37 +569,6 @@ type ReportingPeriod = {
|
|
|
520
569
|
end: string;
|
|
521
570
|
timeZone: string;
|
|
522
571
|
};
|
|
523
|
-
type DateRangeContractOptions = {
|
|
524
|
-
minDate?: string;
|
|
525
|
-
maxDate?: string | (() => string);
|
|
526
|
-
maxRangeDays: number;
|
|
527
|
-
timeZone: string;
|
|
528
|
-
/** Defaults to complete days through yesterday in the reporting timezone. Set false to include today. */
|
|
529
|
-
completeDays?: boolean;
|
|
530
|
-
};
|
|
531
|
-
/** One source policy for datetime picker validation and operation requests. */
|
|
532
|
-
declare function defineDateRangeContract({ minDate, maxDate, maxRangeDays, timeZone, completeDays }: DateRangeContractOptions): {
|
|
533
|
-
datetime: {
|
|
534
|
-
timeZone: string;
|
|
535
|
-
bounds: (now?: Date) => {
|
|
536
|
-
minDate: string | undefined;
|
|
537
|
-
maxDate: string;
|
|
538
|
-
maxRangeDays: number;
|
|
539
|
-
timeZone: string;
|
|
540
|
-
};
|
|
541
|
-
parse: (value: unknown, now?: Date) => DateTimeRange;
|
|
542
|
-
resolve: (value: unknown, now?: Date) => DateTimeRangeRequest['range'];
|
|
543
|
-
comparison: (value: unknown, now?: Date) => DateTimeRangeRequest['comparison'];
|
|
544
|
-
request(value: unknown, compare?: boolean, now?: Date): DateTimeRangeRequest;
|
|
545
|
-
};
|
|
546
|
-
bounds: (now?: Date) => {
|
|
547
|
-
minDate: string | undefined;
|
|
548
|
-
maxDate: string;
|
|
549
|
-
maxRangeDays: number;
|
|
550
|
-
timeZone: string;
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
type DateRangeContract = ReturnType<typeof defineDateRangeContract>;
|
|
554
572
|
/** Accepts numeric strings from DuckDB; rejects negative, fractional, and unsafe integers. */
|
|
555
573
|
declare function parseCount(value: unknown): number;
|
|
556
574
|
declare function parseLabel(value: unknown, maxLength?: number): string;
|
|
@@ -563,19 +581,50 @@ type QueryLimit<Limit extends number> = number extends Limit ? number : `${Limit
|
|
|
563
581
|
type RegisteredQuery<Queries extends QueryDefinitions> = <Name extends keyof Queries & string, const Params extends object = {}, const Limit extends number = number>(name: Name & (true extends IsUnion<NoInfer<Name>> ? [ParameterNames<Queries, Name>] extends [never] ? unknown : never : unknown), params?: ExactQueryParameters<RegisteredQueryParameters<Queries, NoInfer<Name>>, Params>, options?: {
|
|
564
582
|
limit?: Limit & QueryLimit<NoInfer<Limit>>;
|
|
565
583
|
}) => Promise<QueryResult<QueryRow<Queries[Name]['projections']>>>;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
584
|
+
type OperationRun<Input, Output, Queries extends QueryDefinitions> = (context: Pick<OperationContext, 'signal'> & {
|
|
585
|
+
query: RegisteredQuery<NoInfer<Queries>>;
|
|
586
|
+
}, input: Input) => Promise<Output>;
|
|
587
|
+
type OperationPolicy = DataOperation<unknown, unknown>['policy'];
|
|
588
|
+
/** An operation that reads app filters. Its input has one field per filter, validated by
|
|
589
|
+
* the filters themselves; views derive their filters, scope, and period from it. */
|
|
590
|
+
type FilterOperationDefinition<Filters extends FilterCollection, Output, Queries extends QueryDefinitions> = {
|
|
591
|
+
/** The filters `run` reads. Omit for an operation without inputs. */
|
|
592
|
+
filters?: CheckedOperationFilters<Filters>;
|
|
593
|
+
input?: never;
|
|
594
|
+
checks?: never;
|
|
595
|
+
policy: OperationPolicy;
|
|
596
|
+
run: OperationRun<FilterInput<Filters>, Output, Queries>;
|
|
597
|
+
};
|
|
598
|
+
/** An operation with its own input, such as a detail destination's record id. It may
|
|
599
|
+
* also read filters, such as the displayed scope it lists records for. */
|
|
600
|
+
type InputOperationDefinition<Input, Output, Queries extends QueryDefinitions, Filters extends FilterCollection = {}> = {
|
|
601
|
+
/** Filters the operation reads beside its own input; they are parsed for it. */
|
|
602
|
+
filters?: CheckedOperationFilters<Filters>;
|
|
603
|
+
/** Parses the operation's own fields, without the filters. */
|
|
604
|
+
input: (value: unknown) => Input;
|
|
605
|
+
/** Representative valid own inputs; each must pass `input`. */
|
|
606
|
+
checks: readonly [Input, ...Input[]];
|
|
607
|
+
policy: OperationPolicy;
|
|
608
|
+
run: OperationRun<WithFilterInput<Filters, Input>, Output, Queries>;
|
|
571
609
|
};
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
610
|
+
/** The full input of an operation with its own fields and optional filters. */
|
|
611
|
+
type WithFilterInput<Filters extends FilterCollection, Input> = keyof Filters extends never ? Input : FilterInput<Filters> & Input;
|
|
612
|
+
type DefinedOperation<Input, Output, Queries extends QueryDefinitions, Filters extends FilterCollection | undefined = undefined> = Omit<DataOperation<Input, Output>, 'queryNames' | 'filters'> & {
|
|
575
613
|
queryNames: { readonly [Name in keyof Queries & string]: Name; };
|
|
576
|
-
}
|
|
614
|
+
} & (Filters extends FilterCollection ? {
|
|
615
|
+
readonly filters: Filters;
|
|
616
|
+
} : {
|
|
617
|
+
readonly filters?: never;
|
|
618
|
+
});
|
|
619
|
+
declare function defineOperation<Input, Output, const Queries extends QueryDefinitions, const Filters extends FilterCollection = {}>(operation: InputOperationDefinition<Input, Output, Queries, Filters> & {
|
|
620
|
+
queries: CheckedQueries<Queries>;
|
|
621
|
+
}): DefinedOperation<WithFilterInput<Filters, Input>, Output, Queries, keyof Filters extends never ? undefined : Filters>;
|
|
622
|
+
declare function defineOperation<const Queries extends QueryDefinitions, const Filters extends FilterCollection = {}, Output = unknown>(operation: FilterOperationDefinition<Filters, Output, Queries> & {
|
|
623
|
+
queries: CheckedQueries<Queries>;
|
|
624
|
+
}): DefinedOperation<FilterInput<Filters>, Output, Queries, Filters>;
|
|
577
625
|
/** The built-in connection operation shares one contract with setup clients. */
|
|
578
|
-
type ConnectionOperation = Omit<DataOperation<Record<string, never>, true>, 'queryNames'> & {
|
|
626
|
+
type ConnectionOperation = Omit<DataOperation<Record<string, never>, true>, 'queryNames' | 'filters'> & {
|
|
627
|
+
readonly filters: {};
|
|
579
628
|
queryNames: {
|
|
580
629
|
readonly connection: 'connection';
|
|
581
630
|
};
|
|
@@ -585,5 +634,5 @@ declare function connectionCheck<const Queries extends QueryDefinitions & {
|
|
|
585
634
|
connection: QueryDefinitions[string];
|
|
586
635
|
}>(queries: CheckedQueries<Queries>): ConnectionOperation;
|
|
587
636
|
//#endregion
|
|
588
|
-
export {
|
|
637
|
+
export { DataQueryInput as $, multiChoiceFilter as A, dimensionFilter as At, NumberSelection as B, DateTimeRangePreset as Bt, FilterPresentation as C, DimensionFilterSettings as Ct, choiceFilter as D, DimensionSelectionFilter as Dt, SearchFilter as E, DimensionSelection as Et, NavigationUpdate as F, FacetFilter as Ft, parseNumberSelection as G, DateTimeRangeInput as Gt, numberFilter as H, DateTimeRangeSelection as Ht, BooleanFilter as I, facetSource as It, SourceDimensionFilter as J, DimensionSourceConfig as K, DateTimeRangePolicy as Kt, BooleanSelection as L, DateTimeRangeComparison as Lt, validateChoiceOptions as M, dimensionPredicate as Mt, AppLocation as N, parseDimensionSelection as Nt, defineAppFilters as O, DimensionValue as Ot, HistoryMode as P, parseFacetOptions as Pt, DataQueryBody as Q, NumberFilter as R, DateTimeRangeFilter as Rt, FilterCollection as S, DimensionFilterOptions as St, MultiChoiceFilter as T, DimensionOption as Tt, numberOperatorLabels as U, dateTimeRangeFilter as Ut, booleanFilter as V, DateTimeRangeRequest as Vt, parseBooleanSelection as W, dateTimeRangePresets as Wt, DataOperation as X, dimensionSource as Y, DataOperations as Z, resolveFilterInput as _, QueryProjections as _t, RegisteredQuery as a, OutputOf as at, ChoiceFilter as b, QueryValueType as bt, connectionCheck as c, CheckedQueries as ct, parseCount as d, MAX_QUERY_ROWS as dt, DisclosedQuery as et, parseLabel as f, QueryDefinitions as ft, dateFilterName as g, QueryParameters as gt, combineOperationFilters as h, QueryParameterValue as ht, InputOperationDefinition as i, OperationContracts as it, searchFilter as j, dimensionMemberKey as jt, displayChoice as k, createDimensionFilter as kt, defineOperation as l, IsUnion as lt, FilterInput as m, QueryParameter as mt, DefinedOperation as n, Lakehouse as nt, ReportingPeriod as o, QueryResult as ot, parseTrue as p, QueryField as pt, DimensionSourceQueryName as q, FilterOperationDefinition as r, OperationContext as rt, WithFilterInput as s, TransportResponse as st, ConnectionOperation as t, InputOf as tt, defineQueryNames as u, KnownRecord as ut, AppFilter as v, QueryRow as vt, FilterValues as w, DimensionMember as wt, ChoiceOption as x, DimensionFilter as xt, CheckedFilterDeclarations as y, QuerySnapshot as yt, NumberOperator as z, DateTimeRangeFilterOptions as zt };
|
|
589
638
|
//# sourceMappingURL=contract.d.ts.map
|