@terreno/admin-frontend 57.2.0 → 57.3.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 (115) hide show
  1. package/.ai/guidelines/core.md +10 -7
  2. package/README.md +2 -0
  3. package/dist/AdminScreenPage.d.ts +18 -0
  4. package/dist/AdminScreenPage.js +35 -0
  5. package/dist/AdminScreenPage.js.map +1 -0
  6. package/dist/AdminScreenRouter.js +4 -3
  7. package/dist/AdminScreenRouter.js.map +1 -1
  8. package/dist/DocumentStorageBrowser.js +4 -3
  9. package/dist/DocumentStorageBrowser.js.map +1 -1
  10. package/dist/comms/CommsDashboardScreen.d.ts +10 -0
  11. package/dist/comms/CommsDashboardScreen.js +183 -0
  12. package/dist/comms/CommsDashboardScreen.js.map +1 -0
  13. package/dist/comms/CommsDashboardScreenWidget.d.ts +4 -0
  14. package/dist/comms/CommsDashboardScreenWidget.js +11 -0
  15. package/dist/comms/CommsDashboardScreenWidget.js.map +1 -0
  16. package/dist/comms/CommsMessageDetail.d.ts +8 -0
  17. package/dist/comms/CommsMessageDetail.js +50 -0
  18. package/dist/comms/CommsMessageDetail.js.map +1 -0
  19. package/dist/comms/CommsStatCard.d.ts +17 -0
  20. package/dist/comms/CommsStatCard.js +14 -0
  21. package/dist/comms/CommsStatCard.js.map +1 -0
  22. package/dist/comms/CommsStatusBadge.d.ts +5 -0
  23. package/dist/comms/CommsStatusBadge.js +14 -0
  24. package/dist/comms/CommsStatusBadge.js.map +1 -0
  25. package/dist/comms/commsDashboardParams.d.ts +17 -0
  26. package/dist/comms/commsDashboardParams.js +71 -0
  27. package/dist/comms/commsDashboardParams.js.map +1 -0
  28. package/dist/comms/commsMessagePayload.d.ts +49 -0
  29. package/dist/comms/commsMessagePayload.js +43 -0
  30. package/dist/comms/commsMessagePayload.js.map +1 -0
  31. package/dist/comms/commsRetrySummary.d.ts +4 -0
  32. package/dist/comms/commsRetrySummary.js +12 -0
  33. package/dist/comms/commsRetrySummary.js.map +1 -0
  34. package/dist/comms/useCommsDashboardApi.d.ts +78 -0
  35. package/dist/comms/useCommsDashboardApi.js +60 -0
  36. package/dist/comms/useCommsDashboardApi.js.map +1 -0
  37. package/dist/comms/useCommsDashboardUrlFilters.d.ts +5 -0
  38. package/dist/comms/useCommsDashboardUrlFilters.js +16 -0
  39. package/dist/comms/useCommsDashboardUrlFilters.js.map +1 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.js +7 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/types.d.ts +2 -0
  44. package/dist/useAdminBackgroundTask.d.ts +10 -2
  45. package/dist/useAdminBackgroundTask.js.map +1 -1
  46. package/dist/useConfigurationApi.d.ts +13 -15
  47. package/dist/useConfigurationApi.js.map +1 -1
  48. package/dist/widgets/AIRequestsScreenWidget.js +4 -3
  49. package/dist/widgets/AIRequestsScreenWidget.js.map +1 -1
  50. package/dist/widgets/DocumentsScreenWidget.js +2 -2
  51. package/dist/widgets/DocumentsScreenWidget.js.map +1 -1
  52. package/dist/widgets/builtInWidgets.js +2 -1
  53. package/dist/widgets/builtInWidgets.js.map +1 -1
  54. package/package.json +17 -3
  55. package/src/AdminActionMenu.test.tsx +1 -1
  56. package/src/AdminBreadcrumbs.test.tsx +1 -1
  57. package/src/AdminFieldRenderer.test.tsx +6 -1
  58. package/src/AdminHome.test.tsx +1 -1
  59. package/src/AdminModelForm.test.tsx +1 -1
  60. package/src/AdminModelList.test.tsx +1 -1
  61. package/src/AdminModelTable.test.tsx +1 -1
  62. package/src/AdminPrimitiveArrayField.test.tsx +1 -1
  63. package/src/AdminRolesList.test.tsx +1 -1
  64. package/src/AdminScreenPage.test.tsx +81 -0
  65. package/src/AdminScreenPage.tsx +37 -0
  66. package/src/AdminScreenRouter.test.tsx +2 -1
  67. package/src/AdminScreenRouter.tsx +18 -5
  68. package/src/AdminScriptList.test.tsx +1 -1
  69. package/src/AdminShell.test.tsx +1 -1
  70. package/src/AdminVersionConfig.test.tsx +1 -1
  71. package/src/CheckboxListEditor.test.tsx +1 -1
  72. package/src/ConfigurationScreen.test.tsx +1 -1
  73. package/src/ConsentFormEditor.test.tsx +1 -1
  74. package/src/ConsentFormList.test.tsx +1 -1
  75. package/src/ConsentHistory.test.tsx +1 -1
  76. package/src/ConsentResponseViewer.test.tsx +1 -1
  77. package/src/DocumentStorageBrowser.test.tsx +1 -1
  78. package/src/DocumentStorageBrowser.tsx +10 -3
  79. package/src/LocaleContentEditor.test.tsx +1 -1
  80. package/src/adminModelListQueryParams.test.ts +59 -0
  81. package/src/comms/CommsDashboardScreen.test.tsx +397 -0
  82. package/src/comms/CommsDashboardScreen.tsx +500 -0
  83. package/src/comms/CommsDashboardScreenWidget.test.tsx +62 -0
  84. package/src/comms/CommsDashboardScreenWidget.tsx +20 -0
  85. package/src/comms/CommsMessageDetail.test.tsx +245 -0
  86. package/src/comms/CommsMessageDetail.tsx +239 -0
  87. package/src/comms/CommsStatCard.test.tsx +69 -0
  88. package/src/comms/CommsStatCard.tsx +60 -0
  89. package/src/comms/CommsStatusBadge.tsx +14 -0
  90. package/src/comms/commsDashboardParams.test.ts +75 -0
  91. package/src/comms/commsDashboardParams.ts +91 -0
  92. package/src/comms/commsMessagePayload.test.ts +22 -0
  93. package/src/comms/commsMessagePayload.ts +83 -0
  94. package/src/comms/commsRetrySummary.ts +10 -0
  95. package/src/comms/useCommsDashboardApi.test.tsx +144 -0
  96. package/src/comms/useCommsDashboardApi.tsx +128 -0
  97. package/src/comms/useCommsDashboardUrlFilters.test.tsx +58 -0
  98. package/src/comms/useCommsDashboardUrlFilters.tsx +31 -0
  99. package/src/dynamicHookApi.ts +1 -1
  100. package/src/index.tsx +14 -0
  101. package/src/isolated/AdminFieldRenderer.isolated.tsx +1 -1
  102. package/src/{AdminFilterDrawer.test.tsx → isolated/AdminFilterDrawer.isolated.tsx} +8 -2
  103. package/src/isolated/AdminNestedArrayField.isolated.tsx +1 -1
  104. package/src/isolated/AdminObjectPicker.isolated.tsx +1 -1
  105. package/src/isolated/AdminRefField.isolated.tsx +1 -1
  106. package/src/isolated/AdminScriptRunModal.isolated.tsx +1 -1
  107. package/src/isolated/DocumentStorageBrowser.isolated.tsx +1 -1
  108. package/src/isolated/hooks.isolated.tsx +1 -1
  109. package/src/types.ts +2 -0
  110. package/src/useAdminBackgroundTask.ts +7 -5
  111. package/src/useConfigurationApi.ts +13 -16
  112. package/src/widgets/AIRequestsScreenWidget.tsx +5 -4
  113. package/src/widgets/DocumentsScreenWidget.tsx +9 -2
  114. package/src/widgets/builtInWidgets.ts +2 -0
  115. package/src/widgets/pluginWidgets.test.tsx +3 -1
