@malloy-publisher/sdk 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/ServerProvider-Cn_LhKda.cjs.js +1 -0
  2. package/dist/{ServerProvider-DUFPY6Rv.es.js → ServerProvider-sfabtriY.es.js} +110 -106
  3. package/dist/client/api.d.ts +62 -15
  4. package/dist/client/index.cjs.js +1 -1
  5. package/dist/client/index.es.js +14 -13
  6. package/dist/components/Dashboard/Dashboard.d.ts +14 -1
  7. package/dist/components/Dashboard/DashboardTile.d.ts +16 -7
  8. package/dist/{core-hLahnv0W.cjs.js → core-CqRKhtoy.cjs.js} +1 -1
  9. package/dist/{core-lb28vQkR.es.js → core-DyU47reh.es.js} +1 -1
  10. package/dist/hooks/useSuggestOptions.d.ts +1 -1
  11. package/dist/{index-txw04ZbN.es.js → index-CAkFE4Ol.es.js} +13455 -13248
  12. package/dist/index-DD4b_bt0.cjs.js +356 -0
  13. package/dist/index.cjs.js +1 -1
  14. package/dist/index.es.js +9 -9
  15. package/dist/theme/buildTableCssVars.d.ts +17 -1
  16. package/package.json +1 -1
  17. package/src/components/Connections/AddConnectionDialog.tsx +102 -23
  18. package/src/components/Connections/EditConnectionDialog.tsx +134 -33
  19. package/src/components/Connections/common.ts +30 -2
  20. package/src/components/Dashboard/Dashboard.spec.tsx +216 -0
  21. package/src/components/Dashboard/Dashboard.tsx +77 -17
  22. package/src/components/Dashboard/DashboardTile.spec.tsx +81 -0
  23. package/src/components/Dashboard/DashboardTile.tsx +58 -12
  24. package/src/components/Dashboard/tileGridColumn.spec.ts +35 -0
  25. package/src/components/Notebook/Notebook.spec.tsx +88 -0
  26. package/src/components/Notebook/Notebook.tsx +1 -0
  27. package/src/components/Package/Package.spec.tsx +113 -0
  28. package/src/components/Package/Package.tsx +29 -3
  29. package/src/components/RenderedResult/RenderedResult.tsx +47 -7
  30. package/src/hooks/useSuggestOptions.dom.spec.ts +91 -0
  31. package/src/hooks/useSuggestOptions.ts +6 -1
  32. package/src/theme/buildTableCssVars.spec.ts +19 -0
  33. package/src/theme/buildTableCssVars.ts +31 -0
  34. package/test/README.md +44 -0
  35. package/test/serverProvider.tsx +72 -0
  36. package/dist/ServerProvider-CTopDUWW.cjs.js +0 -1
  37. package/dist/index-DvEanVgc.cjs.js +0 -339
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DvEanVgc.cjs.js"),r=require("./ServerProvider-CTopDUWW.cjs.js");exports.AnalyzePackageButton=e.AnalyzePackageButton;exports.BrowserWorkbookStorage=e.BrowserWorkbookStorage;exports.ConnectionExplorer=e.ConnectionExplorer;exports.DOC_LINKS=e.DOC_LINKS;exports.DRILL_CELL_CLASS=e.DRILL_CELL_CLASS;exports.DRILL_SELF=e.DRILL_SELF;exports.Dashboard=e.Dashboard;exports.DashboardTile=e.DashboardTile;exports.DataAppViewer=e.DataAppViewer;exports.DimensionFilter=e.DimensionFilter;exports.EmbeddedQueryResult=e.EmbeddedQueryResult;exports.Environment=e.Environment;exports.EnvironmentMaterializations=e.EnvironmentMaterializations;exports.GivenInput=e.GivenInput;exports.GivensPanel=e.GivensPanel;exports.Home=e.Home;exports.Loading=e.Loading;exports.Materializations=e.Materializations;exports.Model=e.Model;exports.ModelExplorer=e.ModelExplorer;exports.ModelExplorerDialog=e.ModelExplorerDialog;exports.Models=e.Models;exports.Notebook=e.Notebook;exports.Package=e.Package;exports.Packages=e.Packages;exports.QueryResult=e.QueryResult;exports.RenderedResult=e.RenderedResult;exports.ResultContainer=e.ResultContainer;exports.SourceExplorerComponent=e.SourceExplorerComponent;exports.SourcesExplorer=e.SourcesExplorer;exports.Workbook=e.Workbook;exports.WorkbookList=e.WorkbookList;exports.WorkbookManager=e.WorkbookManager;exports.WorkbookStorageProvider=e.WorkbookStorageProvider;exports.buildMalloyExplicitTheme=e.buildMalloyExplicitTheme;exports.buildTableCssVars=e.buildTableCssVars;exports.buildVegaThemeOverride=e.buildVegaThemeOverride;exports.createEmbeddedQueryResult=e.createEmbeddedQueryResult;exports.drillDestinations=e.drillDestinations;exports.drillValueToFilter=e.drillValueToFilter;exports.drillableFieldNames=e.drillableFieldNames;exports.encodeDrillValue=e.encodeDrillValue;exports.encodeResourceUri=e.encodeResourceUri;exports.extractDimensionSpecs=e.extractDimensionSpecs;exports.extractSourceFromQuery=e.extractSourceFromQuery;exports.generateFilterClause=e.generateFilterClause;exports.getDimensionKey=e.getDimensionKey;exports.getJoinedSources=e.getJoinedSources;exports.humanizeSlug=e.humanizeSlug;exports.injectWhereClause=e.injectWhereClause;exports.makeDimensionKey=e.makeDimensionKey;exports.markDrillableCells=e.markDrillableCells;exports.packageFileUrl=e.packageFileUrl;exports.parseAllSourceInfos=e.parseAllSourceInfos;exports.parseDimensionFilterAnnotation=e.parseDimensionFilterAnnotation;exports.parseNotebookFilterAnnotation=e.parseNotebookFilterAnnotation;exports.parseResourceUri=e.parseResourceUri;exports.readChartAnnotations=e.readChartAnnotations;exports.resolveDrill=e.resolveDrill;exports.useDimensionFilters=e.useDimensionFilters;exports.useDimensionFiltersFromSpec=e.useDimensionFiltersFromSpec;exports.useDimensionFiltersQuery=e.useDimensionFiltersQuery;exports.useDimensionalFilterRangeData=e.useDimensionalFilterRangeData;exports.useDrill=e.useDrill;exports.useGivensState=e.useGivensState;exports.useModelData=e.useModelData;exports.useModelGivens=e.useModelGivens;exports.useRawQueryData=e.useRawQueryData;exports.useRouterClickHandler=e.useRouterClickHandler;exports.useSuggestOptions=e.useSuggestOptions;exports.DEFAULT_THEME=r.DEFAULT_THEME;exports.ServerProvider=r.ServerProvider;exports.ThemeProvider=r.ThemeProvider;exports.resolveMode=r.resolveMode;exports.resolveTheme=r.resolveTheme;exports.usePublisherTheme=r.usePublisherTheme;exports.useServer=r.useServer;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DD4b_bt0.cjs.js"),r=require("./ServerProvider-Cn_LhKda.cjs.js");exports.AnalyzePackageButton=e.AnalyzePackageButton;exports.BrowserWorkbookStorage=e.BrowserWorkbookStorage;exports.ConnectionExplorer=e.ConnectionExplorer;exports.DOC_LINKS=e.DOC_LINKS;exports.DRILL_CELL_CLASS=e.DRILL_CELL_CLASS;exports.DRILL_SELF=e.DRILL_SELF;exports.Dashboard=e.Dashboard;exports.DashboardTile=e.DashboardTile;exports.DataAppViewer=e.DataAppViewer;exports.DimensionFilter=e.DimensionFilter;exports.EmbeddedQueryResult=e.EmbeddedQueryResult;exports.Environment=e.Environment;exports.EnvironmentMaterializations=e.EnvironmentMaterializations;exports.GivenInput=e.GivenInput;exports.GivensPanel=e.GivensPanel;exports.Home=e.Home;exports.Loading=e.Loading;exports.Materializations=e.Materializations;exports.Model=e.Model;exports.ModelExplorer=e.ModelExplorer;exports.ModelExplorerDialog=e.ModelExplorerDialog;exports.Models=e.Models;exports.Notebook=e.Notebook;exports.Package=e.Package;exports.Packages=e.Packages;exports.QueryResult=e.QueryResult;exports.RenderedResult=e.RenderedResult;exports.ResultContainer=e.ResultContainer;exports.SourceExplorerComponent=e.SourceExplorerComponent;exports.SourcesExplorer=e.SourcesExplorer;exports.Workbook=e.Workbook;exports.WorkbookList=e.WorkbookList;exports.WorkbookManager=e.WorkbookManager;exports.WorkbookStorageProvider=e.WorkbookStorageProvider;exports.buildMalloyExplicitTheme=e.buildMalloyExplicitTheme;exports.buildTableCssVars=e.buildTableCssVars;exports.buildVegaThemeOverride=e.buildVegaThemeOverride;exports.createEmbeddedQueryResult=e.createEmbeddedQueryResult;exports.drillDestinations=e.drillDestinations;exports.drillValueToFilter=e.drillValueToFilter;exports.drillableFieldNames=e.drillableFieldNames;exports.encodeDrillValue=e.encodeDrillValue;exports.encodeResourceUri=e.encodeResourceUri;exports.extractDimensionSpecs=e.extractDimensionSpecs;exports.extractSourceFromQuery=e.extractSourceFromQuery;exports.generateFilterClause=e.generateFilterClause;exports.getDimensionKey=e.getDimensionKey;exports.getJoinedSources=e.getJoinedSources;exports.humanizeSlug=e.humanizeSlug;exports.injectWhereClause=e.injectWhereClause;exports.makeDimensionKey=e.makeDimensionKey;exports.markDrillableCells=e.markDrillableCells;exports.packageFileUrl=e.packageFileUrl;exports.parseAllSourceInfos=e.parseAllSourceInfos;exports.parseDimensionFilterAnnotation=e.parseDimensionFilterAnnotation;exports.parseNotebookFilterAnnotation=e.parseNotebookFilterAnnotation;exports.parseResourceUri=e.parseResourceUri;exports.readChartAnnotations=e.readChartAnnotations;exports.resolveDrill=e.resolveDrill;exports.useDimensionFilters=e.useDimensionFilters;exports.useDimensionFiltersFromSpec=e.useDimensionFiltersFromSpec;exports.useDimensionFiltersQuery=e.useDimensionFiltersQuery;exports.useDimensionalFilterRangeData=e.useDimensionalFilterRangeData;exports.useDrill=e.useDrill;exports.useGivensState=e.useGivensState;exports.useModelData=e.useModelData;exports.useModelGivens=e.useModelGivens;exports.useRawQueryData=e.useRawQueryData;exports.useRouterClickHandler=e.useRouterClickHandler;exports.useSuggestOptions=e.useSuggestOptions;exports.DEFAULT_THEME=r.DEFAULT_THEME;exports.ServerProvider=r.ServerProvider;exports.ThemeProvider=r.ThemeProvider;exports.resolveMode=r.resolveMode;exports.resolveTheme=r.resolveTheme;exports.usePublisherTheme=r.usePublisherTheme;exports.useServer=r.useServer;
package/dist/index.es.js CHANGED
@@ -1,10 +1,10 @@
1
- import { A as s, a7 as r, C as o, ao as i, j as l, l as n, D as t, g as u, i as d, x as m, a0 as D, E as c, R as k, L as p, M as S, N as b, O as g, Q as v, S as E, T as F, U as R, _ as C, Y as L, Z as M, P as h, $ as T, a2 as x, a3 as y, W as A, V as P, a4 as Q, a5 as V, a8 as W, a6 as I, ai as U, aj as _, ak as G, a1 as N, n as f, o as z, k as H, q as K, an as O, y as j, B as w, F as B, ad as J, G as q, r as X, H as Y, ae as Z, m as $, p as aa, I as ea, J as sa, K as ra, am as oa, al as ia, t as la, a9 as na, aa as ta, ab as ua, ac as da, v as ma, ag as Da, X as ca, af as ka, u as pa, e as Sa, ah as ba } from "./index-txw04ZbN.es.js";
2
- import { aT as va, S as Ea, aV as Fa, aU as Ra, aS as Ca, aD as La, u as Ma } from "./ServerProvider-DUFPY6Rv.es.js";
1
+ import { A as s, a7 as r, C as o, ao as i, j as l, l as n, D as t, g as u, i as d, x as m, a0 as D, E as c, R as k, L as p, M as S, N as b, O as g, Q as E, S as v, T as F, U as R, _ as C, Y as L, Z as M, P as h, $ as T, a2 as x, a3 as y, W as A, V as P, a4 as W, a5 as Q, a8 as V, a6 as I, ai as U, aj as _, ak as G, a1 as N, n as f, o as z, k as H, q as K, an as O, y as j, B as w, F as B, ad as J, G as q, r as X, H as Y, ae as Z, m as $, p as aa, I as ea, J as sa, K as ra, am as oa, al as ia, t as la, a9 as na, aa as ta, ab as ua, ac as da, v as ma, ag as Da, X as ca, af as ka, u as pa, e as Sa, ah as ba } from "./index-CAkFE4Ol.es.js";
2
+ import { aU as Ea, S as va, aW as Fa, aV as Ra, aT as Ca, aE as La, u as Ma } from "./ServerProvider-sfabtriY.es.js";
3
3
  export {
4
4
  s as AnalyzePackageButton,
5
5
  r as BrowserWorkbookStorage,
6
6
  o as ConnectionExplorer,
7
- va as DEFAULT_THEME,
7
+ Ea as DEFAULT_THEME,
8
8
  i as DOC_LINKS,
9
9
  l as DRILL_CELL_CLASS,
10
10
  n as DRILL_SELF,
@@ -19,8 +19,8 @@ export {
19
19
  S as GivensPanel,
20
20
  b as Home,
21
21
  g as Loading,
22
- v as Materializations,
23
- E as Model,
22
+ E as Materializations,
23
+ v as Model,
24
24
  F as ModelExplorer,
25
25
  R as ModelExplorerDialog,
26
26
  C as Models,
@@ -30,13 +30,13 @@ export {
30
30
  T as QueryResult,
31
31
  x as RenderedResult,
32
32
  y as ResultContainer,
33
- Ea as ServerProvider,
33
+ va as ServerProvider,
34
34
  A as SourceExplorerComponent,
35
35
  P as SourcesExplorer,
36
36
  Fa as ThemeProvider,
37
- Q as Workbook,
38
- V as WorkbookList,
39
- W as WorkbookManager,
37
+ W as Workbook,
38
+ Q as WorkbookList,
39
+ V as WorkbookManager,
40
40
  I as WorkbookStorageProvider,
41
41
  U as buildMalloyExplicitTheme,
42
42
  _ as buildTableCssVars,
@@ -1,4 +1,20 @@
1
1
  import { ResolvedTheme } from './types';
2
+ /**
3
+ * Padding inside a dashboard card, around the result. The renderer's own
4
+ * default, shared with the composite tile so the two cards cannot drift.
5
+ */
6
+ export declare const DASHBOARD_CARD_PADDING_PX = 20;
7
+ /**
8
+ * Geometry the two dashboard cards agree on. Not part of {@link ResolvedTheme}
9
+ * because the radius comes from the HOST's MUI `shape.borderRadius` rather than
10
+ * from the instance theme: a dashboard card should read as a card of the app it
11
+ * is embedded in, and pinning it to a constant is what made the renderer's 8px
12
+ * the only 8px card on a 4px page.
13
+ */
14
+ export interface DashboardCardGeometry {
15
+ radius: string;
16
+ padding: string;
17
+ }
2
18
  /**
3
19
  * Build the CSS variable map applied to the wrapper element around
4
20
  * `<malloy-render>`. The values here power two things only:
@@ -22,4 +38,4 @@ import { ResolvedTheme } from './types';
22
38
  * compete with that lookup, so the shadow namespace just bloated
23
39
  * every wrapper element's inline style.
24
40
  */
25
- export declare function buildTableCssVars(theme: ResolvedTheme): Record<string, string>;
41
+ export declare function buildTableCssVars(theme: ResolvedTheme, card?: DashboardCardGeometry): Record<string, string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/sdk",
3
3
  "description": "Malloy Publisher SDK",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -56,6 +56,10 @@ export default function AddConnectionDialog({
56
56
  // DuckLake top-level connection state
57
57
  const [ducklakeCatalogType, setDucklakeCatalogType] = useState("postgres");
58
58
  const [ducklakeStorageType, setDucklakeStorageType] = useState("s3");
59
+ // Which S3 credential shape the storage fields are showing. Needed as state
60
+ // because this section renders uncontrolled inputs read from FormData, so
61
+ // `visibleWhen` has nothing to compare against without it.
62
+ const [ducklakeS3Provider, setDucklakeS3Provider] = useState("config");
59
63
 
60
64
  const handleClickOpen = () => {
61
65
  setOpen(true);
@@ -67,6 +71,7 @@ export default function AddConnectionDialog({
67
71
  setType("postgres");
68
72
  setDucklakeCatalogType("postgres");
69
73
  setDucklakeStorageType("s3");
74
+ setDucklakeS3Provider("config");
70
75
  };
71
76
 
72
77
  const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
@@ -123,11 +128,26 @@ export default function AddConnectionDialog({
123
128
  }
124
129
  });
125
130
  // Validate required fields
126
- if (!s3Config.accessKeyId) {
127
- throw new Error("S3 Access Key ID is required");
128
- }
129
- if (!s3Config.secretAccessKey) {
130
- throw new Error("S3 Secret Access Key is required");
131
+ // Under `credential_chain` the host supplies the credential, so a key
132
+ // pair is not merely optional — the server rejects one that is present
133
+ // and unused.
134
+ if (s3Config.provider === "credential_chain") {
135
+ delete s3Config.accessKeyId;
136
+ delete s3Config.secretAccessKey;
137
+ delete s3Config.sessionToken;
138
+ } else {
139
+ // Symmetric with the deletion above, and load-bearing on the edit
140
+ // path: switching the provider to a key pair unmounts the chain
141
+ // field, so it never resubmits and a carried-forward value would
142
+ // survive into a config the server rejects — naming a field the form
143
+ // is no longer showing.
144
+ delete s3Config.chain;
145
+ if (!s3Config.accessKeyId) {
146
+ throw new Error("S3 Access Key ID is required");
147
+ }
148
+ if (!s3Config.secretAccessKey) {
149
+ throw new Error("S3 Secret Access Key is required");
150
+ }
131
151
  }
132
152
  if (Object.keys(s3Config).length > 0) {
133
153
  storageConfig.s3Connection = s3Config;
@@ -203,6 +223,29 @@ export default function AddConnectionDialog({
203
223
  }
204
224
  });
205
225
 
226
+ // The S3 key fields are no longer HTML-`required`, because under
227
+ // `credential_chain` there is no key to give and a hidden required
228
+ // field blocks submit with nothing on screen to fix. Enforce the
229
+ // pair here instead, where it can be conditional — otherwise a
230
+ // keyless key-based attachment would save and fail at attach.
231
+ if (dbType === "s3") {
232
+ if (connectionConfig.provider === "credential_chain") {
233
+ delete connectionConfig.accessKeyId;
234
+ delete connectionConfig.secretAccessKey;
235
+ delete connectionConfig.sessionToken;
236
+ } else {
237
+ delete connectionConfig.chain;
238
+ if (
239
+ !connectionConfig.accessKeyId ||
240
+ !connectionConfig.secretAccessKey
241
+ ) {
242
+ throw new Error(
243
+ `Attached database "${dbName}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`,
244
+ );
245
+ }
246
+ }
247
+ }
248
+
206
249
  // Set the appropriate connection property based on type
207
250
  const connectionFieldName =
208
251
  attachedDatabaseConnectionFieldName[dbType];
@@ -512,24 +555,60 @@ export default function AddConnectionDialog({
512
555
  >
513
556
  S3 Credentials
514
557
  </Typography>
515
- {s3AttachedDatabaseFields.map((field) => (
516
- <TextField
517
- key={`s3_${field.name}`}
518
- margin="dense"
519
- id={`ducklake_s3_${field.name}`}
520
- name={`ducklake_s3_${field.name}`}
521
- label={field.label}
522
- type={field.type}
523
- fullWidth
524
- variant="standard"
525
- required={field.required}
526
- placeholder={
527
- field.name === "region"
528
- ? "us-east-1"
529
- : undefined
530
- }
531
- />
532
- ))}
558
+ {s3AttachedDatabaseFields
559
+ .filter((field) =>
560
+ field.visibleWhen
561
+ ? ducklakeS3Provider ===
562
+ field.visibleWhen.value
563
+ : true,
564
+ )
565
+ .map((field) => (
566
+ <TextField
567
+ key={`s3_${field.name}`}
568
+ margin="dense"
569
+ id={`ducklake_s3_${field.name}`}
570
+ name={`ducklake_s3_${field.name}`}
571
+ label={field.label}
572
+ type={
573
+ field.selectOptions
574
+ ? undefined
575
+ : field.type
576
+ }
577
+ fullWidth
578
+ variant="standard"
579
+ required={field.required}
580
+ select={!!field.selectOptions}
581
+ defaultValue={
582
+ field.selectOptions
583
+ ? ducklakeS3Provider
584
+ : undefined
585
+ }
586
+ onChange={
587
+ field.name === "provider"
588
+ ? (e) =>
589
+ setDucklakeS3Provider(
590
+ e.target.value,
591
+ )
592
+ : undefined
593
+ }
594
+ placeholder={
595
+ field.name === "region"
596
+ ? "us-east-1"
597
+ : undefined
598
+ }
599
+ >
600
+ {field.selectOptions?.map(
601
+ (option) => (
602
+ <MenuItem
603
+ key={option.value}
604
+ value={option.value}
605
+ >
606
+ {option.label}
607
+ </MenuItem>
608
+ ),
609
+ )}
610
+ </TextField>
611
+ ))}
533
612
  </>
534
613
  )}
535
614
  {ducklakeStorageType === "gcs" && (
@@ -80,10 +80,22 @@ export default function EditConnectionDialog({
80
80
  const [ducklakeStorageType, setDucklakeStorageType] = useState(() =>
81
81
  initDucklakeStorageType(connection),
82
82
  );
83
+ // Which S3 credential shape the storage fields are showing. Seeded from the
84
+ // connection being edited, so opening a host-credential connection shows the
85
+ // chain fields rather than empty key fields it does not use.
86
+ const [ducklakeS3Provider, setDucklakeS3Provider] = useState<string>(
87
+ () =>
88
+ connection.ducklakeConnection?.storage?.s3Connection?.provider ??
89
+ "config",
90
+ );
83
91
 
84
92
  const handleClickOpen = () => {
85
93
  setAttachedDatabases(initAttachedDatabases(connection));
86
94
  setType(connection.type);
95
+ setDucklakeS3Provider(
96
+ connection.ducklakeConnection?.storage?.s3Connection?.provider ??
97
+ "config",
98
+ );
87
99
  setDucklakeCatalogType("postgres");
88
100
  setDucklakeStorageType(initDucklakeStorageType(connection));
89
101
  setOpen(true);
@@ -147,10 +159,23 @@ export default function EditConnectionDialog({
147
159
  s3Config[field.name] = value;
148
160
  }
149
161
  });
150
- // For updates, use existing values if not provided
162
+ // For updates, use existing values if not provided. `provider` and
163
+ // `chain` are carried forward for the same reason the key pair is:
164
+ // this form rebuilds the whole s3Connection from its own fields, so
165
+ // anything it does not resubmit is dropped. Losing `provider` here
166
+ // silently downgrades a host-credential connection to a key-based one
167
+ // that has no key — and because the checks below used to be
168
+ // unconditional, it also made a chain-auth connection impossible to
169
+ // edit at all, including just its bucket URL.
151
170
  const existingS3 =
152
171
  connection.ducklakeConnection?.storage?.s3Connection;
153
172
  if (existingS3) {
173
+ if (!s3Config.provider && existingS3.provider) {
174
+ s3Config.provider = existingS3.provider;
175
+ }
176
+ if (!s3Config.chain && existingS3.chain) {
177
+ s3Config.chain = existingS3.chain;
178
+ }
154
179
  if (!s3Config.accessKeyId && existingS3.accessKeyId) {
155
180
  s3Config.accessKeyId = existingS3.accessKeyId;
156
181
  }
@@ -158,12 +183,26 @@ export default function EditConnectionDialog({
158
183
  s3Config.secretAccessKey = existingS3.secretAccessKey;
159
184
  }
160
185
  }
161
- // Validate required fields
162
- if (!s3Config.accessKeyId) {
163
- throw new Error("S3 Access Key ID is required");
164
- }
165
- if (!s3Config.secretAccessKey) {
166
- throw new Error("S3 Secret Access Key is required");
186
+ // Validate required fields. Under `credential_chain` the host supplies
187
+ // the credential, so a key pair is not merely optional — the server
188
+ // rejects one that is present and unused.
189
+ if (s3Config.provider === "credential_chain") {
190
+ delete s3Config.accessKeyId;
191
+ delete s3Config.secretAccessKey;
192
+ delete s3Config.sessionToken;
193
+ } else {
194
+ // Symmetric with the deletion above, and load-bearing on the edit
195
+ // path: switching the provider to a key pair unmounts the chain
196
+ // field, so it never resubmits and a carried-forward value would
197
+ // survive into a config the server rejects — naming a field the form
198
+ // is no longer showing.
199
+ delete s3Config.chain;
200
+ if (!s3Config.accessKeyId) {
201
+ throw new Error("S3 Access Key ID is required");
202
+ }
203
+ if (!s3Config.secretAccessKey) {
204
+ throw new Error("S3 Secret Access Key is required");
205
+ }
167
206
  }
168
207
  if (Object.keys(s3Config).length > 0) {
169
208
  storageConfig.s3Connection = s3Config;
@@ -247,6 +286,32 @@ export default function EditConnectionDialog({
247
286
  }
248
287
  });
249
288
 
289
+ // The S3 key fields are no longer HTML-`required`, because under
290
+ // `credential_chain` there is no key to give and a hidden required
291
+ // field blocks submit with nothing on screen to fix. Enforce the
292
+ // pair here instead, where it can be conditional — otherwise a
293
+ // keyless key-based attachment would save and fail at attach. This
294
+ // does not ask anyone to retype a secret: the inputs are seeded
295
+ // from the stored connection, so an untouched field resubmits its
296
+ // existing value.
297
+ if (dbType === "s3") {
298
+ if (connectionConfig.provider === "credential_chain") {
299
+ delete connectionConfig.accessKeyId;
300
+ delete connectionConfig.secretAccessKey;
301
+ delete connectionConfig.sessionToken;
302
+ } else {
303
+ delete connectionConfig.chain;
304
+ if (
305
+ !connectionConfig.accessKeyId ||
306
+ !connectionConfig.secretAccessKey
307
+ ) {
308
+ throw new Error(
309
+ `Attached database "${dbName}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`,
310
+ );
311
+ }
312
+ }
313
+ }
314
+
250
315
  const connectionFieldName =
251
316
  attachedDatabaseConnectionFieldName[dbType];
252
317
  if (connectionFieldName) {
@@ -625,32 +690,68 @@ export default function EditConnectionDialog({
625
690
  >
626
691
  S3 Credentials
627
692
  </Typography>
628
- {s3AttachedDatabaseFields.map((field) => (
629
- <TextField
630
- key={`s3_${field.name}`}
631
- margin="dense"
632
- id={`ducklake_s3_${field.name}`}
633
- name={`ducklake_s3_${field.name}`}
634
- label={field.label}
635
- type={field.type}
636
- fullWidth
637
- variant="standard"
638
- required={
639
- field.required &&
640
- field.name !== "secretAccessKey"
641
- }
642
- defaultValue={getDucklakeDefault(
643
- `s3_${field.name}`,
644
- )}
645
- placeholder={
646
- field.name === "region"
647
- ? "us-east-1"
648
- : field.name === "secretAccessKey"
649
- ? "Leave empty to keep existing"
650
- : undefined
651
- }
652
- />
653
- ))}
693
+ {s3AttachedDatabaseFields
694
+ .filter((field) =>
695
+ field.visibleWhen
696
+ ? ducklakeS3Provider ===
697
+ field.visibleWhen.value
698
+ : true,
699
+ )
700
+ .map((field) => (
701
+ <TextField
702
+ key={`s3_${field.name}`}
703
+ margin="dense"
704
+ id={`ducklake_s3_${field.name}`}
705
+ name={`ducklake_s3_${field.name}`}
706
+ label={field.label}
707
+ type={
708
+ field.selectOptions
709
+ ? undefined
710
+ : field.type
711
+ }
712
+ fullWidth
713
+ variant="standard"
714
+ required={
715
+ field.required &&
716
+ field.name !== "secretAccessKey"
717
+ }
718
+ select={!!field.selectOptions}
719
+ defaultValue={
720
+ field.selectOptions
721
+ ? ducklakeS3Provider
722
+ : getDucklakeDefault(
723
+ `s3_${field.name}`,
724
+ )
725
+ }
726
+ onChange={
727
+ field.name === "provider"
728
+ ? (e) =>
729
+ setDucklakeS3Provider(
730
+ e.target.value,
731
+ )
732
+ : undefined
733
+ }
734
+ placeholder={
735
+ field.name === "region"
736
+ ? "us-east-1"
737
+ : field.name ===
738
+ "secretAccessKey"
739
+ ? "Leave empty to keep existing"
740
+ : undefined
741
+ }
742
+ >
743
+ {field.selectOptions?.map(
744
+ (option) => (
745
+ <MenuItem
746
+ key={option.value}
747
+ value={option.value}
748
+ >
749
+ {option.label}
750
+ </MenuItem>
751
+ ),
752
+ )}
753
+ </TextField>
754
+ ))}
654
755
  </>
655
756
  )}
656
757
  {ducklakeStorageType === "gcs" && (
@@ -355,17 +355,44 @@ export const attachedDatabaseConnectionFieldName: Record<string, string> = {
355
355
 
356
356
  // Fields for S3 attached database
357
357
  export const s3AttachedDatabaseFields: Array<ConnectionField> = [
358
+ {
359
+ label: "Credential Provider",
360
+ name: "provider" as keyof S3Connection,
361
+ type: "text",
362
+ required: false,
363
+ selectOptions: [
364
+ { label: "Access key pair", value: "config" },
365
+ { label: "Host credential chain", value: "credential_chain" },
366
+ ],
367
+ },
368
+ // Neither key is `required` any more, because under `credential_chain` there is
369
+ // no key to give and a hidden-but-required field blocks submit with nothing on
370
+ // screen to fix. Presence is enforced where it can be conditional instead: each
371
+ // dialog checks the pair on the `config` path, in BOTH the DuckLake storage
372
+ // branch and the attached-database branch. Server-side, a keyless `config`
373
+ // storage DESTINATION is rejected at config load; a DuckLake connection or an
374
+ // attached database still fails at attach, because a load-time throw there would
375
+ // take the whole environment down with it.
358
376
  {
359
377
  label: "Access Key ID",
360
378
  name: "accessKeyId" as keyof S3Connection,
361
379
  type: "text",
362
- required: true,
380
+ required: false,
381
+ visibleWhen: { field: "provider", value: "config" },
363
382
  },
364
383
  {
365
384
  label: "Secret Access Key",
366
385
  name: "secretAccessKey" as keyof S3Connection,
367
386
  type: "password",
368
- required: true,
387
+ required: false,
388
+ visibleWhen: { field: "provider", value: "config" },
389
+ },
390
+ {
391
+ label: "Credential Chain",
392
+ name: "chain" as keyof S3Connection,
393
+ type: "text",
394
+ required: false,
395
+ visibleWhen: { field: "provider", value: "credential_chain" },
369
396
  },
370
397
  {
371
398
  label: "Region",
@@ -384,6 +411,7 @@ export const s3AttachedDatabaseFields: Array<ConnectionField> = [
384
411
  name: "sessionToken" as keyof S3Connection,
385
412
  type: "password",
386
413
  required: false,
414
+ visibleWhen: { field: "provider", value: "config" },
387
415
  },
388
416
  ];
389
417