@malloy-publisher/sdk 0.3.0 → 0.4.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/README.md +22 -9
- package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
- package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
- package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9482 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/Dashboard.d.ts +19 -14
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
- package/dist/components/Dashboard/telemetry.d.ts +48 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
- package/dist/components/DocumentStorage/index.d.ts +1 -1
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/drill/index.d.ts +1 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/styles.d.ts +49 -44
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/index.cjs.js +22 -273
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16888 -44451
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +24 -9
- package/src/builder-entry.ts +55 -0
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +165 -175
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +66 -123
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
- package/src/components/Dashboard/telemetry.ts +51 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +16 -62
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +33 -72
- package/src/components/Notebook/Notebook.tsx +25 -88
- package/src/components/Notebook/NotebookCell.tsx +35 -183
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/RenderedResult/ResultContainer.tsx +4 -12
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +1 -0
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/drill/index.ts +1 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +16 -0
- package/src/components/styles.ts +49 -122
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/vite.config.ts +5 -0
- package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { DashboardDocument, DashboardTile, LocalGiven } from './document';
|
|
2
|
+
/**
|
|
3
|
+
* The builder's view of the dashboard's filter controls, and the pure edits it
|
|
4
|
+
* makes to them. Kept out of the component so every rule here has a test that
|
|
5
|
+
* needs no DOM.
|
|
6
|
+
*
|
|
7
|
+
* A control is a GIVEN some tile binds. It comes from one of two places, and
|
|
8
|
+
* the difference decides what the builder may do with it:
|
|
9
|
+
*
|
|
10
|
+
* - `dashboard` — declared in this file ({@link LocalGiven}). The builder owns
|
|
11
|
+
* it outright: add, retag, remove, and bind on any tile.
|
|
12
|
+
* - `model` — declared in the model and reaching this file through an import.
|
|
13
|
+
* The builder may bind it on tiles, because a binding is a refinement in this
|
|
14
|
+
* file, but it cannot change or remove the declaration, because the builder
|
|
15
|
+
* never edits imports or model files.
|
|
16
|
+
*
|
|
17
|
+
* Declaring in the dashboard is the convention; see {@link LocalGiven}.
|
|
18
|
+
*/
|
|
19
|
+
export type ControlOrigin = "dashboard" | "model";
|
|
20
|
+
/** A given the builder can bind a tile to, from either origin. */
|
|
21
|
+
export interface BuilderGiven {
|
|
22
|
+
/** The given's name, as written after `$` in a `where:`. */
|
|
23
|
+
name: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
/** The declared type, which decides how a binding compares; see {@link defaultOperator}. */
|
|
26
|
+
type?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The field to compare against, used as the default when this given is
|
|
29
|
+
* bound to a tile. The dimension its control suggests over is the right
|
|
30
|
+
* guess — a `CATEGORY` control that suggests over `category` is almost
|
|
31
|
+
* always filtering `category` — and it is only a default: the binding is
|
|
32
|
+
* editable afterwards, because the tile's source may spell it differently.
|
|
33
|
+
*/
|
|
34
|
+
field?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface BuilderControl extends BuilderGiven {
|
|
37
|
+
origin: ControlOrigin;
|
|
38
|
+
/** The declaration, for a control this dashboard owns. */
|
|
39
|
+
local?: LocalGiven;
|
|
40
|
+
/** How many tiles bind it. Zero means declared but not yet a control. */
|
|
41
|
+
boundTiles: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Every control the builder can offer: the dashboard's own first, in file
|
|
45
|
+
* order, then the model's that the caller knows about. A model given that
|
|
46
|
+
* shares a name with a local one is the same control as far as any `where:` is
|
|
47
|
+
* concerned, and the local declaration is the one that binds — so it is not
|
|
48
|
+
* listed twice.
|
|
49
|
+
*/
|
|
50
|
+
export declare function controlsOf(document: DashboardDocument, modelGivens?: readonly BuilderGiven[]): BuilderControl[];
|
|
51
|
+
/**
|
|
52
|
+
* How a binding to a given of this type compares.
|
|
53
|
+
*
|
|
54
|
+
* A `filter<…>` given is a filter EXPRESSION and binds with `~`, which is the
|
|
55
|
+
* common case and is left implicit on the binding. A plain-typed given is a
|
|
56
|
+
* VALUE: a `date` is "since", a `number` is "at least", a `string` is "equals".
|
|
57
|
+
* Measured: `created_at ~ $SINCE` does not compile against a `date` given.
|
|
58
|
+
*/
|
|
59
|
+
export declare function defaultOperator(type: string | undefined): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a given of `givenType` can compare a field of `fieldType` (the
|
|
62
|
+
* catalog's spelling: `string_type`, `number_type`, `date_type`, …).
|
|
63
|
+
*
|
|
64
|
+
* A `filter<string>` over a number field compiles nowhere and a `date` over a
|
|
65
|
+
* string field compares nothing, so the picker offers only the fields a control
|
|
66
|
+
* can take, and a binding to one it cannot is marked. Dates and timestamps
|
|
67
|
+
* compare with each other. Unknown on EITHER side is accepted: the catalog may
|
|
68
|
+
* carry no type, and a given of a type this does not know is not refused on
|
|
69
|
+
* that account.
|
|
70
|
+
*/
|
|
71
|
+
export declare function acceptsField(givenType: string | undefined, fieldType: string | undefined): boolean;
|
|
72
|
+
/** `number_type` -> "a number", as a message would say it. */
|
|
73
|
+
export declare function typeLabel(type: string | undefined): string;
|
|
74
|
+
/**
|
|
75
|
+
* The control a field of this type naturally gets: a number range for a
|
|
76
|
+
* number, a date picker for a date, a pick-list for anything else. What the
|
|
77
|
+
* window switches a new control to when the field picked does not fit the kind
|
|
78
|
+
* it started with.
|
|
79
|
+
*/
|
|
80
|
+
export declare function kindForFieldType(fieldType: string | undefined): ControlKind;
|
|
81
|
+
/** The comparisons a binding can use, with how a reader would say them. */
|
|
82
|
+
export declare const OPERATORS: ReadonlyArray<{
|
|
83
|
+
op: string;
|
|
84
|
+
label: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* A given name from a field: `products.category` -> `CATEGORY`, and kept
|
|
88
|
+
* distinct from any name already taken.
|
|
89
|
+
*/
|
|
90
|
+
export declare function givenNameFor(field: string, taken: Iterable<string>): string;
|
|
91
|
+
/** What kind of control a new filter is, in a reader's terms. */
|
|
92
|
+
export type ControlKind = "select" | "multiselect" | "text" | "number" | "date";
|
|
93
|
+
export declare const CONTROL_KINDS: ReadonlyArray<{
|
|
94
|
+
kind: ControlKind;
|
|
95
|
+
label: string;
|
|
96
|
+
hint: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* A new control's declaration, from what the dialog asked.
|
|
100
|
+
*
|
|
101
|
+
* The picker's options come from the source the field lives on — the base of
|
|
102
|
+
* the tile's own extension — which the file necessarily already imports, so a
|
|
103
|
+
* `suggest` here always resolves and the builder never has to add an import.
|
|
104
|
+
*/
|
|
105
|
+
export declare function newLocalGiven(spec: {
|
|
106
|
+
name: string;
|
|
107
|
+
label: string;
|
|
108
|
+
kind: ControlKind;
|
|
109
|
+
field: string;
|
|
110
|
+
/** The source to suggest over, for `select` and `multiselect`. */
|
|
111
|
+
source?: string;
|
|
112
|
+
/** A date's default, `YYYY-MM-DD`; a number range's bounds. */
|
|
113
|
+
dateDefault?: string;
|
|
114
|
+
range?: {
|
|
115
|
+
min: number;
|
|
116
|
+
max: number;
|
|
117
|
+
};
|
|
118
|
+
}): LocalGiven;
|
|
119
|
+
/** One tile's row in a control's mapping: whether it binds, and how. */
|
|
120
|
+
export interface MappingRow {
|
|
121
|
+
include: boolean;
|
|
122
|
+
field: string;
|
|
123
|
+
/** Absent means `~`; see {@link defaultOperator}. */
|
|
124
|
+
op?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Which tiles can take a binding, and why the others cannot.
|
|
128
|
+
*
|
|
129
|
+
* A binding is a `+ { where: … }` refinement on the tile's declaration, so the
|
|
130
|
+
* tile has to BE a declaration this file owns that the reader will read back.
|
|
131
|
+
* That is the `reference` form only: an `inherited` tile is declared on the
|
|
132
|
+
* model's source, and an `inline` tile's body is a query, not a reference, so a
|
|
133
|
+
* refinement written onto it would not come back and the round-trip gate would
|
|
134
|
+
* refuse the whole save. Better to refuse the tick.
|
|
135
|
+
*/
|
|
136
|
+
export declare const canBind: (tile: DashboardTile) => boolean;
|
|
137
|
+
/** The mapping a control has NOW, one row per tile, for the dialog to open on. */
|
|
138
|
+
export declare function mappingOf(document: DashboardDocument, control: {
|
|
139
|
+
name: string;
|
|
140
|
+
field?: string;
|
|
141
|
+
type?: string;
|
|
142
|
+
}): MappingRow[];
|
|
143
|
+
/**
|
|
144
|
+
* Apply a mapping: a DIFF against what each tile carries now — added where
|
|
145
|
+
* newly ticked, dropped where unticked, rewritten where only the field or the
|
|
146
|
+
* comparison changed. Mutates the draft; the caller makes it one history entry.
|
|
147
|
+
*/
|
|
148
|
+
export declare function applyMapping(draft: DashboardDocument, given: string, rows: readonly MappingRow[]): void;
|
|
149
|
+
/** Declare a control in this dashboard, or replace its declaration by name. */
|
|
150
|
+
export declare function declareControl(draft: DashboardDocument, given: LocalGiven): void;
|
|
151
|
+
/**
|
|
152
|
+
* Take a control off the dashboard: every binding to it, and — when this file
|
|
153
|
+
* declares it — the declaration too. A model given keeps its declaration, which
|
|
154
|
+
* is not ours; it simply stops being a control here, because a control is a
|
|
155
|
+
* given some tile binds.
|
|
156
|
+
*/
|
|
157
|
+
export declare function removeControl(draft: DashboardDocument, name: string): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A line diff, for showing an author what a structural save will do to the
|
|
3
|
+
* file before it does it.
|
|
4
|
+
*
|
|
5
|
+
* Adding or removing a tile moves a declaration and the comment block above
|
|
6
|
+
* it, and the file cannot say whether that comment belonged to the tile, the
|
|
7
|
+
* row, or the page. The writer makes a defensible choice (a tile's `#` tags
|
|
8
|
+
* go with it; `//` comments stay), and this is what turns that choice from a
|
|
9
|
+
* silent one into one the author sees and approves.
|
|
10
|
+
*
|
|
11
|
+
* Longest-common-subsequence over lines: exact, and a dashboard file is a few
|
|
12
|
+
* hundred lines, so the quadratic table is small. Past `LIMIT` lines a side,
|
|
13
|
+
* the diff degrades to "everything changed" rather than stalling the page.
|
|
14
|
+
*/
|
|
15
|
+
export type DiffLine = {
|
|
16
|
+
kind: "same";
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "add";
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "del";
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function lineDiff(before: string, after: string): DiffLine[];
|
|
26
|
+
/**
|
|
27
|
+
* The diff with unchanged stretches folded, keeping `context` lines around
|
|
28
|
+
* every change — what a review tool shows, and all a reader needs to judge a
|
|
29
|
+
* save. A fold is one entry saying how many lines it hides.
|
|
30
|
+
*/
|
|
31
|
+
export type DiffHunkLine = DiffLine | {
|
|
32
|
+
kind: "fold";
|
|
33
|
+
count: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function foldUnchanged(lines: DiffLine[], context?: number): DiffHunkLine[];
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dashboard builder's working representation of a `dashboards/*.malloy`
|
|
3
|
+
* file.
|
|
4
|
+
*
|
|
5
|
+
* This is an editing PROJECTION, not a complete representation of the file, and
|
|
6
|
+
* the distinction is load-bearing. The builder writes changes by SPLICING the
|
|
7
|
+
* source text — patching the ranges it owns and leaving every other byte alone —
|
|
8
|
+
* so anything this type does not model survives an edit untouched. A `where:` in
|
|
9
|
+
* a source extension, an inline computed dimension, a `#(doc)` tag, a reader's
|
|
10
|
+
* comments: none of them appear below, and none of them are lost.
|
|
11
|
+
*
|
|
12
|
+
* What that buys is the reason the projection exists. A writer that regenerated
|
|
13
|
+
* the whole file would have to model everything or destroy it, which is why the
|
|
14
|
+
* earlier design could only ever have edited files it wrote itself.
|
|
15
|
+
*
|
|
16
|
+
* The document is still what decides whether a file can be opened at all: the
|
|
17
|
+
* reader refuses a file it cannot fully turn into one of these, rather than
|
|
18
|
+
* opening it half-understood. See {@link readDashboardDocument}.
|
|
19
|
+
*/
|
|
20
|
+
/** One `import` line. The file needs both forms, and for different reasons. */
|
|
21
|
+
export type DashboardImport =
|
|
22
|
+
/** `import "../givens.malloy"` — the whole file's declarations. */
|
|
23
|
+
{
|
|
24
|
+
kind: "all";
|
|
25
|
+
from: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `import { products, regions } from "../storefront.malloy"` — specific
|
|
29
|
+
* names. Not interchangeable with the bare form: a bare import is not
|
|
30
|
+
* transitive, so a dashboard whose control has `suggest { source=products }`
|
|
31
|
+
* must name `products` here or the package load reports an error for every
|
|
32
|
+
* such given.
|
|
33
|
+
*/
|
|
34
|
+
| {
|
|
35
|
+
kind: "names";
|
|
36
|
+
names: string[];
|
|
37
|
+
from: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A given this dashboard declares itself, rather than taking from the model.
|
|
41
|
+
*
|
|
42
|
+
* This is the CONVENTION for a dashboard the builder edits, not the exception:
|
|
43
|
+
* the builder adds and removes filters, and a filter it can add has to be a
|
|
44
|
+
* declaration in the one file it writes. A given imported from the model is
|
|
45
|
+
* still read and still bindable, but it is the model's, and the builder never
|
|
46
|
+
* edits imports or model files.
|
|
47
|
+
*
|
|
48
|
+
* Measured, and the reason the convention has to be this way round: a local
|
|
49
|
+
* given does NOT drive a model-level `where:` of the same name. Binding is per
|
|
50
|
+
* declaration, not per name, so a dashboard that declares `CATEGORY` and extends
|
|
51
|
+
* a source whose own `where:` reads the model's `CATEGORY` gets a control that
|
|
52
|
+
* moves nothing. The filtering therefore lives on the dashboard's tiles, as
|
|
53
|
+
* {@link DashboardTile.filters} — which is what the builder writes anyway.
|
|
54
|
+
*
|
|
55
|
+
* The fields are the declaration and its control contract, spelled as in the
|
|
56
|
+
* file. A tag this does not model survives an edit like any other unmodelled
|
|
57
|
+
* Malloy, because the writer patches rather than regenerates.
|
|
58
|
+
*/
|
|
59
|
+
export interface LocalGiven {
|
|
60
|
+
name: string;
|
|
61
|
+
/** The declared type, spelled as in the file: `filter<string>`, `date`, … */
|
|
62
|
+
type: string;
|
|
63
|
+
/** The default, spelled as in the file: `f'Jeans'`, `@2023-01-01`, … */
|
|
64
|
+
default: string;
|
|
65
|
+
label?: string;
|
|
66
|
+
/** `# description="…"`: helper text under the control. */
|
|
67
|
+
description?: string;
|
|
68
|
+
/** `control=select` / `multiselect`. */
|
|
69
|
+
control?: string;
|
|
70
|
+
/**
|
|
71
|
+
* `suggest { source=products dimension=category }`, or `{ query=… }`: where
|
|
72
|
+
* a picker gets its options. The source or query has to resolve in this file,
|
|
73
|
+
* and the builder does not add imports — so a given it creates suggests over
|
|
74
|
+
* a source the file already reads, or over nothing.
|
|
75
|
+
*/
|
|
76
|
+
suggest?: {
|
|
77
|
+
source?: string;
|
|
78
|
+
query?: string;
|
|
79
|
+
dimension: string;
|
|
80
|
+
};
|
|
81
|
+
/** `range_min=` / `range_max=` on a `filter<number>`: a slider's bounds. */
|
|
82
|
+
rangeMin?: number;
|
|
83
|
+
rangeMax?: number;
|
|
84
|
+
}
|
|
85
|
+
/** A `# drill` dimension the dashboard declares in its own source extension. */
|
|
86
|
+
export interface DashboardDrill {
|
|
87
|
+
/** The source this dimension is declared on. */
|
|
88
|
+
source: string;
|
|
89
|
+
/** `dimension: <name> is <expression>`. */
|
|
90
|
+
name: string;
|
|
91
|
+
expression: string;
|
|
92
|
+
/** Dashboard slugs, or the literal `self`. */
|
|
93
|
+
to: string[];
|
|
94
|
+
/** The given a click seeds. Absent means the dimension's own name. */
|
|
95
|
+
given?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Where a tile's view is declared, and therefore what the builder may edit.
|
|
99
|
+
*
|
|
100
|
+
* Three forms, all of them found in dashboards that ship in this repository, and
|
|
101
|
+
* the distinction decides which affordances a tile gets:
|
|
102
|
+
*
|
|
103
|
+
* - `reference` — `view: revenue_trend is sales_by_month` in this file. Fully
|
|
104
|
+
* editable: the layout tags sit above that line and the builder owns them.
|
|
105
|
+
* - `inline` — `view: order_tile is { aggregate: order_count }` in this file.
|
|
106
|
+
* Its tags are editable for the same reason; its QUERY is not, because
|
|
107
|
+
* authoring a query body is a separate feature. The projection holds: the body
|
|
108
|
+
* is never rewritten, so it cannot be damaged.
|
|
109
|
+
* - `inherited` — not declared in this file at all, as in a dashboard whose only
|
|
110
|
+
* tile is `orders -> by_brand` against an imported source. Nothing about it is
|
|
111
|
+
* editable here, because its tags live on the model's own view and the builder
|
|
112
|
+
* does not write model files. Read and shown, not changed.
|
|
113
|
+
*/
|
|
114
|
+
export type TileDeclaration = {
|
|
115
|
+
kind: "reference";
|
|
116
|
+
from: string;
|
|
117
|
+
} | {
|
|
118
|
+
kind: "inline";
|
|
119
|
+
} | {
|
|
120
|
+
kind: "inherited";
|
|
121
|
+
};
|
|
122
|
+
/** One tile: a view shown on the page, plus how it is presented. */
|
|
123
|
+
export interface DashboardTile {
|
|
124
|
+
/**
|
|
125
|
+
* The view name. For a tile declared in this file, assigned ONCE when the
|
|
126
|
+
* tile is added and never recomputed — deriving it from position would
|
|
127
|
+
* rename every later tile on a reorder, turning a pure-layout edit into a
|
|
128
|
+
* large diff.
|
|
129
|
+
*/
|
|
130
|
+
name: string;
|
|
131
|
+
/**
|
|
132
|
+
* The source it reads, by NAME — an index would break on reorder. May name a
|
|
133
|
+
* source this file declares in {@link DashboardDocument.sources}, or one it
|
|
134
|
+
* merely imports.
|
|
135
|
+
*/
|
|
136
|
+
source: string;
|
|
137
|
+
declaration: TileDeclaration;
|
|
138
|
+
/**
|
|
139
|
+
* Given bindings, emitted as a `+ { where: … }` refinement on the view.
|
|
140
|
+
*
|
|
141
|
+
* `op` is the comparison, and absent means `~`, which is how a `filter<…>`
|
|
142
|
+
* given binds. A plain `date` or `number` given is a VALUE, not a filter,
|
|
143
|
+
* and compares with `>=`, `<=` or `=` — measured: `created_at >= $SINCE`
|
|
144
|
+
* compiles and `created_at ~ $SINCE` does not, on a `date` given.
|
|
145
|
+
*/
|
|
146
|
+
filters?: Array<{
|
|
147
|
+
field: string;
|
|
148
|
+
given: string;
|
|
149
|
+
op?: string;
|
|
150
|
+
}>;
|
|
151
|
+
label?: string;
|
|
152
|
+
subtitle?: string;
|
|
153
|
+
colspan?: number;
|
|
154
|
+
break?: boolean;
|
|
155
|
+
borderless?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A source extension the dashboard DECLARES, holding tiles that read it.
|
|
159
|
+
*
|
|
160
|
+
* A LIST, not one source, because a composite dashboard exists precisely to
|
|
161
|
+
* combine queries no single Malloy result can span. Measured: a dashboard whose
|
|
162
|
+
* tiles come from two sources loads clean and scopes givens per source. A picker
|
|
163
|
+
* over a package catalog offers every source's views side by side, so the second
|
|
164
|
+
* tile a reader adds can already need this.
|
|
165
|
+
*
|
|
166
|
+
* May be EMPTY. A dashboard whose tiles all read imported sources declares no
|
|
167
|
+
* extension at all — `tiles=["orders -> by_brand"]` over an imported `orders` is
|
|
168
|
+
* a complete dashboard with nothing else in the file.
|
|
169
|
+
*/
|
|
170
|
+
export interface DashboardSource {
|
|
171
|
+
name: string;
|
|
172
|
+
/** What it extends: `source: <name> is <base> extend { … }`. */
|
|
173
|
+
base: string;
|
|
174
|
+
/** A `#(doc)` description on the source. */
|
|
175
|
+
doc?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The dimensions this extension declares itself, in file order. These are
|
|
178
|
+
* the only fields a `# drill` can be authored on here: a drill is a tag on
|
|
179
|
+
* the dimension's declaration, and the model's dimensions are declared in
|
|
180
|
+
* the model.
|
|
181
|
+
*/
|
|
182
|
+
dimensions?: DashboardDimension[];
|
|
183
|
+
}
|
|
184
|
+
/** A tile's identity across a reorder: what the grid keys on, a drag names and the writer matches. */
|
|
185
|
+
export declare const tileKey: (tile: {
|
|
186
|
+
source: string;
|
|
187
|
+
name: string;
|
|
188
|
+
}) => string;
|
|
189
|
+
/** `dimension: <name> is <expression>` in the dashboard's own extension. */
|
|
190
|
+
export interface DashboardDimension {
|
|
191
|
+
name: string;
|
|
192
|
+
expression: string;
|
|
193
|
+
}
|
|
194
|
+
export interface DashboardDocument {
|
|
195
|
+
title: string;
|
|
196
|
+
/** The narrative header, as markdown. Emitted as `##"` lines. */
|
|
197
|
+
description?: string;
|
|
198
|
+
/** `# dashboard { columns=N }`. */
|
|
199
|
+
columns?: number;
|
|
200
|
+
/** `## artifact { autorun=false }`. Absent means autorun. */
|
|
201
|
+
autorun?: boolean;
|
|
202
|
+
imports: DashboardImport[];
|
|
203
|
+
sources: DashboardSource[];
|
|
204
|
+
localGivens?: LocalGiven[];
|
|
205
|
+
/** `## artifact { givens { … } }` — where the controls open. */
|
|
206
|
+
startingGivens?: Record<string, string>;
|
|
207
|
+
drills?: DashboardDrill[];
|
|
208
|
+
/**
|
|
209
|
+
* Tiles in layout order. The grid flows in declaration order, so this array
|
|
210
|
+
* IS the layout, and there is no separate ordering field to fall out of step
|
|
211
|
+
* with it.
|
|
212
|
+
*
|
|
213
|
+
* One array drives both halves of the file: the `## artifact { tiles=[…] }`
|
|
214
|
+
* list and the `view:` declarations inside each extension. They therefore
|
|
215
|
+
* cannot disagree, which they can and do in hand-written files.
|
|
216
|
+
*/
|
|
217
|
+
tiles: DashboardTile[];
|
|
218
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GridTile } from '../Dashboard/DashboardGrid';
|
|
2
|
+
import { DashboardTile } from './document';
|
|
3
|
+
/**
|
|
4
|
+
* How the builder's grid is arranged: what a reorder does to the rows, and
|
|
5
|
+
* where the empty end of a row is. Pure, so the gestures that call it can be
|
|
6
|
+
* tested without a pointer.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Reordering keeps the ROW STRUCTURE and moves only the tiles through it.
|
|
10
|
+
*
|
|
11
|
+
* `# break` starts a fresh row. It is written as a tag on a tile, so the
|
|
12
|
+
* obvious reading is that it belongs to the tile and should travel with it.
|
|
13
|
+
* That is wrong in practice: drag one of four half-width tiles and its `break`
|
|
14
|
+
* lands mid-row, forcing a new row and leaving the half beside it empty — four
|
|
15
|
+
* `colspan=6` tiles stop being a 2x2 the moment one moves.
|
|
16
|
+
*
|
|
17
|
+
* The tag is positional in MEANING even though it is stored per tile: it
|
|
18
|
+
* says "a row starts here", which is a fact about the grid, not about the
|
|
19
|
+
* view that happens to sit there. So a move re-applies the break pattern by
|
|
20
|
+
* POSITION, and the surrounding tiles close up behind the one that left.
|
|
21
|
+
* Widths still travel with their tiles, because a width really is the tile's.
|
|
22
|
+
*/
|
|
23
|
+
export declare const keepRowStructure: (reordered: DashboardTile[], pattern: readonly boolean[]) => DashboardTile[];
|
|
24
|
+
/**
|
|
25
|
+
* Moving a tile INTO A GAP — the empty end of a row — is the one move that
|
|
26
|
+
* must change the row structure, because the gap IS the row structure.
|
|
27
|
+
*
|
|
28
|
+
* A gap exists for one reason: the tile after the row's last tile carries a
|
|
29
|
+
* `# break`, so it starts a fresh row instead of filling the space. Dropping a
|
|
30
|
+
* tile into that space says, as plainly as a gesture can, "this belongs up
|
|
31
|
+
* here" — and {@link keepRowStructure} would refuse it: re-applying the break
|
|
32
|
+
* by position hands the break to the moved tile, which then starts its own row
|
|
33
|
+
* and leaves the gap exactly where it was. Measured on the storefront overview
|
|
34
|
+
* with the trend narrowed to half width: the map could not be dragged up
|
|
35
|
+
* beside it at all.
|
|
36
|
+
*
|
|
37
|
+
* So a gap drop lets the break TRAVEL instead: the moved tile arrives with
|
|
38
|
+
* none, so it flows into the row; the tile that started the next row keeps its
|
|
39
|
+
* break and still does. And the row the tile LEFT closes up — if it was that
|
|
40
|
+
* row's first tile, the tile after it starts the row now, which is what the
|
|
41
|
+
* positional rule would have done there too.
|
|
42
|
+
*
|
|
43
|
+
* `to` is where the tile lands in the array it is spliced back into, after
|
|
44
|
+
* `from` has been removed — the same convention the tile-target move uses.
|
|
45
|
+
*/
|
|
46
|
+
export declare const moveIntoGap: (tiles: readonly DashboardTile[], from: number, to: number) => DashboardTile[];
|
|
47
|
+
/** One thing the grid lays out: a tile, or the empty end of a row. */
|
|
48
|
+
export type GridEntry = GridTile & ({
|
|
49
|
+
kind: "tile";
|
|
50
|
+
tile: DashboardTile;
|
|
51
|
+
/** Its place among the TILES — what a sortable item is told. */
|
|
52
|
+
index: number;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "gap";
|
|
55
|
+
after: string;
|
|
56
|
+
});
|
|
57
|
+
export declare const tileEntry: (tile: DashboardTile, index: number) => GridEntry;
|
|
58
|
+
/** A gap's id: its drop target's, and the grid's key for it. */
|
|
59
|
+
export declare const gapId: (after: string) => string;
|
|
60
|
+
/**
|
|
61
|
+
* The grid's entries with a drop target in every gap.
|
|
62
|
+
*
|
|
63
|
+
* A flow grid has no element where a row runs out; the space is simply not
|
|
64
|
+
* painted, so there is nothing for a drag to be "over". This walks the tiles
|
|
65
|
+
* as the grid will place them — `# break` starts a row, and so does a tile too
|
|
66
|
+
* wide for what is left of the current one — and wherever a row ends short of
|
|
67
|
+
* the last column, lays a gap entry spanning exactly the columns left over. It
|
|
68
|
+
* fills space that was already empty, so adding it moves nothing; and it
|
|
69
|
+
* carries the key of the tile it follows, which is what a drop on it needs.
|
|
70
|
+
*/
|
|
71
|
+
export declare const withGaps: (tiles: readonly DashboardTile[], columns: number) => GridEntry[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const isIdentifier: (text: string) => boolean;
|
|
2
|
+
/** A one-line `<keyword>: <name> is <rest>` declaration. */
|
|
3
|
+
export interface DeclarationAt {
|
|
4
|
+
line: number;
|
|
5
|
+
/** Everything after `is`, trimmed: a base view, an expression, or `{`. */
|
|
6
|
+
rest: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `<keyword>:` declarations under `source: <owner>`, in file order. The
|
|
10
|
+
* body of a source ends at the next top-level declaration or `##` line.
|
|
11
|
+
*/
|
|
12
|
+
export declare function declarationsUnder(lines: string[], owner: string, keyword: "view" | "dimension"): Map<string, DeclarationAt>;
|
|
13
|
+
/** The line declaring `<keyword>: <name> is`, or -1. */
|
|
14
|
+
export declare function declarationLine(lines: string[], keyword: "view" | "source", name: string): number;
|
|
15
|
+
/** The line carrying the model-level `## artifact` tag, or -1. */
|
|
16
|
+
export declare const artifactLine: (lines: string[]) => number;
|
|
17
|
+
/** A `given:` declaration: its line, and the block header when it is in one. */
|
|
18
|
+
export interface GivenAt {
|
|
19
|
+
line: number;
|
|
20
|
+
blockHeader?: number;
|
|
21
|
+
/** `NAME :: type is default`, as written. */
|
|
22
|
+
declaration: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every `given:` declaration, by name, in both spellings Malloy accepts:
|
|
26
|
+
*
|
|
27
|
+
* given: CATEGORY :: filter<string> is f'' // one per line
|
|
28
|
+
*
|
|
29
|
+
* given: // a block
|
|
30
|
+
* CATEGORY :: filter<string> is f''
|
|
31
|
+
* SINCE :: date is @2023-01-01
|
|
32
|
+
*/
|
|
33
|
+
export declare function givenDeclarations(lines: string[]): Map<string, GivenAt>;
|
|
34
|
+
/** A tile expression's steps: `orders -> by_brand + { limit: 2 }`. */
|
|
35
|
+
export interface TileSteps {
|
|
36
|
+
source: string;
|
|
37
|
+
view: string;
|
|
38
|
+
/** The refinement on the view, `+ { … }`, when the expression carries one. */
|
|
39
|
+
refinement?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `source -> view`, optionally refined — the one form the builder lays out.
|
|
43
|
+
* Undefined for anything else: an inline stage, or a longer pipeline.
|
|
44
|
+
*/
|
|
45
|
+
export declare function tileSteps(expression: string | undefined): TileSteps | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A new dashboard file, the way the builder would have written it: the
|
|
3
|
+
* dashboard-declared-givens convention with no givens yet, one extension of
|
|
4
|
+
* the chosen source named the way the builder names one (`<source>_tiles`),
|
|
5
|
+
* and one tile on it — the reader needs a tile to lay out, and a first view
|
|
6
|
+
* is what the author picked anyway.
|
|
7
|
+
*/
|
|
8
|
+
export interface NewDashboard {
|
|
9
|
+
title: string;
|
|
10
|
+
/** The model that declares the source, relative to the package root. */
|
|
11
|
+
modelPath: string;
|
|
12
|
+
source: string;
|
|
13
|
+
view: string;
|
|
14
|
+
}
|
|
15
|
+
/** `Sales by region` → `sales-by-region`: the file name, and so the slug. */
|
|
16
|
+
export declare function slugFor(title: string): string;
|
|
17
|
+
export declare function newDashboardSource({ title, modelPath, source, view, }: NewDashboard): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Given } from '../../client';
|
|
2
|
+
import { GivenValue } from '../../hooks/givenValue';
|
|
3
|
+
import { DashboardDocument, DashboardTile } from './document';
|
|
4
|
+
/**
|
|
5
|
+
* What a reader would see if the DOCUMENT were the file: the controls, and
|
|
6
|
+
* each tile's query — so the builder's live view follows an edit the moment it
|
|
7
|
+
* is made, rather than the file on the server's disk. Run from the file, an
|
|
8
|
+
* unbound tile keeps filtering and a removed control stays in the row until a
|
|
9
|
+
* save lands, so the edit looks like it did nothing.
|
|
10
|
+
*
|
|
11
|
+
* Two functions, one per half of what a reader sees. Both are pure, so the
|
|
12
|
+
* host can hold the live document and derive its preview from it. A given the
|
|
13
|
+
* document declares but the server's model has not compiled cannot be SENT to
|
|
14
|
+
* it — the server refuses a given it does not know — so a new control's value
|
|
15
|
+
* is written into the query as a literal instead, and the new filter works the
|
|
16
|
+
* moment it is added rather than after a save.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The controls this document shows: every given some tile binds, this file's
|
|
20
|
+
* own declarations first in declaration order, then the model's.
|
|
21
|
+
*
|
|
22
|
+
* That is the reader's rule — only a given some tile reads becomes a control
|
|
23
|
+
* — applied to the document instead of the manifest. A local declaration is
|
|
24
|
+
* built into a `Given` from its control contract; a model given is the
|
|
25
|
+
* manifest's own spec, which carries what the file cannot say (`givenNames` a
|
|
26
|
+
* suggest is gated by, for one).
|
|
27
|
+
*/
|
|
28
|
+
export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[]): Given[];
|
|
29
|
+
/** A tile's query as the document has it, and the givens it sends. */
|
|
30
|
+
export interface PreviewTileQuery {
|
|
31
|
+
/** A run expression, without `run:` — what `DashboardTile.tile` takes. */
|
|
32
|
+
expression: string;
|
|
33
|
+
/**
|
|
34
|
+
* The givens this tile binds and the server can take, for narrowing the
|
|
35
|
+
* request. Undefined for a tile whose bindings live in the model, where the
|
|
36
|
+
* document cannot know them: send the whole row, as the reader does.
|
|
37
|
+
*/
|
|
38
|
+
givenNames: string[] | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A tile's query with the DOCUMENT's bindings, run on the dashboard's own
|
|
42
|
+
* extension.
|
|
43
|
+
*
|
|
44
|
+
* `overview -> revenue_trend` would run the view AS SAVED, bindings and all.
|
|
45
|
+
* `overview -> sales_by_month + { where: category ~ $CATEGORY }` is the base
|
|
46
|
+
* view the tile names, on the same extension, refined by what the document
|
|
47
|
+
* binds now — which is exactly the declaration the writer would produce, run
|
|
48
|
+
* before it is written. Every reference tile has such a base view, and the
|
|
49
|
+
* extension inherits it: `view: x is base_view + …` can only name a view of the
|
|
50
|
+
* source the extension extends.
|
|
51
|
+
*
|
|
52
|
+
* `runnable` is the set of givens the server's model declares; a binding to
|
|
53
|
+
* one of them is written as `$NAME` and the given is sent with the request. A
|
|
54
|
+
* binding to a given outside it — one this document just declared, which the
|
|
55
|
+
* server would refuse by name — is written with its VALUE as a literal,
|
|
56
|
+
* `where: brand ~ f'Nike'`, from `values` and the declaration's type; with no
|
|
57
|
+
* value yet it is left out, which is what an empty filter means. A binding to
|
|
58
|
+
* a given neither side knows is left out too.
|
|
59
|
+
*/
|
|
60
|
+
export declare function previewTileQuery(document: DashboardDocument, tile: DashboardTile, runnable: ReadonlySet<string>, values?: ReadonlyMap<string, GivenValue>): PreviewTileQuery;
|