@malloy-publisher/sdk 0.0.249 → 0.0.250
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 +5 -0
- package/TREE_SHAKING.md +5 -0
- package/bunfig.toml +3 -0
- package/dist/client/api.d.ts +9 -3
- package/dist/components/drill/resolveDrill.d.ts +0 -20
- package/dist/components/given/filterValue.d.ts +0 -20
- package/dist/components/styles.d.ts +12 -4
- package/dist/{core-DZk7z7ko.cjs.js → core-CVXEUnnm.cjs.js} +1 -1
- package/dist/{core-DFBwNhvb.es.js → core-Cr-9Wkp3.es.js} +1 -1
- package/dist/{index-CWQXhe0D.cjs.js → index-C-KeIwsG.cjs.js} +84 -83
- package/dist/{index-CLcRrkxd.es.js → index-DVkelll3.es.js} +6530 -6545
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/utils/malloyString.d.ts +7 -0
- package/package.json +1 -1
- package/src/client-entry.ts +3 -0
- package/src/components/AnalyzePackageButton.tsx +3 -0
- package/src/components/ApiErrorDisplay.tsx +3 -0
- package/src/components/Connections/AddConnectionDialog.tsx +3 -0
- package/src/components/Connections/DeleteConnectionDialog.tsx +3 -0
- package/src/components/Connections/EditConnectionDialog.tsx +3 -0
- package/src/components/Connections/common.ts +3 -0
- package/src/components/DOMElement/DOMElement.tsx +3 -0
- package/src/components/DOMElement/index.ts +3 -0
- package/src/components/Dashboard/Dashboard.tsx +3 -0
- package/src/components/Dashboard/DashboardTile.tsx +3 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +3 -0
- package/src/components/DataAppViewer/index.ts +3 -0
- package/src/components/Environment/About.tsx +3 -0
- package/src/components/Environment/AddPackageDialog.tsx +3 -0
- package/src/components/Environment/ConnectionExplorer.tsx +3 -0
- package/src/components/Environment/Connections.tsx +3 -0
- package/src/components/Environment/DeletePackageDialog.tsx +3 -0
- package/src/components/Environment/EditPackageDialog.tsx +3 -0
- package/src/components/Environment/Environment.tsx +3 -0
- package/src/components/Environment/Packages.tsx +3 -0
- package/src/components/Environment/index.ts +3 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +3 -0
- package/src/components/Home/DeleteEnvironmentDialog.tsx +3 -0
- package/src/components/Home/EditEnvironmentDialog.tsx +3 -0
- package/src/components/Home/Home.tsx +13 -14
- package/src/components/Home/index.ts +3 -0
- package/src/components/Loading.tsx +3 -0
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +3 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +3 -0
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +3 -0
- package/src/components/Materializations/EnvironmentMaterializations.tsx +3 -0
- package/src/components/Materializations/ManifestView.tsx +3 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +3 -0
- package/src/components/Materializations/MaterializationRunsList.tsx +3 -0
- package/src/components/Materializations/Materializations.tsx +3 -0
- package/src/components/Materializations/ScheduleCard.tsx +3 -0
- package/src/components/Materializations/SectionLabel.tsx +3 -0
- package/src/components/Materializations/SetScheduleDialog.tsx +3 -0
- package/src/components/Materializations/TriggerChip.tsx +3 -0
- package/src/components/Materializations/cron.ts +3 -0
- package/src/components/Materializations/index.ts +3 -0
- package/src/components/Materializations/utils.ts +3 -0
- package/src/components/Model/Model.tsx +3 -0
- package/src/components/Model/ModelCell.tsx +3 -0
- package/src/components/Model/ModelExplorer.tsx +3 -0
- package/src/components/Model/ModelExplorerDialog.tsx +3 -0
- package/src/components/Model/SourcesExplorer.tsx +3 -0
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +3 -0
- package/src/components/Notebook/Notebook.tsx +3 -0
- package/src/components/Notebook/NotebookCell.tsx +3 -0
- package/src/components/Notebook/index.ts +3 -0
- package/src/components/Notebook/runPlan.spec.ts +3 -0
- package/src/components/Notebook/runPlan.ts +3 -0
- package/src/components/Notebook/types.ts +3 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +3 -0
- package/src/components/Package/ContentTypeIcon.tsx +3 -0
- package/src/components/Package/FileTreeView.tsx +3 -0
- package/src/components/Package/Models.tsx +3 -0
- package/src/components/Package/Package.tsx +3 -0
- package/src/components/Package/index.ts +3 -0
- package/src/components/QueryResult/QueryResult.tsx +3 -0
- package/src/components/QueryResult/index.ts +3 -0
- package/src/components/RenderedResult/RenderedResult.tsx +3 -0
- package/src/components/RenderedResult/ResultContainer.tsx +3 -0
- package/src/components/RenderedResult/index.ts +3 -0
- package/src/components/RenderedResult/renderLogs.spec.ts +3 -0
- package/src/components/RenderedResult/renderLogs.ts +3 -0
- package/src/components/ResultsDialog.tsx +3 -0
- package/src/components/ServerProvider.tsx +3 -0
- package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
- package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
- package/src/components/Workbook/ModelPicker.tsx +3 -0
- package/src/components/Workbook/MutableCell.tsx +3 -0
- package/src/components/Workbook/Workbook.tsx +3 -0
- package/src/components/Workbook/WorkbookList.tsx +3 -0
- package/src/components/Workbook/WorkbookManager.ts +3 -0
- package/src/components/Workbook/WorkbookStorage.ts +3 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
- package/src/components/Workbook/index.ts +3 -0
- package/src/components/click_helper.ts +3 -0
- package/src/components/drill/index.ts +3 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +3 -0
- package/src/components/drill/markDrillableCells.spec.ts +3 -0
- package/src/components/drill/markDrillableCells.ts +3 -0
- package/src/components/drill/resolveDrill.spec.ts +3 -0
- package/src/components/drill/resolveDrill.ts +3 -0
- package/src/components/drill/useDrill.tsx +3 -0
- package/src/components/filter/DimensionFilter.tsx +3 -0
- package/src/components/filter/index.ts +3 -0
- package/src/components/filter/utils.ts +16 -5
- package/src/components/given/GivenInput.spec.tsx +3 -0
- package/src/components/given/GivenInput.tsx +3 -0
- package/src/components/given/GivensPanel.spec.tsx +3 -0
- package/src/components/given/GivensPanel.tsx +3 -0
- package/src/components/given/filterValue.spec.ts +3 -0
- package/src/components/given/filterValue.ts +3 -0
- package/src/components/given/index.ts +3 -0
- package/src/components/given/paramCodec.spec.ts +3 -0
- package/src/components/given/paramCodec.ts +3 -0
- package/src/components/given/utils.spec.ts +3 -0
- package/src/components/given/utils.ts +3 -0
- package/src/components/highlighter.ts +3 -0
- package/src/components/index.ts +3 -0
- package/src/components/styles.ts +15 -4
- package/src/constants/docLinks.spec.ts +3 -0
- package/src/constants/docLinks.ts +3 -0
- package/src/hooks/givenValue.ts +3 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useDimensionFilters.ts +4 -7
- package/src/hooks/useDimensionFiltersFromSpec.ts +3 -0
- package/src/hooks/useDimensionFiltersQuery.ts +4 -7
- package/src/hooks/useDimensionalFilterRangeData.ts +4 -7
- package/src/hooks/useGivensState.spec.ts +3 -0
- package/src/hooks/useGivensState.ts +3 -0
- package/src/hooks/useModelGivens.ts +3 -0
- package/src/hooks/useQueryWithApiError.ts +3 -0
- package/src/hooks/useRawQueryData.ts +3 -0
- package/src/hooks/useSuggestOptions.spec.ts +3 -0
- package/src/hooks/useSuggestOptions.ts +3 -0
- package/src/index.ts +3 -0
- package/src/react-app-env.d.ts +3 -0
- package/src/theme/ThemeContext.tsx +3 -0
- package/src/theme/buildMalloyExplicitTheme.ts +3 -0
- package/src/theme/buildTableCssVars.spec.ts +3 -0
- package/src/theme/buildTableCssVars.ts +3 -0
- package/src/theme/buildVegaThemeOverride.spec.ts +3 -0
- package/src/theme/buildVegaThemeOverride.ts +3 -0
- package/src/theme/defaults.ts +3 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/keys.ts +3 -0
- package/src/theme/readChartAnnotations.spec.ts +3 -0
- package/src/theme/readChartAnnotations.ts +3 -0
- package/src/theme/resolveTheme.spec.ts +3 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +3 -0
- package/src/utils/dataAppEmbed.spec.ts +3 -0
- package/src/utils/dataAppEmbed.ts +3 -0
- package/src/utils/formatting.spec.ts +3 -0
- package/src/utils/formatting.ts +3 -0
- package/src/utils/malloyString.spec.ts +24 -0
- package/src/utils/malloyString.ts +12 -0
- package/src/utils/parsing.spec.ts +3 -0
- package/src/utils/parsing.ts +3 -0
- package/src/utils/queryClient.ts +3 -0
- package/test/README.md +5 -0
- package/test/setup.ts +3 -0
- package/vite.config.ts +3 -0
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import * as Malloy from "@malloydata/malloy-interfaces";
|
|
2
5
|
import {
|
|
3
6
|
DimensionSpec,
|
|
4
7
|
FilterType,
|
|
5
8
|
} from "../../hooks/useDimensionalFilterRangeData";
|
|
6
9
|
import { FilterSelection } from "../../hooks/useDimensionFilters";
|
|
10
|
+
import { escapeMalloyString } from "../../utils/malloyString";
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* A single filter specification with source and dimension
|
|
@@ -136,9 +140,16 @@ export function parseAllSourceInfos(
|
|
|
136
140
|
if (cell.type === "code") {
|
|
137
141
|
// Extract model path from the first import statement found
|
|
138
142
|
if (!modelPath && cell.text) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
// The first quoted string on the first `import` line is the
|
|
144
|
+
// module path, for both `import 'x'` and `import {a} from 'x'`.
|
|
145
|
+
// A line scan rather than one regex over the whole cell: the
|
|
146
|
+
// optional `{...} from` group made that regex backtrack
|
|
147
|
+
// polynomially on adversarial input.
|
|
148
|
+
const importLine = cell.text
|
|
149
|
+
.split("\n")
|
|
150
|
+
.map((line) => line.trim())
|
|
151
|
+
.find((line) => line.startsWith("import "));
|
|
152
|
+
const importMatch = importLine?.match(/['"]([^'"\n]+)['"]/);
|
|
142
153
|
if (importMatch) {
|
|
143
154
|
modelPath = importMatch[1];
|
|
144
155
|
}
|
|
@@ -295,7 +306,7 @@ export function generateFilterClause(
|
|
|
295
306
|
return `@${v.getFullYear()}-${String(v.getMonth() + 1).padStart(2, "0")}-${String(v.getDate()).padStart(2, "0")}`;
|
|
296
307
|
}
|
|
297
308
|
if (typeof v === "string") {
|
|
298
|
-
return `'${v
|
|
309
|
+
return `'${escapeMalloyString(v)}'`;
|
|
299
310
|
}
|
|
300
311
|
if (typeof v === "boolean") return v ? "true" : "false";
|
|
301
312
|
return String(v);
|
|
@@ -314,7 +325,7 @@ export function generateFilterClause(
|
|
|
314
325
|
|
|
315
326
|
case "Contains":
|
|
316
327
|
if (typeof value === "string") {
|
|
317
|
-
return `${fieldName} ~ f'%${value
|
|
328
|
+
return `${fieldName} ~ f'%${escapeMalloyString(value)}%'`;
|
|
318
329
|
}
|
|
319
330
|
return `${fieldName} = ${formatValue(value)}`;
|
|
320
331
|
|
package/src/components/index.ts
CHANGED
package/src/components/styles.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { Card, CardContent, CardMedia, styled } from "@mui/material";
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -24,10 +27,18 @@ export const MALLOY_BRAND = {
|
|
|
24
27
|
* WCAG minimum for a graphical object. The nearest series hues do not: `#aacd85`
|
|
25
28
|
* sage is 1.8:1, `#ec72b8` pink 2.7:1, `#b87ced` violet 2.9:1.
|
|
26
29
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* These three were picked against the bar, but they are not the only colors it
|
|
31
|
+
* now binds. `CONTENT_TINT` in `Package/ContentTypeIcon.tsx` paints all three of
|
|
32
|
+
* `MALLOY_BRAND` behind glyphs as well, and `ContentTypeIcon.spec.ts` holds two
|
|
33
|
+
* of them to the same 3:1: orange at 3.09:1 and darkBlue at 5.17:1. Orange
|
|
34
|
+
* clears it by 0.09, so retuning it lighter turns that suite red, in a file a
|
|
35
|
+
* brand change would not otherwise open. For those two the bar is a component
|
|
36
|
+
* constraint, not only a brand decision.
|
|
37
|
+
*
|
|
38
|
+
* Teal is the exception at 2.5:1, below the bar and inherited from the logo, so
|
|
39
|
+
* the row it backs carries a white-on-teal glyph that does not meet the
|
|
40
|
+
* standard. Pre-existing, not introduced here. The spec grandfathers it by
|
|
41
|
+
* content type rather than by color, so a new type handed teal still fails.
|
|
31
42
|
*/
|
|
32
43
|
export const MALLOY_ACCENT = {
|
|
33
44
|
violet: "#7c4dcc",
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
// Central list of the Malloy documentation URLs the Publisher UI links to.
|
|
2
5
|
// Keeping them in one place means a docs move only needs updating here, rather
|
|
3
6
|
// than hunting down hardcoded links across the app.
|
package/src/hooks/givenValue.ts
CHANGED
package/src/hooks/index.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useCallback, useEffect, useState } from "react";
|
|
2
5
|
import {
|
|
3
6
|
DimensionSpec,
|
|
4
7
|
getDimensionKey,
|
|
5
8
|
} from "./useDimensionalFilterRangeData";
|
|
9
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Match types for filtering dimensions
|
|
@@ -75,13 +79,6 @@ export interface UseDimensionFiltersResult {
|
|
|
75
79
|
generateWhereClause: () => string;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
/**
|
|
79
|
-
* Escapes special characters in strings for Malloy queries
|
|
80
|
-
*/
|
|
81
|
-
function escapeMalloyString(value: string): string {
|
|
82
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
82
|
/**
|
|
86
83
|
* Formats a value for use in Malloy query
|
|
87
84
|
*/
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useCallback, useMemo, useState } from "react";
|
|
2
5
|
import { createEmbeddedQueryResult } from "../components/QueryResult";
|
|
3
6
|
import { encodeResourceUri } from "../utils/formatting";
|
|
4
7
|
import { FilterSelection, FilterValuePrimitive } from "./useDimensionFilters";
|
|
8
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Parameters for the useDimensionFiltersQuery hook
|
|
@@ -39,13 +43,6 @@ export interface DimensionFiltersQueryResult {
|
|
|
39
43
|
canExecute: boolean;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
/**
|
|
43
|
-
* Escapes special characters in strings for Malloy queries
|
|
44
|
-
*/
|
|
45
|
-
function escapeMalloyString(value: string): string {
|
|
46
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* Formats a value for use in Malloy query
|
|
51
48
|
*/
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useMemo } from "react";
|
|
2
5
|
import { useServer } from "../components/ServerProvider";
|
|
3
6
|
import { FilterSelection, FilterValuePrimitive } from "./useDimensionFilters";
|
|
4
7
|
import { useQueryWithApiError } from "./useQueryWithApiError";
|
|
8
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Filter types for dimensions
|
|
@@ -114,13 +118,6 @@ export interface DimensionalFilterRangeDataResult {
|
|
|
114
118
|
refetch: () => void;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
/**
|
|
118
|
-
* Escapes special characters in strings for Malloy queries
|
|
119
|
-
*/
|
|
120
|
-
function escapeMalloyString(value: string): string {
|
|
121
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
121
|
/**
|
|
125
122
|
* Formats a value for use in Malloy query
|
|
126
123
|
*/
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
5
|
import { givensToParams, paramsToGivens } from "../components/given/paramCodec";
|
|
3
6
|
import type { GivenValue } from "./givenValue";
|
package/src/index.ts
CHANGED
package/src/react-app-env.d.ts
CHANGED