@terreno/admin-frontend 0.13.3 → 0.14.1

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 (101) hide show
  1. package/dist/AdminFieldRenderer.d.ts +5 -53
  2. package/dist/AdminFieldRenderer.js +6 -168
  3. package/dist/AdminFieldRenderer.js.map +1 -1
  4. package/dist/AdminFieldRendererCore.d.ts +26 -0
  5. package/dist/AdminFieldRendererCore.js +138 -0
  6. package/dist/AdminFieldRendererCore.js.map +1 -0
  7. package/dist/AdminModelForm.d.ts +6 -7
  8. package/dist/AdminModelForm.js.map +1 -1
  9. package/dist/AdminModelList.d.ts +2 -3
  10. package/dist/AdminModelList.js.map +1 -1
  11. package/dist/AdminModelTable.d.ts +2 -2
  12. package/dist/AdminModelTable.js +2 -1
  13. package/dist/AdminModelTable.js.map +1 -1
  14. package/dist/AdminNestedArrayField.d.ts +6 -7
  15. package/dist/AdminNestedArrayField.js +26 -2
  16. package/dist/AdminNestedArrayField.js.map +1 -1
  17. package/dist/AdminObjectPicker.d.ts +2 -2
  18. package/dist/AdminObjectPicker.js +13 -7
  19. package/dist/AdminObjectPicker.js.map +1 -1
  20. package/dist/AdminPrimitiveArrayField.d.ts +2 -3
  21. package/dist/AdminPrimitiveArrayField.js.map +1 -1
  22. package/dist/AdminScriptList.d.ts +2 -2
  23. package/dist/AdminScriptList.js.map +1 -1
  24. package/dist/AdminScriptRunModal.d.ts +2 -2
  25. package/dist/AdminScriptRunModal.js.map +1 -1
  26. package/dist/AdminVersionConfig.d.ts +2 -2
  27. package/dist/AdminVersionConfig.js +16 -10
  28. package/dist/AdminVersionConfig.js.map +1 -1
  29. package/dist/ConfigurationScreen.d.ts +2 -2
  30. package/dist/ConfigurationScreen.js +18 -9
  31. package/dist/ConfigurationScreen.js.map +1 -1
  32. package/dist/ConsentFormEditor.d.ts +27 -2
  33. package/dist/ConsentFormEditor.js +48 -32
  34. package/dist/ConsentFormEditor.js.map +1 -1
  35. package/dist/ConsentFormList.d.ts +2 -1
  36. package/dist/ConsentFormList.js.map +1 -1
  37. package/dist/ConsentResponseViewer.d.ts +2 -1
  38. package/dist/ConsentResponseViewer.js.map +1 -1
  39. package/dist/DocumentStorageBrowser.js.map +1 -1
  40. package/dist/types.d.ts +29 -4
  41. package/dist/types.js.map +1 -1
  42. package/dist/useAdminApi.d.ts +2 -2
  43. package/dist/useAdminApi.js +8 -5
  44. package/dist/useAdminApi.js.map +1 -1
  45. package/dist/useAdminConfig.d.ts +2 -3
  46. package/dist/useAdminConfig.js +2 -0
  47. package/dist/useAdminConfig.js.map +1 -1
  48. package/dist/useAdminScripts.d.ts +2 -3
  49. package/dist/useAdminScripts.js +6 -3
  50. package/dist/useAdminScripts.js.map +1 -1
  51. package/dist/useConfigurationApi.d.ts +11 -8
  52. package/dist/useConfigurationApi.js +7 -4
  53. package/dist/useConfigurationApi.js.map +1 -1
  54. package/dist/useDocumentStorageApi.d.ts +2 -2
  55. package/dist/useDocumentStorageApi.js +9 -6
  56. package/dist/useDocumentStorageApi.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/AdminFieldRenderer.test.tsx +48 -22
  59. package/src/AdminFieldRenderer.tsx +18 -371
  60. package/src/AdminFieldRendererCore.tsx +356 -0
  61. package/src/AdminModelForm.test.tsx +146 -40
  62. package/src/AdminModelForm.tsx +22 -17
  63. package/src/AdminModelList.test.tsx +14 -5
  64. package/src/AdminModelList.tsx +5 -5
  65. package/src/AdminModelTable.test.tsx +58 -31
  66. package/src/AdminModelTable.tsx +11 -10
  67. package/src/AdminNestedArrayField.tsx +91 -26
  68. package/src/AdminObjectPicker.tsx +33 -16
  69. package/src/AdminPrimitiveArrayField.test.tsx +14 -10
  70. package/src/AdminPrimitiveArrayField.tsx +2 -3
  71. package/src/AdminScriptList.test.tsx +7 -4
  72. package/src/AdminScriptList.tsx +2 -3
  73. package/src/AdminScriptRunModal.test.tsx +5 -2
  74. package/src/AdminScriptRunModal.tsx +2 -3
  75. package/src/AdminVersionConfig.test.tsx +47 -21
  76. package/src/AdminVersionConfig.tsx +29 -5
  77. package/src/CheckboxListEditor.test.tsx +9 -6
  78. package/src/ConfigurationScreen.test.tsx +16 -11
  79. package/src/ConfigurationScreen.tsx +43 -29
  80. package/src/ConsentFormEditor.test.tsx +95 -75
  81. package/src/ConsentFormEditor.tsx +76 -49
  82. package/src/ConsentFormList.test.tsx +28 -10
  83. package/src/ConsentFormList.tsx +14 -2
  84. package/src/ConsentResponseViewer.test.tsx +15 -12
  85. package/src/ConsentResponseViewer.tsx +3 -2
  86. package/src/DocumentStorageBrowser.test.tsx +69 -42
  87. package/src/DocumentStorageBrowser.tsx +4 -4
  88. package/src/LocaleContentEditor.test.tsx +28 -18
  89. package/src/isolated/AdminFieldRenderer.isolated.tsx +5 -2
  90. package/src/isolated/AdminNestedArrayField.isolated.tsx +49 -36
  91. package/src/isolated/AdminObjectPicker.isolated.tsx +31 -26
  92. package/src/isolated/AdminRefField.isolated.tsx +4 -1
  93. package/src/isolated/AdminScriptRunModal.isolated.tsx +24 -17
  94. package/src/isolated/DocumentStorageBrowser.isolated.tsx +80 -63
  95. package/src/isolated/hooks.isolated.tsx +40 -33
  96. package/src/types.ts +34 -4
  97. package/src/useAdminApi.ts +21 -13
  98. package/src/useAdminConfig.ts +5 -4
  99. package/src/useAdminScripts.ts +9 -7
  100. package/src/useConfigurationApi.ts +26 -12
  101. package/src/useDocumentStorageApi.ts +12 -9
