@elevasis/ui 2.73.0 → 2.75.0

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 (97) hide show
  1. package/dist/api/index.js +3 -3
  2. package/dist/app/index.d.ts +58 -0
  3. package/dist/app/index.js +9 -10
  4. package/dist/auth/index.js +5 -6
  5. package/dist/charts/index.js +5 -6
  6. package/dist/chunk-2GIJBHZT.js +60 -0
  7. package/dist/{chunk-Z4ICFQXG.js → chunk-2ZRY3ARL.js} +1 -1
  8. package/dist/{chunk-5B2ZFO44.js → chunk-3H5DIJN7.js} +1 -1
  9. package/dist/{chunk-LZT2H2MA.js → chunk-47YJVIZE.js} +36 -43
  10. package/dist/{chunk-3TS5U5BL.js → chunk-5RH6NYZH.js} +1 -1
  11. package/dist/chunk-5SLRGUC4.js +224 -0
  12. package/dist/{chunk-JYBJMVNY.js → chunk-5VF5LPYS.js} +1 -1
  13. package/dist/{chunk-SWKAH2YM.js → chunk-6BJ5HMMC.js} +282 -553
  14. package/dist/{chunk-NI37YNRP.js → chunk-7OOFMEX6.js} +11 -5
  15. package/dist/{chunk-IBCEAVB2.js → chunk-A2SB32YV.js} +65 -5
  16. package/dist/{chunk-CJ2232PQ.js → chunk-CRPH5AAB.js} +1 -1
  17. package/dist/chunk-D3XXPCCK.js +69 -0
  18. package/dist/chunk-DMSTDZCJ.js +305 -0
  19. package/dist/chunk-DTEGVSJ6.js +645 -0
  20. package/dist/chunk-DVAOCHIF.js +165 -0
  21. package/dist/chunk-G7O4CBMC.js +231 -0
  22. package/dist/{chunk-IGBPWD6S.js → chunk-GDTK33QT.js} +5 -3
  23. package/dist/chunk-ICHDIVQO.js +54 -0
  24. package/dist/{chunk-U2H3TIHD.js → chunk-IYATYH5I.js} +2 -52
  25. package/dist/chunk-L3NBMLRN.js +49 -0
  26. package/dist/{chunk-LEPYXLJ2.js → chunk-LFLM723H.js} +1 -1
  27. package/dist/chunk-M6VAZAQW.js +45 -0
  28. package/dist/{chunk-AJOVWB47.js → chunk-MLHZUN2X.js} +6 -3
  29. package/dist/chunk-N6K2Q5BM.js +393 -0
  30. package/dist/chunk-NMHQAYZU.js +439 -0
  31. package/dist/chunk-NYIIRZSA.js +286 -0
  32. package/dist/{chunk-ETN3TTRT.js → chunk-OGHTJKBV.js} +115 -8
  33. package/dist/{chunk-M7WWRZ5Z.js → chunk-QFGNRKIE.js} +1 -78
  34. package/dist/chunk-QFS2GZMV.js +515 -0
  35. package/dist/{chunk-OCVSPAKM.js → chunk-SB3IHM5Y.js} +1150 -4346
  36. package/dist/{chunk-4CW2C5BD.js → chunk-SEYOVNS5.js} +1 -1
  37. package/dist/chunk-SN7X5N2A.js +116 -0
  38. package/dist/{chunk-PQ4B62HH.js → chunk-TX3UHDL5.js} +2 -2
  39. package/dist/chunk-VM2OWOXL.js +24 -0
  40. package/dist/{chunk-ZDKPHFTH.js → chunk-VWGCURZF.js} +5 -3
  41. package/dist/chunk-WDBNW44Z.js +49 -0
  42. package/dist/chunk-YQQ5GRUR.js +21 -0
  43. package/dist/{chunk-NHNTX6ZL.js → chunk-ZG6YJUT4.js} +3 -2
  44. package/dist/components/index.d.ts +228 -6
  45. package/dist/components/index.js +321 -35
  46. package/dist/components/navigation/index.js +6 -7
  47. package/dist/features/auth/index.d.ts +78 -2
  48. package/dist/features/auth/index.js +18 -9
  49. package/dist/features/clients/index.js +7 -7
  50. package/dist/features/content/index.d.ts +226 -5
  51. package/dist/features/content/index.js +270 -19
  52. package/dist/features/crm/index.d.ts +58 -0
  53. package/dist/features/crm/index.js +10 -8
  54. package/dist/features/dashboard/index.js +9 -8
  55. package/dist/features/delivery/index.d.ts +58 -0
  56. package/dist/features/delivery/index.js +23 -7
  57. package/dist/features/knowledge/index.js +5 -6
  58. package/dist/features/lead-gen/index.d.ts +9 -15
  59. package/dist/features/lead-gen/index.js +12 -8
  60. package/dist/features/monitoring/index.js +11 -9
  61. package/dist/features/monitoring/requests/index.js +8 -7
  62. package/dist/features/operations/index.js +15 -11
  63. package/dist/features/public-agent-chat/index.js +3 -1
  64. package/dist/features/settings/index.d.ts +66 -3
  65. package/dist/features/settings/index.js +9 -8
  66. package/dist/hooks/access/index.js +5 -6
  67. package/dist/hooks/delivery/index.d.ts +58 -0
  68. package/dist/hooks/delivery/index.js +3 -2
  69. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +1 -1
  70. package/dist/hooks/published.d.ts +181 -5
  71. package/dist/hooks/published.js +22 -6
  72. package/dist/initialization/index.d.ts +58 -0
  73. package/dist/knowledge/index.js +167 -11
  74. package/dist/{knowledge-search-index-RZLIVWPJ.js → knowledge-search-index-6GQK55IQ.js} +1 -1
  75. package/dist/layout/index.js +8 -9
  76. package/dist/profile/index.d.ts +58 -0
  77. package/dist/provider/index.d.ts +77 -1
  78. package/dist/provider/index.js +5 -6
  79. package/dist/provider/published.d.ts +105 -1
  80. package/dist/provider/published.js +5 -6
  81. package/dist/test-utils/index.d.ts +16 -5
  82. package/dist/test-utils/index.js +17 -18
  83. package/dist/types/index.d.ts +73 -1
  84. package/dist/utils/index.d.ts +83 -3
  85. package/dist/utils/index.js +1 -1
  86. package/package.json +10 -5
  87. package/dist/chunk-6M6OLGQY.js +0 -36
  88. package/dist/chunk-MKH2KOAO.js +0 -39
  89. package/dist/hooks/index.css +0 -659
  90. package/dist/hooks/index.d.ts +0 -14073
  91. package/dist/hooks/index.js +0 -27
  92. package/dist/supabase/index.d.ts +0 -7118
  93. package/dist/supabase/index.js +0 -3
  94. package/dist/typeform/index.d.ts +0 -462
  95. package/dist/typeform/index.js +0 -2051
  96. package/dist/typeform/schemas.d.ts +0 -67
  97. package/dist/typeform/schemas.js +0 -2
