@burdenoff/microfe-botmanor 2026.1120.22 → 2026.1120.23

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 (30) hide show
  1. package/dist/botlit/BotmanorRootInner.js +46 -45
  2. package/dist/botlit/BotmanorRootInner.js.map +1 -1
  3. package/dist/botlit/components/PlanUsageCard.d.ts +2 -0
  4. package/dist/botlit/components/PlanUsageCard.js +79 -0
  5. package/dist/botlit/components/PlanUsageCard.js.map +1 -0
  6. package/dist/botlit/components/QuotaExhaustedDialog.d.ts +14 -3
  7. package/dist/botlit/components/QuotaExhaustedDialog.js +33 -13
  8. package/dist/botlit/components/QuotaExhaustedDialog.js.map +1 -1
  9. package/dist/botlit/hooks/usePlanUsage.d.ts +19 -0
  10. package/dist/botlit/hooks/usePlanUsage.js +45 -0
  11. package/dist/botlit/hooks/usePlanUsage.js.map +1 -0
  12. package/dist/botlit/pages/BotDetailPage.js +4 -4
  13. package/dist/botlit/pages/DashboardPage.js +151 -149
  14. package/dist/botlit/pages/DashboardPage.js.map +1 -1
  15. package/dist/botlit/providers/QuotaGuard.d.ts +2 -0
  16. package/dist/botlit/providers/QuotaGuard.js +51 -0
  17. package/dist/botlit/providers/QuotaGuard.js.map +1 -0
  18. package/dist/botlit/providers/quotaGuardContext.d.ts +11 -0
  19. package/dist/botlit/providers/quotaGuardContext.js +9 -0
  20. package/dist/botlit/providers/quotaGuardContext.js.map +1 -0
  21. package/dist/botlit/utils/quotaErrors.d.ts +48 -0
  22. package/dist/botlit/utils/quotaErrors.js +118 -0
  23. package/dist/botlit/utils/quotaErrors.js.map +1 -0
  24. package/dist/botlit/utils/watchPlanLimits.d.ts +12 -0
  25. package/dist/botlit/utils/watchPlanLimits.js +27 -0
  26. package/dist/botlit/utils/watchPlanLimits.js.map +1 -0
  27. package/dist/generated/wspace-operations.d.ts +52 -0
  28. package/dist/generated/wspace-operations.js +60 -40
  29. package/dist/generated/wspace-operations.js.map +1 -1
  30. package/package.json +1 -1
@@ -1,73 +1,74 @@
1
1
  import { BotlitProvider as e } from "./providers/BotlitProvider.js";
2
- import { BotlitRoutes as t } from "./BotlitRoutes.js";
3
- import { RouteLoader as n } from "./components/RouteLoader.js";
4
- import { useTr as r } from "../shared/hooks/useTr.js";
5
- import { WorkspaceRequired as i } from "./components/WorkspaceRequired.js";
6
- import { useEffect as a, useState as o } from "react";
7
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
- import { useGatewayClient as l } from "@burdenoff/fe-libs/shared/graphql";
9
- import { ApolloProvider as u } from "@apollo/client/react";
10
- import { QueryClient as d, QueryClientProvider as f } from "@tanstack/react-query";
11
- import { ErrorBoundary as p } from "@burdenoff/fe-libs/shared/components";
12
- import { FeatureFlagProvider as m } from "@burdenoff/fe-libs/shared/feature-flags";
2
+ import { QuotaGuard as t } from "./providers/QuotaGuard.js";
3
+ import { BotlitRoutes as n } from "./BotlitRoutes.js";
4
+ import { RouteLoader as r } from "./components/RouteLoader.js";
5
+ import { useTr as i } from "../shared/hooks/useTr.js";
6
+ import { WorkspaceRequired as a } from "./components/WorkspaceRequired.js";
7
+ import { useEffect as o, useState as s } from "react";
8
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
+ import { useGatewayClient as u } from "@burdenoff/fe-libs/shared/graphql";
10
+ import { ApolloProvider as d } from "@apollo/client/react";
11
+ import { QueryClient as f, QueryClientProvider as p } from "@tanstack/react-query";
12
+ import { ErrorBoundary as m } from "@burdenoff/fe-libs/shared/components";
13
+ import { FeatureFlagProvider as h } from "@burdenoff/fe-libs/shared/feature-flags";
13
14
  // src/botlit/BotmanorRootInner.tsx
