@trops/dash-core 0.1.357 → 0.1.358

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.
@@ -652,6 +652,7 @@ function requireDashboardConfigEvents () {
652
652
  const DASHBOARD_CONFIG_INSTALL_PROGRESS = "dashboard-config-install-progress";
653
653
  const DASHBOARD_CONFIG_COLLECT_DEPENDENCIES =
654
654
  "dashboard-config-collect-dependencies";
655
+ const DASHBOARD_CONFIG_PUBLISH_PLAN = "dashboard-config-publish-plan";
655
656
 
656
657
  dashboardConfigEvents$1 = {
657
658
  DASHBOARD_CONFIG_EXPORT,
@@ -666,6 +667,7 @@ function requireDashboardConfigEvents () {
666
667
  DASHBOARD_CONFIG_SELECT_FILE,
667
668
  DASHBOARD_CONFIG_INSTALL_PROGRESS,
668
669
  DASHBOARD_CONFIG_COLLECT_DEPENDENCIES,
670
+ DASHBOARD_CONFIG_PUBLISH_PLAN,
669
671
  };
670
672
  return dashboardConfigEvents$1;
671
673
  }
@@ -63123,6 +63125,55 @@ async function publishToRegistry$1(zipPath, manifest) {
63123
63125
  }
63124
63126
  }
63125
63127
 
