@dashboard-designer/core 0.2.1 → 0.2.3

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/index.d.ts CHANGED
@@ -175,6 +175,7 @@ interface Dashboard {
175
175
  exportOptions?: DashboardExportOptions;
176
176
  /** View-mode display preferences (widget chrome, etc.). */
177
177
  displayOptions?: DashboardDisplayOptions;
178
+ printSettings?: DashboardPrintSettings;
178
179
  layout: GridItem[];
179
180
  globalFilters: FilterDef[];
180
181
  widgets: Widget[];
@@ -276,6 +277,8 @@ interface DashboardVersion extends DashboardVersionMeta {
276
277
  dashboard: Dashboard;
277
278
  }
278
279
  interface ConnectionConfig {
280
+ /** Environment connection variable (synthetic data-source option). */
281
+ variableName?: string;
279
282
  id: string;
280
283
  name: string;
281
284
  provider: DbProvider;
@@ -326,7 +329,7 @@ interface ExecuteQueryRequest {
326
329
  type VariableValue = string | number | boolean | null;
327
330
  interface DashboardVariable {
328
331
  name: string;
329
- type: 'string' | 'number' | 'boolean';
332
+ type: 'string' | 'number' | 'boolean' | 'connection';
330
333
  description?: string;
331
334
  defaultValue?: VariableValue;
332
335
  }
@@ -371,5 +374,31 @@ declare function normalizeChartAxisGuidelines(raw: unknown): ChartAxisGuideline[
371
374
  declare function createEmptyDashboard(partial?: Partial<Dashboard>): Dashboard;
372
375
  declare function createEmptyWidget(type?: WidgetType): Widget;
373
376
  declare function createId(): string;
377
+ /** Connection variables have environment-owned values, never dashboard defaults. */
378
+ declare function connectionVariableNames(dashboard: Dashboard): string[];
379
+ declare function portableDashboard(dashboard: Dashboard): Dashboard;
380
+ /** Defaults for the print dialog. Printed-by is supplied by the host or signed-in user. */
381
+ interface DashboardPrintHeader {
382
+ enabled?: boolean;
383
+ repeat?: boolean;
384
+ logoUrl?: string;
385
+ organization?: string;
386
+ title?: string;
387
+ printedBy?: string;
388
+ showPrintedOn?: boolean;
389
+ fields?: Array<{
390
+ label: string;
391
+ value: string;
392
+ }>;
393
+ }
394
+ /** Saved dashboard defaults. User identity and print time are resolved at print time. */
395
+ interface DashboardPrintSettings {
396
+ orientation?: 'portrait' | 'landscape';
397
+ layout?: 'designed' | 'one-column' | 'two-column';
398
+ header?: Omit<DashboardPrintHeader, 'printedBy'> & {
399
+ showPrintedBy?: boolean;
400
+ };
401
+ }
402
+ declare function resolvePrintHeader(title: string, settings?: DashboardPrintSettings, runtime?: DashboardPrintHeader, user?: string): DashboardPrintHeader;
374
403
 
375
- export { type AuthConfig, type AuthMode, type ChartAxisGuideline, type ChartGuidelineAxis, type ConnectionConfig, type ContainerLabelItem, type ContainerLabelLayout, type ContainerLabelTemplate, DASHBOARD_FILE_FORMAT, DASHBOARD_FILE_VERSION, DB_PROVIDERS, DEFAULT_CHART_COLORS, DEFAULT_THEME_ACCENT, type Dashboard, type DashboardAclEntry, type DashboardDisplayOptions, type DashboardEmailOptions, type DashboardExportOptions, type DashboardFileEnvelope, type DashboardPermission, type DashboardTheme, type DashboardVariable, type DashboardVersion, type DashboardVersionMeta, type DataBinding, type DbProvider, type DrillDownDef, type EmbedTokenRequest, type EmbedTokenResponse, type ExecuteQueryRequest, type FilterDef, type FilterOperator, type GridItem, type JoinDef, type JoinType, LEGACY_LABEL_FOREGROUND, type LabelClickAction, type LabelContainerSource, type ProcedureParameter, type ProcedureWhereClause, type QueryColumn, type QueryDef, type QueryLabelDrillDown, type QueryResult, RTL_LOCALES, THEME_PRESETS, type User, type UserRole, type VariableValue, WIDGET_TYPES, type Widget, type WidgetType, buildContainerLabelsFromQuery, buildDashboardExportFile, buildProcedureWhereClause, cloneDashboardForImport, createChartAxisGuideline, createContainerLabelItem, createEmptyDashboard, createEmptyWidget, createId, getKpiDefaultValue, getLabelClickUrl, hasContainerLabelCustomStyles, hasContainerLabelTemplateCustomStyles, isDefaultDashboardTheme, labelClickOpensNewTab, labelWidgetShowsHeader, matchThemePreset, normalizeChartAxisGuidelines, normalizeContainerLabelTemplate, normalizeContainerLabels, normalizeQueryLabelDrillDowns, parseDashboardImport, parseStoredProcedureName, resetContainerLabelItemStyles, resetContainerLabelTemplateStyles, resolveDashboardDir, resolveDashboardTheme, resolveDashboardVariables, resolveDisplayOptions, resolveEmailOptions, resolveExportOptions, resolveFilterVariables, resolveLabelClickAction, resolveLabelContainerSource, resolveProcedureParameterValue, resolveRequestVariables, resolveVariableValue, sanitizeLabelStyleBackground, sanitizeLabelStyleColor };
404
+ export { type AuthConfig, type AuthMode, type ChartAxisGuideline, type ChartGuidelineAxis, type ConnectionConfig, type ContainerLabelItem, type ContainerLabelLayout, type ContainerLabelTemplate, DASHBOARD_FILE_FORMAT, DASHBOARD_FILE_VERSION, DB_PROVIDERS, DEFAULT_CHART_COLORS, DEFAULT_THEME_ACCENT, type Dashboard, type DashboardAclEntry, type DashboardDisplayOptions, type DashboardEmailOptions, type DashboardExportOptions, type DashboardFileEnvelope, type DashboardPermission, type DashboardPrintHeader, type DashboardPrintSettings, type DashboardTheme, type DashboardVariable, type DashboardVersion, type DashboardVersionMeta, type DataBinding, type DbProvider, type DrillDownDef, type EmbedTokenRequest, type EmbedTokenResponse, type ExecuteQueryRequest, type FilterDef, type FilterOperator, type GridItem, type JoinDef, type JoinType, LEGACY_LABEL_FOREGROUND, type LabelClickAction, type LabelContainerSource, type ProcedureParameter, type ProcedureWhereClause, type QueryColumn, type QueryDef, type QueryLabelDrillDown, type QueryResult, RTL_LOCALES, THEME_PRESETS, type User, type UserRole, type VariableValue, WIDGET_TYPES, type Widget, type WidgetType, buildContainerLabelsFromQuery, buildDashboardExportFile, buildProcedureWhereClause, cloneDashboardForImport, connectionVariableNames, createChartAxisGuideline, createContainerLabelItem, createEmptyDashboard, createEmptyWidget, createId, getKpiDefaultValue, getLabelClickUrl, hasContainerLabelCustomStyles, hasContainerLabelTemplateCustomStyles, isDefaultDashboardTheme, labelClickOpensNewTab, labelWidgetShowsHeader, matchThemePreset, normalizeChartAxisGuidelines, normalizeContainerLabelTemplate, normalizeContainerLabels, normalizeQueryLabelDrillDowns, parseDashboardImport, parseStoredProcedureName, portableDashboard, resetContainerLabelItemStyles, resetContainerLabelTemplateStyles, resolveDashboardDir, resolveDashboardTheme, resolveDashboardVariables, resolveDisplayOptions, resolveEmailOptions, resolveExportOptions, resolveFilterVariables, resolveLabelClickAction, resolveLabelContainerSource, resolvePrintHeader, resolveProcedureParameterValue, resolveRequestVariables, resolveVariableValue, sanitizeLabelStyleBackground, sanitizeLabelStyleColor };
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ function buildDashboardExportFile(dashboard) {
82
82
  format: DASHBOARD_FILE_FORMAT,
83
83
  version: DASHBOARD_FILE_VERSION,
84
84
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
85
- dashboard: structuredClone(dashboard)
85
+ dashboard: portableDashboard(dashboard)
86
86
  };
87
87
  }
88
88
  function remapFilterIds(filters, idMap) {
@@ -298,6 +298,7 @@ function resolveDashboardVariables(dashboard, predefined = [], runtime = {}) {
298
298
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(variable.name)) throw new Error(`Invalid variable name: ${variable.name}`);
299
299
  if (seen.has(variable.name)) throw new Error(`Duplicate variable name: ${variable.name}`);
300
300
  seen.add(variable.name);
301
+ if (variable.type === "connection") continue;
301
302
  let value = variable.defaultValue;
302
303
  if (predefined.some((p) => p.name === variable.name) && Object.prototype.hasOwnProperty.call(dashboard.variableDefaults ?? {}, variable.name))
303
304
  value = dashboard.variableDefaults[variable.name];
@@ -515,6 +516,7 @@ function createEmptyDashboard(partial) {
515
516
  theme: partial?.theme,
516
517
  exportOptions: partial?.exportOptions,
517
518
  displayOptions: partial?.displayOptions,
519
+ printSettings: partial?.printSettings,
518
520
  layout: partial?.layout ?? [],
519
521
  globalFilters: partial?.globalFilters ?? [],
520
522
  widgets: partial?.widgets ?? [],
@@ -608,6 +610,31 @@ function createId() {
608
610
  function cryptoRandomId() {
609
611
  return createId();
610
612
  }
613
+ function connectionVariableNames(dashboard) {
614
+ return [.../* @__PURE__ */ new Set([
615
+ ...(dashboard.variables ?? []).filter((v) => v.type === "connection").map((v) => v.name),
616
+ ...dashboard.widgets.map((w) => /^connvar:([A-Za-z_][A-Za-z0-9_]*)$/.exec(w.query.connectionId)?.[1]).filter((v) => !!v)
617
+ ])];
618
+ }
619
+ function portableDashboard(dashboard) {
620
+ const copy = structuredClone(dashboard);
621
+ const names = connectionVariableNames(copy);
622
+ copy.variables = [...(copy.variables ?? []).filter((v) => v.type !== "connection"), ...names.map((name) => ({ name, type: "connection" }))];
623
+ for (const name of names) if (copy.variableDefaults) delete copy.variableDefaults[name];
624
+ return copy;
625
+ }
626
+ function resolvePrintHeader(title, settings, runtime, user) {
627
+ const saved = settings?.header;
628
+ return {
629
+ enabled: true,
630
+ repeat: true,
631
+ showPrintedOn: true,
632
+ ...saved,
633
+ ...runtime,
634
+ title: runtime?.title || saved?.title || title,
635
+ printedBy: saved?.showPrintedBy === false ? void 0 : runtime?.printedBy ?? user
636
+ };
637
+ }
611
638
  export {
612
639
  DASHBOARD_FILE_FORMAT,
613
640
  DASHBOARD_FILE_VERSION,
@@ -622,6 +649,7 @@ export {
622
649
  buildDashboardExportFile,
623
650
  buildProcedureWhereClause,
624
651
  cloneDashboardForImport,
652
+ connectionVariableNames,
625
653
  createChartAxisGuideline,
626
654
  createContainerLabelItem,
627
655
  createEmptyDashboard,
@@ -641,6 +669,7 @@ export {
641
669
  normalizeQueryLabelDrillDowns,
642
670
  parseDashboardImport,
643
671
  parseStoredProcedureName,
672
+ portableDashboard,
644
673
  resetContainerLabelItemStyles,
645
674
  resetContainerLabelTemplateStyles,
646
675
  resolveDashboardDir,
@@ -652,6 +681,7 @@ export {
652
681
  resolveFilterVariables,
653
682
  resolveLabelClickAction,
654
683
  resolveLabelContainerSource,
684
+ resolvePrintHeader,
655
685
  resolveProcedureParameterValue,
656
686
  resolveRequestVariables,
657
687
  resolveVariableValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashboard-designer/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",