@@ -1,4 +1,3 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {
3
2
  BooleanField,
4
3
  Box,
@@ -12,7 +11,7 @@ import {
12
11
  import startCase from "lodash/startCase";
13
12
  import React, {useCallback} from "react";
14
13
  import {AdminRefField} from "./AdminRefField";
15
- import type {RefRendererMap} from "./types";
14
+ import type {AdminApi, RefRendererMap} from "./types";
16
15
 
17
16
  interface AdminPrimitiveArrayFieldProps {
18
17
  title: string;
@@ -23,7 +22,7 @@ interface AdminPrimitiveArrayFieldProps {
23
22
  itemRef?: string;
24
23
  value: PrimitiveItem[];
25
24
  onChange: (value: PrimitiveItem[]) => void;
26
- api: Api<any, any, any, any>;
25
+ api: AdminApi;
27
26
  baseUrl: string;
28
27
  modelConfigs?: Array<{name: string; routePath: string}>;
29
28
  /**
@@ -1,18 +1,21 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic mock returns
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
4
6
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
5
7
  import {AdminScriptList} from "./AdminScriptList";
8
+ import type {AdminApi, AdminConfigResponse} from "./types";
6
9
 
7
10
  // Mock useAdminConfig to control returned data
8
11
  const mockUseAdminConfig = mock(() => ({
9
- config: null as any,
10
- error: null as any,
12
+ config: null as AdminConfigResponse | null,
13
+ error: null as Error | null,
11
14
  isLoading: false,
12
15
  }));
13
16
 
14
17
  mock.module("./useAdminConfig", () => ({
15
- useAdminConfig: (...args: any[]) => mockUseAdminConfig(...args),
18
+ useAdminConfig: (...args: unknown[]) => mockUseAdminConfig(...args),
16
19
  }));
17
20
 
18
21
  const modalCallbacks: {
@@ -35,7 +38,7 @@ mock.module("./AdminScriptRunModal", () => ({
35
38
  },
36
39
  }));
37
40
 
38
- const mockApi = {} as any;
41
+ const mockApi = {} as unknown as AdminApi;
39
42
 
40
43
  describe("AdminScriptList", () => {
41
44
  beforeEach(() => {
@@ -1,13 +1,12 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {Box, Button, Card, Heading, Page, Spinner, Text} from "@terreno/ui";
3
2
  import React, {useCallback, useState} from "react";
4
3
  import {AdminScriptRunModal} from "./AdminScriptRunModal";
5
- import type {AdminScriptConfig} from "./types";
4
+ import type {AdminApi, AdminScriptConfig} from "./types";
6
5
  import {useAdminConfig} from "./useAdminConfig";
7
6
 
8
7
  interface AdminScriptListProps {
9
8
  baseUrl: string;
10
- api: Api<any, any, any, any>;
9
+ api: AdminApi;
11
10
  /** When false, the Run button is disabled. Defaults to true. */
12
11
  isAdmin?: boolean;
13
12
  }
@@ -1,9 +1,12 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic mock returns
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
4
  import * as terrenoUi from "@terreno/ui";
3
5
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
4
6
  import React from "react";
5
7
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
6
8
  import {AdminScriptRunModal} from "./AdminScriptRunModal";
9
+ import type {AdminApi} from "./types";
7
10
 
8
11
  // Render Modal children inline so we can interact with them in tests
9
12
  mock.module("@terreno/ui", () => ({
@@ -26,10 +29,10 @@ const mockUseAdminScripts = mock(() => ({
26
29
  }));
27
30
 
28
31
  mock.module("./useAdminScripts", () => ({
29
- useAdminScripts: (...args: any[]) => mockUseAdminScripts(...args),
32
+ useAdminScripts: (...args: unknown[]) => mockUseAdminScripts(...args),
30
33
  }));
31
34
 
32
- const mockApi = {} as any;
35
+ const mockApi = {} as unknown as AdminApi;
33
36
 
34
37
  describe("AdminScriptRunModal", () => {
35
38
  beforeEach(() => {
@@ -1,12 +1,11 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {Badge, Box, Button, Heading, Icon, Modal, Spinner, Text} from "@terreno/ui";
3
2
  import React, {useCallback, useEffect, useRef, useState} from "react";
4
- import type {BackgroundTask} from "./types";
3
+ import type {AdminApi, BackgroundTask} from "./types";
5
4
  import {useAdminScripts} from "./useAdminScripts";
6
5
 
7
6
  interface AdminScriptRunModalProps {
8
7
  baseUrl: string;
9
- api: Api<any, any, any, any>;
8
+ api: AdminApi;
10
9
  scriptName: string | null;
11
10
  scriptDescription?: string;
12
11
  visible: boolean;
@@ -1,7 +1,11 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic endpoint builders
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
6
+ import type {ReactTestInstance} from "react-test-renderer";
4
7
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
8
+ import type {AdminApi} from "./types";
5
9
 
6
10
  const routerBack = mock(() => {});
7
11
  mock.module("expo-router", () => ({
@@ -9,10 +13,10 @@ mock.module("expo-router", () => ({
9
13
  }));
10
14
 
11
15
  interface ApiState {
12
- data: any;
16
+ data: Record<string, unknown> | null;
13
17
  error: unknown;
14
18
  isLoading: boolean;
15
- updateImpl: (body: any) => Promise<any>;
19
+ updateImpl: (body: unknown) => Promise<unknown>;
16
20
  }
17
21
 
18
22
  const apiState: ApiState = {
@@ -22,20 +26,20 @@ const apiState: ApiState = {
22
26
  updateImpl: async () => ({}),
23
27
  };
24
28
 
25
- const updateCalls: any[] = [];
26
- const querySpecs: any[] = [];
27
- const mutationSpecs: any[] = [];
29
+ const updateCalls: unknown[] = [];
30
+ const querySpecs: unknown[] = [];
31
+ const mutationSpecs: unknown[] = [];
28
32
  const makeApi = () => ({
29
- injectEndpoints: ({endpoints}: {endpoints: (b: any) => Record<string, any>}) => {
33
+ injectEndpoints: ({endpoints}: {endpoints: (b: unknown) => Record<string, unknown>}) => {
30
34
  const build = {
31
- mutation: (spec: any) => {
35
+ mutation: (spec: Record<string, unknown>) => {
32
36
  // Invoke the mutation's query lambda so the URL + body builder runs.
33
37
  if (typeof spec?.query === "function") {
34
38
  mutationSpecs.push(spec.query({demo: true}));
35
39
  }
36
40
  return spec;
37
41
  },
38
- query: (spec: any) => {
42
+ query: (spec: Record<string, unknown>) => {
39
43
  // Invoke the query lambda so the request descriptor builder runs.
40
44
  if (typeof spec?.query === "function") {
41
45
  querySpecs.push(spec.query());
@@ -51,7 +55,7 @@ const makeApi = () => ({
51
55
  isLoading: apiState.isLoading,
52
56
  }),
53
57
  useUpdateVersionConfigMutation: () => [
54
- (body: any) => ({
58
+ (body: unknown) => ({
55
59
  unwrap: async () => {
56
60
  updateCalls.push(body);
57
61
  return apiState.updateImpl(body);
@@ -78,7 +82,7 @@ describe("AdminVersionConfig", () => {
78
82
  });
79
83
 
80
84
  it("wires the injected query and mutation endpoints to the version-config URL", () => {
81
- renderWithTheme(<AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />);
85
+ renderWithTheme(<AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />);
82
86
  expect(querySpecs.length).toBeGreaterThan(0);
83
87
  expect(querySpecs[0]).toEqual({method: "GET", url: "/admin/version-config"});
84
88
  expect(mutationSpecs.length).toBeGreaterThan(0);
@@ -100,11 +104,13 @@ describe("AdminVersionConfig", () => {
100
104
  webWarningVersion: 4,
101
105
  };
102
106
  const {UNSAFE_root, getByText} = renderWithTheme(
103
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
107
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
108
+ );
109
+ const numberNodes = UNSAFE_root.findAll(
110
+ (n: ReactTestInstance) => typeof n.props?.onChange === "function"
104
111
  );
105
- const numberNodes = UNSAFE_root.findAll((n: any) => typeof n.props?.onChange === "function");
106
112
  // Fire onChange on every field with an onChange prop so every setState path runs.
107
- numberNodes.forEach((n: any, index: number) => {
113
+ numberNodes.forEach((n: ReactTestInstance, index: number) => {
108
114
  try {
109
115
  n.props.onChange(String(100 + index));
110
116
  } catch {
@@ -121,7 +127,7 @@ describe("AdminVersionConfig", () => {
121
127
  it("renders loading state", () => {
122
128
  apiState.isLoading = true;
123
129
  const {toJSON} = renderWithTheme(
124
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
130
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
125
131
  );
126
132
  expect(toJSON()).toBeDefined();
127
133
  });
@@ -129,7 +135,7 @@ describe("AdminVersionConfig", () => {
129
135
  it("renders error state and calls back on press", async () => {
130
136
  apiState.error = new Error("boom");
131
137
  const {getByText} = renderWithTheme(
132
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
138
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
133
139
  );
134
140
  await act(async () => {
135
141
  fireEvent.press(getByText("Back"));
@@ -141,7 +147,7 @@ describe("AdminVersionConfig", () => {
141
147
  it("populates the form with defaults when data is missing", () => {
142
148
  apiState.data = null;
143
149
  const {toJSON} = renderWithTheme(
144
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
150
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
145
151
  );
146
152
  expect(toJSON()).toBeDefined();
147
153
  });
@@ -150,6 +156,7 @@ describe("AdminVersionConfig", () => {
150
156
  apiState.data = {
151
157
  mobileRequiredVersion: 1,
152
158
  mobileWarningVersion: 2,
159
+ pollingIntervalMinutes: 120,
153
160
  requiredMessage: "R",
154
161
  updateUrl: " https://x.com ",
155
162
  warningMessage: "W",
@@ -157,14 +164,33 @@ describe("AdminVersionConfig", () => {
157
164
  webWarningVersion: 4,
158
165
  };
159
166
  const {getByText} = renderWithTheme(
160
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
167
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
168
+ );
169
+ await act(async () => {
170
+ fireEvent.press(getByText("Save"));
171
+ await new Promise((r) => setTimeout(r, 150));
172
+ });
173
+ expect(updateCalls.length).toBe(1);
174
+ expect((updateCalls[0] as Record<string, unknown>).updateUrl).toBe("https://x.com");
175
+ expect(updateCalls[0].pollingIntervalMinutes).toBe(120);
176
+ });
177
+
178
+ it("saves default pollingIntervalMinutes (1440) when not provided by backend", async () => {
179
+ apiState.data = {
180
+ mobileRequiredVersion: 0,
181
+ mobileWarningVersion: 0,
182
+ webRequiredVersion: 0,
183
+ webWarningVersion: 0,
184
+ };
185
+ const {getByText} = renderWithTheme(
186
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
161
187
  );
162
188
  await act(async () => {
163
189
  fireEvent.press(getByText("Save"));
164
190
  await new Promise((r) => setTimeout(r, 150));
165
191
  });
166
192
  expect(updateCalls.length).toBe(1);
167
- expect(updateCalls[0].updateUrl).toBe("https://x.com");
193
+ expect((updateCalls[0] as Record<string, unknown>).pollingIntervalMinutes).toBe(1440);
168
194
  });
169
195
 
170
196
  it("handles save failures gracefully", async () => {
@@ -173,7 +199,7 @@ describe("AdminVersionConfig", () => {
173
199
  throw new Error("server down");
174
200
  };
175
201
  const {getByText} = renderWithTheme(
176
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
202
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
177
203
  );
178
204
  await act(async () => {
179
205
  fireEvent.press(getByText("Save"));
@@ -185,12 +211,12 @@ describe("AdminVersionConfig", () => {
185
211
  it("sets updateUrl to null when empty", async () => {
186
212
  apiState.data = {updateUrl: null};
187
213
  const {getByText} = renderWithTheme(
188
- <AdminVersionConfig api={makeApi() as any} baseUrl="/admin" />
214
+ <AdminVersionConfig api={makeApi() as unknown as AdminApi} baseUrl="/admin" />
189
215
  );
190
216
  await act(async () => {
191
217
  fireEvent.press(getByText("Save"));
192
218
  await new Promise((r) => setTimeout(r, 150));
193
219
  });
194
- expect(updateCalls[0].updateUrl).toBeNull();
220
+ expect((updateCalls[0] as Record<string, unknown>).updateUrl).toBeNull();
195
221
  });
196
222
  });
@@ -1,11 +1,13 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {Box, Button, NumberField, Page, Spinner, Text, TextField, useToast} from "@terreno/ui";
3
2
  import {router} from "expo-router";
4
3
  import React, {useCallback, useEffect, useMemo, useState} from "react";
4
+ import type {AdminApi, EndpointBuilder} from "./types";
5
5
 
6
6
  interface VersionConfigData {
7
7
  mobileRequiredVersion?: number;
8
8
  mobileWarningVersion?: number;
9
+ /** How often clients poll for version updates, in minutes. */
10
+ pollingIntervalMinutes?: number;
9
11
  requiredMessage?: string;
10
12
  updateUrl?: string | null;
11
13
  webRequiredVersion?: number;
@@ -14,7 +16,7 @@ interface VersionConfigData {
14
16
  }
15
17
 
16
18
  interface AdminVersionConfigProps {
17
- api: Api<any, any, any, any>;
19
+ api: AdminApi;
18
20
  baseUrl: string;
19
21
  }
20
22
 
@@ -27,7 +29,7 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
27
29
 
28
30
  const enhancedApi = useMemo(() => {
29
31
  return api.injectEndpoints({
30
- endpoints: (build: any) => ({
32
+ endpoints: (build: EndpointBuilder) => ({
31
33
  [VERSION_CONFIG_ENDPOINT]: build.query({
32
34
  query: () => ({
33
35
  method: "GET",
@@ -46,8 +48,11 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
46
48
  });
47
49
  }, [api, baseUrl]);
48
50
 
49
- const useVersionConfigQuery = (enhancedApi as any).useAdminVersionConfigQuery;
50
- const [updateConfig] = (enhancedApi as any).useUpdateVersionConfigMutation();
51
+ // noExplicitAny: RTK Query generates hook names dynamically; not statically expressible
52
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
53
+ const enhanced = enhancedApi as any;
54
+ const useVersionConfigQuery = enhanced.useAdminVersionConfigQuery;
55
+ const [updateConfig] = enhanced.useUpdateVersionConfigMutation();
51
56
 
52
57
  const {data, isLoading: isFetching, error: fetchError} = useVersionConfigQuery();
53
58
 
@@ -59,6 +64,7 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
59
64
  const defaults = {
60
65
  mobileRequiredVersion: 0,
61
66
  mobileWarningVersion: 0,
67
+ pollingIntervalMinutes: 1440,
62
68
  requiredMessage: "This version is no longer supported. Please update to continue.",
63
69
  updateUrl: "",
64
70
  warningMessage: "A new version is available. Please update for the best experience.",
@@ -69,6 +75,7 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
69
75
  setFormState({
70
76
  mobileRequiredVersion: data.mobileRequiredVersion ?? 0,
71
77
  mobileWarningVersion: data.mobileWarningVersion ?? 0,
78
+ pollingIntervalMinutes: data.pollingIntervalMinutes ?? defaults.pollingIntervalMinutes,
72
79
  requiredMessage: data.requiredMessage ?? defaults.requiredMessage,
73
80
  updateUrl: data.updateUrl ?? "",
74
81
  warningMessage: data.warningMessage ?? defaults.warningMessage,
@@ -94,6 +101,7 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
94
101
  await updateConfig({
95
102
  mobileRequiredVersion: Number(formState.mobileRequiredVersion) || 0,
96
103
  mobileWarningVersion: Number(formState.mobileWarningVersion) || 0,
104
+ pollingIntervalMinutes: Math.max(1, Number(formState.pollingIntervalMinutes) || 1440),
97
105
  requiredMessage: formState.requiredMessage ?? "",
98
106
  updateUrl: trimmedUpdateUrl || null,
99
107
  warningMessage: formState.warningMessage ?? "",
@@ -202,6 +210,22 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({api, base
202
210
  />
203
211
  </Box>
204
212
 
213
+ <Box gap={2}>
214
+ <Text bold size="md">
215
+ Polling
216
+ </Text>
217
+ <NumberField
218
+ onChange={(v) => handleFieldChange("pollingIntervalMinutes", parseInt(v, 10) || 1440)}
219
+ title="Update check interval (minutes)"
220
+ type="number"
221
+ value={String(formState.pollingIntervalMinutes ?? 1440)}
222
+ />
223
+ <Text color="secondaryDark" size="sm">
224
+ How often clients check for updates in the background. Default: 1440 (24 hours).
225
+ Minimum: 1.
226
+ </Text>
227
+ </Box>
228
+
205
229
  <Box direction="row" gap={2}>
206
230
  <Button onClick={handleBack} text="Back" variant="outline" />
207
231
  <Button loading={isSaving} onClick={handleSave} text="Save" variant="primary" />
@@ -1,10 +1,13 @@
1
+ // noExplicitAny: test mocks use type-erased mock.calls access for assertion
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
6
+ import type {ReactTestInstance} from "react-test-renderer";
4
7
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
5
8
  import {CheckboxListEditor} from "./CheckboxListEditor";
6
9
 
7
- const press = async (el: any): Promise<void> => {
10
+ const press = async (el: ReactTestInstance): Promise<void> => {
8
11
  await act(async () => {
9
12
  fireEvent.press(el);
10
13
  await new Promise((r) => setTimeout(r, 150));
@@ -32,7 +35,7 @@ describe("CheckboxListEditor", () => {
32
35
 
33
36
  it("handles non-array values gracefully", () => {
34
37
  const {toJSON} = renderWithTheme(
35
- <CheckboxListEditor onChange={() => {}} value={undefined as any} />
38
+ <CheckboxListEditor onChange={() => {}} value={undefined as unknown as undefined} />
36
39
  );
37
40
  expect(toJSON()).toBeDefined();
38
41
  });
@@ -42,7 +45,7 @@ describe("CheckboxListEditor", () => {
42
45
  const {getByTestId} = renderWithTheme(<CheckboxListEditor onChange={onChange} value={[]} />);
43
46
  await press(getByTestId("checkbox-add-button"));
44
47
  expect(onChange).toHaveBeenCalled();
45
- const next = (onChange.mock.calls[0] as any)[0];
48
+ const next = (onChange.mock.calls[0] as unknown[])[0];
46
49
  expect(next).toEqual([{label: "", required: false}]);
47
50
  });
48
51
 
@@ -59,7 +62,7 @@ describe("CheckboxListEditor", () => {
59
62
  );
60
63
  await press(getByTestId("checkbox-remove-0"));
61
64
  expect(onChange).toHaveBeenCalled();
62
- const next = (onChange.mock.calls[0] as any)[0];
65
+ const next = (onChange.mock.calls[0] as unknown[])[0];
63
66
  expect(next).toHaveLength(1);
64
67
  expect(next[0].label).toBe("b");
65
68
  });
@@ -70,11 +73,11 @@ describe("CheckboxListEditor", () => {
70
73
  <CheckboxListEditor onChange={onChange} value={[{label: "a", required: false}]} />
71
74
  );
72
75
  fireEvent.changeText(getByTestId("checkbox-label-0"), "new-label");
73
- const first = (onChange.mock.calls[0] as any)[0];
76
+ const first = (onChange.mock.calls[0] as unknown[])[0];
74
77
  expect(first[0].label).toBe("new-label");
75
78
 
76
79
  fireEvent.changeText(getByTestId("checkbox-prompt-0"), "prompt?");
77
- const second = (onChange.mock.calls[1] as any)[0];
80
+ const second = (onChange.mock.calls[1] as unknown[])[0];
78
81
  expect(second[0].confirmationPrompt).toBe("prompt?");
79
82
  });
80
83
  });
@@ -1,22 +1,25 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic mock returns
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
4
6
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
7
+ import type {AdminApi} from "./types";
5
8
 
6
9
  interface QueryState<T> {
7
10
  data: T | undefined;
8
11
  isLoading: boolean;
9
12
  }
10
- const metaState: QueryState<any> = {data: undefined, isLoading: false};
11
- const valuesState: QueryState<any> = {data: undefined, isLoading: false};
12
- let updateImpl: (body: any) => Promise<any> = async () => ({});
13
- const updateCalls: any[] = [];
13
+ const metaState: QueryState<unknown> = {data: undefined, isLoading: false};
14
+ const valuesState: QueryState<unknown> = {data: undefined, isLoading: false};
15
+ let updateImpl: (body: unknown) => Promise<unknown> = async () => ({});
16
+ const updateCalls: unknown[] = [];
14
17
 
15
18
  mock.module("./useConfigurationApi", () => ({
16
19
  useConfigurationApi: () => ({
17
20
  useMetaQuery: () => ({data: metaState.data, isLoading: metaState.isLoading}),
18
21
  useUpdateMutation: () => [
19
- (body: any) => ({
22
+ (body: unknown) => ({
20
23
  unwrap: async () => {
21
24
  updateCalls.push(body);
22
25
  return updateImpl(body);
@@ -71,12 +74,14 @@ describe("ConfigurationScreen", () => {
71
74
  it("renders loading state on initial load", () => {
72
75
  metaState.isLoading = true;
73
76
  valuesState.isLoading = true;
74
- const {toJSON} = renderWithTheme(<ConfigurationScreen api={{} as any} />);
77
+ const {toJSON} = renderWithTheme(<ConfigurationScreen api={{} as unknown as AdminApi} />);
75
78
  expect(toJSON()).toBeDefined();
76
79
  });
77
80
 
78
81
  it("renders an empty-state when metadata is missing", () => {
79
- const {toJSON, getByText} = renderWithTheme(<ConfigurationScreen api={{} as any} />);
82
+ const {toJSON, getByText} = renderWithTheme(
83
+ <ConfigurationScreen api={{} as unknown as AdminApi} />
84
+ );
80
85
  expect(toJSON()).toBeDefined();
81
86
  expect(getByText(/No configuration metadata available/)).toBeDefined();
82
87
  });
@@ -85,7 +90,7 @@ describe("ConfigurationScreen", () => {
85
90
  metaState.data = {sections: []};
86
91
  valuesState.data = {};
87
92
  const {getByText} = renderWithTheme(
88
- <ConfigurationScreen api={{} as any} basePath="/config" title="My Config" />
93
+ <ConfigurationScreen api={{} as unknown as AdminApi} basePath="/config" title="My Config" />
89
94
  );
90
95
  expect(getByText(/No configuration sections defined/)).toBeDefined();
91
96
  });
@@ -97,7 +102,7 @@ describe("ConfigurationScreen", () => {
97
102
  name: "Initial",
98
103
  smtp: {apiKey: "secret", host: "h", notes: "notes", port: 25},
99
104
  };
100
- const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as any} />);
105
+ const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as unknown as AdminApi} />);
101
106
  await act(async () => {
102
107
  fireEvent.changeText(getByTestId("config-__root__-name"), "Updated");
103
108
  await new Promise((r) => setTimeout(r, 50));
@@ -116,7 +121,7 @@ describe("ConfigurationScreen", () => {
116
121
  updateImpl = async () => {
117
122
  throw new Error("nope");
118
123
  };
119
- const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as any} />);
124
+ const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as unknown as AdminApi} />);
120
125
  await act(async () => {
121
126
  fireEvent.changeText(getByTestId("config-__root__-name"), "Boom");
122
127
  await new Promise((r) => setTimeout(r, 50));
@@ -131,7 +136,7 @@ describe("ConfigurationScreen", () => {
131
136
  it("accepts non-numeric number input and preserves the raw text", async () => {
132
137
  metaState.data = baseMeta;
133
138
  valuesState.data = {};
134
- const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as any} />);
139
+ const {getByTestId} = renderWithTheme(<ConfigurationScreen api={{} as unknown as AdminApi} />);
135
140
  await act(async () => {
136
141
  fireEvent.changeText(getByTestId("config-smtp-port"), "not-a-number");
137
142
  await new Promise((r) => setTimeout(r, 50));