@altertable/data-app 0.72.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/AGENTS.md +5 -61
  2. package/CONTRIBUTING.md +93 -180
  3. package/README.md +3 -4
  4. package/REFERENCE.md +30 -345
  5. package/dist/chunks/contract-BeLPJwlO.js +558 -0
  6. package/dist/chunks/contract-BeLPJwlO.js.map +1 -0
  7. package/dist/chunks/contract-Di8SP74I.js +462 -0
  8. package/dist/chunks/contract-Di8SP74I.js.map +1 -0
  9. package/dist/chunks/format-BdFlv_xa.js +148 -0
  10. package/dist/chunks/format-BdFlv_xa.js.map +1 -0
  11. package/dist/chunks/iframe-C3uCZEXh.js +809 -0
  12. package/dist/chunks/iframe-C3uCZEXh.js.map +1 -0
  13. package/dist/chunks/operation-CBxhjNhK.js +131 -0
  14. package/dist/chunks/operation-CBxhjNhK.js.map +1 -0
  15. package/dist/chunks/request-body-H1qPmmTN.js +50 -0
  16. package/dist/chunks/request-body-H1qPmmTN.js.map +1 -0
  17. package/dist/client/index.js +253 -285
  18. package/dist/client/index.js.map +1 -13
  19. package/dist/core/appearance.js +171 -162
  20. package/dist/core/appearance.js.map +1 -10
  21. package/dist/core/config.js +49 -11
  22. package/dist/core/config.js.map +1 -9
  23. package/dist/core/contract.js +3 -73
  24. package/dist/core/format.js +1 -26
  25. package/dist/index.js +1 -12
  26. package/dist/internal.js +352 -397
  27. package/dist/internal.js.map +1 -15
  28. package/dist/server/index.js +85 -97
  29. package/dist/server/index.js.map +1 -10
  30. package/dist/types/chunks/appearance.d.ts +45 -0
  31. package/dist/types/chunks/contract.d.ts +720 -0
  32. package/dist/types/chunks/index.d.ts +189 -0
  33. package/dist/types/client/index.d.ts +3 -13
  34. package/dist/types/core/appearance.d.ts +2 -42
  35. package/dist/types/core/config.d.ts +36 -39
  36. package/dist/types/core/contract.d.ts +2 -114
  37. package/dist/types/core/format.d.ts +44 -17
  38. package/dist/types/index.d.ts +3 -3
  39. package/dist/types/internal.d.ts +312 -22
  40. package/dist/types/server/index.d.ts +15 -4
  41. package/docs/app-authoring.md +72 -128
  42. package/docs/client.md +29 -63
  43. package/docs/composition.md +44 -75
  44. package/docs/contract.md +60 -100
  45. package/docs/data-context.md +35 -61
  46. package/docs/embed.md +83 -55
  47. package/docs/formatting-and-appearance.md +17 -38
  48. package/docs/hosted-apps.md +7 -14
  49. package/docs/layout.md +30 -47
  50. package/docs/local-data-apps.md +7 -7
  51. package/docs/react-embed.md +20 -26
  52. package/docs/react.md +10 -27
  53. package/docs/server-bun.md +2 -27
  54. package/docs/server.md +6 -12
  55. package/docs/stories-and-export.md +38 -40
  56. package/docs/styling.md +14 -22
  57. package/docs/ui-quality.md +5 -5
  58. package/docs/ui.md +68 -70
  59. package/docs/variables.md +142 -254
  60. package/docs/views.md +85 -116
  61. package/docs/widgets.md +100 -153
  62. package/docs/worker.md +15 -27
  63. package/package.json +3 -2
  64. package/dist/chunks/index-5a27erdg.js +0 -54
  65. package/dist/chunks/index-5a27erdg.js.map +0 -10
  66. package/dist/chunks/index-9yxr7nmm.js +0 -742
  67. package/dist/chunks/index-9yxr7nmm.js.map +0 -17
  68. package/dist/chunks/index-j5q5n3ra.js +0 -151
  69. package/dist/chunks/index-j5q5n3ra.js.map +0 -10
  70. package/dist/chunks/index-q75zm3a7.js +0 -153
  71. package/dist/chunks/index-q75zm3a7.js.map +0 -11
  72. package/dist/chunks/index-vhaec7m5.js +0 -30
  73. package/dist/chunks/index-vhaec7m5.js.map +0 -10
  74. package/dist/chunks/index-zp78caex.js +0 -1047
  75. package/dist/chunks/index-zp78caex.js.map +0 -19
  76. package/dist/core/contract.js.map +0 -9
  77. package/dist/core/format.js.map +0 -9
  78. package/dist/index.js.map +0 -9
  79. package/dist/types/client/annotations.d.ts +0 -27
  80. package/dist/types/client/data-client.d.ts +0 -43
  81. package/dist/types/client/download.d.ts +0 -5
  82. package/dist/types/client/iframe.d.ts +0 -59
  83. package/dist/types/client/location.d.ts +0 -13
  84. package/dist/types/client/logger.d.ts +0 -14
  85. package/dist/types/client/messages.d.ts +0 -7
  86. package/dist/types/client/navigation.d.ts +0 -15
  87. package/dist/types/client/transport.d.ts +0 -15
  88. package/dist/types/core/annotations.d.ts +0 -99
  89. package/dist/types/core/bridge-endpoint.d.ts +0 -21
  90. package/dist/types/core/bridge.d.ts +0 -172
  91. package/dist/types/core/data-view.d.ts +0 -46
  92. package/dist/types/core/date-format.d.ts +0 -24
  93. package/dist/types/core/date-range.d.ts +0 -20
  94. package/dist/types/core/dimension-source.d.ts +0 -64
  95. package/dist/types/core/dimension.d.ts +0 -71
  96. package/dist/types/core/facets.d.ts +0 -13
  97. package/dist/types/core/filters.d.ts +0 -45
  98. package/dist/types/core/invariant.d.ts +0 -2
  99. package/dist/types/core/keys.d.ts +0 -2
  100. package/dist/types/core/logger.d.ts +0 -12
  101. package/dist/types/core/messages.d.ts +0 -62
  102. package/dist/types/core/navigation.d.ts +0 -11
  103. package/dist/types/core/operation-types.d.ts +0 -80
  104. package/dist/types/core/operation.d.ts +0 -20
  105. package/dist/types/core/presentation.d.ts +0 -9
  106. package/dist/types/core/queries.d.ts +0 -84
  107. package/dist/types/core/reading.d.ts +0 -17
  108. package/dist/types/core/uuid.d.ts +0 -2
  109. package/dist/types/core/variables.d.ts +0 -133
  110. package/dist/types/server/handler.d.ts +0 -13
  111. package/dist/types/server/request-body.d.ts +0 -4
