@malloy-publisher/sdk 0.7.0 → 0.8.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/dist/client/api.d.ts +38 -1
- package/dist/components/DataAppViewer/DataAppViewer.d.ts +6 -0
- package/dist/components/Materializations/utils.d.ts +31 -0
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +3235 -3174
- package/package.json +1 -1
- package/src/components/DataAppViewer/DataAppViewer.tsx +6 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +47 -1
- package/src/components/Materializations/MaterializationRunsList.tsx +2 -1
- package/src/components/Materializations/utils.spec.ts +56 -0
- package/src/components/Materializations/utils.ts +56 -0
package/package.json
CHANGED
|
@@ -40,6 +40,12 @@ function parseDataAppResource(resourceUri: string) {
|
|
|
40
40
|
* height changes; we listen and resize the iframe to match so embedded
|
|
41
41
|
* dashboards don't get a nested scrollbar.
|
|
42
42
|
*
|
|
43
|
+
* When those two origins differ, the worker serving the app must name this
|
|
44
|
+
* SPA's origin in `PUBLISHER_FRAME_ANCESTORS`. The server's default is
|
|
45
|
+
* `frame-ancestors 'self'`, which permits only its own origin, so a
|
|
46
|
+
* cross-origin embed is refused by the browser and the iframe renders blank
|
|
47
|
+
* with nothing logged server-side. A same-origin deployment needs no setting.
|
|
48
|
+
*
|
|
43
49
|
* Full-screen apps (e.g. slide decks) can opt out of content-height sizing
|
|
44
50
|
* with `<meta name="publisher:fit" content="viewport">`, surfaced as
|
|
45
51
|
* `DataApp.fit === "viewport"`. The iframe then fills the available viewport
|
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
formatTimestamp,
|
|
28
28
|
isActiveStatus,
|
|
29
29
|
parseMetadata,
|
|
30
|
+
refusedSourcesOf,
|
|
31
|
+
sourcesSummary,
|
|
30
32
|
statusColor,
|
|
31
33
|
statusLabel,
|
|
32
34
|
} from "./utils";
|
|
@@ -47,6 +49,7 @@ export default function MaterializationDetailDialog({
|
|
|
47
49
|
onClose,
|
|
48
50
|
}: MaterializationDetailDialogProps) {
|
|
49
51
|
const meta = materialization ? parseMetadata(materialization) : {};
|
|
52
|
+
const refused = materialization ? refusedSourcesOf(materialization) : [];
|
|
50
53
|
const planSources = Object.values(buildPlan?.sources ?? {});
|
|
51
54
|
|
|
52
55
|
return (
|
|
@@ -135,7 +138,7 @@ export default function MaterializationDetailDialog({
|
|
|
135
138
|
/>
|
|
136
139
|
<DetailField
|
|
137
140
|
label="Sources"
|
|
138
|
-
value={
|
|
141
|
+
value={sourcesSummary(meta, " · ")}
|
|
139
142
|
/>
|
|
140
143
|
<DetailField
|
|
141
144
|
label="Force refresh"
|
|
@@ -170,6 +173,49 @@ export default function MaterializationDetailDialog({
|
|
|
170
173
|
</Box>
|
|
171
174
|
)}
|
|
172
175
|
|
|
176
|
+
{refused.length > 0 && (
|
|
177
|
+
<Box
|
|
178
|
+
sx={{
|
|
179
|
+
borderRadius: 2,
|
|
180
|
+
p: 2,
|
|
181
|
+
mb: 3,
|
|
182
|
+
border: "1px solid",
|
|
183
|
+
borderColor: "warning.main",
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
<SectionLabel>
|
|
187
|
+
<Box component="span" sx={{ color: "warning.main" }}>
|
|
188
|
+
Refused sources
|
|
189
|
+
</Box>
|
|
190
|
+
</SectionLabel>
|
|
191
|
+
<Typography
|
|
192
|
+
variant="body2"
|
|
193
|
+
color="text.secondary"
|
|
194
|
+
sx={{ mb: 1 }}
|
|
195
|
+
>
|
|
196
|
+
Not built, because materializing them would be
|
|
197
|
+
unsafe. They serve live until the model changes.
|
|
198
|
+
</Typography>
|
|
199
|
+
{refused.map((r) => (
|
|
200
|
+
<Box key={r.name} sx={{ mt: 1 }}>
|
|
201
|
+
<Typography
|
|
202
|
+
variant="body2"
|
|
203
|
+
sx={{ fontFamily: MONO_FONT_FAMILY }}
|
|
204
|
+
>
|
|
205
|
+
{r.name}
|
|
206
|
+
</Typography>
|
|
207
|
+
<Typography
|
|
208
|
+
variant="body2"
|
|
209
|
+
color="text.secondary"
|
|
210
|
+
sx={{ whiteSpace: "pre-wrap" }}
|
|
211
|
+
>
|
|
212
|
+
{r.message}
|
|
213
|
+
</Typography>
|
|
214
|
+
</Box>
|
|
215
|
+
))}
|
|
216
|
+
</Box>
|
|
217
|
+
)}
|
|
218
|
+
|
|
173
219
|
<Box sx={{ mb: 3 }}>
|
|
174
220
|
<SectionLabel>Build plan</SectionLabel>
|
|
175
221
|
{planSources.length === 0 ? (
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
isActiveStatus,
|
|
30
30
|
isTerminalStatus,
|
|
31
31
|
parseMetadata,
|
|
32
|
+
sourcesSummary,
|
|
32
33
|
statusColor,
|
|
33
34
|
statusLabel,
|
|
34
35
|
} from "./utils";
|
|
@@ -124,7 +125,7 @@ function MaterializationRow({
|
|
|
124
125
|
const meta = parseMetadata(materialization);
|
|
125
126
|
const sourcesLabel =
|
|
126
127
|
meta.sourcesBuilt !== undefined || meta.sourcesReused !== undefined
|
|
127
|
-
?
|
|
128
|
+
? sourcesSummary(meta, ", ")
|
|
128
129
|
: "-";
|
|
129
130
|
const active = isActiveStatus(materialization.status);
|
|
130
131
|
const terminal = isTerminalStatus(materialization.status);
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
isActiveStatus,
|
|
11
11
|
isTerminalStatus,
|
|
12
12
|
parseMetadata,
|
|
13
|
+
refusedSourcesOf,
|
|
14
|
+
sourcesSummary,
|
|
13
15
|
statusColor,
|
|
14
16
|
statusLabel,
|
|
15
17
|
triggerLabel,
|
|
@@ -180,3 +182,57 @@ describe("formatRelativeTime", () => {
|
|
|
180
182
|
expect(formatRelativeTime(undefined)).toBe("-");
|
|
181
183
|
});
|
|
182
184
|
});
|
|
185
|
+
|
|
186
|
+
describe("sourcesSummary", () => {
|
|
187
|
+
it("reads as built and reused on a run that refused nothing", () => {
|
|
188
|
+
expect(sourcesSummary({ sourcesBuilt: 2, sourcesReused: 1 }, ", ")).toBe(
|
|
189
|
+
"2 built, 1 reused",
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("names the refused count when the run skipped a source", () => {
|
|
194
|
+
expect(
|
|
195
|
+
sourcesSummary(
|
|
196
|
+
{ sourcesBuilt: 5, sourcesReused: 0, sourcesRefused: 7 },
|
|
197
|
+
" · ",
|
|
198
|
+
),
|
|
199
|
+
).toBe("5 built · 0 reused · 7 refused");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe("refusedSourcesOf", () => {
|
|
204
|
+
it("reads auto-run's metadata list and orchestrated failures marked refused", () => {
|
|
205
|
+
const materialization = {
|
|
206
|
+
metadata: {
|
|
207
|
+
refusedSources: {
|
|
208
|
+
"b@m": { name: "b", message: "b is gated" },
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
manifest: {
|
|
212
|
+
entries: {},
|
|
213
|
+
failures: {
|
|
214
|
+
x: {
|
|
215
|
+
sourceEntityId: "x",
|
|
216
|
+
sourceName: "a",
|
|
217
|
+
reason: "a reads a given",
|
|
218
|
+
refused: true,
|
|
219
|
+
},
|
|
220
|
+
y: {
|
|
221
|
+
sourceEntityId: "y",
|
|
222
|
+
sourceName: "c",
|
|
223
|
+
reason: "permission denied",
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
} as unknown as Materialization;
|
|
228
|
+
|
|
229
|
+
expect(refusedSourcesOf(materialization)).toEqual([
|
|
230
|
+
{ name: "a", message: "a reads a given" },
|
|
231
|
+
{ name: "b", message: "b is gated" },
|
|
232
|
+
]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("is empty for a run that refused nothing", () => {
|
|
236
|
+
expect(refusedSourcesOf({} as Materialization)).toEqual([]);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -81,6 +81,62 @@ export interface MaterializationMetadata {
|
|
|
81
81
|
trigger?: "ON_DEMAND" | "SCHEDULER";
|
|
82
82
|
sourcesBuilt?: number;
|
|
83
83
|
sourcesReused?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Persist sources the eligibility gate refused, so the run skipped them and
|
|
86
|
+
* they serve live. Absent when the run refused nothing; the refused sources
|
|
87
|
+
* themselves are named in `refusedSources`, beside this count.
|
|
88
|
+
*/
|
|
89
|
+
sourcesRefused?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The sources auto-run refused, keyed by sourceID. An orchestrated run
|
|
92
|
+
* reports its refusals in the manifest's `failures` instead, marked
|
|
93
|
+
* `refused`; {@link refusedSourcesOf} reads both.
|
|
94
|
+
*/
|
|
95
|
+
refusedSources?: Record<string, { name: string; message: string }>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** One source a run did not build because the eligibility gate refused it. */
|
|
99
|
+
export interface RunRefusal {
|
|
100
|
+
name: string;
|
|
101
|
+
message: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Every source the run refused, from either place a run records one: the
|
|
106
|
+
* metadata list auto-run writes, and the `failures` an orchestrated run marks
|
|
107
|
+
* `refused`. Sorted by name so the list reads the same on every render.
|
|
108
|
+
*/
|
|
109
|
+
export function refusedSourcesOf(
|
|
110
|
+
materialization: Materialization,
|
|
111
|
+
): RunRefusal[] {
|
|
112
|
+
const fromMetadata = Object.values(
|
|
113
|
+
parseMetadata(materialization).refusedSources ?? {},
|
|
114
|
+
).map((r) => ({ name: r.name, message: r.message }));
|
|
115
|
+
const fromFailures = Object.values(materialization.manifest?.failures ?? {})
|
|
116
|
+
.filter((f) => f.refused)
|
|
117
|
+
.map((f) => ({
|
|
118
|
+
name: f.sourceName ?? f.sourceEntityId,
|
|
119
|
+
message: f.reason,
|
|
120
|
+
}));
|
|
121
|
+
return [...fromMetadata, ...fromFailures].sort((a, b) =>
|
|
122
|
+
a.name.localeCompare(b.name),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The run's source counts, joined by `separator`. Refused sources are named
|
|
128
|
+
* only when there are some, so a clean run reads as it always has.
|
|
129
|
+
*/
|
|
130
|
+
export function sourcesSummary(
|
|
131
|
+
meta: MaterializationMetadata,
|
|
132
|
+
separator: string,
|
|
133
|
+
): string {
|
|
134
|
+
const parts = [
|
|
135
|
+
`${meta.sourcesBuilt ?? 0} built`,
|
|
136
|
+
`${meta.sourcesReused ?? 0} reused`,
|
|
137
|
+
];
|
|
138
|
+
if (meta.sourcesRefused) parts.push(`${meta.sourcesRefused} refused`);
|
|
139
|
+
return parts.join(separator);
|
|
84
140
|
}
|
|
85
141
|
|
|
86
142
|
export function parseMetadata(
|