63128
+ /**
63129
+ * Bulk-resolve package refs to their registry state. Used by the
63130
+ * batch-publish dialog to decorate dependency rows with ownership +
63131
+ * latest version + visibility.
63132
+ *
63133
+ * Sends token if available (authenticated callers see their private
63134
+ * packages too). Anonymous calls still work — only public data is
63135
+ * returned.
63136
+ *
63137
+ * @param {Array<{scope: string, name: string}>} refs
63138
+ * @returns {Promise<Object>} { success, resolved: [...], error? }
63139
+ */
63140
+ async function resolvePackages(refs) {
63141
+ if (!Array.isArray(refs) || refs.length === 0) {
63142
+ return { success: true, resolved: [] };
63143
+ }
63144
+
63145
+ try {
63146
+ const headers = { "Content-Type": "application/json" };
63147
+ const auth = getStoredToken$2();
63148
+ if (auth?.token) {
63149
+ headers.Authorization = `Bearer ${auth.token}`;
63150
+ }
63151
+
63152
+ const response = await fetch(`${REGISTRY_BASE_URL}/api/packages/resolve`, {
63153
+ method: "POST",
63154
+ headers,
63155
+ body: JSON.stringify({ refs }),
63156
+ });
63157
+
63158
+ const data = await response.json().catch(() => null);
63159
+
63160
+ if (!response.ok) {
63161
+ return {
63162
+ success: false,
63163
+ error: data?.error || `Resolve failed: ${response.status}`,
63164
+ };
63165
+ }
63166
+
63167
+ return { success: true, resolved: Array.isArray(data) ? data : [] };
63168
+ } catch (err) {
63169
+ console.error("[RegistryApiController] Resolve error:", err);
63170
+ return {
63171
+ success: false,
63172
+ error: err.message || "Failed to resolve packages",
63173
+ };
63174
+ }
63175
+ }
63176
+
63126
63177
  /**
63127
63178
  * Get the registry URL for a published package.
63128
63179
  *
@@ -63136,6 +63187,7 @@ function getRegistryUrl$1(scope, name) {
63136
63187
 
63137
63188
  var registryApiController$2 = {
63138
63189
  publishToRegistry: publishToRegistry$1,
63190
+ resolvePackages,
63139
63191
  getRegistryUrl: getRegistryUrl$1,
63140
63192
  REGISTRY_BASE_URL,
63141
63193
  };
@@ -64855,6 +64907,100 @@ async function collectDashboardDependencies$1(
64855
64907
  }
64856
64908
  }
64857
64909
 
64910
+ /**
64911
+ * Build an enriched dependency plan for batch-publishing a dashboard.
64912
+ *
64913
+ * Combines local dependency info (collectDashboardDependencies) with the
64914
+ * registry's current state (POST /api/packages/resolve) so the batch-
64915
+ * publish UI can decorate each widget + theme row with "already in
64916
+ * registry at vX.Y.Z", "owned by you", "public/private", etc.
64917
+ *
64918
+ * Each returned widget has a `registry` sub-object that is either null
64919
+ * (registry call failed or the package didn't exist) or the resolved
64920
+ * entry from the API. Never throws on registry failures — the UI can
64921
+ * still fall back to local-only info.
64922
+ *
64923
+ * @param {string} appId - Application identifier
64924
+ * @param {number|string} workspaceId - Workspace ID
64925
+ * @param {Object} widgetRegistry - WidgetRegistry instance
64926
+ * @param {Object} options - { componentConfigs?: Object }
64927
+ * @returns {Promise<Object>} { success, widgets, theme, registryError? }
64928
+ */
64929
+ async function getDashboardPublishPlan$1(
64930
+ appId,
64931
+ workspaceId,
64932
+ widgetRegistry = null,
64933
+ options = {},
64934
+ ) {
64935
+ try {
64936
+ const { resolvePackages } = registryApiController$2;
64937
+
64938
+ const deps = await collectDashboardDependencies$1(
64939
+ appId,
64940
+ workspaceId,
64941
+ widgetRegistry,
64942
+ options,
64943
+ );
64944
+ if (!deps.success) {
64945
+ return { success: false, error: deps.error };
64946
+ }
64947
+
64948
+ const refs = [];
64949
+ for (const w of deps.widgets) {
64950
+ if (w.scope && w.packageName) {
64951
+ refs.push({ scope: w.scope, name: w.packageName });
64952
+ }
64953
+ }
64954
+ if (deps.theme && deps.theme.scope && deps.theme.name) {
64955
+ refs.push({ scope: deps.theme.scope, name: deps.theme.name });
64956
+ }
64957
+
64958
+ let registryError = null;
64959
+ const resolvedByKey = new Map();
64960
+ if (refs.length > 0) {
64961
+ const res = await resolvePackages(refs);
64962
+ if (res.success && Array.isArray(res.resolved)) {
64963
+ for (const r of res.resolved) {
64964
+ resolvedByKey.set(`${r.scope}/${r.name}`, r);
64965
+ }
64966
+ } else {
64967
+ registryError = res.error || "Registry lookup failed";
64968
+ }
64969
+ }
64970
+
64971
+ const widgets = deps.widgets.map((w) => {
64972
+ const key =
64973
+ w.scope && w.packageName ? `${w.scope}/${w.packageName}` : null;
64974
+ return {
64975
+ ...w,
64976
+ registry: key ? resolvedByKey.get(key) || null : null,
64977
+ };
64978
+ });
64979
+
64980
+ let theme = null;
64981
+ if (deps.theme) {
64982
+ const key =
64983
+ deps.theme.scope && deps.theme.name
64984
+ ? `${deps.theme.scope}/${deps.theme.name}`
64985
+ : null;
64986
+ theme = {
64987
+ ...deps.theme,
64988
+ registry: key ? resolvedByKey.get(key) || null : null,
64989
+ };
64990
+ }
64991
+
64992
+ return {
64993
+ success: true,
64994
+ widgets,
64995
+ theme,
64996
+ ...(registryError ? { registryError } : {}),
64997
+ };
64998
+ } catch (error) {
64999
+ console.error("[dashboardConfig] getDashboardPublishPlan failed:", error);
65000
+ return { success: false, error: error.message };
65001
+ }
65002
+ }
65003
+
64858
65004
  /**
64859
65005
  * Prepare a dashboard for publishing to the registry.
64860
65006
  *
@@ -65324,6 +65470,7 @@ var dashboardConfigController$1 = {
65324
65470
  checkCompatibility: checkCompatibility$1,
65325
65471
  prepareDashboardForPublish: prepareDashboardForPublish$1,
65326
65472
  collectDashboardDependencies: collectDashboardDependencies$1,
65473
+ getDashboardPublishPlan: getDashboardPublishPlan$1,
65327
65474
  getDashboardPreview: getDashboardPreview$1,
65328
65475
  checkDashboardUpdatesForApp: checkDashboardUpdatesForApp$1,
65329
65476
  getProviderSetupManifest: getProviderSetupManifest$1,
@@ -71643,6 +71790,7 @@ const {
71643
71790
  checkCompatibility,
71644
71791
  prepareDashboardForPublish,
71645
71792
  collectDashboardDependencies,
71793
+ getDashboardPublishPlan,
71646
71794
  getDashboardPreview,
71647
71795
  checkDashboardUpdatesForApp,
71648
71796
  getProviderSetupManifest,
@@ -71740,6 +71888,7 @@ var controller = {
71740
71888
  checkCompatibility,
71741
71889
  prepareDashboardForPublish,
71742
71890
  collectDashboardDependencies,
71891
+ getDashboardPublishPlan,
71743
71892
  getDashboardPreview,
71744
71893
  checkDashboardUpdatesForApp,
71745
71894
  getProviderSetupManifest,
@@ -73276,6 +73425,7 @@ const {
73276
73425
  DASHBOARD_CONFIG_PUBLISH_PREVIEW,
73277
73426
  DASHBOARD_CONFIG_INSTALL_PROGRESS,
73278
73427
  DASHBOARD_CONFIG_COLLECT_DEPENDENCIES,
73428
+ DASHBOARD_CONFIG_PUBLISH_PLAN,
73279
73429
  } = events$8;
73280
73430
 
73281
73431
  const dashboardConfigApi$2 = {
@@ -73379,6 +73529,23 @@ const dashboardConfigApi$2 = {
73379
73529
  options,
73380
73530
  }),
73381
73531
 
73532
+ /**
73533
+ * Build an enriched dependency plan for batch-publishing a dashboard.
73534
+ * Merges local dep info with registry state (existence, version,
73535
+ * visibility, ownership) so the UI can decorate each row.
73536
+ *
73537
+ * @param {string} appId - Application identifier
73538
+ * @param {number|string} workspaceId - Workspace ID
73539
+ * @param {Object} options - { componentConfigs?: Object }
73540
+ * @returns {Promise<Object>} { success, widgets, theme, registryError? }
73541
+ */
73542
+ getDashboardPublishPlan: (appId, workspaceId, options = {}) =>
73543
+ ipcRenderer$9.invoke(DASHBOARD_CONFIG_PUBLISH_PLAN, {
73544
+ appId,
73545
+ workspaceId,
73546
+ options,
73547
+ }),
73548
+
73382
73549
  /**
73383
73550
  * Get a preview of a dashboard package from the registry.
73384
73551
  * Returns structured preview data and compatibility report.