@@ -1,9 +1,9 @@
1
1
  // noExplicitAny: test mocks use type-erased UI component stubs and field config literals
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import {fireEvent} from "@testing-library/react-native";
6
5
  import React from "react";
6
+ import {renderWithTheme} from "../../../ui/src/test-utils";
7
7
 
8
8
  mock.module("../AdminNestedArrayField", () => ({
9
9
  AdminNestedArrayField: ({title}: {title: string}) =>
@@ -1,9 +1,15 @@
1
+ // noExplicitAny: test mock typing
1
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
+ /**
4
+ * Isolated because the whole `react-native` module is replaced below. `mock.module` is
5
+ * process-wide and permanent, so running this alongside other files leaves every later
6
+ * suite on `Platform.OS === "web"`, where `@terreno/ui` `Modal` reaches for `document`.
7
+ */
2
8
  import {beforeEach, describe, expect, it, mock} from "bun:test";
3
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
4
9
  import {act, fireEvent} from "@testing-library/react-native";
5
10
  import React from "react";
6
- import {AdminFilterDrawer} from "./AdminFilterDrawer";
11
+ import {renderWithTheme} from "../../../ui/src/test-utils";
12
+ import {AdminFilterDrawer} from "../AdminFilterDrawer";
7
13
 
8
14
  let mockWindowWidth = 1200;
9
15
 
@@ -1,10 +1,10 @@
1
1
  // noExplicitAny: test mocks use type-erased UI component stubs and mock field renderers
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import {fireEvent} from "@testing-library/react-native";
6
5
  import React from "react";
7
6
  import type {ReactTestInstance} from "react-test-renderer";
7
+ import {renderWithTheme} from "../../../ui/src/test-utils";
8
8
  import type {AdminApi, AdminFieldConfig} from "../types";
9
9
 
10
10
  mock.module("../AdminFieldRendererCore", () => ({
@@ -1,9 +1,9 @@
1
1
  // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic endpoint injection
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import {act, fireEvent} from "@testing-library/react-native";
6
5
  import React from "react";
6
+ import {renderWithTheme} from "../../../ui/src/test-utils";
7
7
  import {AdminObjectPicker as BaseAdminObjectPicker} from "../AdminObjectPicker";
8
8
  import type {AdminApi} from "../types";
9
9
 
@@ -1,8 +1,8 @@
1
1
  // noExplicitAny: test mocks use type-erased RTK Query API doubles
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import React from "react";
5
+ import {renderWithTheme} from "../../../ui/src/test-utils";
6
6
 
7
7
  mock.module("../AdminObjectPicker", () => ({
8
8
  AdminObjectPicker: ({title, refModelName}: {title: string; refModelName: string}) =>
@@ -1,10 +1,10 @@
1
1
  // noExplicitAny: test mocks use type-erased RTK Query API doubles and UNSAFE_root traversal
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import {act, fireEvent} from "@testing-library/react-native";
6
5
  import React from "react";
7
6
  import type {ReactTestInstance} from "react-test-renderer";
7
+ import {renderWithTheme} from "../../../ui/src/test-utils";
8
8
  import type {AdminApi} from "../types";
9
9
 
10
10
  // Mock @terreno/ui so the Modal renders its children inline. The real Modal
@@ -1,11 +1,11 @@
1
1
  // noExplicitAny: test mocks use type-erased RTK Query API doubles and UNSAFE_root traversal
2
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
4
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
5
4
  import {act, fireEvent} from "@testing-library/react-native";
6
5
  import React from "react";
7
6
  import {Platform} from "react-native";
8
7
  import type {ReactTestInstance} from "react-test-renderer";
8
+ import {renderWithTheme} from "../../../ui/src/test-utils";
9
9
  import type {AdminApi} from "../types";
10
10
 
11
11
  mock.module("react-native-webview", () => ({
@@ -10,8 +10,8 @@
10
10
  * - the returned hook functions correspond to the generated hook names
11
11
  */
12
12
  import {describe, expect, it, mock} from "bun:test";
13
- import {renderWithTheme} from "@terreno/ui/src/test-utils";
14
13
  import React from "react";
14
+ import {renderWithTheme} from "../../../ui/src/test-utils";
15
15
  import {useAdminApi} from "../useAdminApi";
16
16
  import {useAdminConfig} from "../useAdminConfig";
17
17
  import {useAdminScripts} from "../useAdminScripts";
package/src/types.ts CHANGED
@@ -362,6 +362,8 @@ export interface DocumentListResponse {
362
362
  export interface DocumentStorageBrowserProps {
363
363
  api: AdminApi;
364
364
  basePath: string;
365
+ /** Route opened by the standard admin screen back arrow. */
366
+ backHref?: string;
365
367
  title?: string;
366
368
  allowDelete?: boolean;
367
369
  allowUpload?: boolean;
@@ -10,16 +10,18 @@ export interface AdminBackgroundTaskBody {
10
10
  resourceRoute?: string;
11
11
  }
12
12
 
13
+ type AdminBackgroundTaskMutation = readonly [
14
+ (body: AdminBackgroundTaskBody) => {unwrap: () => Promise<unknown>},
15
+ {isLoading: boolean},
16
+ ];
17
+
13
18
  /**
14
19
  * RTK Query mutation hook for `POST {adminApiRoot}/background-tasks` (admin enqueue).
15
20
  */
16
21
  export const useAdminBackgroundTaskMutation = (
17
22
  api: AdminApi,
18
23
  adminApiRoot: string
19
- ): ReturnType<// noExplicitAny: RTK mutation type from dynamic injectEndpoints
20
- // noExplicitAny: dynamic hook lookup on RTK Query enhanced API
21
- // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
22
- any> => {
24
+ ): AdminBackgroundTaskMutation => {
23
25
  const enhancedApi = useMemo(() => {
24
26
  const root = adminApiRoot.replace(/\/$/, "");
25
27
  return api.enhanceEndpoints({addTagTypes: ["AdminBackgroundTask"]}).injectEndpoints({
@@ -38,5 +40,5 @@ any> => {
38
40
  }, [api, adminApiRoot]);
39
41
 
40
42
  const enhanced = asDynamicHookApi(enhancedApi);
41
- return enhanced.useAdminPostBackgroundTaskMutation();
43
+ return enhanced.useAdminPostBackgroundTaskMutation() as AdminBackgroundTaskMutation;
42
44
  };
@@ -4,18 +4,15 @@ import type {AdminApi, EndpointBuilder} from "./types";
4
4
 
5
5
  // The configuration document shape varies per consumer — different apps register different
6
6
  // configuration sections via @terreno/api's Configuration model.
7
- // noExplicitAny: configuration values are heterogeneous per consumer
8
- // biome-ignore lint/suspicious/noExplicitAny: configuration values are heterogeneous per consumer
9
- type ConfigBody = any;
10
- // noExplicitAny: RTK Query's hook return shape varies per endpoint
11
- // biome-ignore lint/suspicious/noExplicitAny: RTK Query's hook return shape varies per endpoint
12
- type RtkHookResult = any;
13
- // noExplicitAny: RTK Query's mutation trigger has a complex generic shape
14
- // biome-ignore lint/suspicious/noExplicitAny: RTK Query's mutation trigger has a complex generic shape
15
- type RtkMutationTrigger = any;
16
- // noExplicitAny: RTK Query's error union type erases at the hook boundary
17
- // biome-ignore lint/suspicious/noExplicitAny: RTK Query's error union type erases at the hook boundary
18
- type RtkError = any;
7
+ type ConfigBody = Record<string, unknown>;
8
+
9
+ interface RtkQueryHookResult {
10
+ data?: unknown;
11
+ error?: unknown;
12
+ isLoading: boolean;
13
+ }
14
+
15
+ type RtkMutationTrigger = (body: ConfigBody) => {unwrap: () => Promise<unknown>};
19
16
 
20
17
  interface UseConfigurationApiOptions {
21
18
  api: AdminApi;
@@ -23,10 +20,10 @@ interface UseConfigurationApiOptions {
23
20
  }
24
21
 
25
22
  interface UseConfigurationApiResult {
26
- useMetaQuery: () => {data: RtkHookResult; isLoading: boolean; error: RtkError};
27
- useRefreshSecretsMutation: () => [RtkMutationTrigger, {isLoading: boolean}];
28
- useUpdateMutation: () => [RtkMutationTrigger, {isLoading: boolean}];
29
- useValuesQuery: () => {data: RtkHookResult; isLoading: boolean; error: RtkError};
23
+ useMetaQuery: () => RtkQueryHookResult;
24
+ useRefreshSecretsMutation: () => readonly [RtkMutationTrigger, {isLoading: boolean}];
25
+ useUpdateMutation: () => readonly [RtkMutationTrigger, {isLoading: boolean}];
26
+ useValuesQuery: () => RtkQueryHookResult;
30
27
  }
31
28
 
32
29
  /**
@@ -1,5 +1,6 @@
1
- import {AIRequestExplorer, type AIRequestExplorerData, Page} from "@terreno/ui";
1
+ import {AIRequestExplorer, type AIRequestExplorerData} from "@terreno/ui";
2
2
  import React, {useCallback, useMemo, useState} from "react";
3
+ import {AdminScreenPage} from "../AdminScreenPage";
3
4
  import {asDynamicHookApi} from "../dynamicHookApi";
4
5
  import type {AdminScreenWidgetProps, EndpointBuilder, ScreenWidgetComponent} from "../types";
5
6
 
@@ -14,7 +15,7 @@ interface AIRequestsResponse {
14
15
  total: number;
15
16
  }
16
17
 
17
- export const AIRequestsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api}) => {
18
+ export const AIRequestsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api, routeBase}) => {
18
19
  const [page, setPage] = useState(1);
19
20
  const [requestTypeFilter, setRequestTypeFilter] = useState<string[]>([]);
20
21
  const [startDate, setStartDate] = useState("");
@@ -68,7 +69,7 @@ export const AIRequestsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api})
68
69
  const total = data?.total ?? 0;
69
70
 
70
71
  return (
71
- <Page maxWidth="100%" scroll title="AI Request Explorer">
72
+ <AdminScreenPage backHref={routeBase} maxWidth="100%" scroll title="AI Request Explorer">
72
73
  <AIRequestExplorer
73
74
  data={data?.data ?? []}
74
75
  endDate={endDate}
@@ -84,7 +85,7 @@ export const AIRequestsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api})
84
85
  totalCount={total}
85
86
  totalPages={Math.ceil(total / EXPLORER_LIMIT)}
86
87
  />
87
- </Page>
88
+ </AdminScreenPage>
88
89
  );
89
90
  };
90
91
 
@@ -2,8 +2,15 @@ import React from "react";
2
2
  import {DocumentStorageBrowser} from "../DocumentStorageBrowser";
3
3
  import type {AdminScreenWidgetProps, ScreenWidgetComponent} from "../types";
4
4
 
5
- export const DocumentsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api}) => {
6
- return <DocumentStorageBrowser api={api} basePath="/documents" title="Documents" />;
5
+ export const DocumentsScreenWidget: React.FC<AdminScreenWidgetProps> = ({api, routeBase}) => {
6
+ return (
7
+ <DocumentStorageBrowser
8
+ api={api}
9
+ backHref={routeBase}
10
+ basePath="/documents"
11
+ title="Documents"
12
+ />
13
+ );
7
14
  };
8
15
 
9
16
  export const DOCUMENT_STORAGE_ADMIN_WIDGETS: Record<string, ScreenWidgetComponent> = {
@@ -1,3 +1,4 @@
1
+ import {COMMS_ADMIN_WIDGETS} from "../comms/CommsDashboardScreenWidget";
1
2
  import type {
2
3
  AdminWidgetRegistry,
3
4
  FieldWidgetComponent,
@@ -26,6 +27,7 @@ export const BUILT_IN_HOME_WIDGETS: Record<string, HomeWidgetComponent> = {
26
27
 
27
28
  export const BUILT_IN_SCREEN_WIDGETS: Record<string, ScreenWidgetComponent> = {
28
29
  ...AI_ADMIN_WIDGETS,
30
+ ...COMMS_ADMIN_WIDGETS,
29
31
  ...DOCUMENT_STORAGE_ADMIN_WIDGETS,
30
32
  "version-config": VersionConfigScreenWidget,
31
33
  };
@@ -1,4 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
+ import {COMMS_ADMIN_WIDGETS} from "../comms/CommsDashboardScreenWidget";
2
3
  import {AI_ADMIN_WIDGETS} from "./AIRequestsScreenWidget";
3
4
  import {CONSENT_ADMIN_WIDGETS} from "./consentWidgets";
4
5
  import {DOCUMENT_STORAGE_ADMIN_WIDGETS} from "./DocumentsScreenWidget";
@@ -22,8 +23,9 @@ describe("plugin admin widget registries", () => {
22
23
  ]);
23
24
  });
24
25
 
25
- it("exports documents and AI request screen widgets by custom screen name", () => {
26
+ it("exports documents, AI request, and comms screen widgets by custom screen name", () => {
26
27
  expect(DOCUMENT_STORAGE_ADMIN_WIDGETS.documents).toBeDefined();
27
28
  expect(AI_ADMIN_WIDGETS["ai-requests"]).toBeDefined();
29
+ expect(COMMS_ADMIN_WIDGETS.comms).toBeDefined();
28
30
  });
29
31
  });