@@ -1,99 +0,0 @@
1
- export type DataAppAnnotationDraft = {
2
- id: string;
3
- target: {
4
- id: string;
5
- label: string;
6
- kind: 'widget' | 'element' | 'app';
7
- text: string;
8
- queryNames: string[];
9
- glossaryIds: string[];
10
- };
11
- context: {
12
- search: string;
13
- hash: string;
14
- displayedInput?: unknown;
15
- /** Normalized position within the selected target, stable across scrolling/resizing. */
16
- anchor?: {
17
- x: number;
18
- y: number;
19
- };
20
- cursor?: {
21
- x: number;
22
- y: number;
23
- };
24
- /** Normalized custom selection rectangle within the iframe document. */
25
- region?: {
26
- x: number;
27
- y: number;
28
- width: number;
29
- height: number;
30
- };
31
- screenshot?: {
32
- mimeType: 'image/png';
33
- dataUrl: string;
34
- width: number;
35
- height: number;
36
- };
37
- view?: string;
38
- viewport: {
39
- width: number;
40
- height: number;
41
- };
42
- rect: {
43
- x: number;
44
- y: number;
45
- width: number;
46
- height: number;
47
- };
48
- };
49
- comment: string;
50
- };
51
- export type DataAppAnnotationPresentation = {
52
- enabled: boolean;
53
- /** When provided, the host owns the mode and renders the annotation trigger. */
54
- active?: boolean;
55
- pinsVisible?: boolean;
56
- showHint?: boolean;
57
- readOnly?: boolean;
58
- targets?: {
59
- id: string;
60
- targetId: string;
61
- number: number;
62
- comment?: string;
63
- anchor?: {
64
- x: number;
65
- y: number;
66
- };
67
- region?: {
68
- x: number;
69
- y: number;
70
- width: number;
71
- height: number;
72
- };
73
- }[];
74
- selectedAnnotationId?: string;
75
- selectedTargetId?: string;
76
- selectionId?: string;
77
- /** Confirmed host click outside the iframe; occurredAt is epoch milliseconds. */
78
- dismissal?: {
79
- id: string;
80
- occurredAt: number;
81
- };
82
- };
83
- /** Reconstruct at the boundary; discard extra fields and bound the entire JSON payload. */
84
- export declare function parseDataAppAnnotationDraft(value: unknown): DataAppAnnotationDraft;
85
- export declare const annotationDraftRoute: import("./messages.js").MessageRoute<DataAppAnnotationDraft, null>;
86
- export declare const annotationEditorStateRoute: import("./messages.js").MessageRoute<{
87
- hasUnsavedChanges: boolean;
88
- }, null>;
89
- /** Request host-owned batch submission without transferring ownership of drafts. */
90
- export declare const annotationSendRoute: import("./messages.js").MessageRoute<null, null>;
91
- export declare const annotationUpdateRoute: import("./messages.js").MessageRoute<{
92
- id: string;
93
- comment: string;
94
- }, null>;
95
- /** A controlled shell acknowledges local exits (for example Escape). */
96
- export declare const annotationModeRoute: import("./messages.js").MessageRoute<{
97
- active: boolean;
98
- }, null>;
99
- export declare function isAnnotationPresentation(value: unknown): value is DataAppAnnotationPresentation;
@@ -1,21 +0,0 @@
1
- import { type BridgeDiagnostic, type BridgeMessage, type BridgeRole, type BridgeEventsFrom, type BridgePayload, type BridgeEnvelope, type BridgeHandlers } from './bridge.js';
2
- type ConnectionContext = Pick<BridgeEnvelope, 'sessionId' | 'token'> & {
3
- documentId?: string;
4
- };
5
- /** The connection owns IDs and token rotation; callers can only supply event payloads. */
6
- export declare function createBridgeEndpoint<const Role extends BridgeRole>({ role, origin, source, opaque, context, post, diagnostic, invalidRequest, handlers, }: {
7
- role: Role;
8
- handlers: BridgeHandlers<NoInfer<Role>>;
9
- origin: string;
10
- source: () => MessageEventSource | null;
11
- opaque: boolean;
12
- context: () => ConnectionContext;
13
- post: (message: BridgeMessage) => void;
14
- diagnostic?: (event: BridgeDiagnostic) => void;
15
- invalidRequest?: (id: string) => void;
16
- }): {
17
- send: <Name extends BridgeEventsFrom<Role>, const Payload extends BridgePayload<NoInfer<Name>>>(name: Name, payload: Payload & Record<Exclude<keyof Payload, keyof BridgePayload<NoInfer<Name>>>, never>) => void;
18
- receive: (event: MessageEvent) => void;
19
- dispose(): void;
20
- };
21
- export {};
@@ -1,172 +0,0 @@
1
- /** Data app delivery protocol. IDs identify a document, a shell session, and an individual call. */
2
- export declare const BRIDGE = "altertable:data-app";
3
- export declare const PARENT_PARAM = "__altertable_parent";
4
- /** Bound pending requests in the client and host independently.
5
- * The host enforces its own limit because frames can send messages directly. */
6
- export declare const MAX_PENDING = 128;
7
- export declare const REQUEST_TIMEOUT_MS = 60000;
8
- export { type TransportResponse } from './operation-types.js';
9
- export declare function validId(value: unknown): value is string;
10
- type Fields = Record<string, unknown>;
11
- export type BridgeRole = 'host' | 'app';
12
- /** Parsers project known fields; opaque values are validated by their owning route or adapter. */
13
- export declare const bridgeProtocol: {
14
- readonly channel: "altertable:data-app";
15
- readonly version: 1;
16
- readonly events: {
17
- readonly connect: {
18
- wire: "bridge:connect";
19
- from: "host";
20
- session: "none";
21
- parse: (fields: Fields) => {};
22
- };
23
- readonly ready: {
24
- wire: "bridge:ready";
25
- from: "app";
26
- session: "none";
27
- parse: (fields: Fields) => {};
28
- };
29
- readonly initialize: {
30
- wire: "bridge:initialize";
31
- from: "host";
32
- session: "establish";
33
- parse: (fields: Fields) => {
34
- state: unknown;
35
- };
36
- };
37
- readonly request: {
38
- wire: "bridge:request";
39
- from: "app";
40
- session: "current";
41
- parse: (fields: Fields) => {
42
- id: string;
43
- route: string;
44
- payload: unknown;
45
- };
46
- };
47
- readonly result: {
48
- wire: "bridge:result";
49
- from: "host";
50
- session: "current";
51
- parse: (fields: Fields) => {
52
- id: string;
53
- response: unknown;
54
- };
55
- };
56
- readonly error: {
57
- wire: "bridge:error";
58
- from: "host";
59
- session: "current";
60
- parse: (fields: Fields) => {
61
- id: string;
62
- code: string;
63
- message: string;
64
- requestId?: string | undefined;
65
- };
66
- };
67
- readonly cancel: {
68
- wire: "bridge:cancel";
69
- from: "app";
70
- session: "current";
71
- parse: (fields: Fields) => {
72
- id: string;
73
- };
74
- };
75
- readonly disconnect: {
76
- wire: "bridge:disconnect";
77
- from: "app";
78
- session: "current";
79
- parse: (fields: Fields) => {};
80
- };
81
- readonly scriptLoad: {
82
- wire: "script:load";
83
- from: "host";
84
- session: "current";
85
- parse: (fields: Fields) => {
86
- javascript: string;
87
- };
88
- };
89
- readonly stateUpdate: {
90
- wire: "state:update";
91
- from: "host";
92
- session: "current";
93
- parse: (fields: Fields) => {
94
- state: unknown;
95
- };
96
- };
97
- readonly runtimeLog: {
98
- wire: "runtime:log";
99
- from: "app";
100
- session: "current";
101
- parse: (fields: Fields) => {
102
- payload: import("./logger.js").LogEntry;
103
- };
104
- };
105
- readonly runtimeReady: {
106
- wire: "runtime:ready";
107
- from: "app";
108
- session: "current";
109
- parse: (fields: Fields) => {};
110
- };
111
- readonly runtimeError: {
112
- wire: "runtime:error";
113
- from: "app";
114
- session: "current";
115
- parse: (fields: Fields) => {};
116
- };
117
- };
118
- };
119
- type Events = typeof bridgeProtocol.events;
120
- export type BridgeEventName = keyof Events;
121
- export type BridgePayload<Name extends BridgeEventName> = ReturnType<Events[Name]['parse']>;
122
- export type BridgeEnvelope = {
123
- channel: typeof BRIDGE;
124
- version: typeof bridgeProtocol.version;
125
- documentId: string;
126
- sessionId?: string;
127
- token?: string;
128
- };
129
- export type BridgeEventMessage<Name extends BridgeEventName> = Name extends BridgeEventName ? BridgeEnvelope & {
130
- type: Events[Name]['wire'];
131
- } & (Events[Name]['session'] extends 'none' ? {} : {
132
- sessionId: string;
133
- }) & BridgePayload<Name> : never;
134
- export type BridgeMessage = {
135
- [Name in BridgeEventName]: BridgeEventMessage<Name>;
136
- }[BridgeEventName];
137
- export type BridgeEventsFrom<Role extends BridgeRole> = {
138
- [Name in BridgeEventName]: Events[Name]['from'] extends Role ? Name : never;
139
- }[BridgeEventName];
140
- export type BridgeHandlers<Role extends BridgeRole> = {
141
- [Name in BridgeEventsFrom<Role extends 'host' ? 'app' : 'host'>]: (message: BridgeEventMessage<Name>) => void;
142
- };
143
- /** Delivery metadata safe to log on either side; never payloads or session credentials. */
144
- export type BridgeMessageMetadata = {
145
- type: BridgeMessage['type'];
146
- id?: string;
147
- route?: string;
148
- operation?: string;
149
- error?: {
150
- code: string;
151
- message: string;
152
- requestId?: string;
153
- };
154
- };
155
- export declare function bridgeMessageMetadata(message: BridgeMessage): BridgeMessageMetadata;
156
- /** Why a message from the connected peer was ignored. Messages from other windows are not reported. */
157
- export type BridgeDropReason = 'invalid_envelope' | 'token_mismatch' | 'unexpected_type' | 'session_mismatch' | 'invalid_payload';
158
- export type BridgeDiagnostic = ({
159
- direction: 'send' | 'receive';
160
- } & BridgeMessageMetadata) | {
161
- direction: 'drop';
162
- type?: string;
163
- reason: BridgeDropReason;
164
- };
165
- export declare function bridgeEventName(wire: string): "cancel" | "connect" | "disconnect" | "error" | "initialize" | "ready" | "request" | "result" | "runtimeError" | "runtimeLog" | "runtimeReady" | "scriptLoad" | "stateUpdate" | undefined;
166
- /** Envelope parsing precedes authentication; event-specific fields remain untrusted. */
167
- export declare function parseBridgeEnvelope(value: unknown): (BridgeEnvelope & Fields & {
168
- type: string;
169
- }) | undefined;
170
- /** Project event fields after the caller has checked envelope eligibility. */
171
- export declare function parseBridgePayload(envelope: NonNullable<ReturnType<typeof parseBridgeEnvelope>>, definition: Events[BridgeEventName]): BridgeMessage | undefined;
172
- export declare function parseBridgeMessage(value: unknown): BridgeMessage | undefined;
@@ -1,46 +0,0 @@
1
- export type DataView<T, Input = unknown> = {
2
- kind: 'loading';
3
- } | {
4
- kind: 'empty';
5
- input: Input;
6
- } | {
7
- kind: 'error';
8
- error: Error;
9
- } | {
10
- kind: 'ready';
11
- data: T;
12
- input: Input;
13
- } | {
14
- kind: 'updating';
15
- data: T;
16
- requestedInput: Input;
17
- displayedInput: Input;
18
- message: string;
19
- } | {
20
- kind: 'stale-error';
21
- data: T;
22
- requestedInput: Input;
23
- displayedInput: Input;
24
- error: Error;
25
- message: string;
26
- };
27
- export type DataSnapshot<Data, Input> = {
28
- data: Data;
29
- input: Input;
30
- };
31
- export type DisplayedSnapshot<Data, Input> = DataSnapshot<Data, Input> & {
32
- state: 'ready' | 'updating' | 'stale-error';
33
- };
34
- /** The result currently shown to the reader, including the input that produced it. */
35
- export declare function displayedSnapshot<Data, Input>(view: DataView<Data, Input>): DisplayedSnapshot<Data, Input> | undefined;
36
- /** Keep the requested input separate from the input that produced visible data. */
37
- export declare function resolveDataView<Data, Input>({ requestedInput, current, previous, pending, error, sameInput, describe, isEmpty, }: {
38
- requestedInput: Input;
39
- current?: DataSnapshot<Data, Input>;
40
- previous?: DataSnapshot<Data, Input>;
41
- pending: boolean;
42
- error?: Error;
43
- sameInput: (a: Input, b: Input) => boolean;
44
- describe: (input: Input) => string;
45
- isEmpty: (data: Data) => boolean;
46
- }): DataView<Data, Input>;
@@ -1,24 +0,0 @@
1
- /** Formatting for calendar dates and instants without implicit time-zone parsing. */
2
- export type DateFormatOptions = {
3
- locale?: string;
4
- missing?: string;
5
- };
6
- export type DateTimeFormatOptions = DateFormatOptions & {
7
- timeZone?: string;
8
- precision?: 'minute' | 'second';
9
- };
10
- export type DateFormat = ({
11
- kind: 'date';
12
- } & DateFormatOptions) | ({
13
- kind: 'dateTime';
14
- } & DateTimeFormatOptions);
15
- type DateTimeValue = string | Date | number | null | undefined;
16
- /** Format an ISO calendar date as a date, never as a browser-local instant. */
17
- export declare function formatDate(value: string | null | undefined, options?: DateFormatOptions): string;
18
- /** Parse only unambiguous instants. String values must include `Z` or an explicit offset. */
19
- export declare function parseDateTime(value: DateTimeValue): Date | null;
20
- /** Format an instant in an explicit reporting zone. Defaults use UTC and 24-hour minutes. */
21
- export declare function formatDateTime(value: DateTimeValue, options?: DateTimeFormatOptions): string;
22
- /** Format an instant's time for intraday chart axes using the same zone and precision policy. */
23
- export declare function formatTime(value: DateTimeValue, options?: DateTimeFormatOptions): string;
24
- export {};
@@ -1,20 +0,0 @@
1
- /** ISO calendar dates; the app operation defines timezone and inclusive bounds. */
2
- export type DateRange = {
3
- start: string;
4
- end: string;
5
- };
6
- export type DatePresetId = 'day' | 'last-3' | 'last-7' | 'last-14' | 'last-30' | 'last-90' | 'this-week' | 'previous-week' | 'this-month' | 'previous-month';
7
- export type DatePreset = {
8
- id: DatePresetId;
9
- label: string;
10
- range: DateRange;
11
- };
12
- export declare function inclusiveDays(range: DateRange): number;
13
- export declare function withinBounds(range: DateRange, minDate?: string, maxDate?: string, maxRangeDays?: number): boolean;
14
- /** Only offer ranges the app says it can query. Dates and range lengths are inclusive. */
15
- export declare function availableDatePresets({ minDate, maxDate, maxRangeDays, timeZone, }: {
16
- minDate?: string;
17
- maxDate?: string;
18
- maxRangeDays?: number;
19
- timeZone?: string;
20
- }): DatePreset[];
@@ -1,64 +0,0 @@
1
- import { type DimensionSettings, type DimensionSelectionVariable, type DimensionValue } from './dimension.js';
2
- import type { AppVariableValues, VariableCollection } from './variables.js';
3
- import { type QueryDefinitions, type QueryParameters } from './queries.js';
4
- import type { DataOperation, DataOperations, QueryResult } from './operation-types.js';
5
- export declare const dimensionSource: unique symbol;
6
- export type SourceDimensionVariable<Value extends DimensionValue> = DimensionSelectionVariable<Value> & {
7
- readonly optionsSource: 'query';
8
- readonly [dimensionSource]: {
9
- readonly operation: string;
10
- };
11
- };
12
- declare const invalidMemberKey: unique symbol;
13
- export declare class DimensionMembershipError extends Error {
14
- readonly [invalidMemberKey] = true;
15
- static [Symbol.hasInstance](value: unknown): boolean;
16
- }
17
- /** Validate named variable values at the operation boundary. Date inputs belong to the base parser. */
18
- export declare function variableInput<Input extends object, const Variables extends VariableCollection>(parse: (value: unknown) => Input, variables: Variables & {
19
- [Key in keyof Variables]: Variables[Key] extends {
20
- kind: 'dateRange';
21
- } ? never : Variables[Key];
22
- }): (value: unknown) => Input & AppVariableValues<Variables>;
23
- export type DimensionSourceConfig<Type extends 'string' | 'number'> = DimensionSettings & {
24
- allowMissing?: false;
25
- valueType: Type;
26
- source: {
27
- query: string;
28
- };
29
- };
30
- export type DimensionSourceQueryName<Queries extends QueryDefinitions, Type extends 'string' | 'number'> = {
31
- [Name in keyof Queries & string]: Queries[Name] extends {
32
- params: {
33
- member: {
34
- type: Type;
35
- nullable: true;
36
- };
37
- };
38
- projections: {
39
- value: {
40
- type: Type;
41
- nullable?: false;
42
- };
43
- label: {
44
- type: 'string';
45
- nullable?: false;
46
- };
47
- };
48
- } ? 'count' extends keyof Queries[Name]['projections'] ? Queries[Name]['projections']['count'] extends {
49
- type: 'number';
50
- nullable?: false;
51
- } ? Name : never : Name : never;
52
- }[keyof Queries & string];
53
- /** A query supplies independent options and exact member lookup; it declares a nullable `member` parameter. */
54
- export declare function bindDimensionSource<const Type extends 'string' | 'number'>(config: DimensionSourceConfig<Type>, queries: QueryDefinitions): SourceDimensionVariable<{
55
- string: string;
56
- number: number;
57
- }[Type]>;
58
- type Query = (name: string, params: QueryParameters, options: {
59
- limit: number;
60
- }) => Promise<QueryResult<Record<string, unknown>>>;
61
- export declare function validateVariableInput(parser: Function, input: unknown, query: Query): Promise<void>;
62
- export declare function attachDimensionSelectors(operation: DataOperation<any, any>, queries: QueryDefinitions): void;
63
- export declare function withDimensionSelectors<Operations extends DataOperations>(operations: Operations): Operations;
64
- export {};
@@ -1,71 +0,0 @@
1
- import { facetSource } from './facets.js';
2
- import type { AppVariable, HistoryMode, VariablePresentation } from './variables.js';
3
- export type DimensionValue = string | number;
4
- export type DimensionMember<T extends DimensionValue = DimensionValue> = {
5
- kind: 'value';
6
- value: T;
7
- } | {
8
- kind: 'missing';
9
- };
10
- export type DimensionSelection<T extends DimensionValue = DimensionValue> = {
11
- kind: 'all';
12
- } | {
13
- kind: 'include' | 'exclude';
14
- members: readonly DimensionMember<T>[];
15
- };
16
- export type DimensionOption<T extends DimensionValue = DimensionValue> = {
17
- value: T;
18
- label: string;
19
- count?: number;
20
- };
21
- export type DimensionSelectionVariable<T extends DimensionValue = DimensionValue> = AppVariable<DimensionSelection<T>, 'dimension'> & {
22
- readonly optionsSource: 'fixed' | 'query';
23
- label: string;
24
- selectionMode: 'single' | 'multiple';
25
- readonly valueType: T extends number ? 'number' : 'string';
26
- allowMissing: boolean;
27
- allowExclusion: boolean;
28
- maxSelected: number;
29
- options: readonly DimensionOption<T>[];
30
- describe: (selection: DimensionSelection<T>, options?: readonly DimensionOption<T>[]) => string;
31
- };
32
- /** A fixed-option dimension retains its distinction from query-backed facets. */
33
- export type DimensionVariable<T extends DimensionValue = DimensionValue> = DimensionSelectionVariable<T> & {
34
- readonly optionsSource: 'fixed';
35
- readonly [facetSource]?: never;
36
- };
37
- export declare function dimensionMemberKey(member: DimensionMember): string;
38
- export type DimensionSettings = {
39
- key: string;
40
- label: string;
41
- allowMissing?: boolean;
42
- allowExclusion?: boolean;
43
- history?: HistoryMode;
44
- presentation?: VariablePresentation;
45
- } & ({
46
- selectionMode: 'single';
47
- maxSelected?: 1;
48
- } | {
49
- selectionMode: 'multiple';
50
- maxSelected?: number;
51
- });
52
- export type DimensionFilterSettings<T extends DimensionValue> = DimensionSettings & {
53
- valueType: T extends number ? 'number' : 'string';
54
- };
55
- export type DimensionFilterOptions<T extends DimensionValue> = DimensionFilterSettings<T> & {
56
- options: readonly DimensionOption<T>[];
57
- facet?: never;
58
- };
59
- /** A bounded categorical filter with app-owned fixed options. */
60
- export declare function dimensionFilter<const T extends string>(config: DimensionFilterOptions<T>): DimensionVariable<T>;
61
- export declare function dimensionFilter<const T extends number>(config: DimensionFilterOptions<T>): DimensionVariable<T>;
62
- /** Shared fixed-option and query-backed selection behavior. */
63
- export declare function createDimensionFilter<const T extends DimensionValue>(config: DimensionFilterSettings<T> & {
64
- options: readonly DimensionOption<T>[];
65
- }, dynamic?: boolean): DimensionSelectionVariable<T>;
66
- /** Server-side parser; call from the operation input parser before building SQL. */
67
- export declare function parseDimensionSelection<T extends DimensionValue>(value: unknown, filter: DimensionSelectionVariable<T>): DimensionSelection<T>;
68
- /** Validate bounded facet results before showing them in a picker. */
69
- export declare function parseFacetOptions<T extends DimensionValue>(value: unknown, filter: DimensionSelectionVariable<T>): DimensionOption<T>[];
70
- /** Central SQL literal encoding for transports without bound parameters. Column is an allowlisted identifier. */
71
- export declare function dimensionPredicate<T extends DimensionValue, const Columns extends readonly string[]>(column: Columns[number], selection: DimensionSelection<T>, allowedColumns: Columns): string;
@@ -1,13 +0,0 @@
1
- import type { VariableCollection } from './variables.js';
2
- import type { DimensionSelectionVariable, DimensionValue } from './dimension.js';
3
- /** Executable facet sources are attached only by the typed hooks factory. */
4
- export declare const facetSource: unique symbol;
5
- export type FacetSourceDefinition<Context extends VariableCollection = VariableCollection, Name extends string = string, Input = unknown> = {
6
- readonly context: Context;
7
- readonly operation: Name;
8
- readonly input: (values: Record<string, unknown>) => Input;
9
- };
10
- export type FacetVariable<Value extends DimensionValue, Context extends VariableCollection, Name extends string, Input> = DimensionSelectionVariable<Value> & {
11
- readonly optionsSource: 'query';
12
- readonly [facetSource]: FacetSourceDefinition<Context, Name, Input>;
13
- };
@@ -1,45 +0,0 @@
1
- import { type AppVariable, type HistoryMode, type VariablePresentation } from './variables.js';
2
- export type NumberOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
3
- export type NumberSelection = {
4
- kind: 'all';
5
- } | {
6
- kind: 'comparison';
7
- operator: NumberOperator;
8
- value: number;
9
- } | {
10
- kind: 'range';
11
- min?: number;
12
- max?: number;
13
- };
14
- export type BooleanSelection = {
15
- kind: 'all';
16
- } | {
17
- kind: 'is';
18
- value: boolean;
19
- };
20
- export type NumberFilter = AppVariable<NumberSelection, 'numberFilter'> & {
21
- label: string;
22
- min?: number;
23
- max?: number;
24
- };
25
- export type BooleanFilter = AppVariable<BooleanSelection, 'booleanFilter'> & {
26
- label: string;
27
- };
28
- type FilterOptions<Value> = {
29
- key: string;
30
- label: string;
31
- defaultValue?: Value;
32
- history?: HistoryMode;
33
- presentation?: VariablePresentation;
34
- };
35
- export declare const numberOperatorLabels: Record<NumberOperator, string>;
36
- /** Exact numeric predicates; range bounds are inclusive and may be open-ended. */
37
- export declare function numberFilter({ key, label, min, max, defaultValue, history, presentation, }: FilterOptions<NumberSelection> & {
38
- min?: number;
39
- max?: number;
40
- }): NumberFilter;
41
- /** Boolean predicate with a distinct unrestricted state. */
42
- export declare function booleanFilter({ key, label, defaultValue, history, presentation, }: FilterOptions<BooleanSelection>): BooleanFilter;
43
- export declare function parseNumberSelection(value: unknown, filter: NumberFilter): NumberSelection;
44
- export declare function parseBooleanSelection(value: unknown, filter: BooleanFilter): BooleanSelection;
45
- export {};
@@ -1,2 +0,0 @@
1
- /** Assert an author or data contract while preserving a useful failure message. */
2
- export declare function invariant(condition: unknown, message: string): asserts condition;
@@ -1,2 +0,0 @@
1
- /** Separator for opaque composite keys, independent of URL and DOM ID formats. */
2
- export declare const KEY_SEPARATOR = ":";
@@ -1,12 +0,0 @@
1
- /** Host-owned log sink; compatible with console and frontend createLogger(). */
2
- export type DataAppLogger = {
3
- log: (...args: unknown[]) => void;
4
- info: (...args: unknown[]) => void;
5
- warn: (...args: unknown[]) => void;
6
- error: (...args: unknown[]) => void;
7
- };
8
- export type LogEntry = {
9
- method: keyof DataAppLogger;
10
- args: unknown[];
11
- };
12
- export declare function isLogEntry(value: unknown): value is LogEntry;
@@ -1,62 +0,0 @@
1
- import { type QueryParameters } from './queries.js';
2
- import { type TransportResponse, type QueryResult, type OperationContracts, type DataQueryInput, type DataQueryBody, type OutputOf } from './operation-types.js';
3
- export { type OperationContracts, type DataQueryInput, type DataQueryBody, } from './operation-types.js';
4
- import { type NavigationUpdate } from './navigation.js';
5
- export { type NavigationUpdate } from './navigation.js';
6
- export type MessageContext = {
7
- signal: AbortSignal;
8
- };
9
- export type RoutedMessage = {
10
- route: string;
11
- payload: unknown;
12
- };
13
- export type MessageDispatcher = (message: unknown, context: MessageContext) => Promise<unknown>;
14
- export type MessageTransport = (message: RoutedMessage, signal?: AbortSignal) => Promise<unknown>;
15
- export type MessageRoute<Input, Output> = {
16
- input: (value: unknown) => Input;
17
- output: (value: unknown, input: Input) => Output;
18
- };
19
- export type MessageRoutes = Record<string, {
20
- input: (value: unknown) => unknown;
21
- output: (value: unknown, input: never) => unknown;
22
- }>;
23
- export type MessageInput<Route extends MessageRoutes[string]> = ReturnType<Route['input']>;
24
- export type MessageHandlers<Routes extends MessageRoutes> = {
25
- [Name in keyof Routes]: (payload: MessageInput<Routes[Name]>, context: MessageContext) => ReturnType<Routes[Name]['output']> | Promise<ReturnType<Routes[Name]['output']>>;
26
- };
27
- declare const errorBrand: unique symbol;
28
- /** Only these deliberate, public failures cross the message boundary. Other errors stay private. */
29
- export declare class MessageRoutingError extends Error {
30
- readonly code: string;
31
- readonly requestId?: string | undefined;
32
- readonly [errorBrand] = true;
33
- static [Symbol.hasInstance](value: unknown): boolean;
34
- constructor(code: string, message: string, requestId?: string | undefined,
35
- /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */
36
- options?: ErrorOptions);
37
- }
38
- export declare function defineMessageRoute<Input, Output>(route: MessageRoute<Input, Output>): MessageRoute<Input, Output>;
39
- /** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */
40
- export declare function createMessageRouter<const Routes extends MessageRoutes>(routes: Routes, handlers: MessageHandlers<NoInfer<Routes>>): {
41
- dispatch: (value: unknown, context: MessageContext) => Promise<unknown>;
42
- };
43
- export type DataQueryRoute<Operations extends OperationContracts> = MessageRoute<DataQueryInput<Operations>, TransportResponse> & {
44
- operations: Operations | undefined;
45
- };
46
- export type MessageOutput<Route extends MessageRoutes[string], Input> = Route extends DataQueryRoute<infer Operations> ? Input extends {
47
- operation: infer Name extends keyof Operations;
48
- } ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>> : never : ReturnType<Route['output']>;
49
- /** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */
50
- export declare function defineDataQueryRoute<Operations extends OperationContracts = OperationContracts>(operations?: Operations): DataQueryRoute<Operations>;
51
- export declare const navigationUpdateRoute: MessageRoute<NavigationUpdate, null>;
52
- export type SqlQueryInput = {
53
- statement: string;
54
- limit: number;
55
- params?: QueryParameters;
56
- };
57
- /** SQL delivery for browser-owned operations. Hosts must enforce backend access and resource limits. */
58
- export declare const sqlQueryRoute: MessageRoute<SqlQueryInput, QueryResult>;
59
- export declare const dataAppRoutes: {
60
- 'data:query': DataQueryRoute<OperationContracts>;
61
- 'navigation:update': MessageRoute<NavigationUpdate, null>;
62
- };