14
- var h = 1e4, g = 2e3, _ = new d({ defaultOptions: { queries: {
15
+ var g = 1e4, _ = 2e3, v = new f({ defaultOptions: { queries: {
15
16
  staleTime: 3e5,
16
17
  retry: 1
17
- } } }), v = (d) => {
18
- let v = r(), y = l("workspace"), b = !!y, [x, S] = o(!1), [C, w] = o(!1);
19
- if (a(() => {
20
- if (b) return;
18
+ } } }), y = (f) => {
19
+ let y = i(), b = u("workspace"), x = !!b, [S, C] = s(!1), [w, T] = s(!1);
20
+ if (o(() => {
21
+ if (x) return;
21
22
  let e = setTimeout(() => {
22
- S(!0);
23
- }, h);
23
+ C(!0);
24
+ }, g);
24
25
  return () => clearTimeout(e);
25
- }, [b]), a(() => {
26
- if (d.workspaceId) return;
27
- let e = setTimeout(() => w(!0), g);
26
+ }, [x]), o(() => {
27
+ if (f.workspaceId) return;
28
+ let e = setTimeout(() => T(!0), _);
28
29
  return () => clearTimeout(e);
29
- }, [d.workspaceId]), !d.workspaceId) return C ? /* @__PURE__ */ s(i, {
30
- basePath: d.basePath,
31
- navigate: d.navigate
32
- }) : /* @__PURE__ */ s(n, { label: v("botlit.root.loadingWorkspace", "Loading your workspace…") });
33
- if (!b) return x ? /* @__PURE__ */ s("div", {
30
+ }, [f.workspaceId]), !f.workspaceId) return w ? /* @__PURE__ */ c(a, {
31
+ basePath: f.basePath,
32
+ navigate: f.navigate
33
+ }) : /* @__PURE__ */ c(r, { label: y("botlit.root.loadingWorkspace", "Loading your workspace…") });
34
+ if (!x) return S ? /* @__PURE__ */ c("div", {
34
35
  className: "flex h-full min-h-[200px] w-full items-center justify-center p-6",
35
- children: /* @__PURE__ */ c("div", {
36
+ children: /* @__PURE__ */ l("div", {
36
37
  className: "text-center",
37
- children: [/* @__PURE__ */ s("p", {
38
+ children: [/* @__PURE__ */ c("p", {
38
39
  className: "mb-4 text-sm text-text-secondary",
39
- children: v("botlit.root.connectError", "BotManor could not connect to the gateway. Please refresh the page or check your configuration.")
40
- }), /* @__PURE__ */ s("button", {
40
+ children: y("botlit.root.connectError", "BotManor could not connect to the gateway. Please refresh the page or check your configuration.")
41
+ }), /* @__PURE__ */ c("button", {
41
42
  type: "button",
42
43
  onClick: () => window.location.reload(),
43
44
  className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover",
44
- children: v("botlit.root.reload", "Reload Page")
45
+ children: y("botlit.root.reload", "Reload Page")
45
46
  })]
46
47
  })
47
- }) : /* @__PURE__ */ s(n, {});
48
- let T = !!d.basePath, E = /* @__PURE__ */ s(e, {
49
- ...d,
50
- children: /* @__PURE__ */ s(t, {})
48
+ }) : /* @__PURE__ */ c(r, {});
49
+ let E = !!f.basePath, D = /* @__PURE__ */ c(e, {
50
+ ...f,
51
+ children: /* @__PURE__ */ c(t, { children: /* @__PURE__ */ c(n, {}) })
51
52
  });
52
- return /* @__PURE__ */ s(p, {
53
- fallback: /* @__PURE__ */ s("div", {
53
+ return /* @__PURE__ */ c(m, {
54
+ fallback: /* @__PURE__ */ c("div", {
54
55
  className: "p-6 text-center text-text-secondary",
55
- children: v("botlit.root.loadFailed", "Something went wrong loading BotManor. Please refresh the page.")
56
+ children: y("botlit.root.loadFailed", "Something went wrong loading BotManor. Please refresh the page.")
56
57
  }),
57
- children: /* @__PURE__ */ s(m, {
58
+ children: /* @__PURE__ */ c(h, {
58
59
  workspaceId: null,
59
60
  gateway: "global",
60
61
  defaultEnabled: !0,
61
- children: /* @__PURE__ */ s(f, {
62
- client: _,
63
- children: T ? E : /* @__PURE__ */ s(u, {
64
- client: y,
65
- children: E
62
+ children: /* @__PURE__ */ c(p, {
63
+ client: v,
64
+ children: E ? D : /* @__PURE__ */ c(d, {
65
+ client: b,
66
+ children: D
66
67
  })
67
68
  })
68
69
  })
69
70
  });
70
71
  };
71
- export { v as BotmanorRootInner };
72
+ export { y as BotmanorRootInner };
72
73
 
73
74
  //# sourceMappingURL=BotmanorRootInner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","tr","useTr","workspaceClient","useGatewayClient","clientReady","clientTimedOut","setClientTimedOut","useState","workspaceSettled","setWorkspaceSettled","useEffect","timer","props","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","BotlitRoutes","ErrorBoundary","FeatureFlagProvider","QueryClientProvider","ApolloProvider"],"sources":["../../src/botlit/BotmanorRootInner.tsx"],"sourcesContent":["/**\n * BotManor Root — implementation\n * @module botlit\n *\n * Product pages live behind this lazy boundary. Workflow routes and SDK\n * lifecycle are owned by the app-shell WorkflowsRoot, shared with every host.\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useState } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { BotlitProvider } from './providers/BotlitProvider';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { BotlitRoutes } from './BotlitRoutes';\nimport { RouteLoader } from './components/RouteLoader';\nimport { useTr } from '../shared/hooks/useTr';\nimport { WorkspaceRequired } from './components/WorkspaceRequired';\nimport type { BotmanorRootProps } from './types';\n\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\n/** How long to wait for the shell's gateway clients before showing an error. */\nconst CLIENT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * How long to keep showing the loading skeleton before concluding that the\n * shell really has no active workspace.\n *\n * The shell resolves org/workspace asynchronously and passes `workspaceId=\"\"`\n * until it lands, which is indistinguishable from \"this user has no\n * workspace\". Without this settle window the guided zero state would flash on\n * every cold load — a get-started screen appearing and vanishing reads as a\n * broken page, which is exactly what this component exists to avoid.\n */\nconst WORKSPACE_SETTLE_MS = 2_000;\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const BotmanorRootInner: FC<BotmanorRootProps> = (props) => {\n // NOTE: Navigation is now handled by the shell's NavRegistration.tsx\n // The shell manages all product submenu items in a centralized way\n\n // Product operations use the shell's authenticated workspace gateway client.\n const tr = useTr();\n const workspaceClient = useGatewayClient('workspace');\n const clientReady = Boolean(workspaceClient);\n const [clientTimedOut, setClientTimedOut] = useState(false);\n const [workspaceSettled, setWorkspaceSettled] = useState(false);\n\n // Timeout fallback: if gateway clients are never provided (test env, shell\n // misconfiguration, auth failure before hydration), show an error rather than\n // spinning indefinitely.\n useEffect(() => {\n if (clientReady) return;\n const timer = setTimeout(() => {\n setClientTimedOut(true);\n }, CLIENT_READY_TIMEOUT_MS);\n return () => clearTimeout(timer);\n }, [clientReady]);\n\n // Give the shell a bounded window to resolve the active workspace before the\n // guided zero state is allowed to render. Cancelled the moment a workspace\n // arrives — a workspace that is already present never starts the timer.\n useEffect(() => {\n if (props.workspaceId) return;\n const timer = setTimeout(() => setWorkspaceSettled(true), WORKSPACE_SETTLE_MS);\n return () => clearTimeout(timer);\n }, [props.workspaceId]);\n\n // Without a workspace every BotManor query is unscoped and every write is\n // rejected — guide the user instead of rendering empty lists. Until the\n // settle window elapses we cannot tell \"still resolving\" from \"none\", so we\n // keep the same skeleton the shell was already showing.\n if (!props.workspaceId) {\n if (!workspaceSettled) {\n return <RouteLoader label={tr('botlit.root.loadingWorkspace', 'Loading your workspace…')} />;\n }\n return <WorkspaceRequired basePath={props.basePath} navigate={props.navigate} />;\n }\n\n // Don't render until clients are ready (same pattern as microfe-bigconsole)\n if (!clientReady) {\n if (clientTimedOut) {\n return (\n <div className=\"flex h-full min-h-[200px] w-full items-center justify-center p-6\">\n <div className=\"text-center\">\n <p className=\"mb-4 text-sm text-text-secondary\">\n {tr(\n 'botlit.root.connectError',\n 'BotManor could not connect to the gateway. Please refresh the page or check your configuration.'\n )}\n </p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover\"\n >\n {tr('botlit.root.reload', 'Reload Page')}\n </button>\n </div>\n </div>\n );\n }\n // Same skeleton as the lazy-chunk fallback, so the content region never\n // switches loading idioms between first paint and the page rendering.\n return <RouteLoader />;\n }\n\n const isIntegrated = !!props.basePath;\n\n const content = (\n <BotlitProvider {...props}>\n <BotlitRoutes />\n </BotlitProvider>\n );\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'botlit.root.loadFailed',\n 'Something went wrong loading BotManor. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <QueryClientProvider client={queryClient}>\n {isIntegrated ? (\n content\n ) : (\n <ApolloProvider client={workspaceClient}>{content}</ApolloProvider>\n )}\n </QueryClientProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAMA,IAA0B,KAY1BC,IAAsB,KAGtBC,IAAc,IAAIC,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW;CACX,OAAO;AACT,EACF,EACF,CAAC,GAEYC,KAA4C,MAAU;CAKjE,IAAMC,IAAKC,EAAM,GACXC,IAAkBC,EAAiB,WAAW,GAC9CC,IAAc,EAAQF,GACtB,CAACG,GAAgBC,KAAqBC,EAAS,EAAK,GACpD,CAACC,GAAkBC,KAAuBF,EAAS,EAAK;CA0B9D,IArBAG,QAAgB;EACd,IAAIN,GAAa;EACjB,IAAMO,IAAQ,iBAAiB;GAC7B,EAAkB,EAAI;EACxB,GAAGhB,CAAuB;EAC1B,aAAa,aAAagB,CAAK;CACjC,GAAG,CAACP,CAAW,CAAC,GAKhBM,QAAgB;EACd,IAAIE,EAAM,aAAa;EACvB,IAAMD,IAAQ,iBAAiBF,EAAoB,EAAI,GAAGb,CAAmB;EAC7E,aAAa,aAAae,CAAK;CACjC,GAAG,CAACC,EAAM,WAAW,CAAC,GAMlB,CAACA,EAAM,aAIT,OAHKJ,IAGE,kBAACK,GAAD;EAAmB,UAAUD,EAAM;EAAU,UAAUA,EAAM;CAAW,CAAA,IAFtE,kBAACE,GAAD,EAAa,OAAOd,EAAG,gCAAgC,yBAAyB,EAAI,CAAA;CAM/F,IAAI,CAACI,GAwBH,OAvBIC,IAEA,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAL,EACC,4BACA,iGACF;GACC,CAAA,GACH,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,OAAO,SAAS,OAAO;IACtC,WAAU;IAET,UAAAA,EAAG,sBAAsB,aAAa;GACjC,CAAA,CACL;;CACF,CAAA,IAKF,kBAACc,GAAD,CAAc,CAAA;CAGvB,IAAMC,IAAe,CAAC,CAACH,EAAM,UAEvBI,IACJ,kBAACC,GAAD;EAAgB,GAAIL;EAClB,UAAA,kBAACM,GAAD,CAAe,CAAA;CACD,CAAA;CAGlB,OACE,kBAACC,GAAD;EACE,UACE,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAAnB,EACC,0BACA,iEACF;EACG,CAAA;EAGP,UAAA,kBAACoB,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;GACvE,UAAA,kBAACC,GAAD;IAAqB,QAAQxB;IAC1B,UAAAkB,IACCC,IAEA,kBAACM,GAAD;KAAgB,QAAQpB;KAAkB,UAAAc;IAAwB,CAAA;GAEjD,CAAA;EACF,CAAA;CACR,CAAA;AAEnB"}
1
+ {"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","tr","useTr","workspaceClient","useGatewayClient","clientReady","clientTimedOut","setClientTimedOut","useState","workspaceSettled","setWorkspaceSettled","useEffect","timer","props","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","QuotaGuard","BotlitRoutes","ErrorBoundary","FeatureFlagProvider","QueryClientProvider","ApolloProvider"],"sources":["../../src/botlit/BotmanorRootInner.tsx"],"sourcesContent":["/**\n * BotManor Root — implementation\n * @module botlit\n *\n * Product pages live behind this lazy boundary. Workflow routes and SDK\n * lifecycle are owned by the app-shell WorkflowsRoot, shared with every host.\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useState } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { BotlitProvider } from './providers/BotlitProvider';\nimport { QuotaGuard } from './providers/QuotaGuard';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { BotlitRoutes } from './BotlitRoutes';\nimport { RouteLoader } from './components/RouteLoader';\nimport { useTr } from '../shared/hooks/useTr';\nimport { WorkspaceRequired } from './components/WorkspaceRequired';\nimport type { BotmanorRootProps } from './types';\n\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\n/** How long to wait for the shell's gateway clients before showing an error. */\nconst CLIENT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * How long to keep showing the loading skeleton before concluding that the\n * shell really has no active workspace.\n *\n * The shell resolves org/workspace asynchronously and passes `workspaceId=\"\"`\n * until it lands, which is indistinguishable from \"this user has no\n * workspace\". Without this settle window the guided zero state would flash on\n * every cold load — a get-started screen appearing and vanishing reads as a\n * broken page, which is exactly what this component exists to avoid.\n */\nconst WORKSPACE_SETTLE_MS = 2_000;\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const BotmanorRootInner: FC<BotmanorRootProps> = (props) => {\n // NOTE: Navigation is now handled by the shell's NavRegistration.tsx\n // The shell manages all product submenu items in a centralized way\n\n // Product operations use the shell's authenticated workspace gateway client.\n const tr = useTr();\n const workspaceClient = useGatewayClient('workspace');\n const clientReady = Boolean(workspaceClient);\n const [clientTimedOut, setClientTimedOut] = useState(false);\n const [workspaceSettled, setWorkspaceSettled] = useState(false);\n\n // Timeout fallback: if gateway clients are never provided (test env, shell\n // misconfiguration, auth failure before hydration), show an error rather than\n // spinning indefinitely.\n useEffect(() => {\n if (clientReady) return;\n const timer = setTimeout(() => {\n setClientTimedOut(true);\n }, CLIENT_READY_TIMEOUT_MS);\n return () => clearTimeout(timer);\n }, [clientReady]);\n\n // Give the shell a bounded window to resolve the active workspace before the\n // guided zero state is allowed to render. Cancelled the moment a workspace\n // arrives — a workspace that is already present never starts the timer.\n useEffect(() => {\n if (props.workspaceId) return;\n const timer = setTimeout(() => setWorkspaceSettled(true), WORKSPACE_SETTLE_MS);\n return () => clearTimeout(timer);\n }, [props.workspaceId]);\n\n // Without a workspace every BotManor query is unscoped and every write is\n // rejected — guide the user instead of rendering empty lists. Until the\n // settle window elapses we cannot tell \"still resolving\" from \"none\", so we\n // keep the same skeleton the shell was already showing.\n if (!props.workspaceId) {\n if (!workspaceSettled) {\n return <RouteLoader label={tr('botlit.root.loadingWorkspace', 'Loading your workspace…')} />;\n }\n return <WorkspaceRequired basePath={props.basePath} navigate={props.navigate} />;\n }\n\n // Don't render until clients are ready (same pattern as microfe-bigconsole)\n if (!clientReady) {\n if (clientTimedOut) {\n return (\n <div className=\"flex h-full min-h-[200px] w-full items-center justify-center p-6\">\n <div className=\"text-center\">\n <p className=\"mb-4 text-sm text-text-secondary\">\n {tr(\n 'botlit.root.connectError',\n 'BotManor could not connect to the gateway. Please refresh the page or check your configuration.'\n )}\n </p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover\"\n >\n {tr('botlit.root.reload', 'Reload Page')}\n </button>\n </div>\n </div>\n );\n }\n // Same skeleton as the lazy-chunk fallback, so the content region never\n // switches loading idioms between first paint and the page rendering.\n return <RouteLoader />;\n }\n\n const isIntegrated = !!props.basePath;\n\n const content = (\n <BotlitProvider {...props}>\n {/* Every metered mutation that hits a plan limit opens one translated dialog. */}\n <QuotaGuard>\n <BotlitRoutes />\n </QuotaGuard>\n </BotlitProvider>\n );\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'botlit.root.loadFailed',\n 'Something went wrong loading BotManor. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <QueryClientProvider client={queryClient}>\n {isIntegrated ? (\n content\n ) : (\n <ApolloProvider client={workspaceClient}>{content}</ApolloProvider>\n )}\n </QueryClientProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAMA,IAA0B,KAY1BC,IAAsB,KAGtBC,IAAc,IAAIC,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW;CACX,OAAO;AACT,EACF,EACF,CAAC,GAEYC,KAA4C,MAAU;CAKjE,IAAMC,IAAKC,EAAM,GACXC,IAAkBC,EAAiB,WAAW,GAC9CC,IAAc,EAAQF,GACtB,CAACG,GAAgBC,KAAqBC,EAAS,EAAK,GACpD,CAACC,GAAkBC,KAAuBF,EAAS,EAAK;CA0B9D,IArBAG,QAAgB;EACd,IAAIN,GAAa;EACjB,IAAMO,IAAQ,iBAAiB;GAC7B,EAAkB,EAAI;EACxB,GAAGhB,CAAuB;EAC1B,aAAa,aAAagB,CAAK;CACjC,GAAG,CAACP,CAAW,CAAC,GAKhBM,QAAgB;EACd,IAAIE,EAAM,aAAa;EACvB,IAAMD,IAAQ,iBAAiBF,EAAoB,EAAI,GAAGb,CAAmB;EAC7E,aAAa,aAAae,CAAK;CACjC,GAAG,CAACC,EAAM,WAAW,CAAC,GAMlB,CAACA,EAAM,aAIT,OAHKJ,IAGE,kBAACK,GAAD;EAAmB,UAAUD,EAAM;EAAU,UAAUA,EAAM;CAAW,CAAA,IAFtE,kBAACE,GAAD,EAAa,OAAOd,EAAG,gCAAgC,yBAAyB,EAAI,CAAA;CAM/F,IAAI,CAACI,GAwBH,OAvBIC,IAEA,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAL,EACC,4BACA,iGACF;GACC,CAAA,GACH,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,OAAO,SAAS,OAAO;IACtC,WAAU;IAET,UAAAA,EAAG,sBAAsB,aAAa;GACjC,CAAA,CACL;;CACF,CAAA,IAKF,kBAACc,GAAD,CAAc,CAAA;CAGvB,IAAMC,IAAe,CAAC,CAACH,EAAM,UAEvBI,IACJ,kBAACC,GAAD;EAAgB,GAAIL;EAElB,UAAA,kBAACM,GAAD,EAAA,UACE,kBAACC,GAAD,CAAe,CAAA,EACL,CAAA;CACE,CAAA;CAGlB,OACE,kBAACC,GAAD;EACE,UACE,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAApB,EACC,0BACA,iEACF;EACG,CAAA;EAGP,UAAA,kBAACqB,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;GACvE,UAAA,kBAACC,GAAD;IAAqB,QAAQzB;IAC1B,UAAAkB,IACCC,IAEA,kBAACO,GAAD;KAAgB,QAAQrB;KAAkB,UAAAc;IAAwB,CAAA;GAEjD,CAAA;EACF,CAAA;CACR,CAAA;AAEnB"}
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const PlanUsageCard: FC;
@@ -0,0 +1,79 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { usePlanUsage as t } from "../hooks/usePlanUsage.js";
3
+ import { useBotlit as n } from "../providers/BotlitProvider.js";
4
+ import { graphqlErrorCode as r } from "../utils/errors.js";
5
+ import { quotaLabel as i } from "../utils/quotaErrors.js";
6
+ import { Button as a } from "./Button.js";
7
+ import { Card as o, CardContent as s, CardHeader as c, CardTitle as l } from "./Card.js";
8
+ import { ErrorState as u } from "./ErrorState.js";
9
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
+ import { QuotaMeter as p } from "@burdenoff/fe-libs/shared/components";
11
+ // src/botlit/components/PlanUsageCard.tsx
12
+ var m = 80, h = /* @__PURE__ */ new Set([
13
+ "FORBIDDEN",
14
+ "PERMISSION_DENIED",
15
+ "UNAUTHENTICATED"
16
+ ]), g = () => {
17
+ let g = e(), { navigate: _ } = n(), { data: v, loading: y, error: b, refetch: x } = t();
18
+ if (b && h.has(r(b) ?? "")) return null;
19
+ let S = () => {
20
+ _ ? _("/billing") : window.location.assign("/billing");
21
+ }, C = (e) => e.key ? i(g, e.key) : e.quotaName, w = (e) => {
22
+ switch (e.resetPeriod.toUpperCase()) {
23
+ case "MONTHLY": return g("botlit.usage.plan.resetsMonthly", "Resets monthly");
24
+ case "DAILY": return g("botlit.usage.plan.resetsDaily", "Resets daily");
25
+ default: return null;
26
+ }
27
+ };
28
+ return /* @__PURE__ */ f(o, {
29
+ "data-testid": "plan-usage-card",
30
+ children: [/* @__PURE__ */ f(c, {
31
+ className: "flex flex-row flex-wrap items-center justify-between gap-2",
32
+ children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d(l, {
33
+ as: "h2",
34
+ children: g("botlit.usage.plan.title", "Plan and usage")
35
+ }), /* @__PURE__ */ d("p", {
36
+ className: "mt-1 text-sm text-text-secondary",
37
+ children: g("botlit.usage.plan.subtitle", "What your plan includes for BotManor and how much of it you've used.")
38
+ })] }), /* @__PURE__ */ d(a, {
39
+ type: "button",
40
+ variant: "outline",
41
+ size: "sm",
42
+ onClick: S,
43
+ children: g("botlit.usage.plan.manage", "Manage plan")
44
+ })]
45
+ }), /* @__PURE__ */ d(s, { children: b ? /* @__PURE__ */ d(u, {
46
+ resource: g("botlit.usage.plan.resource", "your plan usage"),
47
+ error: b,
48
+ onRetry: () => void x()
49
+ }) : y && v.length === 0 ? /* @__PURE__ */ d("p", {
50
+ role: "status",
51
+ className: "text-sm text-text-secondary",
52
+ children: g("botlit.usage.plan.loading", "Loading your plan usage…")
53
+ }) : v.length === 0 ? /* @__PURE__ */ d("p", {
54
+ className: "text-sm text-text-secondary",
55
+ children: g("botlit.usage.plan.empty", "Your plan has no BotManor allowances yet. Choose a plan in billing to start building bots.")
56
+ }) : /* @__PURE__ */ d("ul", {
57
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",
58
+ children: v.map((e) => {
59
+ let t = w(e);
60
+ return /* @__PURE__ */ f("li", {
61
+ className: "space-y-1",
62
+ children: [/* @__PURE__ */ d(p, {
63
+ label: C(e),
64
+ used: e.used,
65
+ limit: e.limit,
66
+ warningPercent: m,
67
+ exhaustedHint: g("botlit.usage.plan.exhaustedHint", "Limit reached. Upgrade your plan to add more.")
68
+ }), t ? /* @__PURE__ */ d("p", {
69
+ className: "text-xs text-text-secondary",
70
+ children: t
71
+ }) : null]
72
+ }, e.quotaName);
73
+ })
74
+ }) })]
75
+ });
76
+ };
77
+ export { g as PlanUsageCard };
78
+
79
+ //# sourceMappingURL=PlanUsageCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanUsageCard.js","names":["WARNING_PERCENT","HIDDEN_CODES","PlanUsageCard","t","useTr","useBotlit","allowances","usePlanUsage","error","graphqlErrorCode","openBilling","navigate","label","allowance","quotaLabel","resetHint","Card","CardHeader","CardTitle","Button","CardContent","ErrorState","refetch","loading","hint","QuotaMeter"],"sources":["../../../src/botlit/components/PlanUsageCard.tsx"],"sourcesContent":["/**\n * Plan and usage card (BOFF-15484)\n * @module botlit/components\n *\n * One meter per BotManor allowance on the workspace's plan (bots, runs,\n * messages, knowledge bases, …) with what is used, the limit and when it\n * resets, plus the way to billing. A workspace member who may not read usage\n * simply does not see the card.\n */\n\nimport type { FC } from 'react';\nimport { QuotaMeter } from '@burdenoff/fe-libs/shared/components';\n\nimport { useTr } from '../../shared/hooks/useTr';\nimport { usePlanUsage, type PlanAllowance } from '../hooks/usePlanUsage';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { graphqlErrorCode } from '../utils/errors';\nimport { quotaLabel } from '../utils/quotaErrors';\nimport { Button } from './Button';\nimport { Card, CardContent, CardHeader, CardTitle } from './Card';\nimport { ErrorState } from './ErrorState';\n\n/** Usage at or above this share of the limit shows the warning state. */\nconst WARNING_PERCENT = 80;\n\nconst HIDDEN_CODES = new Set(['FORBIDDEN', 'PERMISSION_DENIED', 'UNAUTHENTICATED']);\n\nexport const PlanUsageCard: FC = () => {\n const t = useTr();\n const { navigate } = useBotlit();\n const { data: allowances, loading, error, refetch } = usePlanUsage();\n\n if (error && HIDDEN_CODES.has(graphqlErrorCode(error) ?? '')) return null;\n\n const openBilling = () => {\n if (navigate) navigate('/billing');\n else window.location.assign('/billing');\n };\n\n const label = (allowance: PlanAllowance) =>\n allowance.key ? quotaLabel(t, allowance.key) : allowance.quotaName;\n\n const resetHint = (allowance: PlanAllowance): string | null => {\n switch (allowance.resetPeriod.toUpperCase()) {\n case 'MONTHLY':\n return t('botlit.usage.plan.resetsMonthly', 'Resets monthly');\n case 'DAILY':\n return t('botlit.usage.plan.resetsDaily', 'Resets daily');\n default:\n return null;\n }\n };\n\n return (\n <Card data-testid=\"plan-usage-card\">\n <CardHeader className=\"flex flex-row flex-wrap items-center justify-between gap-2\">\n <div>\n <CardTitle as=\"h2\">{t('botlit.usage.plan.title', 'Plan and usage')}</CardTitle>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {t(\n 'botlit.usage.plan.subtitle',\n \"What your plan includes for BotManor and how much of it you've used.\"\n )}\n </p>\n </div>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={openBilling}>\n {t('botlit.usage.plan.manage', 'Manage plan')}\n </Button>\n </CardHeader>\n <CardContent>\n {error ? (\n <ErrorState\n resource={t('botlit.usage.plan.resource', 'your plan usage')}\n error={error}\n onRetry={() => void refetch()}\n />\n ) : loading && allowances.length === 0 ? (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n {t('botlit.usage.plan.loading', 'Loading your plan usage…')}\n </p>\n ) : allowances.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'botlit.usage.plan.empty',\n 'Your plan has no BotManor allowances yet. Choose a plan in billing to start building bots.'\n )}\n </p>\n ) : (\n <ul className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {allowances.map((allowance) => {\n const hint = resetHint(allowance);\n return (\n <li key={allowance.quotaName} className=\"space-y-1\">\n <QuotaMeter\n label={label(allowance)}\n used={allowance.used}\n limit={allowance.limit}\n warningPercent={WARNING_PERCENT}\n exhaustedHint={t(\n 'botlit.usage.plan.exhaustedHint',\n 'Limit reached. Upgrade your plan to add more.'\n )}\n />\n {hint ? <p className=\"text-xs text-text-secondary\">{hint}</p> : null}\n </li>\n );\n })}\n </ul>\n )}\n </CardContent>\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;AAuBA,IAAMA,IAAkB,IAElBC,oBAAe,IAAI,IAAI;CAAC;CAAa;CAAqB;AAAiB,CAAC,GAErEC,UAA0B;CACrC,IAAMC,IAAIC,EAAM,GACV,EAAE,gBAAaC,EAAU,GACzB,EAAE,MAAMC,GAAY,YAAS,UAAO,eAAYC,EAAa;CAEnE,IAAIC,KAASP,EAAa,IAAIQ,EAAiBD,CAAK,KAAK,EAAE,GAAG,OAAO;CAErE,IAAME,UAAoB;EACxB,AAAIC,IAAUA,EAAS,UAAU,IAC5B,OAAO,SAAS,OAAO,UAAU;CACxC,GAEMC,KAAS,MACbC,EAAU,MAAMC,EAAWX,GAAGU,EAAU,GAAG,IAAIA,EAAU,WAErDE,KAAa,MAA4C;EAC7D,QAAQF,EAAU,YAAY,YAAY,GAA1C;GACE,KAAK,WACH,OAAOV,EAAE,mCAAmC,gBAAgB;GAC9D,KAAK,SACH,OAAOA,EAAE,iCAAiC,cAAc;GAC1D,SACE,OAAO;EACX;CACF;CAEA,OACE,kBAACa,GAAD;EAAM,eAAY;EAAlB,UAAA,CACE,kBAACC,GAAD;GAAY,WAAU;GAAtB,UAAA,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAACC,GAAD;IAAW,IAAG;IAAM,UAAAf,EAAE,2BAA2B,gBAAgB;GAAa,CAAA,GAC9E,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAA,EACC,8BACA,sEACF;GACC,CAAA,CACA,EAAA,CAAA,GACL,kBAACgB,GAAD;IAAQ,MAAK;IAAS,SAAQ;IAAU,MAAK;IAAK,SAAST;IACxD,UAAAP,EAAE,4BAA4B,aAAa;GACtC,CAAA,CACE;EACZ,CAAA,GAAA,kBAACiB,GAAD,EAAA,UACGZ,IACC,kBAACa,GAAD;GACE,UAAUlB,EAAE,8BAA8B,iBAAiB;GACpD;GACP,eAAe,KAAKmB,EAAQ;EAC7B,CAAA,IACCC,KAAWjB,EAAW,WAAW,IACnC,kBAAC,KAAD;GAAG,MAAK;GAAS,WAAU;GACxB,UAAAH,EAAE,6BAA6B,0BAA0B;EACzD,CAAA,IACDG,EAAW,WAAW,IACxB,kBAAC,KAAD;GAAG,WAAU;GACV,UAAAH,EACC,2BACA,4FACF;EACC,CAAA,IAEH,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAG,EAAW,KAAK,MAAc;IAC7B,IAAMkB,IAAOT,EAAUF,CAAS;IAChC,OACE,kBAAC,MAAD;KAA8B,WAAU;KAAxC,UAAA,CACE,kBAACY,GAAD;MACE,OAAOb,EAAMC,CAAS;MACtB,MAAMA,EAAU;MAChB,OAAOA,EAAU;MACjB,gBAAgBb;MAChB,eAAeG,EACb,mCACA,+CACF;KACD,CAAA,GACAqB,IAAO,kBAAC,KAAD;MAAG,WAAU;MAA+B,UAAAA;KAAQ,CAAA,IAAI,IAC9D;IAZK,GAAAX,EAAU,SAYf;GAER,CAAC;EACC,CAAA,EAEK,CAAA,CACT;;AAEV"}
@@ -1,9 +1,20 @@
1
- interface QuotaExhaustedDialogProps {
1
+ /**
2
+ * Plan-limit dialog (BOFF-15484)
3
+ * @module botlit/components
4
+ *
5
+ * `PlanLimitDialog` is the dialog itself. `QuotaExhaustedDialog` is what pages
6
+ * render: inside BotManor's root it hands its copy to the one shared dialog
7
+ * (see `providers/QuotaGuard.tsx`), which also opens on its own for every
8
+ * metered mutation that hits a limit — so a page that handles the error
9
+ * itself and the automatic routing never stack two dialogs.
10
+ */
11
+ export interface PlanLimitDialogProps {
2
12
  open: boolean;
3
13
  title: string;
4
14
  description: string;
5
15
  onClose: () => void;
6
16
  onViewBilling: () => void;
7
17
  }
8
- export declare function QuotaExhaustedDialog({ open, title, description, onClose, onViewBilling, }: QuotaExhaustedDialogProps): import('react').JSX.Element;
9
- export {};
18
+ export declare function PlanLimitDialog({ open, title, description, onClose, onViewBilling, }: PlanLimitDialogProps): import('react').JSX.Element;
19
+ export type QuotaExhaustedDialogProps = PlanLimitDialogProps;
20
+ export declare function QuotaExhaustedDialog(props: QuotaExhaustedDialogProps): import('react').JSX.Element | null;
@@ -1,19 +1,39 @@
1
- import { AlertDialog as e, AlertDialogAction as t, AlertDialogCancel as n, AlertDialogContent as r, AlertDialogDescription as i, AlertDialogFooter as a, AlertDialogHeader as o, AlertDialogTitle as s } from "@burdenoff/fe-libs/ui";
2
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { useQuotaGuard as t } from "../providers/quotaGuardContext.js";
3
+ import { useEffect as n, useLayoutEffect as r, useRef as i } from "react";
4
+ import { AlertDialog as a, AlertDialogAction as o, AlertDialogCancel as s, AlertDialogContent as c, AlertDialogDescription as l, AlertDialogFooter as u, AlertDialogHeader as d, AlertDialogTitle as f } from "@burdenoff/fe-libs/ui";
5
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
3
6
  // src/botlit/components/QuotaExhaustedDialog.tsx
4
- function u({ open: u, title: d, description: f, onClose: p, onViewBilling: m }) {
5
- return /* @__PURE__ */ c(e, {
6
- open: u,
7
- onOpenChange: (e) => !e && p(),
8
- children: /* @__PURE__ */ l(r, { children: [/* @__PURE__ */ l(o, { children: [/* @__PURE__ */ c(s, { children: d }), /* @__PURE__ */ c(i, { children: f })] }), /* @__PURE__ */ l(a, { children: [/* @__PURE__ */ c(n, {
9
- onClick: p,
10
- children: "Dismiss"
11
- }), /* @__PURE__ */ c(t, {
12
- onClick: m,
13
- children: "View Billing"
7
+ function h({ open: t, title: n, description: r, onClose: i, onViewBilling: h }) {
8
+ let g = e();
9
+ return /* @__PURE__ */ p(a, {
10
+ open: t,
11
+ onOpenChange: (e) => !e && i(),
12
+ children: /* @__PURE__ */ m(c, { children: [/* @__PURE__ */ m(d, { children: [/* @__PURE__ */ p(f, { children: n }), /* @__PURE__ */ p(l, { children: r })] }), /* @__PURE__ */ m(u, { children: [/* @__PURE__ */ p(s, {
13
+ onClick: i,
14
+ children: g("botlit.usage.dialog.dismiss", "Dismiss")
15
+ }), /* @__PURE__ */ p(o, {
16
+ onClick: h,
17
+ children: g("botlit.usage.dialog.viewBilling", "View Billing")
14
18
  })] })] })
15
19
  });
16
20
  }
17
- export { u as QuotaExhaustedDialog };
21
+ function g(e) {
22
+ let a = t(), { open: o, title: s, description: c } = e, l = i(e.onClose);
23
+ return r(() => {
24
+ l.current = e.onClose;
25
+ }, [e.onClose]), n(() => {
26
+ if (a && o) return a.present({
27
+ title: s,
28
+ description: c
29
+ }, () => l.current());
30
+ }, [
31
+ a,
32
+ o,
33
+ s,
34
+ c
35
+ ]), a ? null : /* @__PURE__ */ p(h, { ...e });
36
+ }
37
+ export { h as PlanLimitDialog, g as QuotaExhaustedDialog };
18
38
 
19
39
  //# sourceMappingURL=QuotaExhaustedDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaExhaustedDialog.js","names":["QuotaExhaustedDialog","AlertDialog","nextOpen","onClose","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","title","AlertDialogDescription","description","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","onViewBilling"],"sources":["../../../src/botlit/components/QuotaExhaustedDialog.tsx"],"sourcesContent":["import {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '@burdenoff/fe-libs/ui';\n\ninterface QuotaExhaustedDialogProps {\n open: boolean;\n title: string;\n description: string;\n onClose: () => void;\n onViewBilling: () => void;\n}\n\nexport function QuotaExhaustedDialog({\n open,\n title,\n description,\n onClose,\n onViewBilling,\n}: QuotaExhaustedDialogProps) {\n return (\n <AlertDialog open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>{title}</AlertDialogTitle>\n <AlertDialogDescription>{description}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel onClick={onClose}>Dismiss</AlertDialogCancel>\n <AlertDialogAction onClick={onViewBilling}>View Billing</AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n"],"mappings":";;;AAmBA,SAAgBA,EAAqB,EACnC,SACA,UACA,gBACA,YACA,oBAC4B;CAC5B,OACE,kBAACC,GAAD;EAAmB;EAAM,eAAe,MAAa,CAACC,KAAYC,EAAQ;EACxE,UAAA,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAmBC,EAAwB,CAAA,GAC3C,kBAACC,GAAD,EAAA,UAAyBC,EAAoC,CAAA,CAC5C,EAAA,CAAA,GACnB,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;GAAmB,SAASR;GAAS,UAAA;EAA0B,CAAA,GAC/D,kBAACS,GAAD;GAAmB,SAASC;GAAe,UAAA;EAA+B,CAAA,CACzD,EAAA,CAAA,CACD,EAAA,CAAA;CACT,CAAA;AAEjB"}
1
+ {"version":3,"file":"QuotaExhaustedDialog.js","names":["PlanLimitDialog","t","useTr","AlertDialog","nextOpen","onClose","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","title","AlertDialogDescription","description","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","onViewBilling","QuotaExhaustedDialog","guard","useQuotaGuard","props","onCloseRef","useRef","useLayoutEffect","useEffect","open"],"sources":["../../../src/botlit/components/QuotaExhaustedDialog.tsx"],"sourcesContent":["/**\n * Plan-limit dialog (BOFF-15484)\n * @module botlit/components\n *\n * `PlanLimitDialog` is the dialog itself. `QuotaExhaustedDialog` is what pages\n * render: inside BotManor's root it hands its copy to the one shared dialog\n * (see `providers/QuotaGuard.tsx`), which also opens on its own for every\n * metered mutation that hits a limit — so a page that handles the error\n * itself and the automatic routing never stack two dialogs.\n */\n\nimport { useEffect, useLayoutEffect, useRef } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '@burdenoff/fe-libs/ui';\n\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useQuotaGuard } from '../providers/quotaGuardContext';\n\nexport interface PlanLimitDialogProps {\n open: boolean;\n title: string;\n description: string;\n onClose: () => void;\n onViewBilling: () => void;\n}\n\nexport function PlanLimitDialog({\n open,\n title,\n description,\n onClose,\n onViewBilling,\n}: PlanLimitDialogProps) {\n const t = useTr();\n return (\n <AlertDialog open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>{title}</AlertDialogTitle>\n <AlertDialogDescription>{description}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel onClick={onClose}>\n {t('botlit.usage.dialog.dismiss', 'Dismiss')}\n </AlertDialogCancel>\n <AlertDialogAction onClick={onViewBilling}>\n {t('botlit.usage.dialog.viewBilling', 'View Billing')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n\nexport type QuotaExhaustedDialogProps = PlanLimitDialogProps;\n\nexport function QuotaExhaustedDialog(props: QuotaExhaustedDialogProps) {\n const guard = useQuotaGuard();\n const { open, title, description } = props;\n const onCloseRef = useRef(props.onClose);\n useLayoutEffect(() => {\n onCloseRef.current = props.onClose;\n }, [props.onClose]);\n\n useEffect(() => {\n if (!guard || !open) return undefined;\n return guard.present({ title, description }, () => onCloseRef.current());\n }, [guard, open, title, description]);\n\n if (guard) return null;\n return <PlanLimitDialog {...props} />;\n}\n"],"mappings":";;;;;;AAkCA,SAAgBA,EAAgB,EAC9B,SACA,UACA,gBACA,YACA,oBACuB;CACvB,IAAMC,IAAIC,EAAM;CAChB,OACE,kBAACC,GAAD;EAAmB;EAAM,eAAe,MAAa,CAACC,KAAYC,EAAQ;EACxE,UAAA,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAmBC,EAAwB,CAAA,GAC3C,kBAACC,GAAD,EAAA,UAAyBC,EAAoC,CAAA,CAC5C,EAAA,CAAA,GACnB,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;GAAmB,SAASR;GACzB,UAAAJ,EAAE,+BAA+B,SAAS;EAC1B,CAAA,GACnB,kBAACa,GAAD;GAAmB,SAASC;GACzB,UAAAd,EAAE,mCAAmC,cAAc;EACnC,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;CACT,CAAA;AAEjB;AAIA,SAAgBe,EAAqB,GAAkC;CACrE,IAAMC,IAAQC,EAAc,GACtB,EAAE,SAAM,UAAO,mBAAgBC,GAC/BC,IAAaC,EAAOF,EAAM,OAAO;CAWvC,OAVAG,QAAsB;EACpB,EAAW,UAAUH,EAAM;CAC7B,GAAG,CAACA,EAAM,OAAO,CAAC,GAElBI,QAAgB;EACd,IAAKN,KAAUO,GACf,OAAOP,EAAM,QAAQ;GAAE;GAAO;EAAY,SAASG,EAAW,QAAQ,CAAC;CACzE,GAAG;EAACH;EAAOO;EAAMf;EAAOE;CAAW,CAAC,GAEhCM,IAAc,OACX,kBAACjB,GAAD,EAAiB,GAAImB,EAAQ,CAAA;AACtC"}
@@ -0,0 +1,19 @@
1
+ import { BotmanorPlanUsageQuery } from '../../generated/wspace-operations';
2
+ import { BotmanorQuotaKey } from '../utils/quotaErrors';
3
+ import { QueryResult } from './internal/workspaceGateway';
4
+ export interface PlanAllowance {
5
+ quotaName: string;
6
+ /** Known BotManor allowance, or undefined for a quota this build has no label for. */
7
+ key: BotmanorQuotaKey | undefined;
8
+ used: number;
9
+ /** null = unlimited. */
10
+ limit: number | null;
11
+ /** NEVER | DAILY | MONTHLY. */
12
+ resetPeriod: string;
13
+ lastResetAt: string | null;
14
+ }
15
+ type Row = BotmanorPlanUsageQuery['workspaceQuotaOverview'][number];
16
+ /** Folds the overview rows into one allowance per quota. */
17
+ export declare function toPlanAllowances(rows: readonly Row[]): PlanAllowance[];
18
+ export declare function usePlanUsage(): QueryResult<PlanAllowance[]>;
19
+ export {};
@@ -0,0 +1,45 @@
1
+ import { BotmanorPlanUsageDocument as e } from "../../generated/wspace-operations.js";
2
+ import { quotaKeyOfName as t } from "../utils/quotaErrors.js";
3
+ import { useWorkspaceId as n, useWorkspaceQuery as r } from "./internal/workspaceGateway.js";
4
+ import { useMemo as i } from "react";
5
+ // src/botlit/hooks/usePlanUsage.ts
6
+ var a = {
7
+ bots: 0,
8
+ runs: 1,
9
+ messages: 2,
10
+ knowledgeBases: 3,
11
+ mcpServers: 4,
12
+ aiCredits: 5
13
+ }, o = Object.keys(a).length, s = [];
14
+ function c(e) {
15
+ let n = /* @__PURE__ */ new Map();
16
+ for (let r of e) {
17
+ let { assignment: e } = r;
18
+ if (!e.isActive || e.productId !== "botmanor") continue;
19
+ let i = Number.isFinite(r.effectiveUsed) ? r.effectiveUsed : e.used, a = e.noLimit ? null : e.limit ?? 0, o = n.get(e.quotaName);
20
+ o ? (o.used += i, o.limit = o.limit === null || a === null ? null : o.limit + a) : n.set(e.quotaName, {
21
+ quotaName: e.quotaName,
22
+ key: t(e.quotaName),
23
+ used: i,
24
+ limit: a,
25
+ resetPeriod: e.resetPeriod,
26
+ lastResetAt: e.lastResetAt ?? null
27
+ });
28
+ }
29
+ let r = (e) => e.key ? a[e.key] : o;
30
+ return [...n.values()].sort((e, t) => r(e) - r(t) || e.quotaName.localeCompare(t.quotaName));
31
+ }
32
+ function l() {
33
+ let t = n(), a = i(() => t ? { workspaceId: t } : void 0, [t]);
34
+ return r({
35
+ document: e,
36
+ variables: a,
37
+ select: (e) => c(e?.workspaceQuotaOverview ?? []),
38
+ fallback: s,
39
+ enabled: !!t,
40
+ errorMessage: "Failed to load your plan usage"
41
+ });
42
+ }
43
+ export { c as toPlanAllowances, l as usePlanUsage };
44
+
45
+ //# sourceMappingURL=usePlanUsage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePlanUsage.js","names":["RANK","UNRANKED","EMPTY","toPlanAllowances","byName","row","rows","assignment","used","limit","existing","quotaKeyOfName","rank","allowance","a","b","usePlanUsage","workspaceId","useWorkspaceId","variables","useMemo","useWorkspaceQuery","BotmanorPlanUsageDocument","data"],"sources":["../../../src/botlit/hooks/usePlanUsage.ts"],"sourcesContent":["/**\n * BotManor plan allowances (BOFF-15484)\n * @module botlit/hooks\n *\n * The workspace's BotManor quotas from `workspaceQuotaOverview`, filtered to\n * product `botmanor` on the server: what the plan allows, what has been used\n * and when the counter resets. Only active assignments count; a quota with\n * several assignments (stacked subscriptions) is summed.\n */\n\nimport { useMemo } from 'react';\n\nimport {\n BotmanorPlanUsageDocument,\n type BotmanorPlanUsageQuery,\n} from '../../generated/wspace-operations';\nimport { quotaKeyOfName, type BotmanorQuotaKey } from '../utils/quotaErrors';\nimport { useWorkspaceId, useWorkspaceQuery, type QueryResult } from './internal/workspaceGateway';\n\nexport interface PlanAllowance {\n quotaName: string;\n /** Known BotManor allowance, or undefined for a quota this build has no label for. */\n key: BotmanorQuotaKey | undefined;\n used: number;\n /** null = unlimited. */\n limit: number | null;\n /** NEVER | DAILY | MONTHLY. */\n resetPeriod: string;\n lastResetAt: string | null;\n}\n\n/**\n * Display rank on the plan card; quotas without a known key follow, by name.\n * A Record, so adding a BotmanorQuotaKey without a rank fails to compile.\n */\nconst RANK: Record<BotmanorQuotaKey, number> = {\n bots: 0,\n runs: 1,\n messages: 2,\n knowledgeBases: 3,\n mcpServers: 4,\n aiCredits: 5,\n};\nconst UNRANKED = Object.keys(RANK).length;\n\nconst EMPTY: PlanAllowance[] = [];\n\ntype Row = BotmanorPlanUsageQuery['workspaceQuotaOverview'][number];\n\n/** Folds the overview rows into one allowance per quota. */\nexport function toPlanAllowances(rows: readonly Row[]): PlanAllowance[] {\n const byName = new Map<string, PlanAllowance>();\n for (const row of rows) {\n const { assignment } = row;\n if (!assignment.isActive || assignment.productId !== 'botmanor') continue;\n const used = Number.isFinite(row.effectiveUsed) ? row.effectiveUsed : assignment.used;\n const limit = assignment.noLimit ? null : (assignment.limit ?? 0);\n const existing = byName.get(assignment.quotaName);\n if (!existing) {\n byName.set(assignment.quotaName, {\n quotaName: assignment.quotaName,\n key: quotaKeyOfName(assignment.quotaName),\n used,\n limit,\n resetPeriod: assignment.resetPeriod,\n lastResetAt: assignment.lastResetAt ?? null,\n });\n continue;\n }\n existing.used += used;\n existing.limit = existing.limit === null || limit === null ? null : existing.limit + limit;\n }\n const rank = (allowance: PlanAllowance) => (allowance.key ? RANK[allowance.key] : UNRANKED);\n return [...byName.values()].sort(\n (a, b) => rank(a) - rank(b) || a.quotaName.localeCompare(b.quotaName)\n );\n}\n\nexport function usePlanUsage(): QueryResult<PlanAllowance[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => (workspaceId ? { workspaceId } : undefined), [workspaceId]);\n return useWorkspaceQuery<BotmanorPlanUsageQuery, PlanAllowance[]>({\n document: BotmanorPlanUsageDocument,\n variables,\n select: (data) => toPlanAllowances(data?.workspaceQuotaOverview ?? []),\n fallback: EMPTY,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load your plan usage',\n });\n}\n"],"mappings":";;;;;AAmCA,IAAMA,IAAyC;CAC7C,MAAM;CACN,MAAM;CACN,UAAU;CACV,gBAAgB;CAChB,YAAY;CACZ,WAAW;AACb,GACMC,IAAW,OAAO,KAAKD,CAAI,CAAC,CAAC,QAE7BE,IAAyB,CAAC;AAKhC,SAAgBC,EAAiB,GAAuC;CACtE,IAAMC,oBAAS,IAAI,IAA2B;CAC9C,KAAK,IAAMC,KAAOC,GAAM;EACtB,IAAM,EAAE,kBAAeD;EACvB,IAAI,CAACE,EAAW,YAAYA,EAAW,cAAc,YAAY;EACjE,IAAMC,IAAO,OAAO,SAASH,EAAI,aAAa,IAAIA,EAAI,gBAAgBE,EAAW,MAC3EE,IAAQF,EAAW,UAAU,OAAQA,EAAW,SAAS,GACzDG,IAAWN,EAAO,IAAIG,EAAW,SAAS;EAChD,AAAKG,KAWL,EAAS,QAAQF,GACjB,EAAS,QAAQE,EAAS,UAAU,QAAQD,MAAU,OAAO,OAAOC,EAAS,QAAQD,KAXnFL,EAAO,IAAIG,EAAW,WAAW;GAC/B,WAAWA,EAAW;GACtB,KAAKI,EAAeJ,EAAW,SAAS;GACxC;GACA;GACA,aAAaA,EAAW;GACxB,aAAaA,EAAW,eAAe;EACzC,CAAC;CAKL;CACA,IAAMK,KAAQ,MAA8BC,EAAU,MAAMb,EAAKa,EAAU,OAAOZ;CAClF,OAAO,CAAC,GAAGG,EAAO,OAAO,CAAC,CAAC,CAAC,MACzB,GAAG,MAAMQ,EAAKE,CAAC,IAAIF,EAAKG,CAAC,KAAKD,EAAE,UAAU,cAAcC,EAAE,SAAS,CACtE;AACF;AAEA,SAAgBC,IAA6C;CAC3D,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,QAAeH,IAAc,EAAE,eAAY,IAAI,KAAA,GAAY,CAACA,CAAW,CAAC;CAC1F,OAAOI,EAA2D;EAChE,UAAUC;EACV;EACA,SAAS,MAASnB,EAAiBoB,GAAM,0BAA0B,CAAC,CAAC;EACrE,UAAUrB;EACV,SAAS,EAAQe;EACjB,cAAc;CAChB,CAAC;AACH"}
@@ -4,9 +4,9 @@ import { AiOperationsPanel as ee } from "../components/AiOperationsPanel.js";
4
4
  import { Card as n, CardContent as r, CardHeader as i, CardTitle as a } from "../components/Card.js";
5
5
  import { Button as o } from "../components/Button.js";
6
6
  import { Badge as s, StatusBadge as c } from "../components/Badge.js";
7
+ import { EmptyState as te } from "../components/EmptyState.js";
7
8
  import { BOTMANOR_PERMISSIONS as l } from "../permissions/botmanorPermissions.js";
8
- import { BotmanorPermissionGate as u, useBotmanorCan as te } from "../permissions/useBotmanorPermissions.js";
9
- import { EmptyState as ne } from "../components/EmptyState.js";
9
+ import { BotmanorPermissionGate as u, useBotmanorCan as ne } from "../permissions/useBotmanorPermissions.js";
10
10
  import { ErrorState as re } from "../components/ErrorState.js";
11
11
  import { BOT_VISIBILITIES as d, BotFormFields as f, DEFAULT_BOT_FORM as p, ROUTING_STRATEGIES as m } from "../components/BotFormFields.js";
12
12
  import { useBot as ie, useCreateBot as ae, useDeleteBot as oe, useUpdateBot as se } from "../hooks/useBots.js";
@@ -92,7 +92,7 @@ function qe(e) {
92
92
  return N.find((e) => e === t) ?? "overview";
93
93
  }
94
94
  var P = ({ isNew: d, isEditing: m }) => {
95
- let h = e(), { botId: v } = je(), [k] = Me(), A = te(), { navigateTo: j, getPath: M, workspaceId: N, navigate: P } = ue(), { data: F, loading: Je, error: I, refetch: L } = ie(d ? void 0 : v), { data: R } = ce(), [Ye, Xe] = ae(), [z, B] = se(), [Ze, Qe] = oe(), [V, H] = b(() => qe(k)), [U, W] = b(p), [$e, et] = b(p), [G, K] = b(!1), [tt, q] = b(!1), [nt, J] = b(!1), Y = me(U.name, U.slug), rt = Object.keys(Y).length > 0, X = !tt && JSON.stringify(U) !== JSON.stringify($e), it = !!(d || m), at = () => {
95
+ let h = e(), { botId: v } = je(), [k] = Me(), A = ne(), { navigateTo: j, getPath: M, workspaceId: N, navigate: P } = ue(), { data: F, loading: Je, error: I, refetch: L } = ie(d ? void 0 : v), { data: R } = ce(), [Ye, Xe] = ae(), [z, B] = se(), [Ze, Qe] = oe(), [V, H] = b(() => qe(k)), [U, W] = b(p), [$e, et] = b(p), [G, K] = b(!1), [tt, q] = b(!1), [nt, J] = b(!1), Y = me(U.name, U.slug), rt = Object.keys(Y).length > 0, X = !tt && JSON.stringify(U) !== JSON.stringify($e), it = !!(d || m), at = () => {
96
96
  P ? P("/billing") : window.location.assign("/billing");
97
97
  };
98
98
  y(() => {
@@ -256,7 +256,7 @@ var P = ({ isNew: d, isEditing: m }) => {
256
256
  });
257
257
  if (!F) return /* @__PURE__ */ S(t, {
258
258
  title: h("botlit.botDetail.notFound.title", "Bot Not Found"),
259
- children: /* @__PURE__ */ S(ne, {
259
+ children: /* @__PURE__ */ S(te, {
260
260
  illustration: "empty-agents",
261
261
  title: h("botlit.botDetail.notFound.title", "Bot Not Found"),
262
262
  description: h("botlit.botDetail.notFound.description", "The bot you're looking for doesn't exist."),