@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,10 +1,14 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and UNSAFE_root traversal
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
  interface ListState {
7
- data: any;
11
+ data: unknown;
8
12
  isLoading: boolean;
9
13
  error: unknown;
10
14
  }
@@ -31,19 +35,25 @@ describe("ConsentFormList", () => {
31
35
 
32
36
  it("renders loading state", () => {
33
37
  listState.isLoading = true;
34
- const {toJSON} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
38
+ const {toJSON} = renderWithTheme(
39
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
40
+ );
35
41
  expect(toJSON()).toBeDefined();
36
42
  });
37
43
 
38
44
  it("renders error state", () => {
39
45
  listState.error = new Error("x");
40
- const {getByText} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
46
+ const {getByText} = renderWithTheme(
47
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
48
+ );
41
49
  expect(getByText(/Failed to load consent forms/)).toBeDefined();
42
50
  });
43
51
 
44
52
  it("renders empty state", () => {
45
53
  listState.data = {data: [], total: 0};
46
- const {getByText} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
54
+ const {getByText} = renderWithTheme(
55
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
56
+ );
47
57
  expect(getByText(/No consent forms found/)).toBeDefined();
48
58
  });
49
59
 
@@ -53,7 +63,9 @@ describe("ConsentFormList", () => {
53
63
  total: 1,
54
64
  };
55
65
  // No onRowClick is provided. The ActionsCell edit-button path should be hidden.
56
- const {toJSON} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
66
+ const {toJSON} = renderWithTheme(
67
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
68
+ );
57
69
  expect(toJSON()).toBeDefined();
58
70
  });
59
71
 
@@ -76,7 +88,7 @@ describe("ConsentFormList", () => {
76
88
  const onRowClick = mock((_: string) => undefined);
77
89
  const {getByTestId} = renderWithTheme(
78
90
  <ConsentFormList
79
- api={{} as any}
91
+ api={{} as unknown as AdminApi}
80
92
  baseUrl="/admin"
81
93
  onCreateNew={onCreateNew}
82
94
  onRowClick={onRowClick}
@@ -95,19 +107,25 @@ describe("ConsentFormList", () => {
95
107
  total: 1,
96
108
  };
97
109
  const {UNSAFE_root, toJSON} = renderWithTheme(
98
- <ConsentFormList api={{} as any} baseUrl="/admin" onRowClick={() => undefined} />
110
+ <ConsentFormList
111
+ api={{} as unknown as AdminApi}
112
+ baseUrl="/admin"
113
+ onRowClick={() => undefined}
114
+ />
115
+ );
116
+ const tables = UNSAFE_root.findAll(
117
+ (n: ReactTestInstance) => typeof n.props?.setSortColumn === "function"
99
118
  );
100
- const tables = UNSAFE_root.findAll((n: any) => typeof n.props?.setSortColumn === "function");
101
119
  expect(tables.length).toBeGreaterThan(0);
102
120
  await act(async () => {
103
121
  // Column 99 is out of range, so buildSortString returns undefined and
104
122
  // the default "-created" sort should be used.
105
- (tables[0] as any).props.setSortColumn({column: 99, direction: "asc"});
123
+ (tables[0] as ReactTestInstance).props.setSortColumn({column: 99, direction: "asc"});
106
124
  await new Promise((r) => setTimeout(r, 10));
107
125
  });
108
126
  // Also exercise the desc branch on a valid column.
109
127
  await act(async () => {
110
- (tables[0] as any).props.setSortColumn({column: 0, direction: "desc"});
128
+ (tables[0] as ReactTestInstance).props.setSortColumn({column: 0, direction: "desc"});
111
129
  await new Promise((r) => setTimeout(r, 10));
112
130
  });
113
131
  expect(toJSON()).toBeDefined();
@@ -12,15 +12,27 @@ import {
12
12
  Text,
13
13
  } from "@terreno/ui";
14
14
  import React, {useCallback, useMemo, useState} from "react";
15
+ import type {AdminApi} from "./types";
15
16
  import {useAdminApi} from "./useAdminApi";
16
17
 
17
18
  interface ConsentFormListProps {
18
19
  baseUrl: string;
19
- api: any;
20
+ api: AdminApi;
20
21
  onCreateNew?: () => void;
21
22
  onRowClick?: (id: string) => void;
22
23
  }
23
24
 
25
+ /** Row shape returned by the consent forms list endpoint. */
26
+ interface ConsentFormListItem {
27
+ _id: string;
28
+ title?: string;
29
+ type?: string;
30
+ version?: number;
31
+ active?: boolean;
32
+ order?: number;
33
+ [key: string]: unknown;
34
+ }
35
+
24
36
  const DEFAULT_LIMIT = 20;
25
37
 
26
38
  const ACTIONS_COLUMN_TYPE = "consentFormActions";
@@ -103,7 +115,7 @@ export const ConsentFormList: React.FC<ConsentFormListProps> = ({
103
115
  : []),
104
116
  ];
105
117
 
106
- const rows = (listData?.data ?? []).map((item: any) => {
118
+ const rows = ((listData?.data ?? []) as ConsentFormListItem[]).map((item) => {
107
119
  const dataCells = DATA_COLUMN_KEYS.map((key) => {
108
120
  const value = item[key];
109
121
  if (key === "active") {
@@ -1,10 +1,13 @@
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 ReadState {
7
- data: any;
10
+ data: unknown;
8
11
  isLoading: boolean;
9
12
  }
10
13
  const readState: ReadState = {data: undefined, isLoading: false};
@@ -20,10 +23,10 @@ mock.module("./useAdminApi", () => ({
20
23
  }),
21
24
  }));
22
25
 
23
- const pdfCalls: any[] = [];
24
- let pdfImpl: (r: any) => Promise<void> = async () => {};
26
+ const pdfCalls: unknown[] = [];
27
+ let pdfImpl: (r: unknown) => Promise<void> = async () => {};
25
28
  mock.module("./generateConsentPdf", () => ({
26
- generateConsentPdf: async (r: any) => {
29
+ generateConsentPdf: async (r: unknown) => {
27
30
  pdfCalls.push(r);
28
31
  return pdfImpl(r);
29
32
  },
@@ -42,7 +45,7 @@ describe("ConsentResponseViewer", () => {
42
45
  it("renders loading state", () => {
43
46
  readState.isLoading = true;
44
47
  const {toJSON} = renderWithTheme(
45
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
48
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
46
49
  );
47
50
  expect(toJSON()).toBeDefined();
48
51
  });
@@ -54,19 +57,19 @@ describe("ConsentResponseViewer", () => {
54
57
  it("survives the loading → loaded transition without a hook-order error", async () => {
55
58
  readState.isLoading = true;
56
59
  const {rerender, getByText} = renderWithTheme(
57
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
60
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
58
61
  );
59
62
  await act(async () => {
60
63
  readState.isLoading = false;
61
64
  readState.data = {agreed: true, consentFormId: "raw-id", userId: "u1"};
62
- rerender(<ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />);
65
+ rerender(<ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />);
63
66
  });
64
67
  expect(getByText("Download PDF")).toBeDefined();
65
68
  });
66
69
 
67
70
  it("shows not-found state when there is no id / data", () => {
68
71
  const {getByText} = renderWithTheme(
69
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="" />
72
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="" />
70
73
  );
71
74
  expect(getByText(/Response not found\./)).toBeDefined();
72
75
  });
@@ -86,7 +89,7 @@ describe("ConsentResponseViewer", () => {
86
89
  userId: {_id: "u1"},
87
90
  };
88
91
  const {getByText} = renderWithTheme(
89
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
92
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
90
93
  );
91
94
  await act(async () => {
92
95
  fireEvent.press(getByText("Download PDF"));
@@ -102,7 +105,7 @@ describe("ConsentResponseViewer", () => {
102
105
  userId: "u2",
103
106
  };
104
107
  const {toJSON} = renderWithTheme(
105
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r2" />
108
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r2" />
106
109
  );
107
110
  expect(toJSON()).toBeDefined();
108
111
  });
@@ -113,7 +116,7 @@ describe("ConsentResponseViewer", () => {
113
116
  throw new Error("broken");
114
117
  };
115
118
  const {getByText} = renderWithTheme(
116
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
119
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
117
120
  );
118
121
  await act(async () => {
119
122
  fireEvent.press(getByText("Download PDF"));
@@ -125,7 +128,7 @@ describe("ConsentResponseViewer", () => {
125
128
  it("formats invalid dates gracefully", () => {
126
129
  readState.data = {agreed: true, agreedAt: "not-a-date"};
127
130
  const {toJSON} = renderWithTheme(
128
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
131
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
129
132
  );
130
133
  expect(toJSON()).toBeDefined();
131
134
  });
@@ -3,15 +3,16 @@ import {DateTime} from "luxon";
3
3
  import React, {useCallback, useState} from "react";
4
4
  import {Image} from "react-native";
5
5
  import {generateConsentPdf} from "./generateConsentPdf";
6
+ import type {AdminApi} from "./types";
6
7
  import {useAdminApi} from "./useAdminApi";
7
8
 
8
9
  interface ConsentResponseViewerProps {
9
10
  baseUrl: string;
10
- api: any;
11
+ api: AdminApi;
11
12
  id: string;
12
13
  }
13
14
 
14
- const formatDate = (value: any): string => {
15
+ const formatDate = (value: unknown): string => {
15
16
  if (!value) {
16
17
  return "";
17
18
  }
@@ -1,36 +1,41 @@
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 {afterEach, 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 {Platform} from "react-native";
7
+ import type {ReactTestInstance} from "react-test-renderer";
5
8
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
9
+ import type {AdminApi} from "./types";
6
10
 
7
11
  mock.module("react-native-webview", () => ({
8
- WebView: (props: any) => React.createElement("WebView", {...props, testID: "mock-webview"}),
12
+ WebView: (props: Record<string, unknown>) =>
13
+ React.createElement("WebView", {...props, testID: "mock-webview"}),
9
14
  }));
10
15
 
11
16
  interface ListState {
12
- data: any;
17
+ data: unknown;
13
18
  isLoading: boolean;
14
19
  isError: boolean;
15
- error: any;
20
+ error: unknown;
16
21
  }
17
22
  const listState: ListState = {data: undefined, error: null, isError: false, isLoading: false};
18
23
  const refetchMock = mock(() => {});
19
- const uploadCalls: any[] = [];
24
+ const uploadCalls: unknown[] = [];
20
25
  const deleteCalls: string[] = [];
21
26
  const deleteFolderCalls: string[] = [];
22
- const createFolderCalls: any[] = [];
27
+ const createFolderCalls: unknown[] = [];
23
28
  const downloadCalls: string[] = [];
24
- let uploadImpl: (body: any) => Promise<any> = async () => ({});
25
- let deleteImpl: (p: string) => Promise<any> = async () => ({});
26
- let deleteFolderImpl: (p: string) => Promise<any> = async () => ({});
27
- let createFolderImpl: (body: any) => Promise<any> = async () => ({});
28
- let downloadImpl: (p: string) => Promise<any> = async () => new Blob(["hi"]);
29
+ let uploadImpl: (body: unknown) => Promise<unknown> = async () => ({});
30
+ let deleteImpl: (p: string) => Promise<unknown> = async () => ({});
31
+ let deleteFolderImpl: (p: string) => Promise<unknown> = async () => ({});
32
+ let createFolderImpl: (body: unknown) => Promise<unknown> = async () => ({});
33
+ let downloadImpl: (p: string) => Promise<unknown> = async () => new Blob(["hi"]);
29
34
 
30
35
  mock.module("./useDocumentStorageApi", () => ({
31
36
  useDocumentStorageApi: () => ({
32
37
  useCreateFolderMutation: () => [
33
- (body: any) => ({
38
+ (body: unknown) => ({
34
39
  unwrap: async () => {
35
40
  createFolderCalls.push(body);
36
41
  return createFolderImpl(body);
@@ -74,7 +79,7 @@ mock.module("./useDocumentStorageApi", () => ({
74
79
  return {...listState, refetch: refetchMock};
75
80
  },
76
81
  useUploadMutation: () => [
77
- (body: any) => ({
82
+ (body: unknown) => ({
78
83
  unwrap: async () => {
79
84
  uploadCalls.push(body);
80
85
  return uploadImpl(body);
@@ -87,7 +92,7 @@ mock.module("./useDocumentStorageApi", () => ({
87
92
 
88
93
  import {DocumentStorageBrowser} from "./DocumentStorageBrowser";
89
94
 
90
- const press = async (el: any): Promise<void> => {
95
+ const press = async (el: ReactTestInstance): Promise<void> => {
91
96
  await act(async () => {
92
97
  fireEvent.press(el);
93
98
  await new Promise((r) => setTimeout(r, 150));
@@ -122,7 +127,7 @@ describe("DocumentStorageBrowser", () => {
122
127
  it("renders loading state", () => {
123
128
  listState.isLoading = true;
124
129
  const {toJSON} = renderWithTheme(
125
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
130
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
126
131
  );
127
132
  expect(toJSON()).toBeDefined();
128
133
  });
@@ -131,7 +136,7 @@ describe("DocumentStorageBrowser", () => {
131
136
  listState.isError = true;
132
137
  listState.error = {status: 500};
133
138
  const {getByText} = renderWithTheme(
134
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
139
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
135
140
  );
136
141
  expect(getByText(/Failed to load files/)).toBeDefined();
137
142
  });
@@ -142,7 +147,7 @@ describe("DocumentStorageBrowser", () => {
142
147
  const onSettingsPress = mock(() => undefined);
143
148
  const {getByText} = renderWithTheme(
144
149
  <DocumentStorageBrowser
145
- api={{} as any}
150
+ api={{} as unknown as AdminApi}
146
151
  basePath="/documents"
147
152
  onSettingsPress={onSettingsPress}
148
153
  />
@@ -153,7 +158,7 @@ describe("DocumentStorageBrowser", () => {
153
158
  it("renders empty state when no files or folders", () => {
154
159
  listState.data = {files: [], folders: []};
155
160
  const {getByText} = renderWithTheme(
156
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
161
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
157
162
  );
158
163
  expect(getByText(/No files found/)).toBeDefined();
159
164
  });
@@ -179,7 +184,7 @@ describe("DocumentStorageBrowser", () => {
179
184
  folders: ["sub/"],
180
185
  };
181
186
  const {toJSON} = renderWithTheme(
182
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
187
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
183
188
  );
184
189
  expect(toJSON()).toBeDefined();
185
190
  });
@@ -187,7 +192,7 @@ describe("DocumentStorageBrowser", () => {
187
192
  it("refreshes the list when refresh is pressed", async () => {
188
193
  listState.data = {files: [], folders: []};
189
194
  const {getByTestId} = renderWithTheme(
190
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
195
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
191
196
  );
192
197
  await press(getByTestId("document-refresh-button"));
193
198
  expect(refetchMock).toHaveBeenCalled();
@@ -196,7 +201,7 @@ describe("DocumentStorageBrowser", () => {
196
201
  it("opens the new-folder modal when pressed", async () => {
197
202
  listState.data = {files: [], folders: []};
198
203
  const {getByTestId, toJSON} = renderWithTheme(
199
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
204
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
200
205
  );
201
206
  await press(getByTestId("document-new-folder-button"));
202
207
  expect(toJSON()).toBeDefined();
@@ -205,7 +210,11 @@ describe("DocumentStorageBrowser", () => {
205
210
  it("does not show upload/new folder when allowUpload is false", () => {
206
211
  listState.data = {files: [], folders: []};
207
212
  const {queryByTestId} = renderWithTheme(
208
- <DocumentStorageBrowser allowUpload={false} api={{} as any} basePath="/documents" />
213
+ <DocumentStorageBrowser
214
+ allowUpload={false}
215
+ api={{} as unknown as AdminApi}
216
+ basePath="/documents"
217
+ />
209
218
  );
210
219
  expect(queryByTestId("document-upload-button")).toBeNull();
211
220
  expect(queryByTestId("document-new-folder-button")).toBeNull();
@@ -218,7 +227,11 @@ describe("DocumentStorageBrowser", () => {
218
227
  };
219
228
  const onFileSelect = mock(() => undefined);
220
229
  const {toJSON} = renderWithTheme(
221
- <DocumentStorageBrowser api={{} as any} basePath="/documents" onFileSelect={onFileSelect} />
230
+ <DocumentStorageBrowser
231
+ api={{} as unknown as AdminApi}
232
+ basePath="/documents"
233
+ onFileSelect={onFileSelect}
234
+ />
222
235
  );
223
236
  expect(toJSON()).toBeDefined();
224
237
  });
@@ -228,7 +241,7 @@ describe("DocumentStorageBrowser", () => {
228
241
  const onSettingsPress = mock(() => undefined);
229
242
  const {toJSON} = renderWithTheme(
230
243
  <DocumentStorageBrowser
231
- api={{} as any}
244
+ api={{} as unknown as AdminApi}
232
245
  basePath="/documents"
233
246
  onSettingsPress={onSettingsPress}
234
247
  />
@@ -239,7 +252,11 @@ describe("DocumentStorageBrowser", () => {
239
252
  it("does not render when allowDelete is false (folder actions return null)", () => {
240
253
  listState.data = {files: [], folders: ["sub/"]};
241
254
  const {toJSON} = renderWithTheme(
242
- <DocumentStorageBrowser allowDelete={false} api={{} as any} basePath="/documents" />
255
+ <DocumentStorageBrowser
256
+ allowDelete={false}
257
+ api={{} as unknown as AdminApi}
258
+ basePath="/documents"
259
+ />
243
260
  );
244
261
  expect(toJSON()).toBeDefined();
245
262
  });
@@ -247,7 +264,11 @@ describe("DocumentStorageBrowser", () => {
247
264
  it("uses custom title when provided", () => {
248
265
  listState.data = {files: [], folders: []};
249
266
  const {getByText} = renderWithTheme(
250
- <DocumentStorageBrowser api={{} as any} basePath="/documents" title="Custom Storage" />
267
+ <DocumentStorageBrowser
268
+ api={{} as unknown as AdminApi}
269
+ basePath="/documents"
270
+ title="Custom Storage"
271
+ />
251
272
  );
252
273
  expect(getByText("Custom Storage")).toBeDefined();
253
274
  });
@@ -256,7 +277,7 @@ describe("DocumentStorageBrowser", () => {
256
277
  listState.isError = true;
257
278
  listState.error = {status: 503};
258
279
  const {getByTestId, rerender} = renderWithTheme(
259
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
280
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
260
281
  );
261
282
  await act(async () => {
262
283
  await new Promise((r) => setTimeout(r, 50));
@@ -265,7 +286,7 @@ describe("DocumentStorageBrowser", () => {
265
286
  listState.isError = false;
266
287
  listState.error = null;
267
288
  listState.data = {files: [], folders: []};
268
- rerender(<DocumentStorageBrowser api={{} as any} basePath="/documents" />);
289
+ rerender(<DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />);
269
290
  expect(true).toBe(true);
270
291
  });
271
292
 
@@ -273,7 +294,7 @@ describe("DocumentStorageBrowser", () => {
273
294
  listState.isError = true;
274
295
  listState.error = {originalStatus: 503};
275
296
  const {getByText} = renderWithTheme(
276
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
297
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
277
298
  );
278
299
  expect(getByText(/Storage is not configured/)).toBeDefined();
279
300
  });
@@ -281,7 +302,7 @@ describe("DocumentStorageBrowser", () => {
281
302
  it("renders breadcrumbs that can be clicked", () => {
282
303
  listState.data = {files: [], folders: []};
283
304
  const {toJSON} = renderWithTheme(
284
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
305
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
285
306
  );
286
307
  // No current prefix, only root crumb
287
308
  expect(toJSON()).toBeDefined();
@@ -290,7 +311,7 @@ describe("DocumentStorageBrowser", () => {
290
311
  it("renders new folder modal markup when opened", async () => {
291
312
  listState.data = {files: [], folders: []};
292
313
  const {getByTestId, toJSON} = renderWithTheme(
293
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
314
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
294
315
  );
295
316
  await press(getByTestId("document-new-folder-button"));
296
317
  expect(toJSON()).toBeDefined();
@@ -300,10 +321,12 @@ describe("DocumentStorageBrowser", () => {
300
321
  Object.defineProperty(Platform, "OS", {configurable: true, value: "web"});
301
322
  listState.data = {files: [], folders: []};
302
323
  const {UNSAFE_getAllByType} = renderWithTheme(
303
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
324
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
304
325
  );
305
- const hostInputs = UNSAFE_getAllByType("input" as any);
306
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
326
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
327
+ const fileInput = hostInputs.find(
328
+ (node: ReactTestInstance) => node.props?.type === "file"
329
+ ) as ReactTestInstance;
307
330
  expect(fileInput).toBeDefined();
308
331
  const fakeFile = new File(["x"], "x.txt", {type: "text/plain"});
309
332
  await act(async () => {
@@ -311,17 +334,19 @@ describe("DocumentStorageBrowser", () => {
311
334
  await new Promise((r) => setTimeout(r, 30));
312
335
  });
313
336
  expect(uploadCalls.length).toBe(1);
314
- expect(uploadCalls[0].prefix).toBeUndefined();
337
+ expect((uploadCalls[0] as Record<string, unknown>).prefix).toBeUndefined();
315
338
  });
316
339
 
317
340
  it("ignores upload change when no file selected", async () => {
318
341
  Object.defineProperty(Platform, "OS", {configurable: true, value: "web"});
319
342
  listState.data = {files: [], folders: []};
320
343
  const {UNSAFE_getAllByType} = renderWithTheme(
321
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
344
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
322
345
  );
323
- const hostInputs = UNSAFE_getAllByType("input" as any);
324
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
346
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
347
+ const fileInput = hostInputs.find(
348
+ (node: ReactTestInstance) => node.props?.type === "file"
349
+ ) as ReactTestInstance;
325
350
  await act(async () => {
326
351
  fileInput.props.onChange({target: {files: []}});
327
352
  await new Promise((r) => setTimeout(r, 10));
@@ -336,10 +361,12 @@ describe("DocumentStorageBrowser", () => {
336
361
  throw new Error("upload failed");
337
362
  };
338
363
  const {UNSAFE_getAllByType} = renderWithTheme(
339
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
364
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
340
365
  );
341
- const hostInputs = UNSAFE_getAllByType("input" as any);
342
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
366
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
367
+ const fileInput = hostInputs.find(
368
+ (node: ReactTestInstance) => node.props?.type === "file"
369
+ ) as ReactTestInstance;
343
370
  const fakeFile = new File(["x"], "y.txt", {type: "text/plain"});
344
371
  await act(async () => {
345
372
  fileInput.props.onChange({target: {files: [fakeFile], value: ""}});
@@ -362,7 +389,7 @@ describe("DocumentStorageBrowser", () => {
362
389
  folders: ["sub-folder/"],
363
390
  };
364
391
  const {toJSON} = renderWithTheme(
365
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
392
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
366
393
  );
367
394
  expect(toJSON()).toBeDefined();
368
395
  });
@@ -391,7 +418,7 @@ describe("DocumentStorageBrowser", () => {
391
418
  folders: [],
392
419
  };
393
420
  const {toJSON} = renderWithTheme(
394
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
421
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
395
422
  );
396
423
  expect(toJSON()).toBeDefined();
397
424
  });
@@ -79,7 +79,7 @@ export const DocumentStorageBrowser: React.FC<DocumentStorageBrowserProps> = ({
79
79
  data: DocumentListResponse | undefined;
80
80
  isLoading: boolean;
81
81
  isError: boolean;
82
- error: any;
82
+ error: {status?: number; originalStatus?: number} | undefined;
83
83
  refetch: () => void;
84
84
  };
85
85
  const [uploadFile, {isLoading: isUploading}] = useUploadMutation();
@@ -391,7 +391,7 @@ export const DocumentStorageBrowser: React.FC<DocumentStorageBrowserProps> = ({
391
391
  );
392
392
 
393
393
  const tableData = useMemo(() => {
394
- const rows: any[][] = [];
394
+ const rows: DataTableCellData[][] = [];
395
395
 
396
396
  for (const folder of listData?.folders ?? []) {
397
397
  const folderName = folder.split("/").filter(Boolean).pop() ?? folder;
@@ -507,8 +507,8 @@ export const DocumentStorageBrowser: React.FC<DocumentStorageBrowserProps> = ({
507
507
  <>
508
508
  <input
509
509
  accept="*/*"
510
- onChange={handleFileChange as any}
511
- ref={fileInputRef as any}
510
+ onChange={handleFileChange}
511
+ ref={fileInputRef}
512
512
  style={{display: "none"}}
513
513
  type="file"
514
514
  />