@malloy-publisher/sdk 0.2.6 → 0.3.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 +172 -204
- package/dist/ServerProvider-CGnLjzag.cjs.js +1 -0
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-DSK9rfSY.es.js} +245 -245
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +4 -2
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +36 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +18 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +1 -0
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +2 -3
- package/dist/components/styles.d.ts +3 -3
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-xdZbLgaF.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +281 -1
- package/dist/index.es.js +45803 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/package.json +2 -6
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.tsx +60 -95
- package/src/components/Dashboard/DashboardTile.tsx +25 -2
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +137 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +129 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +46 -0
- package/src/components/DocumentStorage/index.ts +15 -0
- package/src/components/Environment/Connections.tsx +15 -15
- package/src/components/Model/ModelCell.tsx +2 -1
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +10 -76
- package/src/components/Notebook/NotebookCell.tsx +2 -8
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +21 -24
- package/src/components/RenderedResult/index.ts +15 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +5 -0
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +5 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/vite.config.ts +0 -1
- package/dist/ServerProvider-xXW1HJOJ.cjs.js +0 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-RvrkY1Ss.cjs.js +0 -148
- package/dist/index-B3scIDRd.cjs.js +0 -356
- package/dist/index-Bda7HuZc.es.js +0 -66409
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- package/src/components/Workbook/index.ts +0 -10
package/dist/client/api.d.ts
CHANGED
|
@@ -574,7 +574,7 @@ export interface CompiledModel {
|
|
|
574
574
|
'sourceText'?: string;
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
|
-
* Database connection configuration and metadata
|
|
577
|
+
* Database connection configuration and metadata. Credential fields are WRITE-ONLY. They are accepted on create and update and no read returns them, so this one schema describes a request body in full and a response body with its credentials omitted. Omitted rather than masked, so a client cannot round-trip a placeholder back into stored config as a real credential. An update does not have to resend a credential it could not read; a field left out keeps its stored value, a field sent replaces it, and a field sent empty clears it.
|
|
578
578
|
* @export
|
|
579
579
|
* @interface Connection
|
|
580
580
|
*/
|
|
@@ -597,6 +597,12 @@ export interface Connection {
|
|
|
597
597
|
* @memberof Connection
|
|
598
598
|
*/
|
|
599
599
|
'type'?: ConnectionTypeEnum;
|
|
600
|
+
/**
|
|
601
|
+
* Read-only. Dotted paths of the fields this connection has stored that this response does not return. In practice that is its credentials, but it is any stored field the response withholds, so a field the server does not publish appears here too. Names only, never a value. It exists because a client otherwise cannot tell a credential that is set from one that is absent, and so cannot tell whether leaving a box empty keeps something or leaves the connection without a credential. An editor should read it to label the boxes that are already filled. Ignored on write.
|
|
602
|
+
* @type {Array<string>}
|
|
603
|
+
* @memberof Connection
|
|
604
|
+
*/
|
|
605
|
+
'withheldFields'?: Array<string>;
|
|
600
606
|
/**
|
|
601
607
|
* Optional, opaque, stable fingerprint of this connection\'s data identity. It is a hash of the configuration that determines *which data* the connection reaches (its data-locating settings), and deliberately excludes credentials and other secret values, so it stays constant across credential rotation and changes only when the connection is pointed at different data. When present, it is used as this connection\'s contribution to content-addressed build identifiers so that builds re-address only when the underlying data identity actually changes; consumers should treat it as an opaque token and use the supplied value verbatim rather than deriving their own. This field is optional — when omitted, a connection identity is derived locally instead. Because the fingerprint replaces the derived digest verbatim, it must vary with anything that changes which data the connection can reach — including the impersonated identity: two environments on the same project with different impersonateServiceAccount values but the same fingerprint would share persisted-table ids.
|
|
602
608
|
* @type {string}
|
|
@@ -1491,6 +1497,12 @@ export interface GivenSuggest {
|
|
|
1491
1497
|
* @memberof GivenSuggest
|
|
1492
1498
|
*/
|
|
1493
1499
|
'dimension'?: string;
|
|
1500
|
+
/**
|
|
1501
|
+
* The givens the suggest query needs in its request to run: the ones the source it reads is scoped by (a source-level `where: … ~ $X`) or gated by (an `#(authorize)` reading `$X`), plus, for the `query` form, the named query\'s own. A client sends the current values of exactly these, so a gated source\'s options load while the option list still does not depend on the page\'s other filters. Absent when the query needs none.
|
|
1502
|
+
* @type {Array<string>}
|
|
1503
|
+
* @memberof GivenSuggest
|
|
1504
|
+
*/
|
|
1505
|
+
'givenNames'?: Array<string>;
|
|
1494
1506
|
}
|
|
1495
1507
|
/**
|
|
1496
1508
|
* One incremental source\'s `covered_through` boundary: the table it belongs to, the boundary itself, and the source definition it was measured under. Reported on the manifest entry of every incrementally refreshed source. A caller that owns the ledger stores each one and returns it verbatim in `BuildInstructions.ledger` on the next run — only the publisher derives these values. A returned entry is validated at create time: one naming a table the run does not instruct, or whose `sourceEntityId` is no longer the source\'s, is a 400. After a publish or rollback that changes the source, delete the entry (the source seeds) or set `reseed`.
|
package/dist/client/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../ServerProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../ServerProvider-CGnLjzag.cjs.js");exports.AttachedDatabaseTypeEnum=e.AttachedDatabaseTypeEnum;exports.AzureConnectionAuthTypeEnum=e.AzureConnectionAuthTypeEnum;exports.CompileProblemSeverityEnum=e.CompileProblemSeverityEnum;exports.CompileRequestScopeEnum=e.CompileRequestScopeEnum;exports.CompileResultStatusEnum=e.CompileResultStatusEnum;exports.Configuration=e.Configuration;exports.ConnectionProxyTypeEnum=e.ConnectionProxyTypeEnum;exports.ConnectionStatusStatusEnum=e.ConnectionStatusStatusEnum;exports.ConnectionTypeEnum=e.ConnectionTypeEnum;exports.ConnectionsApi=e.ConnectionsApi;exports.ConnectionsApiAxiosParamCreator=e.ConnectionsApiAxiosParamCreator;exports.ConnectionsApiFactory=e.ConnectionsApiFactory;exports.ConnectionsApiFp=e.ConnectionsApiFp;exports.ConnectionsTestApi=e.ConnectionsTestApi;exports.ConnectionsTestApiAxiosParamCreator=e.ConnectionsTestApiAxiosParamCreator;exports.ConnectionsTestApiFactory=e.ConnectionsTestApiFactory;exports.ConnectionsTestApiFp=e.ConnectionsTestApiFp;exports.DashboardsApi=e.DashboardsApi;exports.DashboardsApiAxiosParamCreator=e.DashboardsApiAxiosParamCreator;exports.DashboardsApiFactory=e.DashboardsApiFactory;exports.DashboardsApiFp=e.DashboardsApiFp;exports.DataAppFitEnum=e.DataAppFitEnum;exports.DataAppsApi=e.DataAppsApi;exports.DataAppsApiAxiosParamCreator=e.DataAppsApiAxiosParamCreator;exports.DataAppsApiFactory=e.DataAppsApiFactory;exports.DataAppsApiFp=e.DataAppsApiFp;exports.DatabaseTypeEnum=e.DatabaseTypeEnum;exports.DatabasesApi=e.DatabasesApi;exports.DatabasesApiAxiosParamCreator=e.DatabasesApiAxiosParamCreator;exports.DatabasesApiFactory=e.DatabasesApiFactory;exports.DatabasesApiFp=e.DatabasesApiFp;exports.EnvironmentsApi=e.EnvironmentsApi;exports.EnvironmentsApiAxiosParamCreator=e.EnvironmentsApiAxiosParamCreator;exports.EnvironmentsApiFactory=e.EnvironmentsApiFactory;exports.EnvironmentsApiFp=e.EnvironmentsApiFp;exports.ExecuteNotebookCellBypassFiltersEnum=e.ExecuteNotebookCellBypassFiltersEnum;exports.FilterTypeEnum=e.FilterTypeEnum;exports.FreshnessFallbackEnum=e.FreshnessFallbackEnum;exports.GivenControlEnum=e.GivenControlEnum;exports.LedgerEntryStrategyEnum=e.LedgerEntryStrategyEnum;exports.LogMessageSeverityEnum=e.LogMessageSeverityEnum;exports.ManifestEntryFreshnessFallbackEnum=e.ManifestEntryFreshnessFallbackEnum;exports.ManifestEntryOriginEnum=e.ManifestEntryOriginEnum;exports.ManifestEntryRefreshEnum=e.ManifestEntryRefreshEnum;exports.MaterializationActionActionEnum=e.MaterializationActionActionEnum;exports.MaterializationStatus=e.MaterializationStatus;exports.MaterializationsApi=e.MaterializationsApi;exports.MaterializationsApiAxiosParamCreator=e.MaterializationsApiAxiosParamCreator;exports.MaterializationsApiFactory=e.MaterializationsApiFactory;exports.MaterializationsApiFp=e.MaterializationsApiFp;exports.ModelsApi=e.ModelsApi;exports.ModelsApiAxiosParamCreator=e.ModelsApiAxiosParamCreator;exports.ModelsApiFactory=e.ModelsApiFactory;exports.ModelsApiFp=e.ModelsApiFp;exports.NotebookCellResultTypeEnum=e.NotebookCellResultTypeEnum;exports.NotebookCellTypeEnum=e.NotebookCellTypeEnum;exports.NotebooksApi=e.NotebooksApi;exports.NotebooksApiAxiosParamCreator=e.NotebooksApiAxiosParamCreator;exports.NotebooksApiFactory=e.NotebooksApiFactory;exports.NotebooksApiFp=e.NotebooksApiFp;exports.PackageEmbeddingIndexStatusEnum=e.PackageEmbeddingIndexStatusEnum;exports.PackageManifestBindingStatusEnum=e.PackageManifestBindingStatusEnum;exports.PackageQueryableSourcesEnum=e.PackageQueryableSourcesEnum;exports.PackageScopeEnum=e.PackageScopeEnum;exports.PackageStorageServeBindingsInnerOriginEnum=e.PackageStorageServeBindingsInnerOriginEnum;exports.PackageWarningsInnerSeverityEnum=e.PackageWarningsInnerSeverityEnum;exports.PackagesApi=e.PackagesApi;exports.PackagesApiAxiosParamCreator=e.PackagesApiAxiosParamCreator;exports.PackagesApiFactory=e.PackagesApiFactory;exports.PackagesApiFp=e.PackagesApiFp;exports.PersistSourcePlanOriginEnum=e.PersistSourcePlanOriginEnum;exports.PostgresConnectionSslmodeEnum=e.PostgresConnectionSslmodeEnum;exports.PublisherApi=e.PublisherApi;exports.PublisherApiAxiosParamCreator=e.PublisherApiAxiosParamCreator;exports.PublisherApiFactory=e.PublisherApiFactory;exports.PublisherApiFp=e.PublisherApiFp;exports.QueryClass=e.QueryClass;exports.QueryResultQueryRowLimitSourceEnum=e.QueryResultQueryRowLimitSourceEnum;exports.QueryResultServedFromEnum=e.QueryResultServedFromEnum;exports.Realization=e.Realization;exports.RefusedSourceReasonEnum=e.RefusedSourceReasonEnum;exports.RefusedSourceTierEnum=e.RefusedSourceTierEnum;exports.RunContextTriggerEnum=e.RunContextTriggerEnum;exports.S3ConnectionProviderEnum=e.S3ConnectionProviderEnum;exports.ServerProvider=e.ServerProvider;exports.ServerStatusOperationalStateEnum=e.ServerStatusOperationalStateEnum;exports.ThemeDefaultModeEnum=e.ThemeDefaultModeEnum;exports.WatchModeApi=e.WatchModeApi;exports.WatchModeApiAxiosParamCreator=e.WatchModeApiAxiosParamCreator;exports.WatchModeApiFactory=e.WatchModeApiFactory;exports.WatchModeApiFp=e.WatchModeApiFp;exports.globalQueryClient=e.globalQueryClient;exports.useServer=e.useServer;
|
package/dist/client/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, a as i, C as o, b as n, c as t, aC as r, e as p, f as u, d as A, O as m, I as c, K as E, J as l, X as C, U as y, W as P, V as F, $ as b, Y as g, _ as d, Z as S, D as k, a3 as M, a0 as h, a2 as x, a1 as v, h as D, a7 as T, a4 as R, a6 as f, a5 as z, ab as N, a8 as Q, aa as W, a9 as B, ap as O, F as I, i as L, G as q, L as w, j, k as G, M as H, l as J, ag as K, m as U, af as V, ac as X, ae as Y, ad as Z, ak as _, ah as $, aj as aa, ai as sa, n as ea, N as ia, ao as oa, al as na, an as ta, am as ra, q as pa, p as ua, o as Aa, P as ma, r as ca, s as Ea, at as la, aq as Ca, as as ya, ar as Pa, t as Fa, v as ba, ax as ga, au as da, aw as Sa, av as ka, Q as Ma, w as ha, x as xa, R as va, z as Da, y as Ta, B as Ra, E as fa, S as za, H as Na, T as Qa, aB as Wa, ay as Ba, aA as Oa, az as Ia, g as La, u as qa } from "../ServerProvider-
|
|
1
|
+
import { A as e, a as i, C as o, b as n, c as t, aC as r, e as p, f as u, d as A, O as m, I as c, K as E, J as l, X as C, U as y, W as P, V as F, $ as b, Y as g, _ as d, Z as S, D as k, a3 as M, a0 as h, a2 as x, a1 as v, h as D, a7 as T, a4 as R, a6 as f, a5 as z, ab as N, a8 as Q, aa as W, a9 as B, ap as O, F as I, i as L, G as q, L as w, j, k as G, M as H, l as J, ag as K, m as U, af as V, ac as X, ae as Y, ad as Z, ak as _, ah as $, aj as aa, ai as sa, n as ea, N as ia, ao as oa, al as na, an as ta, am as ra, q as pa, p as ua, o as Aa, P as ma, r as ca, s as Ea, at as la, aq as Ca, as as ya, ar as Pa, t as Fa, v as ba, ax as ga, au as da, aw as Sa, av as ka, Q as Ma, w as ha, x as xa, R as va, z as Da, y as Ta, B as Ra, E as fa, S as za, H as Na, T as Qa, aB as Wa, ay as Ba, aA as Oa, az as Ia, g as La, u as qa } from "../ServerProvider-DSK9rfSY.es.js";
|
|
2
2
|
export {
|
|
3
3
|
e as AttachedDatabaseTypeEnum,
|
|
4
4
|
i as AzureConnectionAuthTypeEnum,
|
|
@@ -5,9 +5,8 @@ export interface ApiError extends Error {
|
|
|
5
5
|
message: string;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
interface ApiErrorDisplayProps {
|
|
8
|
+
export interface ApiErrorDisplayProps {
|
|
9
9
|
error: ApiError;
|
|
10
10
|
context?: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function ApiErrorDisplay({ error, context }: ApiErrorDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -30,8 +30,10 @@ export interface DashboardProps {
|
|
|
30
30
|
onNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
31
31
|
/**
|
|
32
32
|
* Height cap for a result panel. Left unset, each form gets the cap that
|
|
33
|
-
* suits its shape
|
|
34
|
-
*
|
|
33
|
+
* suits its shape: {@link TILE_MAX_HEIGHT} per tile for the composite form,
|
|
34
|
+
* and no cap at all for the single-query form, where the one result IS the
|
|
35
|
+
* dashboard and a cap would clip the page rather than tidy it. Set it to
|
|
36
|
+
* hold a dashboard to a fixed box, as an embedding host might.
|
|
35
37
|
*/
|
|
36
38
|
height?: number;
|
|
37
39
|
maxResultSize?: number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface ResultShape {
|
|
2
|
+
schema?: {
|
|
3
|
+
fields?: Array<{
|
|
4
|
+
kind?: string;
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
data?: {
|
|
8
|
+
kind?: string;
|
|
9
|
+
array_value?: unknown[];
|
|
10
|
+
};
|
|
11
|
+
annotations?: Array<{
|
|
12
|
+
value?: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* True when the result is one row consisting solely of measures: the shape a
|
|
17
|
+
* `view: kpis is { aggregate: … }` tile produces.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isMeasureRow(result: ResultShape): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* True when any annotation on the result names a render tag.
|
|
22
|
+
*
|
|
23
|
+
* A `# ` line is a MOTLY tag list: space-separated properties, each a bare name
|
|
24
|
+
* or `name=value`, with `{ … }` sub-properties and `.` paths. Quoted values are
|
|
25
|
+
* dropped before tokenizing so a space inside a label does not split it; the
|
|
26
|
+
* remaining tokens are compared whole, so `bar_chart` matches and `bar_charts`
|
|
27
|
+
* does not. `#(…)` and `#"` lines are documentation, never render tags.
|
|
28
|
+
*/
|
|
29
|
+
export declare function carriesRenderTag(annotations: readonly string[]): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The result with `# big_value` prepended when {@link isMeasureRow} and no render
|
|
32
|
+
* tag is already present; otherwise the input string untouched. A result that
|
|
33
|
+
* does not parse as JSON is returned as is, for the renderer to report.
|
|
34
|
+
*/
|
|
35
|
+
export declare function promoteMeasureRowToKpis(result: string): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DocumentLocator, DocumentStorage, DocumentType, Workspace } from './DocumentStorage';
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DocumentStorage} in the browser's localStorage: one workspace,
|
|
4
|
+
* `Local`, private to this browser and this origin. The Console's default, and
|
|
5
|
+
* what a host uses before it has a store of its own.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BrowserDocumentStorage implements DocumentStorage {
|
|
8
|
+
listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
|
|
9
|
+
listDocuments(workspace: Workspace, type?: DocumentType): Promise<DocumentLocator[]>;
|
|
10
|
+
getDocument(locator: DocumentLocator): Promise<string>;
|
|
11
|
+
saveDocument(locator: DocumentLocator, content: string): Promise<void>;
|
|
12
|
+
deleteDocument(locator: DocumentLocator): Promise<void>;
|
|
13
|
+
moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where authored documents are kept, as an interface the host hands the SDK.
|
|
3
|
+
*
|
|
4
|
+
* The SDK renders dashboards and notebooks that a Publisher server serves out
|
|
5
|
+
* of a package, and it will author them too, but it does not decide where an
|
|
6
|
+
* authored document goes. That is the host's business: the Console keeps one
|
|
7
|
+
* in the browser, a platform keeps one in its own document store, a repo-backed
|
|
8
|
+
* host writes it to the package directory. So the SDK asks for a
|
|
9
|
+
* {@link DocumentStorage} through {@link DocumentStorageProvider} and calls it,
|
|
10
|
+
* and never touches a backend itself.
|
|
11
|
+
*
|
|
12
|
+
* A document is a string. The interface does not know whether it is a
|
|
13
|
+
* `dashboards/*.malloy` file, a `.malloynb`, or something else; the
|
|
14
|
+
* {@link DocumentLocator.type} says what kind it is so a backend can keep the
|
|
15
|
+
* kinds apart (a database column, a directory, a key prefix) and a listing can
|
|
16
|
+
* ask for one kind. Everything else a backend may know about a document, who
|
|
17
|
+
* changed it and when, who may see it, stays with the backend.
|
|
18
|
+
*
|
|
19
|
+
* Every method rejects rather than returning a sentinel when the document is
|
|
20
|
+
* not there, so a caller can tell "missing" from "empty".
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The kinds of document the SDK authors. A `dashboard` is a
|
|
24
|
+
* `dashboards/<slug>.malloy` file; a `notebook` is a `.malloynb`.
|
|
25
|
+
*/
|
|
26
|
+
export type DocumentType = "dashboard" | "notebook";
|
|
27
|
+
/** A place documents live, as the backend presents it to a reader. */
|
|
28
|
+
export interface Workspace {
|
|
29
|
+
name: string;
|
|
30
|
+
/** False for a workspace this reader may list and open but not save into. */
|
|
31
|
+
writeable: boolean;
|
|
32
|
+
description: string;
|
|
33
|
+
}
|
|
34
|
+
/** One document's address: which workspace, which kind, and its path there. */
|
|
35
|
+
export interface DocumentLocator {
|
|
36
|
+
workspace: string;
|
|
37
|
+
type: DocumentType;
|
|
38
|
+
/**
|
|
39
|
+
* The document's path within the workspace, spelled the way the backend
|
|
40
|
+
* spells it. For a repo-backed store that is the file path relative to the
|
|
41
|
+
* package (`dashboards/overview.malloy`); a database store may use a slug.
|
|
42
|
+
*/
|
|
43
|
+
path: string;
|
|
44
|
+
}
|
|
45
|
+
export interface DocumentStorage {
|
|
46
|
+
/** The workspaces this reader can see; only the writeable ones when asked. */
|
|
47
|
+
listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
|
|
48
|
+
/** Every document in a workspace, or only those of one kind. */
|
|
49
|
+
listDocuments(workspace: Workspace, type?: DocumentType): Promise<DocumentLocator[]>;
|
|
50
|
+
/** The document's content. Rejects when there is no document there. */
|
|
51
|
+
getDocument(locator: DocumentLocator): Promise<string>;
|
|
52
|
+
/** Write the content, creating the document or replacing it. */
|
|
53
|
+
saveDocument(locator: DocumentLocator, content: string): Promise<void>;
|
|
54
|
+
/** Remove the document. Rejects when there is no document there. */
|
|
55
|
+
deleteDocument(locator: DocumentLocator): Promise<void>;
|
|
56
|
+
/** Rename or relocate a document, keeping its content. Rejects when `from` is missing. */
|
|
57
|
+
moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DocumentStorage } from './DocumentStorage';
|
|
3
|
+
export interface DocumentStorageProviderProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
documentStorage: DocumentStorage;
|
|
6
|
+
}
|
|
7
|
+
interface DocumentStorageContextValue {
|
|
8
|
+
documentStorage: DocumentStorage;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Hands a {@link DocumentStorage} to every SDK component beneath it. The host
|
|
12
|
+
* constructs the storage; the SDK only ever reads it through
|
|
13
|
+
* {@link useDocumentStorage}.
|
|
14
|
+
*/
|
|
15
|
+
export declare function DocumentStorageProvider({ children, documentStorage, }: DocumentStorageProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
/** The host's storage, or a thrown error outside a provider: there is no default. */
|
|
17
|
+
export declare function useDocumentStorage(): DocumentStorageContextValue;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { DocumentLocator, DocumentStorage, DocumentType, Workspace, } from './DocumentStorage';
|
|
2
|
+
export { DocumentStorageProvider, useDocumentStorage, type DocumentStorageProviderProps, } from './DocumentStorageProvider';
|
|
3
|
+
export { BrowserDocumentStorage } from './BrowserDocumentStorage';
|
|
@@ -2,7 +2,6 @@ export { default as Model } from './Model';
|
|
|
2
2
|
export { ModelExplorer } from './ModelExplorer';
|
|
3
3
|
export { ModelExplorerDialog } from './ModelExplorerDialog';
|
|
4
4
|
export { SourcesExplorer } from './SourcesExplorer';
|
|
5
|
-
export { SourceExplorerComponent } from './SourcesExplorer';
|
|
6
5
|
export type { SourceAndPath, QueryExplorerResult } from './SourcesExplorer';
|
|
7
6
|
export { useModelData } from './useModelData';
|
|
8
7
|
export type { ModelExplorerProps } from './ModelExplorer';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { ResultSizing } from './resultSizing';
|
|
2
3
|
import { DrillBinding } from '../drill/useDrill';
|
|
3
4
|
type MalloyRenderElement = HTMLElement & Record<string, unknown>;
|
|
4
5
|
declare global {
|
|
@@ -12,7 +13,18 @@ interface RenderedResultProps {
|
|
|
12
13
|
result: string;
|
|
13
14
|
height?: number;
|
|
14
15
|
isFillElement?: (boolean: any) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The measured content height. Fires only for a content-sized root; a
|
|
18
|
+
* container-sized one has no height of its own to report. See
|
|
19
|
+
* {@link resultSizing}.
|
|
20
|
+
*/
|
|
15
21
|
onSizeChange?: (height: number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Which sizing rule the rendered root follows, as soon as the renderer's
|
|
24
|
+
* metadata says. Lets a caller stop treating its cap as a height for a
|
|
25
|
+
* result that will never report one.
|
|
26
|
+
*/
|
|
27
|
+
onSizing?: (sizing: ResultSizing) => void;
|
|
16
28
|
/**
|
|
17
29
|
* Makes `# drill` cells clickable, and makes them look it. From `useDrill`
|
|
18
30
|
* on the host surface, which decides where a click may go; omitted where
|
|
@@ -2,7 +2,13 @@ import { LogMessage } from '../../client';
|
|
|
2
2
|
import { DrillBinding } from '../drill/useDrill';
|
|
3
3
|
interface ResultContainerProps {
|
|
4
4
|
result: string | undefined;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Cap on the panel's height. A CAP, not a height request: a result shorter
|
|
7
|
+
* than this paints at its own height. Leave it out for no cap, which is what
|
|
8
|
+
* the single-query dashboard form wants — a result that IS the page should
|
|
9
|
+
* not be clipped to tidy it.
|
|
10
|
+
*/
|
|
11
|
+
maxHeight?: number;
|
|
6
12
|
maxResultSize?: number;
|
|
7
13
|
renderLogs?: LogMessage[];
|
|
8
14
|
drill?: DrillBinding;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { default as RenderedResult } from './RenderedResult';
|
|
2
2
|
export { default as ResultContainer } from './ResultContainer';
|
|
3
|
+
export { contentNodeDepth, INITIAL_RENDER_HEIGHT, initialResultHeight, measureContentHeight, MODEL_CELL_MAX_HEIGHT, NOTEBOOK_CELL_MAX_HEIGHT, remeasuresAfterReady, resolveResultHeight, RESULTS_DIALOG_MAX_HEIGHT, resultSizing, TILE_MAX_HEIGHT, UNCAPPED_CONTAINER_HEIGHT, type ResultSizing, } from './resultSizing';
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every height decision a rendered result takes, in one module.
|
|
3
|
+
*
|
|
4
|
+
* Three things used to be tangled together and spread across four files: how
|
|
5
|
+
* tall a result should paint, whether it is the kind of result that has a
|
|
6
|
+
* height of its own at all, and which DOM node that height can be read off.
|
|
7
|
+
* They are separated here so the first two are pure and testable, and the third
|
|
8
|
+
* is the single place this package touches the renderer's DOM.
|
|
9
|
+
*
|
|
10
|
+
* The renderer exposes no size API — `MalloyViz` offers `onReady` and
|
|
11
|
+
* `getMetadata()` and nothing that reports a height — so a result that sizes
|
|
12
|
+
* itself has to be measured. What CAN come from the public metadata is whether
|
|
13
|
+
* it is worth measuring, from two sources, in this order:
|
|
14
|
+
*
|
|
15
|
+
* 1. The root's render plugin declares `sizingStrategy: "fill" | "fixed"`,
|
|
16
|
+
* which is the renderer's own answer to exactly this question. Read it
|
|
17
|
+
* through `getPluginsForField(getRootField().key)`.
|
|
18
|
+
* 2. Where no plugin claims the root — a table, a `# dashboard` grid — fall
|
|
19
|
+
* back to `renderAs()` and the lists below.
|
|
20
|
+
*
|
|
21
|
+
* Keying off either instead of the rendered class names is what keeps the DOM
|
|
22
|
+
* contact down to one bounded walk.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* How a rendered root arrives at its height.
|
|
26
|
+
*
|
|
27
|
+
* - `content`: it has a height of its own and the container should shrink to
|
|
28
|
+
* it — a table, a `# dashboard` grid, a `# big_value`, a list, and the maps,
|
|
29
|
+
* whose height comes from their aspect ratio.
|
|
30
|
+
* - `container`: it fills whatever box it is handed and has no height to
|
|
31
|
+
* report. The plotted charts, and only those. Measuring one tells you what
|
|
32
|
+
* you already gave it, minus the inset it drew itself at.
|
|
33
|
+
*/
|
|
34
|
+
export type ResultSizing = "content" | "container";
|
|
35
|
+
/**
|
|
36
|
+
* Which sizing rule a root follows.
|
|
37
|
+
*
|
|
38
|
+
* `strategy` is the root plugin's declared `sizingStrategy` and wins when it is
|
|
39
|
+
* there, because it is the renderer answering the question directly rather than
|
|
40
|
+
* this SDK inferring it from a name. Note it is the PLUGIN's strategy, not the
|
|
41
|
+
* field entry's: `renderProperties.sizingStrategy` on the root reads `"fit"` for
|
|
42
|
+
* every result and says nothing.
|
|
43
|
+
*
|
|
44
|
+
* Unknown, with no plugin — a renderer newer than this SDK — is treated as
|
|
45
|
+
* content-sized, which is the behavior every root had before this
|
|
46
|
+
* classification existed: measure once and use what comes back.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resultSizing(renderAs: string | undefined, strategy?: string | undefined): ResultSizing;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the result keeps being measured after the first height lands.
|
|
51
|
+
*
|
|
52
|
+
* It has to be, and the acute case is a table. The renderer signals `onReady`
|
|
53
|
+
* as soon as it knows it can paint, and for a table that is immediately — a
|
|
54
|
+
* chart waits for a non-zero parent size, a table does not — so a single
|
|
55
|
+
* measurement taken there lands before the table's virtualized grid has laid
|
|
56
|
+
* out, and reads a height the table never keeps. A `# big_value` row loses the
|
|
57
|
+
* same race more quietly: it reports the box it was handed, so the panel simply
|
|
58
|
+
* keeps the cap and the tile carries a band of empty space under its numbers.
|
|
59
|
+
*
|
|
60
|
+
* Re-measuring a content-sized root TERMINATES, because its height does not
|
|
61
|
+
* depend on the box it is in. `.malloy-table.root` is
|
|
62
|
+
* `height: fit-content; max-height: 100%` in the renderer's own CSS and the
|
|
63
|
+
* wrappers between it and the container add no padding, so shrinking the
|
|
64
|
+
* container to the table's content height is the exact point at which the cap
|
|
65
|
+
* stops binding and the next measurement reports the same number.
|
|
66
|
+
*
|
|
67
|
+
* This used to be tables only, and the reason was the one root this is NOT safe
|
|
68
|
+
* for: a chart draws itself inset from the box it is given, so feeding its
|
|
69
|
+
* height back as the new container height would ratchet the container down by
|
|
70
|
+
* that inset every pass and never converge. Charts are classified
|
|
71
|
+
* container-sized now and are never measured at all, so the hazard is out of
|
|
72
|
+
* the measured set and the narrow exemption it forced can go with it.
|
|
73
|
+
*
|
|
74
|
+
* A root this SDK cannot place stays on the one-shot path. A plugin that
|
|
75
|
+
* declares itself `"fixed"` IS placed — the renderer has said its size is its
|
|
76
|
+
* own — so it re-measures like any other content-sized root. Only a name we do
|
|
77
|
+
* not know, with no plugin behind it, falls back to one measurement, which is
|
|
78
|
+
* what it got before any of this existed.
|
|
79
|
+
*/
|
|
80
|
+
export declare function remeasuresAfterReady(renderAs: string | undefined, strategy?: string | undefined): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* How far below the stage the node carrying a root's content height sits.
|
|
83
|
+
*
|
|
84
|
+
* This is the one renderer-DOM assumption left in the SDK, so it is stated
|
|
85
|
+
* rather than inlined. The stage is our own node and is box-sized, so it is
|
|
86
|
+
* never the answer: measuring it would floor every result at the height the
|
|
87
|
+
* container already has and nothing could ever shrink. Its first child is the
|
|
88
|
+
* renderer's outer wrapper, also box-sized, for the same reason.
|
|
89
|
+
*
|
|
90
|
+
* Depth 2 — the wrapper's child — is the root render node, and for every root
|
|
91
|
+
* but one its `scrollHeight` is the content height.
|
|
92
|
+
*
|
|
93
|
+
* A `# dashboard` grid is the exception: its own wrapper is constrained, and
|
|
94
|
+
* the grid one level further down is what reports the height. That used to be
|
|
95
|
+
* spelled as a class-name check on the rendered DOM
|
|
96
|
+
* (`classList.contains("malloy-dashboard")`); it is keyed off `renderAs()` now,
|
|
97
|
+
* which is metadata the renderer publishes rather than markup it happens to
|
|
98
|
+
* emit.
|
|
99
|
+
*/
|
|
100
|
+
export declare function contentNodeDepth(renderAs: string | undefined): number;
|
|
101
|
+
/**
|
|
102
|
+
* The node under `stage` that carries the result's content height: `depth`
|
|
103
|
+
* first children down, or null if the renderer has not built that deep yet.
|
|
104
|
+
*
|
|
105
|
+
* This is the node measured AND the node watched for changes, so the two can
|
|
106
|
+
* never drift apart.
|
|
107
|
+
*
|
|
108
|
+
* Null rather than the deepest node available, which is the tempting fallback
|
|
109
|
+
* and is actively wrong. A DOM shallower than `depth` almost always means the
|
|
110
|
+
* renderer is still building, and the shallow nodes are its box-sized wrappers:
|
|
111
|
+
* answering with one reports the height the panel already has, which reads as a
|
|
112
|
+
* successful measurement, stops the retry, and leaves the observer watching a
|
|
113
|
+
* node whose size can never change. That is a `# big_value` tile stuck at its
|
|
114
|
+
* 400px cap with 264px of white under its numbers. Reporting nothing instead
|
|
115
|
+
* leaves the panel at its first-paint height and lets the caller measure again
|
|
116
|
+
* when the renderer mutates the DOM into its final shape.
|
|
117
|
+
*/
|
|
118
|
+
export declare function contentNode(stage: HTMLElement, depth: number): HTMLElement | null;
|
|
119
|
+
/**
|
|
120
|
+
* Content height of the rendered result under `stage`, or 0 if the renderer
|
|
121
|
+
* has not built its final shape yet. See {@link contentNode}.
|
|
122
|
+
*
|
|
123
|
+
* `scrollHeight` is the CONTENT height, so this assumes the box adds no chrome
|
|
124
|
+
* of its own. True today: `.malloy-table.root` has no border, and a horizontal
|
|
125
|
+
* scrollbar costs no layout where scrollbars overlay. A wide table clipped by a
|
|
126
|
+
* few pixels on a platform that draws classic scrollbars would be this
|
|
127
|
+
* assumption breaking, and the fix is `+ (offsetHeight - clientHeight)`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function measureContentHeight(stage: HTMLElement, depth: number): number;
|
|
130
|
+
/**
|
|
131
|
+
* Per-tile cap for a dashboard's composite form. A tile is one panel among
|
|
132
|
+
* several, so capping them keeps the grid even instead of letting one long
|
|
133
|
+
* table set the height of its whole row.
|
|
134
|
+
*/
|
|
135
|
+
export declare const TILE_MAX_HEIGHT = 400;
|
|
136
|
+
/**
|
|
137
|
+
* Cap for a notebook cell result that lays itself out: a table, mostly. Tall
|
|
138
|
+
* enough for a screenful of rows, after which the cell scrolls rather than the
|
|
139
|
+
* page turning into one long table.
|
|
140
|
+
*/
|
|
141
|
+
export declare const NOTEBOOK_CELL_MAX_HEIGHT = 700;
|
|
142
|
+
/** Cap for a query result shown inside a model page's cell. */
|
|
143
|
+
export declare const MODEL_CELL_MAX_HEIGHT = 600;
|
|
144
|
+
/** Cap for the results dialog, which gets most of a tall viewport. */
|
|
145
|
+
export declare const RESULTS_DIALOG_MAX_HEIGHT = 800;
|
|
146
|
+
/**
|
|
147
|
+
* Height for a container-sized root whose caller set no cap.
|
|
148
|
+
*
|
|
149
|
+
* A chart has no height of its own, so with nothing to measure and no cap to
|
|
150
|
+
* obey, something has to choose. This is that choice, and it is the same number
|
|
151
|
+
* a dashboard tile gets, so an uncapped chart reads like a tall tile rather
|
|
152
|
+
* than a page-height band.
|
|
153
|
+
*
|
|
154
|
+
* This is what closed the stretch: the single-query dashboard form used to ask
|
|
155
|
+
* for a 20000px "no cap" height, which a bare `# bar_chart` painted at, measured
|
|
156
|
+
* back off itself, and kept — 1992px for a two-row chart against 227px for the
|
|
157
|
+
* same query under a `# dashboard` grid. The cap is `undefined` now and a chart
|
|
158
|
+
* is never measured, so neither half of that can happen.
|
|
159
|
+
*/
|
|
160
|
+
export declare const UNCAPPED_CONTAINER_HEIGHT = 400;
|
|
161
|
+
/**
|
|
162
|
+
* Height to paint at before a content-sized result has been measured.
|
|
163
|
+
*
|
|
164
|
+
* A cap is also the first paint's height, because the measured height starts
|
|
165
|
+
* out equal to it. Harmless while every caller passes something viewport-sized
|
|
166
|
+
* (400 to 800); a caller that passes no cap needs a number that is not "as tall
|
|
167
|
+
* as you like".
|
|
168
|
+
*/
|
|
169
|
+
export declare const INITIAL_RENDER_HEIGHT = 2000;
|
|
170
|
+
/** First-paint height, before anything is known about the result. */
|
|
171
|
+
export declare function initialResultHeight(maxHeight: number | undefined): number;
|
|
172
|
+
/**
|
|
173
|
+
* The height a result panel should paint at, given what is known so far.
|
|
174
|
+
*
|
|
175
|
+
* `maxHeight` is a CAP and `undefined` means uncapped — it is not a height
|
|
176
|
+
* request, which is why "no cap" is expressed by leaving it out rather than by
|
|
177
|
+
* passing a number big enough to mean the same thing.
|
|
178
|
+
*/
|
|
179
|
+
export declare function resolveResultHeight({ sizing, contentHeight, maxHeight, }: {
|
|
180
|
+
sizing: ResultSizing | undefined;
|
|
181
|
+
contentHeight: number | undefined;
|
|
182
|
+
maxHeight: number | undefined;
|
|
183
|
+
}): number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { DRILL_CELL_CLASS, drillableFieldNames, markDrillableCells, type DrillMetadataSource, } from './markDrillableCells';
|
|
2
2
|
export { DRILL_SELF, drillDestinations, drillValueToFilter, encodeDrillValue, humanizeSlug, resolveDrill, type DrillClickPayload, type DrillField, type DrillIntent, type DrillNavigation, type DrillTagReader, } from './resolveDrill';
|
|
3
3
|
export { useDrill, type DrillBinding, type UseDrillOptions, type UseDrillResult, } from './useDrill';
|
|
4
|
+
export { useDrillSelf, type UseDrillSelfOptions, type UseDrillSelfResult, } from './useDrillSelf';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GivenValue } from '../../hooks/givenValue';
|
|
2
|
+
export interface UseDrillSelfOptions {
|
|
3
|
+
/** Declared type per given name: what this document can set. */
|
|
4
|
+
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
5
|
+
/** The control row's setter, from `useGivensState`. */
|
|
6
|
+
setGiven: (name: string, value: GivenValue) => void;
|
|
7
|
+
/**
|
|
8
|
+
* How the document names itself in the warning for a tag that names a given
|
|
9
|
+
* it does not declare: a dashboard's slug, a notebook's path.
|
|
10
|
+
*/
|
|
11
|
+
documentName: string;
|
|
12
|
+
}
|
|
13
|
+
export interface UseDrillSelfResult {
|
|
14
|
+
/** The declared given a drill tag's name refers to, or undefined. */
|
|
15
|
+
resolveGiven: (given: string) => string | undefined;
|
|
16
|
+
/** For `useDrill`: whether a `to=self` on this given can be honoured. */
|
|
17
|
+
canSelf: (given: string) => boolean;
|
|
18
|
+
/** For `useDrill`: set the given to the clicked value, encoded for its type. */
|
|
19
|
+
onSelf: (given: string, rawValue: unknown) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The `# drill { to=self }` half of a document's drill wiring: which of its
|
|
23
|
+
* givens a tag can set, and setting one from a clicked cell.
|
|
24
|
+
*
|
|
25
|
+
* Shared by the dashboard and the notebook so one tag behaves identically on
|
|
26
|
+
* both surfaces, which used to be two copies of this code with the same
|
|
27
|
+
* warning string in each. Three rules live here:
|
|
28
|
+
*
|
|
29
|
+
* - **Names fold case.** `# drill` with no `given=` falls back to the
|
|
30
|
+
* DIMENSION's spelling, conventionally lower_snake, while givens are
|
|
31
|
+
* conventionally SHOUTED; neither convention can be assumed, so a tag naming
|
|
32
|
+
* `region` finds a declared `REGION` and vice versa. First declaration wins
|
|
33
|
+
* when a model declares both spellings.
|
|
34
|
+
* - **The value is encoded against the DECLARED type**, which is knowable here
|
|
35
|
+
* and is not knowable at the click: `useDrill` hands over the raw cell value
|
|
36
|
+
* for exactly this reason. Passing it straight to `setGiven` skipped the
|
|
37
|
+
* encoder, so a clicked date reached a `number` given as epoch milliseconds
|
|
38
|
+
* and a filter value went unescaped. It is set under the name the MODEL
|
|
39
|
+
* declares, so it reaches the URL and the request under the one name the
|
|
40
|
+
* server knows.
|
|
41
|
+
* - **A refusal is said aloud.** `canSelf` checks only that the name resolves,
|
|
42
|
+
* so a `given=` naming a type the clicked value cannot become still paints a
|
|
43
|
+
* whole column clickable and would then drop every click in silence. Both
|
|
44
|
+
* refusals warn, because each is an authoring mistake with no other symptom.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useDrillSelf({ declaredTypes, setGiven, documentName, }: UseDrillSelfOptions): UseDrillSelfResult;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TemporalFilter } from '@malloydata/malloy-filter';
|
|
1
2
|
/** True for the `filter<…>` family, whose values are filter syntax, not plain. */
|
|
2
3
|
export declare function isFilterType(type: string | undefined): boolean;
|
|
3
4
|
/** The `T` of a `filter<T>`, or undefined for any other type. */
|
|
@@ -95,3 +96,65 @@ export declare function encodeAtLeast(value: number): string;
|
|
|
95
96
|
* no lower bound at all.
|
|
96
97
|
*/
|
|
97
98
|
export declare function decodeAtLeast(value: string): number | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* An inclusive number range, which is what a two-handled slider means:
|
|
101
|
+
* `encodeBetween(10, 20)` is `[10 to 20]`, Malloy's `>= 10 and <= 20`. The same
|
|
102
|
+
* spelling Malloyyo's `filters.between` writes, so a value set on either host
|
|
103
|
+
* reads back on the other.
|
|
104
|
+
*/
|
|
105
|
+
export declare function encodeBetween(lo: number, hi: number): string;
|
|
106
|
+
/**
|
|
107
|
+
* The bounds back out of {@link encodeBetween}, or undefined for any other
|
|
108
|
+
* filter. Only the closed range round-trips: `(10 to 20]` and its kin exclude an
|
|
109
|
+
* end the slider's thumbs cannot express, and a negated range is not a range at
|
|
110
|
+
* all, so both fall through to the text box rather than being redrawn as
|
|
111
|
+
* something else.
|
|
112
|
+
*/
|
|
113
|
+
export declare function decodeBetween(value: string): [number, number] | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* The preset windows a time-range control offers for a `filter<date>` or
|
|
116
|
+
* `filter<timestamp>` given. The same six Malloyyo's `TimeRange` widget ships,
|
|
117
|
+
* spelled in Malloy's filter grammar: `today` is the current day, `7 days` is
|
|
118
|
+
* Malloy's "in the last 7 days", a rolling window ending now.
|
|
119
|
+
*
|
|
120
|
+
* Structured clauses rather than strings so the spelling on the wire is the
|
|
121
|
+
* filter package's own, and {@link decodeTimePreset} compares against the same
|
|
122
|
+
* structure the parser returns rather than against text that may be spelled
|
|
123
|
+
* `7 day`, `7 days` or `7 days` by whoever wrote the URL.
|
|
124
|
+
*/
|
|
125
|
+
export declare const TIME_PRESETS: readonly {
|
|
126
|
+
key: string;
|
|
127
|
+
label: string;
|
|
128
|
+
clause: TemporalFilter;
|
|
129
|
+
}[];
|
|
130
|
+
/** The filter text for one of {@link TIME_PRESETS}, by key. */
|
|
131
|
+
export declare function encodeTimePreset(key: string): string | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Which preset a filter is, or undefined when it is none of them. Matched on the
|
|
134
|
+
* parsed clause, so `7 day` and `7 days` are the same window, and a negated or
|
|
135
|
+
* compound filter is not a preset however it is spelled.
|
|
136
|
+
*/
|
|
137
|
+
export declare function decodeTimePreset(value: string): string | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* An inclusive range of whole days, as two `YYYY-MM-DD` strings, in Malloy's
|
|
140
|
+
* filter grammar.
|
|
141
|
+
*
|
|
142
|
+
* Malloy's `A to B` runs from the start of A up to but NOT including the start
|
|
143
|
+
* of B (`filter_compilers.ts`, `case 'to'`), while a reader picking "January
|
|
144
|
+
* 1st to January 31st" means both days. So the end is encoded as the day AFTER
|
|
145
|
+
* the last day picked: `encodeDayRange("2024-01-01", "2024-01-31")` is
|
|
146
|
+
* `2024-01-01 to 2024-02-01`. {@link decodeDayRange} undoes exactly that, so a
|
|
147
|
+
* range written by Malloyyo (which encodes the picked day verbatim) displays
|
|
148
|
+
* here as the days it actually selects.
|
|
149
|
+
*/
|
|
150
|
+
export declare function encodeDayRange(firstDay: string, lastDay: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* The inclusive days back out of {@link encodeDayRange}, or undefined for any
|
|
153
|
+
* other filter. Both ends must be whole-day literals: a range with a time of
|
|
154
|
+
* day, a relative end (`2024-01-01 to now`), or a negation is not something two
|
|
155
|
+
* day pickers can show, and falls through to the text box.
|
|
156
|
+
*/
|
|
157
|
+
export declare function decodeDayRange(value: string): {
|
|
158
|
+
firstDay: string;
|
|
159
|
+
lastDay: string;
|
|
160
|
+
} | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface UseGivenUrlParamsResult {
|
|
2
|
+
/** The query string as a flat record: what a document reads its givens from. */
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* For a document's `onGivensChange`: writes the applied values into the
|
|
6
|
+
* query string, in place, leaving every parameter that is not a given alone.
|
|
7
|
+
*/
|
|
8
|
+
onGivensChange: (next: Record<string, string>, managed: readonly string[]) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Keep a document's control values in the page's query string, so a filtered
|
|
12
|
+
* dashboard or a parameterized notebook is a shareable link.
|
|
13
|
+
*
|
|
14
|
+
* This is the host side of `useGivensState`: the document reports its applied
|
|
15
|
+
* values and the names it manages, this writes them into the URL and feeds the
|
|
16
|
+
* URL back in as `params`. The two Console pages carried a copy each; they
|
|
17
|
+
* agreed line for line, so this is that code once, for any host on
|
|
18
|
+
* react-router.
|
|
19
|
+
*
|
|
20
|
+
* Three things it is careful about, each of which was a bug once:
|
|
21
|
+
*
|
|
22
|
+
* - **Merge, never replace.** The query string is not the document's alone: a
|
|
23
|
+
* tracking tag or any other unrelated parameter shares it, and replacing the
|
|
24
|
+
* whole string dropped those on LOAD, as soon as the first report arrived.
|
|
25
|
+
* Only names that are ours are touched: what the document manages now, plus
|
|
26
|
+
* anything this hook wrote earlier, so a control cleared after a model reload
|
|
27
|
+
* stopped declaring it still gets its parameter removed. That memory outlives
|
|
28
|
+
* a document swap on purpose: the parameter written for the previous
|
|
29
|
+
* document is the stale one the next should clear.
|
|
30
|
+
* - **`hasOwnProperty`, not `in`.** `next` is a plain object literal, so `in`
|
|
31
|
+
* walks its prototype and reports `constructor`, `toString` and friends as
|
|
32
|
+
* present; a given with one of those names could never be cleared.
|
|
33
|
+
* - **Replace, and keep the hash.** Changing a control is not a navigation
|
|
34
|
+
* step, so Back should leave the document rather than walk back through
|
|
35
|
+
* every value tried. And a navigation that names only `search` resolves to an
|
|
36
|
+
* empty fragment, which dropped whatever anchor the reader arrived on;
|
|
37
|
+
* `setSearchParams` has that problem, which is why this navigates itself.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useGivenUrlParams(): UseGivenUrlParamsResult;
|