@@ -1,12 +1,15 @@
1
- import { CRM_API_INTERFACE } from './chunk-PQ4B62HH.js';
1
+ import { useDealDetail, useExecuteAction } from './chunk-M6VAZAQW.js';
2
+ import { CRM_API_INTERFACE } from './chunk-TX3UHDL5.js';
3
+ import { useTableSort, sortData, useCompany, useContact, deriveActions } from './chunk-NYIIRZSA.js';
4
+ import { useTableSelection } from './chunk-WDBNW44Z.js';
2
5
  import { PageContainer } from './chunk-BZZCNLT6.js';
3
6
  import { TableSelectionToolbar, SortableHeader } from './chunk-TUMSNGTX.js';
4
7
  import { FilterBar } from './chunk-PDHTXPSF.js';
5
- import { CrmSidebarMiddle, useDealsSummary, useOptionalElevasisSystems, getCrmPipelineCatalog, CenteredErrorState, StatCard, PageTitleCaption, useDeleteDeal, usePaginationState, useDeals, useTableSort, sortData, useTableSelection, SubshellContentContainer, EmptyState, CustomModal, useDealDetail, useCrmActions, ActivityTimeline, useCompany, ContextViewer, JsonViewer, dealKeys, useContact, deriveActions, useExecuteAction } from './chunk-OCVSPAKM.js';
6
- import { showApiErrorNotification, showSuccessNotification } from './chunk-U2H3TIHD.js';
8
+ import { CrmSidebarMiddle, useDealsSummary, useOptionalElevasisSystems, getCrmPipelineCatalog, CenteredErrorState, StatCard, PageTitleCaption, useDeleteDeal, usePaginationState, useDeals, SubshellContentContainer, EmptyState, CustomModal, useCrmActions, ActivityTimeline, ContextViewer, JsonViewer, dealKeys } from './chunk-SB3IHM5Y.js';
9
+ import { showApiErrorNotification, showSuccessNotification } from './chunk-ICHDIVQO.js';
7
10
  import { SubshellSidebarSection } from './chunk-MISHPEJX.js';
8
11
  import { CardHeader } from './chunk-62GVNH5U.js';
