@nubase/frontend 0.1.11 → 0.1.13

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.mjs CHANGED
@@ -4364,7 +4364,9 @@ import { useContext as useContext3 } from "react";
4364
4364
  // src/components/nubase-app/NubaseContextProvider.tsx
4365
4365
  import { createContext, useContext } from "react";
4366
4366
  import { jsx } from "react/jsx-runtime";
4367
- var NubaseContext = createContext(void 0);
4367
+ var NubaseContext = createContext(
4368
+ void 0
4369
+ );
4368
4370
  var NubaseContextProvider = ({
4369
4371
  context,
4370
4372
  children
@@ -12138,16 +12140,10 @@ DashboardWidget.displayName = "DashboardWidget";
12138
12140
  import { jsx as jsx80 } from "react/jsx-runtime";
12139
12141
  function ConnectedWidget({ widget }) {
12140
12142
  const context = useNubaseContext();
12141
- const endpointKey = widget.endpoint;
12142
- const httpClient = context.http;
12143
- const endpointFn = httpClient[endpointKey];
12144
12143
  const { data, isLoading, error } = useQuery2({
12145
- queryKey: ["dashboard-widget", widget.id, endpointKey],
12144
+ queryKey: ["dashboard-widget", widget.id],
12146
12145
  queryFn: async () => {
12147
- if (typeof endpointFn !== "function") {
12148
- throw new Error(`Endpoint ${endpointKey} not found`);
12149
- }
12150
- const response = await endpointFn({ params: {} });
12146
+ const response = await widget.onLoad({ context });
12151
12147
  return response.data;
12152
12148
  },
12153
12149
  refetchInterval: widget.refreshInterval
@@ -17320,7 +17316,10 @@ function useCreateNubaseContext({
17320
17316
 
17321
17317
  // src/components/nubase-app/ServicesProvider.tsx
17322
17318
  import { jsx as jsx117, jsxs as jsxs57 } from "react/jsx-runtime";
17323
- var ServicesProvider = ({ config, children }) => {
17319
+ function ServicesProvider({
17320
+ config,
17321
+ children
17322
+ }) {
17324
17323
  const {
17325
17324
  data: nubaseContext,
17326
17325
  isLoading,
@@ -17349,7 +17348,7 @@ var ServicesProvider = ({ config, children }) => {
17349
17348
  ] }) });
17350
17349
  }
17351
17350
  return /* @__PURE__ */ jsx117(NubaseContextProvider, { context: nubaseContext, children });
17352
- };
17351
+ }
17353
17352
 
17354
17353
  // src/components/nubase-app/NubaseApp.tsx
17355
17354
  import { jsx as jsx118, jsxs as jsxs58 } from "react/jsx-runtime";
@@ -17947,7 +17946,7 @@ var DashboardBuilder = class _DashboardBuilder {
17947
17946
  this.config = { id };
17948
17947
  }
17949
17948
  /**
17950
- * Configure API endpoints for type-safe widget endpoint references.
17949
+ * Configure API endpoints for type-safe widget data fetching.
17951
17950
  * This must be called before withWidgets() to enable type checking.
17952
17951
  */
17953
17952
  withApiEndpoints(apiEndpoints) {
@@ -17983,11 +17982,8 @@ var DashboardBuilder = class _DashboardBuilder {
17983
17982
  * Configure widgets for this dashboard.
17984
17983
  * This is the final step that produces the DashboardDescriptor.
17985
17984
  *
17986
- * TypeScript will validate that each widget's endpoint matches its expected data type:
17987
- * - Series widgets must reference endpoints returning SeriesData
17988
- * - Proportional widgets must reference endpoints returning ProportionalData
17989
- * - KPI widgets must reference endpoints returning KpiData
17990
- * - Table widgets must reference endpoints returning TableData
17985
+ * Each widget must provide an `onLoad` callback that fetches data
17986
+ * using `context.http` for type-safe API calls.
17991
17987
  */
17992
17988
  withWidgets(widgets) {
17993
17989
  return {