@trops/dash-core 0.1.85 → 0.1.86

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.
@@ -423,12 +423,14 @@ const REGISTRY_FETCH_INDEX = "registry:fetch-index";
423
423
  const REGISTRY_SEARCH = "registry:search";
424
424
  const REGISTRY_GET_PACKAGE = "registry:get-package";
425
425
  const REGISTRY_CHECK_UPDATES = "registry:check-updates";
426
+ const REGISTRY_SEARCH_DASHBOARDS = "registry:search-dashboards";
426
427
 
427
428
  var registryEvents$1 = {
428
429
  REGISTRY_FETCH_INDEX,
429
430
  REGISTRY_SEARCH,
430
431
  REGISTRY_GET_PACKAGE,
431
432
  REGISTRY_CHECK_UPDATES,
433
+ REGISTRY_SEARCH_DASHBOARDS,
432
434
  };
433
435
 
434
436
  /**
@@ -6009,12 +6011,22 @@ async function fetchRegistryIndex(forceRefresh = false) {
6009
6011
  * @param {string} filters.category - Filter by category
6010
6012
  * @param {string} filters.author - Filter by author
6011
6013
  * @param {string} filters.tag - Filter by tag
6014
+ * @param {string} filters.type - Filter by package type ("widget" or "dashboard")
6015
+ * @param {string[]} filters.compatibleWidgets - Only return dashboards whose required widgets are all in this list
6012
6016
  * @returns {Promise<Object>} { packages: [...], totalWidgets: number }
6013
6017
  */
6014
6018
  async function searchRegistry$1(query = "", filters = {}) {
6015
6019
  const index = await fetchRegistryIndex();
6016
6020
  let packages = index.packages || [];
6017
6021
 
6022
+ // Apply type filter — packages without an explicit type default to "widget"
6023
+ if (filters.type) {
6024
+ const typeLower = filters.type.toLowerCase();
6025
+ packages = packages.filter(
6026
+ (pkg) => (pkg.type || "widget").toLowerCase() === typeLower,
6027
+ );
6028
+ }
6029
+
6018
6030
  // Apply search query
6019
6031
  if (query) {
6020
6032
  const q = query.toLowerCase();
@@ -6063,6 +6075,24 @@ async function searchRegistry$1(query = "", filters = {}) {
6063
6075
  );
6064
6076
  }
6065
6077
 
6078
+ // Apply compatibility filter — only dashboards whose required widgets
6079
+ // are all present in the user's installed widget list
6080
+ if (filters.compatibleWidgets && filters.compatibleWidgets.length) {
6081
+ const installedSet = new Set(
6082
+ filters.compatibleWidgets.map((w) => w.toLowerCase()),
6083
+ );
6084
+ packages = packages.filter((pkg) => {
6085
+ const requiredWidgets = (pkg.widgets || []).filter(
6086
+ (w) => w.required !== false,
6087
+ );
6088
+ return requiredWidgets.every(
6089
+ (w) =>
6090
+ installedSet.has((w.package || "").toLowerCase()) ||
6091
+ installedSet.has((w.name || "").toLowerCase()),
6092
+ );
6093
+ });
6094
+ }
6095
+
6066
6096
  // Count total widgets across matched packages
6067
6097
  const totalWidgets = packages.reduce(
6068
6098
  (sum, pkg) => sum + (pkg.widgets || []).length,
@@ -6110,9 +6140,22 @@ async function checkUpdates(installedWidgets = []) {
6110
6140
  return updates;
6111
6141
  }
6112
6142
 
6143
+ /**
6144
+ * Search the registry for dashboard packages only.
6145
+ * Convenience wrapper around searchRegistry with type: "dashboard".
6146
+ *
6147
+ * @param {string} query - Search query string
6148
+ * @param {Object} filters - Optional filters (category, author, tag, compatibleWidgets)
6149
+ * @returns {Promise<Object>} { packages: [...], totalWidgets: number }
6150
+ */
6151
+ async function searchDashboards(query = "", filters = {}) {
6152
+ return searchRegistry$1(query, { ...filters, type: "dashboard" });
6153
+ }
6154
+
6113
6155
  var registryController$1 = {
6114
6156
  fetchRegistryIndex,
6115
6157
  searchRegistry: searchRegistry$1,
6158
+ searchDashboards,
6116
6159
  getPackage: getPackage$1,
6117
6160
  checkUpdates,
6118
6161
  };
@@ -11182,6 +11225,25 @@ const registryApi$2 = {
11182
11225
  throw error;
11183
11226
  }
11184
11227
  },
11228
+
11229
+ /**
11230
+ * Search the registry for dashboard packages only
11231
+ * @param {string} query - Search query
11232
+ * @param {Object} filters - Optional filters { category, author, tag, compatibleWidgets }
11233
+ * @returns {Promise<Object>} { packages: [...], totalWidgets: number }
11234
+ */
11235
+ searchDashboards: async (query = "", filters = {}) => {
11236
+ try {
11237
+ return await ipcRenderer$9.invoke(
11238
+ "registry:search-dashboards",
11239
+ query,
11240
+ filters,
11241
+ );
11242
+ } catch (error) {
11243
+ console.error("[RegistryApi] Error searching dashboards:", error);
11244
+ throw error;
11245
+ }
11246
+ },
11185
11247
  };
11186
11248
 
11187
11249
  var registryApi_1 = registryApi$2;