9
- import { computeInterfaceReadiness, getSystem, PAGE_SIZE_DEFAULT, formatTimeAgo } from './chunk-IBCEAVB2.js';
12
+ import { computeInterfaceReadiness, getSystem, PAGE_SIZE_DEFAULT, formatTimeAgo } from './chunk-A2SB32YV.js';
10
13
  import { useElevasisServices } from './chunk-BI5VDO2K.js';
11
14
  import { Stack, Paper, Center, Loader, Group, Box, Text, Alert, Table, SimpleGrid, Button, Select, TextInput, Tabs, Checkbox, Badge, Tooltip, Pagination, Title, Code, Card, SegmentedControl, Switch, NumberInput, ColorSwatch, Popover, ActionIcon, Anchor, CopyButton, Divider, Textarea } from '@mantine/core';
12
15
  import { IconAddressBook, IconColumns, IconHistory, IconAlertCircle, IconCurrencyDollar, IconChartBar, IconBriefcase, IconTrophy, IconSearch, IconTargetArrow, IconAlertTriangle, IconMessages, IconArrowLeft, IconFileText, IconInbox, IconUser, IconBolt, IconBuilding, IconSettings, IconRestore, IconInfoCircle, IconMailForward, IconPlus, IconArrowRight, IconNote, IconCheck, IconCopy } from '@tabler/icons-react';
@@ -1668,7 +1671,10 @@ function CrmSettingsPage() {
1668
1671
  {
1669
1672
  label: "Priority Enabled",
1670
1673
  checked: draft.enabled,
1671
- onChange: (event) => setDraft((current) => ({ ...current, enabled: event.currentTarget.checked }))
1674
+ onChange: (event) => {
1675
+ const enabled = event.currentTarget.checked;
1676
+ setDraft((current) => ({ ...current, enabled }));
1677
+ }
1672
1678
  }
1673
1679
  ) : null
1674
1680
  }
@@ -64,7 +64,16 @@ var APIClientError = class extends Error {
64
64
  requestId;
65
65
  fields;
66
66
  retryAfter;
67
- constructor(message, code, statusCode, requestId, fields, retryAfter) {
67
+ /**
68
+ * Structured detail payload carried on `APIErrorResponse.details`
69
+ * (`packages/core/src/platform/api/types.ts`). Deliberately typed as a
70
+ * general bag rather than narrowed to any one error family — CONFLICT
71
+ * linked-row counts, SERVICE_UNAVAILABLE readiness payloads, and future
72
+ * error shapes all flow through the same field. Use a shape-specific
73
+ * accessor (e.g. `getSystemReadinessServerErrorDetails`) to narrow it.
74
+ */
75
+ details;
76
+ constructor(message, code, statusCode, requestId, fields, retryAfter, details) {
68
77
  super(message);
69
78
  this.name = "APIClientError";
70
79
  this.code = code;
@@ -72,11 +81,21 @@ var APIClientError = class extends Error {
72
81
  this.requestId = requestId;
73
82
  this.fields = fields;
74
83
  this.retryAfter = retryAfter;
84
+ this.details = details;
75
85
  }
76
86
  };
77
87
  function isAPIClientError(error) {
78
88
  return error instanceof APIClientError;
79
89
  }
90
+ function isSystemReadinessErrorDetails(details) {
91
+ if (!details || typeof details !== "object") return false;
92
+ const candidate = details;
93
+ return typeof candidate.systemPath === "string" && typeof candidate.interfaceKey === "string" && typeof candidate.readinessCode === "string" && Array.isArray(candidate.issues);
94
+ }
95
+ function getSystemReadinessServerErrorDetails(error) {
96
+ if (!isAPIClientError(error)) return void 0;
97
+ return isSystemReadinessErrorDetails(error.details) ? error.details : void 0;
98
+ }
80
99
  function getErrorInfo(error) {
81
100
  if (isAPIClientError(error)) {
82
101
  return {
@@ -862,7 +881,19 @@ function resolveReadinessInterfaceMarker(model, systemPath, interfaceKey) {
862
881
 
863
882
  // ../core/src/organization-model/domains/systems.ts
864
883
  var SystemKindSchema = z.enum(["product", "operational", "platform", "diagnostic"]).meta({ label: "System kind", color: "blue" });
865
- var SystemLifecycleSchema = z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" });
884
+ var SystemLifecycleSchema = z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({
885
+ label: "Lifecycle",
886
+ color: "teal"
887
+ });
888
+ function systemLifecycleAllowsAccess(lifecycle, ctx) {
889
+ if (lifecycle === "active") return true;
890
+ if (lifecycle === "beta") return ctx.betaAccessEnabled === true || ctx.isDevelopment === true;
891
+ return false;
892
+ }
893
+ function isSystemLifecycleVisible(lifecycle, enabled) {
894
+ if (enabled === false) return false;
895
+ return lifecycle !== "draft" && lifecycle !== "deprecated" && lifecycle !== "archived";
896
+ }
866
897
  var SystemIdSchema = ModelIdSchema;
867
898
  var SystemPathSchema = z.string().trim().min(1).regex(
868
899
  /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/,
@@ -988,8 +1019,13 @@ var SystemEntrySchema = z.object({
988
1019
  parentSystemId: SystemIdSchema.optional(),
989
1020
  /** Optional UI presence. Systems without UI omit this. */
990
1021
  ui: SystemUiSchema.optional(),
991
- /** Canonical lifecycle state. `beta` is what gates a System to dev-mode viewers. */
992
- lifecycle: SystemLifecycleSchema.optional(),
1022
+ /**
1023
+ * Canonical lifecycle state. `beta` is what gates a System to dev-mode
1024
+ * viewers. Defaults to `active` (not `.optional()`) so an omitted field
1025
+ * never reaches a consumer as `undefined` -- see `isSystemLifecycleVisible`
1026
+ * and `systemLifecycleAllowsAccess` above.
1027
+ */
1028
+ lifecycle: SystemLifecycleSchema.default("active"),
993
1029
  /** Optional role responsible for this system. */
994
1030
  responsibleRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
995
1031
  /** Optional knowledge nodes that govern this system. */
@@ -1344,6 +1380,30 @@ function computeInterfaceReadiness(model, request) {
1344
1380
  };
1345
1381
  }
1346
1382
 
1383
+ // ../core/src/organization-model/readiness/remedies.ts
1384
+ var REDEPLOY_REMEDY = "Deploy the organization model again to fix this: elevasis-sdk deploy";
1385
+ var FAMILY_REMEDY = {
1386
+ SYSTEM_INTERFACE_MISSING: "The System does not declare this interface. Add an apiInterface block for it in the organization model, then deploy again.",
1387
+ SYSTEM_INTERFACE_DISABLED: "The interface is declared but not enabled. Set its lifecycle to enabled in the organization model, then deploy again.",
1388
+ SYSTEM_INTERFACE_INVALID: "The interface declaration did not validate. Fix the declaration named in the issues above, then deploy again.",
1389
+ SYSTEM_INTERFACE_NOT_READY: "The interface is declared and enabled but its readiness contract is unsatisfied. Resolve the issues above, then deploy again.",
1390
+ SYSTEM_BRIDGE_NOT_READY: "The bridge between two Systems is not ready. Resolve the issues above on both Systems, then deploy again.",
1391
+ STALE_OM_SNAPSHOT: REDEPLOY_REMEDY
1392
+ };
1393
+ var RESOLUTION_ISSUE_CODES = [
1394
+ "model-parse-failed",
1395
+ "stale-om-snapshot",
1396
+ "active-deployment-model-missing",
1397
+ "canonical-fallback-not-allowed"
1398
+ ];
1399
+ function isResolutionIssue(issue) {
1400
+ return RESOLUTION_ISSUE_CODES.includes(issue.code);
1401
+ }
1402
+ function resolveReadinessRemedy(issue) {
1403
+ if (isResolutionIssue(issue)) return REDEPLOY_REMEDY;
1404
+ return FAMILY_REMEDY[issue.family] ?? FAMILY_REMEDY.SYSTEM_INTERFACE_NOT_READY;
1405
+ }
1406
+
1347
1407
  // ../core/src/platform/registry/resource-metadata.ts
1348
1408
  var resourceTypeIconNames = {
1349
1409
  agent: "IconBrain",
@@ -1468,4 +1528,4 @@ function setupBrowserMocks() {
1468
1528
  setupResizeObserver();
1469
1529
  }
1470
1530
 
1471
- export { APIClientError, API_URL, ActionInvocationSchema, ActionSchema, ActionsDomainSchema, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DescriptionSchema, EntitiesDomainSchema, EntitySchema, GC_TIME_LONG, GC_TIME_MEDIUM, GC_TIME_SHORT, IconNameSchema, JsonValueSchema, LIMIT_ACTIVITY_FEED, LabelSchema, ModelIdSchema, NodeIdStringSchema, OAUTH_FLOW_TIMEOUT, OntologyIdSchema, OntologyScopeSchema, PAGE_SIZE_DEFAULT, PathSchema, STALE_TIME_ADMIN, STALE_TIME_DEFAULT, STALE_TIME_MONITORING, SYSTEM_INTERFACE_PROFILES, SystemEntrySchema, SystemIdSchema, SystemInterfaceRefSchema, SystemLifecycleSchema, SystemPathSchema, SystemsDomainSchema, addReadinessIssue, ancestorsOf, childrenOf, compileOrganizationOntology, computeInterfaceReadiness, defaultPathFor, devOnlyFor, findById, findByPath, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatInterfaceIdentity, formatOntologyId, formatRelativeTime, formatTimeAgo, getErrorInfo, getErrorTitle, getResourceColor, getResourceIcon, getResourcesForSystem, getSystem, getSystemAncestors, isAPIClientError, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, registerBuiltInReadinessProfile, registerReadinessInterfaceMarker, requireCatalogReadiness, requireContractReadiness, requireScopedBinding, resolveSystemConfig, resourceBindingIds, restoreConsole, setupBrowserMocks, suppressKnownWarnings, topLevel, validateEmail };
1531
+ export { APIClientError, API_URL, ActionInvocationSchema, ActionSchema, ActionsDomainSchema, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DescriptionSchema, EntitiesDomainSchema, EntitySchema, GC_TIME_LONG, GC_TIME_MEDIUM, GC_TIME_SHORT, IconNameSchema, JsonValueSchema, LIMIT_ACTIVITY_FEED, LabelSchema, ModelIdSchema, NodeIdStringSchema, OAUTH_FLOW_TIMEOUT, OntologyIdSchema, OntologyScopeSchema, PAGE_SIZE_DEFAULT, PathSchema, STALE_TIME_ADMIN, STALE_TIME_DEFAULT, STALE_TIME_MONITORING, SYSTEM_INTERFACE_PROFILES, SystemEntrySchema, SystemIdSchema, SystemInterfaceRefSchema, SystemLifecycleSchema, SystemPathSchema, SystemsDomainSchema, addReadinessIssue, ancestorsOf, childrenOf, compileOrganizationOntology, computeInterfaceReadiness, defaultPathFor, devOnlyFor, findById, findByPath, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatInterfaceIdentity, formatOntologyId, formatRelativeTime, formatTimeAgo, getErrorInfo, getErrorTitle, getResourceColor, getResourceIcon, getResourcesForSystem, getSystem, getSystemAncestors, getSystemReadinessServerErrorDetails, isAPIClientError, isSystemLifecycleVisible, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, registerBuiltInReadinessProfile, registerReadinessInterfaceMarker, requireCatalogReadiness, requireContractReadiness, requireScopedBinding, resolveReadinessRemedy, resolveSystemConfig, resourceBindingIds, restoreConsole, setupBrowserMocks, suppressKnownWarnings, systemLifecycleAllowsAccess, topLevel, validateEmail };
@@ -1,4 +1,4 @@
1
- import { NavigationButton, useAppearance, useElevasisSystems } from './chunk-OCVSPAKM.js';
1
+ import { NavigationButton, useAppearance, useElevasisSystems } from './chunk-SB3IHM5Y.js';
2
2
  import { sidebarItemGap, sidebarSubLinkPaddingY, sidebarSubLinkPaddingX, sidebarSubLinkIndent, sidebarHoverDelay, sidebarTransitionDuration, sidebarCollapsedWidth, sidebarWidth, topbarHeight, sidebarToggleIconSize, sidebarSectionPadding, sidebarGroupChevronSize, sidebarIconInnerSize, SubshellNavItem } from './chunk-MISHPEJX.js';
3
3
  import { useRouterContext } from './chunk-Q7DJKLEN.js';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -0,0 +1,69 @@
1
+ import { requestsKeys } from './chunk-SB3IHM5Y.js';
2
+ import { useElevasisServices } from './chunk-BI5VDO2K.js';
3
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
4
+
5
+ function useRequestsList(filters = {}) {
6
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
7
+ return useQuery({
8
+ queryKey: requestsKeys.list(workOSOrganizationId ?? void 0, filters),
9
+ queryFn: async () => {
10
+ const { type, severity, status, source, limit, offset } = filters;
11
+ const params = new URLSearchParams();
12
+ if (type) params.set("type", type);
13
+ if (severity) params.set("severity", severity);
14
+ if (status) params.set("status", status);
15
+ if (source) params.set("source", source);
16
+ if (limit !== void 0) params.set("limit", String(limit));
17
+ if (offset !== void 0) params.set("offset", String(offset));
18
+ const query = params.toString();
19
+ const { requests } = await apiRequest(`/requests${query ? "?" + query : ""}`);
20
+ return requests;
21
+ },
22
+ enabled: isReady
23
+ });
24
+ }
25
+ function useRequest(id) {
26
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
27
+ return useQuery({
28
+ queryKey: requestsKeys.detail(workOSOrganizationId ?? void 0, id),
29
+ queryFn: async () => {
30
+ const { request } = await apiRequest(`/requests/${id}`);
31
+ return request;
32
+ },
33
+ enabled: isReady && !!id
34
+ });
35
+ }
36
+ function useUpdateRequestStatus() {
37
+ const { apiRequest, workOSOrganizationId } = useElevasisServices();
38
+ const queryClient = useQueryClient();
39
+ return useMutation({
40
+ mutationFn: async ({ id, status }) => {
41
+ const { request } = await apiRequest(`/requests/${id}`, {
42
+ method: "PATCH",
43
+ body: JSON.stringify({ status })
44
+ });
45
+ return request;
46
+ },
47
+ onSuccess: (_data, { id }) => {
48
+ queryClient.invalidateQueries({ queryKey: requestsKeys.lists() });
49
+ queryClient.invalidateQueries({
50
+ queryKey: requestsKeys.detail(workOSOrganizationId ?? void 0, id)
51
+ });
52
+ }
53
+ });
54
+ }
55
+ function useDeleteRequest() {
56
+ const { apiRequest } = useElevasisServices();
57
+ const queryClient = useQueryClient();
58
+ return useMutation({
59
+ mutationFn: async (id) => {
60
+ await apiRequest(`/requests/${id}`, { method: "DELETE" });
61
+ return id;
62
+ },
63
+ onSuccess: () => {
64
+ queryClient.invalidateQueries({ queryKey: requestsKeys.lists() });
65
+ }
66
+ });
67
+ }
68
+
69
+ export { useDeleteRequest, useRequest, useRequestsList, useUpdateRequestStatus };
@@ -0,0 +1,305 @@
1
+ import { GetNotificationsQuerySchema, MarkAsReadParamsSchema } from './chunk-VM2OWOXL.js';
2
+ import { useNotificationAdapter } from './chunk-SB3IHM5Y.js';
3
+ import { getTimeRangeDates } from './chunk-Y6I3IC45.js';
4
+ import { useElevasisServices } from './chunk-BI5VDO2K.js';
5
+ import { useCallback, useState } from 'react';
6
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
7
+
8
+ function useErrorNotification() {
9
+ const adapter = useNotificationAdapter();
10
+ return useCallback(
11
+ (error) => {
12
+ adapter.apiError(error);
13
+ },
14
+ [adapter]
15
+ );
16
+ }
17
+ function useActivityTrend(params = {}) {
18
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
19
+ return useQuery({
20
+ queryKey: ["activities", "trend", workOSOrganizationId, params],
21
+ queryFn: async () => {
22
+ const queryParams = new URLSearchParams();
23
+ if (params.activityType) queryParams.set("activityType", params.activityType);
24
+ if (params.entityType) queryParams.set("entityType", params.entityType);
25
+ if (params.entityId) queryParams.set("entityId", params.entityId);
26
+ if (params.startDate) queryParams.set("startDate", params.startDate);
27
+ if (params.endDate) queryParams.set("endDate", params.endDate);
28
+ const queryString = queryParams.toString();
29
+ const endpoint = `/activities/trend${queryString ? `?${queryString}` : ""}`;
30
+ const response = await apiRequest(endpoint);
31
+ return {
32
+ timestamps: response.timestamps.map((t) => new Date(t)),
33
+ total: response.total
34
+ };
35
+ },
36
+ enabled: isReady,
37
+ refetchInterval: 3e4,
38
+ staleTime: 0
39
+ });
40
+ }
41
+ function useActivities(params = {}) {
42
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
43
+ return useQuery({
44
+ queryKey: ["activities", "list", workOSOrganizationId, params],
45
+ queryFn: async () => {
46
+ const queryParams = new URLSearchParams();
47
+ if (params.limit) queryParams.set("limit", params.limit.toString());
48
+ if (params.offset) queryParams.set("offset", params.offset.toString());
49
+ if (params.activityType) queryParams.set("activityType", params.activityType);
50
+ if (params.entityType) queryParams.set("entityType", params.entityType);
51
+ if (params.entityId) queryParams.set("entityId", params.entityId);
52
+ if (params.startDate) queryParams.set("startDate", params.startDate);
53
+ if (params.endDate) queryParams.set("endDate", params.endDate);
54
+ if (params.status && params.status !== "all") queryParams.set("status", params.status);
55
+ if (params.search && params.search.trim()) queryParams.set("search", params.search.trim());
56
+ const queryString = queryParams.toString();
57
+ const endpoint = `/activities${queryString ? `?${queryString}` : ""}`;
58
+ const response = await apiRequest(endpoint);
59
+ return {
60
+ activities: response.activities.map((activity) => ({
61
+ ...activity,
62
+ occurredAt: new Date(activity.occurredAt),
63
+ createdAt: new Date(activity.createdAt)
64
+ })),
65
+ total: response.total
66
+ };
67
+ },
68
+ enabled: isReady,
69
+ refetchInterval: 3e4,
70
+ // 30s real-time polling
71
+ staleTime: 0
72
+ // Real-time data - always refetch on mount/org switch
73
+ });
74
+ }
75
+ function useExecutionLogs(params = {}) {
76
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
77
+ return useQuery({
78
+ queryKey: ["monitoring", "execution-logs", workOSOrganizationId, params],
79
+ queryFn: async () => {
80
+ const queryParams = new URLSearchParams();
81
+ if (params.resourceId) queryParams.set("resourceId", params.resourceId);
82
+ if (params.status && params.status !== "all") queryParams.set("status", params.status);
83
+ if (params.resourceStatus && params.resourceStatus !== "all")
84
+ queryParams.set("resourceStatus", params.resourceStatus);
85
+ if (params.startDate !== void 0) queryParams.set("startDate", params.startDate.toString());
86
+ if (params.endDate !== void 0) queryParams.set("endDate", params.endDate.toString());
87
+ if (params.limit !== void 0) queryParams.set("limit", params.limit.toString());
88
+ if (params.offset !== void 0) queryParams.set("offset", params.offset.toString());
89
+ const queryString = queryParams.toString();
90
+ const endpoint = `/execution-engine/executions${queryString ? `?${queryString}` : ""}`;
91
+ return apiRequest(endpoint);
92
+ },
93
+ enabled: isReady,
94
+ refetchInterval: 3e4,
95
+ // 30s real-time polling
96
+ staleTime: 0
97
+ // Real-time data - always refetch on mount/org switch
98
+ });
99
+ }
100
+ function useNotifications({ limit = 20, offset = 0 } = {}) {
101
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
102
+ return useQuery({
103
+ queryKey: ["notifications", workOSOrganizationId, { limit, offset }],
104
+ queryFn: async () => {
105
+ const params = GetNotificationsQuerySchema.parse({ limit, offset });
106
+ const response = await apiRequest(
107
+ `/notifications?limit=${params.limit}&offset=${params.offset}`
108
+ );
109
+ return response;
110
+ },
111
+ enabled: isReady
112
+ });
113
+ }
114
+ function useCostSummary(timeRange) {
115
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
116
+ return useQuery({
117
+ queryKey: ["cost-analytics", "cost-summary", workOSOrganizationId, timeRange],
118
+ queryFn: async () => {
119
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
120
+ return apiRequest(`/observability/cost-summary?startDate=${startDate}&endDate=${endDate}`);
121
+ },
122
+ enabled: isReady,
123
+ refetchInterval: 6e4
124
+ // 60s dashboard polling
125
+ });
126
+ }
127
+ function useExecutionHealth({ timeRange }) {
128
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
129
+ return useQuery({
130
+ queryKey: ["monitoring", "execution-health", workOSOrganizationId, timeRange],
131
+ queryFn: async () => {
132
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
133
+ return apiRequest(`/observability/dashboard?startDate=${startDate}&endDate=${endDate}`);
134
+ },
135
+ enabled: isReady,
136
+ refetchInterval: 6e4,
137
+ // 60s dashboard polling
138
+ staleTime: 3e4
139
+ // 30s monitoring stale time
140
+ });
141
+ }
142
+ function useNotificationCount(args) {
143
+ const { notificationCount, notificationConnected, notificationError } = args;
144
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
145
+ const query = useQuery({
146
+ queryKey: ["notifications", "unread-count", workOSOrganizationId],
147
+ queryFn: async () => {
148
+ const response = await apiRequest("/notifications/unread-count");
149
+ return response.count;
150
+ },
151
+ enabled: isReady,
152
+ staleTime: Infinity
153
+ // SSE will keep it updated
154
+ });
155
+ return {
156
+ data: notificationCount !== null && notificationCount !== void 0 ? notificationCount : query.data,
157
+ isLoading: query.isLoading,
158
+ isError: query.isError,
159
+ error: query.error,
160
+ isSuccess: query.isSuccess,
161
+ status: query.status,
162
+ refetch: query.refetch,
163
+ sseConnected: notificationConnected,
164
+ sseError: notificationError
165
+ };
166
+ }
167
+ function useMarkAsRead() {
168
+ const queryClient = useQueryClient();
169
+ const { apiRequest } = useElevasisServices();
170
+ const notify = useNotificationAdapter();
171
+ return useMutation({
172
+ mutationFn: async (notificationId) => {
173
+ MarkAsReadParamsSchema.parse({ id: notificationId });
174
+ await apiRequest(`/notifications/${notificationId}/read`, {
175
+ method: "PATCH"
176
+ });
177
+ },
178
+ onSuccess: () => {
179
+ queryClient.invalidateQueries({ queryKey: ["notifications"] });
180
+ },
181
+ onError: (error) => {
182
+ notify.apiError(error);
183
+ }
184
+ });
185
+ }
186
+ function useMarkAllAsRead() {
187
+ const queryClient = useQueryClient();
188
+ const { apiRequest } = useElevasisServices();
189
+ const notify = useNotificationAdapter();
190
+ return useMutation({
191
+ mutationFn: async () => {
192
+ await apiRequest("/notifications/mark-all-read", {
193
+ method: "PATCH"
194
+ });
195
+ },
196
+ onSuccess: () => {
197
+ queryClient.invalidateQueries({ queryKey: ["notifications"] });
198
+ },
199
+ onError: (error) => {
200
+ notify.apiError(error);
201
+ }
202
+ });
203
+ }
204
+ function useSuccessNotification() {
205
+ const adapter = useNotificationAdapter();
206
+ return useCallback((title, message) => adapter.success(title, message), [adapter]);
207
+ }
208
+ function useWarningNotification() {
209
+ const adapter = useNotificationAdapter();
210
+ return useCallback((title, message) => adapter.warning(title, message), [adapter]);
211
+ }
212
+ function useBatchDelete(invalidateQueryKeys) {
213
+ const { apiRequest } = useElevasisServices();
214
+ const queryClient = useQueryClient();
215
+ const adapter = useNotificationAdapter();
216
+ return useMutation({
217
+ mutationFn: async (ids) => {
218
+ if (ids.length === 0) return;
219
+ const body = { ids };
220
+ await apiRequest("/notifications/batch", {
221
+ method: "DELETE",
222
+ body: JSON.stringify(body)
223
+ });
224
+ },
225
+ onSuccess: () => {
226
+ for (const key of invalidateQueryKeys) {
227
+ queryClient.invalidateQueries({ queryKey: key });
228
+ }
229
+ },
230
+ onError: (err) => {
231
+ adapter.apiError(err);
232
+ }
233
+ });
234
+ }
235
+ function useTestNotification() {
236
+ const queryClient = useQueryClient();
237
+ const { apiRequest } = useElevasisServices();
238
+ const adapter = useNotificationAdapter();
239
+ return useMutation({
240
+ mutationFn: async () => {
241
+ await apiRequest("/notifications/test", {
242
+ method: "POST"
243
+ });
244
+ },
245
+ onSuccess: () => {
246
+ queryClient.invalidateQueries({ queryKey: ["notifications"] });
247
+ },
248
+ onError: (error) => {
249
+ adapter.apiError(error);
250
+ }
251
+ });
252
+ }
253
+ function useActivityFilters(timeRange) {
254
+ const [filters, setFilters] = useState({
255
+ activityType: "all",
256
+ status: "all"
257
+ });
258
+ const updateFilter = useCallback((key, value) => {
259
+ setFilters((prev) => ({ ...prev, [key]: value }));
260
+ }, []);
261
+ const resetFilters = useCallback(() => {
262
+ setFilters({
263
+ activityType: "all",
264
+ status: "all"
265
+ });
266
+ }, []);
267
+ const getApiParams = useCallback(() => {
268
+ const params = {};
269
+ if (filters.activityType && filters.activityType !== "all") {
270
+ params.activityType = filters.activityType;
271
+ }
272
+ const { startDate } = getTimeRangeDates(timeRange);
273
+ params.startDate = startDate;
274
+ if (filters.status && filters.status !== "all") {
275
+ params.status = filters.status;
276
+ }
277
+ if (filters.search?.trim()) {
278
+ params.search = filters.search.trim();
279
+ }
280
+ return params;
281
+ }, [filters, timeRange]);
282
+ return {
283
+ filters,
284
+ updateFilter,
285
+ resetFilters,
286
+ getApiParams
287
+ };
288
+ }
289
+ var DEFAULT_FILTERS = {
290
+ resourceId: void 0,
291
+ status: "all",
292
+ resourceStatus: "all"
293
+ };
294
+ function useExecutionLogsFilters(_timeRange) {
295
+ const [filters, setFilters] = useState(DEFAULT_FILTERS);
296
+ const updateFilter = useCallback((key, value) => {
297
+ setFilters((prev) => ({ ...prev, [key]: value }));
298
+ }, []);
299
+ const resetFilters = useCallback(() => {
300
+ setFilters(DEFAULT_FILTERS);
301
+ }, []);
302
+ return { filters, updateFilter, resetFilters };
303
+ }
304
+
305
+ export { useActivities, useActivityFilters, useActivityTrend, useBatchDelete, useCostSummary, useErrorNotification, useExecutionHealth, useExecutionLogs, useExecutionLogsFilters, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications, useSuccessNotification, useTestNotification, useWarningNotification };