@terreno/admin-frontend 0.13.3 → 0.14.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 (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 +12 -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 +15 -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 +7 -5
  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 +9 -5
  44. package/dist/useAdminApi.js.map +1 -1
  45. package/dist/useAdminConfig.d.ts +2 -3
  46. package/dist/useAdminConfig.js +1 -0
  47. package/dist/useAdminConfig.js.map +1 -1
  48. package/dist/useAdminScripts.d.ts +2 -3
  49. package/dist/useAdminScripts.js +5 -3
  50. package/dist/useAdminScripts.js.map +1 -1
  51. package/dist/useConfigurationApi.d.ts +11 -8
  52. package/dist/useConfigurationApi.js +6 -4
  53. package/dist/useConfigurationApi.js.map +1 -1
  54. package/dist/useDocumentStorageApi.d.ts +2 -2
  55. package/dist/useDocumentStorageApi.js +8 -6
  56. package/dist/useDocumentStorageApi.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/AdminFieldRenderer.test.tsx +1 -0
  59. package/src/AdminFieldRenderer.tsx +18 -371
  60. package/src/AdminFieldRendererCore.tsx +356 -0
  61. package/src/AdminModelForm.test.tsx +1 -0
  62. package/src/AdminModelForm.tsx +22 -17
  63. package/src/AdminModelList.test.tsx +1 -0
  64. package/src/AdminModelList.tsx +5 -5
  65. package/src/AdminModelTable.test.tsx +1 -0
  66. package/src/AdminModelTable.tsx +11 -10
  67. package/src/AdminNestedArrayField.tsx +91 -26
  68. package/src/AdminObjectPicker.tsx +32 -16
  69. package/src/AdminPrimitiveArrayField.test.tsx +1 -0
  70. package/src/AdminPrimitiveArrayField.tsx +2 -3
  71. package/src/AdminScriptList.test.tsx +1 -0
  72. package/src/AdminScriptList.tsx +2 -3
  73. package/src/AdminScriptRunModal.test.tsx +1 -0
  74. package/src/AdminScriptRunModal.tsx +2 -3
  75. package/src/AdminVersionConfig.test.tsx +21 -0
  76. package/src/AdminVersionConfig.tsx +28 -5
  77. package/src/CheckboxListEditor.test.tsx +1 -0
  78. package/src/ConfigurationScreen.test.tsx +1 -0
  79. package/src/ConfigurationScreen.tsx +43 -29
  80. package/src/ConsentFormEditor.test.tsx +1 -0
  81. package/src/ConsentFormEditor.tsx +34 -18
  82. package/src/ConsentFormList.test.tsx +1 -0
  83. package/src/ConsentFormList.tsx +14 -2
  84. package/src/ConsentResponseViewer.test.tsx +1 -0
  85. package/src/ConsentResponseViewer.tsx +3 -2
  86. package/src/DocumentStorageBrowser.test.tsx +1 -0
  87. package/src/DocumentStorageBrowser.tsx +4 -4
  88. package/src/LocaleContentEditor.test.tsx +1 -0
  89. package/src/isolated/AdminFieldRenderer.isolated.tsx +1 -0
  90. package/src/isolated/AdminNestedArrayField.isolated.tsx +1 -0
  91. package/src/isolated/AdminObjectPicker.isolated.tsx +1 -0
  92. package/src/isolated/AdminRefField.isolated.tsx +1 -0
  93. package/src/isolated/AdminScriptRunModal.isolated.tsx +1 -0
  94. package/src/isolated/DocumentStorageBrowser.isolated.tsx +1 -0
  95. package/src/isolated/hooks.isolated.tsx +1 -0
  96. package/src/types.ts +34 -4
  97. package/src/useAdminApi.ts +22 -13
  98. package/src/useAdminConfig.ts +4 -4
  99. package/src/useAdminScripts.ts +8 -7
  100. package/src/useConfigurationApi.ts +25 -12
  101. package/src/useDocumentStorageApi.ts +11 -9
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -15,6 +15,7 @@ import {
15
15
  useToast,
16
16
  } from "@terreno/ui";
17
17
  import React, {useCallback, useEffect, useMemo, useState} from "react";
18
+ import type {AdminApi, EndpointBuilder} from "./types";
18
19
  import {useAdminApi} from "./useAdminApi";
19
20
 
20
21
  interface CheckboxConfig {
@@ -23,13 +24,33 @@ interface CheckboxConfig {
23
24
  confirmationPrompt?: string;
24
25
  }
25
26
 
27
+ /** Consent form document — shape comes from the consumer's Mongoose model. */
28
+ interface ConsentFormDocument {
29
+ _id?: string;
30
+ title?: string;
31
+ slug?: string;
32
+ type?: string;
33
+ order?: number;
34
+ required?: boolean;
35
+ active?: boolean;
36
+ captureSignature?: boolean;
37
+ requireScrollToBottom?: boolean;
38
+ defaultLocale?: string;
39
+ agreeButtonText?: string;
40
+ allowDecline?: boolean;
41
+ declineButtonText?: string;
42
+ content?: Record<string, string>;
43
+ checkboxes?: CheckboxConfig[];
44
+ [key: string]: unknown;
45
+ }
46
+
26
47
  interface ConsentFormEditorProps {
27
48
  baseUrl: string;
28
- api: any;
49
+ api: AdminApi;
29
50
  id?: string;
30
51
  supportedLocales?: string[];
31
52
  hasAiSupport?: boolean;
32
- onSave?: (form: any) => void;
53
+ onSave?: (form: ConsentFormDocument | undefined) => void;
33
54
  onCancel?: () => void;
34
55
  }
35
56
 
@@ -116,7 +137,7 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
116
137
  const enhancedApi = useMemo(
117
138
  () =>
118
139
  api.injectEndpoints({
119
- endpoints: (build: any) => ({
140
+ endpoints: (build: EndpointBuilder) => ({
120
141
  generateConsentContent: build.mutation({
121
142
  query: (body: {type: string; description: string; locale: string}) => ({
122
143
  body,
@@ -143,17 +164,12 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
143
164
  [api, consentApiPath]
144
165
  );
145
166
 
146
- const [publishConsentForm, {isLoading: isPublishing}] = (
147
- enhancedApi as any
148
- ).usePublishConsentFormMutation();
149
-
150
- const [generateContent, {isLoading: isGenerating}] = (
151
- enhancedApi as any
152
- ).useGenerateConsentContentMutation();
153
-
154
- const [translateContent, {isLoading: isTranslating}] = (
155
- enhancedApi as any
156
- ).useTranslateConsentContentMutation();
167
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
168
+ const enhanced = enhancedApi as any;
169
+ const [publishConsentForm, {isLoading: isPublishing}] = enhanced.usePublishConsentFormMutation();
170
+ const [generateContent, {isLoading: isGenerating}] = enhanced.useGenerateConsentContentMutation();
171
+ const [translateContent, {isLoading: isTranslating}] =
172
+ enhanced.useTranslateConsentContentMutation();
157
173
 
158
174
  const {data: formData, isLoading: isFormLoading} = useReadQuery(id ?? "", {
159
175
  skip: !isEditMode || !id,
@@ -224,7 +240,7 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
224
240
  }, []);
225
241
 
226
242
  const handleCheckboxChange = useCallback(
227
- (index: number, field: keyof CheckboxConfig, value: any) => {
243
+ (index: number, field: keyof CheckboxConfig, value: string | boolean) => {
228
244
  setCheckboxes((prev) => {
229
245
  const updated = [...prev];
230
246
  updated[index] = {...updated[index], [field]: value};
@@ -285,11 +301,11 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
285
301
  const payload = buildPayload();
286
302
 
287
303
  try {
288
- let result: any;
304
+ let result: ConsentFormDocument | undefined;
289
305
  if (isEditMode && id) {
290
- result = await updateForm({body: payload, id}).unwrap();
306
+ result = (await updateForm({body: payload, id}).unwrap()) as ConsentFormDocument;
291
307
  } else {
292
- result = await createForm(payload).unwrap();
308
+ result = (await createForm(payload).unwrap()) as ConsentFormDocument;
293
309
  }
294
310
  console.info("Consent form saved", {id: result?._id ?? id});
295
311
  onSave?.(result);
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -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,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -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,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -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
  />
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
3
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
4
  import React from "react";
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  /**
2
3
  * Tests for admin-frontend hooks: useAdminApi, useAdminConfig,
3
4
  * useAdminScripts, useConfigurationApi, useDocumentStorageApi.
package/src/types.ts CHANGED
@@ -1,12 +1,42 @@
1
1
  import type {Api} from "@reduxjs/toolkit/query/react";
2
2
  import type React from "react";
3
3
 
4
+ /**
5
+ * Type alias for an RTK Query API instance with type-erased generic parameters.
6
+ *
7
+ * The admin panel dynamically injects endpoints into the consumer's RTK Query API at
8
+ * runtime via `api.injectEndpoints()`. The consumer's API is built from a generated
9
+ * OpenAPI SDK with thousands of distinct endpoint types — there is no shared base
10
+ * type we can constrain to, so the generic parameters are erased.
11
+ */
12
+ // biome-ignore lint/suspicious/noExplicitAny: RTK Query's Api generics are erased at the dynamic endpoint injection boundary
13
+ export type AdminApi = Api<any, any, any, any>;
14
+
15
+ /**
16
+ * Generic field/document value used throughout the admin panel.
17
+ *
18
+ * Admin screens operate over arbitrary Mongoose documents whose field types are not
19
+ * known statically — they are discovered at runtime via the `/admin/config` endpoint.
20
+ * Read sites must narrow with `typeof` checks before passing to typed UI components.
21
+ */
22
+ export type AdminFieldValue = unknown;
23
+
24
+ /**
25
+ * RTK Query's `build` argument from `api.injectEndpoints({ endpoints: (build) => ... })`.
26
+ *
27
+ * The build helper is generic over the full endpoint set; since the admin panel injects
28
+ * endpoints dynamically into a consumer-supplied API, the endpoint shapes are not
29
+ * statically expressible here.
30
+ */
31
+ // biome-ignore lint/suspicious/noExplicitAny: build helper from RTK Query's dynamic injectEndpoints API
32
+ export type EndpointBuilder = any;
33
+
4
34
  export interface AdminFieldConfig {
5
35
  type: string;
6
36
  required: boolean;
7
37
  description?: string;
8
38
  enum?: string[];
9
- default?: any;
39
+ default?: AdminFieldValue;
10
40
  ref?: string;
11
41
  searchable?: boolean;
12
42
  widget?: string;
@@ -78,7 +108,7 @@ export interface BackgroundTask {
78
108
 
79
109
  export interface AdminScreenProps {
80
110
  baseUrl: string;
81
- api: Api<any, any, any, any>;
111
+ api: AdminApi;
82
112
  }
83
113
 
84
114
  /**
@@ -86,7 +116,7 @@ export interface AdminScreenProps {
86
116
  * custom renderer is a drop-in replacement.
87
117
  */
88
118
  export interface RefFieldRendererProps {
89
- api: Api<any, any, any, any>;
119
+ api: AdminApi;
90
120
  baseUrl: string;
91
121
  routePath: string;
92
122
  refModelName: string;
@@ -125,7 +155,7 @@ export interface DocumentListResponse {
125
155
  }
126
156
 
127
157
  export interface DocumentStorageBrowserProps {
128
- api: Api<any, any, any, any>;
158
+ api: AdminApi;
129
159
  basePath: string;
130
160
  title?: string;
131
161
  allowDelete?: boolean;
@@ -1,5 +1,10 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {useMemo} from "react";
2
+ import type {AdminApi, EndpointBuilder} from "./types";
3
+
4
+ // biome-ignore lint/suspicious/noExplicitAny: payload bodies vary across admin models — handled at runtime
5
+ type AdminPayload = any;
6
+ // biome-ignore lint/suspicious/noExplicitAny: RTK Query tag callback args have a complex generic shape we erase here
7
+ type TagArg = any;
3
8
 
4
9
  /**
5
10
  * Hook that generates RTK Query CRUD hooks for a specific admin model.
@@ -44,7 +49,7 @@ import {useMemo} from "react";
44
49
  * @see useAdminConfig for fetching model configurations
45
50
  * @see AdminModelTable for usage in the table view
46
51
  */
47
- export const useAdminApi = (api: Api<any, any, any, any>, routePath: string, modelName: string) => {
52
+ export const useAdminApi = (api: AdminApi, routePath: string, modelName: string) => {
48
53
  const enhancedApi = useMemo(() => {
49
54
  const listKey = `adminList_${modelName}`;
50
55
  const readKey = `adminRead_${modelName}`;
@@ -54,17 +59,17 @@ export const useAdminApi = (api: Api<any, any, any, any>, routePath: string, mod
54
59
 
55
60
  const tagType = `admin_${modelName}`;
56
61
  return api.enhanceEndpoints({addTagTypes: [tagType]}).injectEndpoints({
57
- endpoints: (build: any) => ({
62
+ endpoints: (build: EndpointBuilder) => ({
58
63
  [listKey]: build.query({
59
64
  providesTags: [`admin_${modelName}`],
60
- query: (params: any) => ({
65
+ query: (params: Record<string, unknown> | undefined) => ({
61
66
  method: "GET",
62
67
  params: params ?? {},
63
68
  url: routePath,
64
69
  }),
65
70
  }),
66
71
  [readKey]: build.query({
67
- providesTags: (_result: any, _error: any, id: string) => [
72
+ providesTags: (_result: TagArg, _error: TagArg, id: string) => [
68
73
  {id, type: `admin_${modelName}`},
69
74
  ],
70
75
  query: (id: string) => ({
@@ -74,18 +79,18 @@ export const useAdminApi = (api: Api<any, any, any, any>, routePath: string, mod
74
79
  }),
75
80
  [createKey]: build.mutation({
76
81
  invalidatesTags: [`admin_${modelName}`],
77
- query: (body: any) => ({
82
+ query: (body: AdminPayload) => ({
78
83
  body,
79
84
  method: "POST",
80
85
  url: routePath,
81
86
  }),
82
87
  }),
83
88
  [updateKey]: build.mutation({
84
- invalidatesTags: (_result: any, _error: any, {id}: {id: string}) => [
89
+ invalidatesTags: (_result: TagArg, _error: TagArg, {id}: {id: string}) => [
85
90
  {id, type: `admin_${modelName}`},
86
91
  `admin_${modelName}`,
87
92
  ],
88
- query: ({id, body}: {id: string; body: any}) => ({
93
+ query: ({id, body}: {id: string; body: AdminPayload}) => ({
89
94
  body,
90
95
  method: "PATCH",
91
96
  url: `${routePath}/${id}`,
@@ -111,11 +116,15 @@ export const useAdminApi = (api: Api<any, any, any, any>, routePath: string, mod
111
116
  const updateKey = `adminUpdate_${modelName}`;
112
117
  const deleteKey = `adminDelete_${modelName}`;
113
118
 
119
+ // RTK Query generates these hook names dynamically from the endpoint keys; the resulting
120
+ // shape is not statically expressible through @reduxjs/toolkit's public types.
121
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
122
+ const enhanced = enhancedApi as any;
114
123
  return {
115
- useCreateMutation: (enhancedApi as any)[`use${capitalize(createKey)}Mutation`],
116
- useDeleteMutation: (enhancedApi as any)[`use${capitalize(deleteKey)}Mutation`],
117
- useListQuery: (enhancedApi as any)[`use${capitalize(listKey)}Query`],
118
- useReadQuery: (enhancedApi as any)[`use${capitalize(readKey)}Query`],
119
- useUpdateMutation: (enhancedApi as any)[`use${capitalize(updateKey)}Mutation`],
124
+ useCreateMutation: enhanced[`use${capitalize(createKey)}Mutation`],
125
+ useDeleteMutation: enhanced[`use${capitalize(deleteKey)}Mutation`],
126
+ useListQuery: enhanced[`use${capitalize(listKey)}Query`],
127
+ useReadQuery: enhanced[`use${capitalize(readKey)}Query`],
128
+ useUpdateMutation: enhanced[`use${capitalize(updateKey)}Mutation`],
120
129
  };
121
130
  };
@@ -1,6 +1,5 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {useMemo} from "react";
3
- import type {AdminConfigResponse} from "./types";
2
+ import type {AdminApi, AdminConfigResponse, EndpointBuilder} from "./types";
4
3
 
5
4
  const ENDPOINT_NAME = "adminConfig";
6
5
 
@@ -33,10 +32,10 @@ const ENDPOINT_NAME = "adminConfig";
33
32
  * @see AdminConfigResponse for the returned configuration structure
34
33
  * @see AdminModelList for usage in the model list screen
35
34
  */
36
- export const useAdminConfig = (api: Api<any, any, any, any>, baseUrl: string) => {
35
+ export const useAdminConfig = (api: AdminApi, baseUrl: string) => {
37
36
  const enhancedApi = useMemo(() => {
38
37
  return api.injectEndpoints({
39
- endpoints: (build: any) => ({
38
+ endpoints: (build: EndpointBuilder) => ({
40
39
  [ENDPOINT_NAME]: build.query({
41
40
  query: () => ({
42
41
  method: "GET",
@@ -48,6 +47,7 @@ export const useAdminConfig = (api: Api<any, any, any, any>, baseUrl: string) =>
48
47
  });
49
48
  }, [api, baseUrl]);
50
49
 
50
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
51
51
  const useConfigQuery = (enhancedApi as any).useAdminConfigQuery;
52
52
 
53
53
  const {data, isLoading, error} = useConfigQuery();
@@ -1,11 +1,10 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {useMemo} from "react";
3
- import type {BackgroundTask} from "./types";
2
+ import type {AdminApi, BackgroundTask, EndpointBuilder} from "./types";
4
3
 
5
- export const useAdminScripts = (api: Api<any, any, any, any>, baseUrl: string) => {
4
+ export const useAdminScripts = (api: AdminApi, baseUrl: string) => {
6
5
  const enhancedApi = useMemo(() => {
7
6
  return api.injectEndpoints({
8
- endpoints: (build: any) => ({
7
+ endpoints: (build: EndpointBuilder) => ({
9
8
  adminCancelScriptTask: build.mutation({
10
9
  invalidatesTags: ["admin_scriptTask"],
11
10
  query: (taskId: string) => ({
@@ -31,16 +30,18 @@ export const useAdminScripts = (api: Api<any, any, any, any>, baseUrl: string) =
31
30
  });
32
31
  }, [api, baseUrl]);
33
32
 
33
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
34
+ const enhanced = enhancedApi as any;
34
35
  return {
35
- useCancelScriptTaskMutation: (enhancedApi as any).useAdminCancelScriptTaskMutation as () => [
36
+ useCancelScriptTaskMutation: enhanced.useAdminCancelScriptTaskMutation as () => [
36
37
  (taskId: string) => {unwrap: () => Promise<{task: BackgroundTask; message: string}>},
37
38
  {isLoading: boolean},
38
39
  ],
39
- useGetScriptTaskQuery: (enhancedApi as any).useAdminGetScriptTaskQuery as (
40
+ useGetScriptTaskQuery: enhanced.useAdminGetScriptTaskQuery as (
40
41
  taskId: string,
41
42
  options?: {skip?: boolean; pollingInterval?: number}
42
43
  ) => {data: {task: BackgroundTask} | undefined; isLoading: boolean; error: unknown},
43
- useRunScriptMutation: (enhancedApi as any).useAdminRunScriptMutation as () => [
44
+ useRunScriptMutation: enhanced.useAdminRunScriptMutation as () => [
44
45
  (args: {name: string; wetRun: boolean}) => {unwrap: () => Promise<{taskId: string}>},
45
46
  {isLoading: boolean},
46
47
  ],
@@ -1,16 +1,27 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {useMemo} from "react";
2
+ import type {AdminApi, EndpointBuilder} from "./types";
3
+
4
+ // The configuration document shape varies per consumer — different apps register different
5
+ // configuration sections via @terreno/api's Configuration model.
6
+ // biome-ignore lint/suspicious/noExplicitAny: configuration values are heterogeneous per consumer
7
+ type ConfigBody = any;
8
+ // biome-ignore lint/suspicious/noExplicitAny: RTK Query's hook return shape varies per endpoint
9
+ type RtkHookResult = any;
10
+ // biome-ignore lint/suspicious/noExplicitAny: RTK Query's mutation trigger has a complex generic shape
11
+ type RtkMutationTrigger = any;
12
+ // biome-ignore lint/suspicious/noExplicitAny: RTK Query's error union type erases at the hook boundary
13
+ type RtkError = any;
3
14
 
4
15
  interface UseConfigurationApiOptions {
5
- api: Api<any, any, any, any>;
16
+ api: AdminApi;
6
17
  basePath: string;
7
18
  }
8
19
 
9
20
  interface UseConfigurationApiResult {
10
- useMetaQuery: () => {data: any; isLoading: boolean; error: any};
11
- useRefreshSecretsMutation: () => [any, {isLoading: boolean}];
12
- useUpdateMutation: () => [any, {isLoading: boolean}];
13
- useValuesQuery: () => {data: any; isLoading: boolean; error: any};
21
+ useMetaQuery: () => {data: RtkHookResult; isLoading: boolean; error: RtkError};
22
+ useRefreshSecretsMutation: () => [RtkMutationTrigger, {isLoading: boolean}];
23
+ useUpdateMutation: () => [RtkMutationTrigger, {isLoading: boolean}];
24
+ useValuesQuery: () => {data: RtkHookResult; isLoading: boolean; error: RtkError};
14
25
  }
15
26
 
16
27
  /**
@@ -28,7 +39,7 @@ export const useConfigurationApi = ({
28
39
  }: UseConfigurationApiOptions): UseConfigurationApiResult => {
29
40
  const enhancedApi = useMemo(() => {
30
41
  return api.enhanceEndpoints({addTagTypes: ["configuration"]}).injectEndpoints({
31
- endpoints: (build: any) => ({
42
+ endpoints: (build: EndpointBuilder) => ({
32
43
  configMeta: build.query({
33
44
  query: () => ({
34
45
  method: "GET",
@@ -43,7 +54,7 @@ export const useConfigurationApi = ({
43
54
  }),
44
55
  configUpdate: build.mutation({
45
56
  invalidatesTags: ["configuration"],
46
- query: (body: any) => ({
57
+ query: (body: ConfigBody) => ({
47
58
  body,
48
59
  method: "PATCH",
49
60
  url: basePath,
@@ -61,10 +72,12 @@ export const useConfigurationApi = ({
61
72
  });
62
73
  }, [api, basePath]);
63
74
 
75
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
76
+ const enhanced = enhancedApi as any;
64
77
  return {
65
- useMetaQuery: (enhancedApi as any).useConfigMetaQuery,
66
- useRefreshSecretsMutation: (enhancedApi as any).useConfigRefreshSecretsMutation,
67
- useUpdateMutation: (enhancedApi as any).useConfigUpdateMutation,
68
- useValuesQuery: (enhancedApi as any).useConfigValuesQuery,
78
+ useMetaQuery: enhanced.useConfigMetaQuery,
79
+ useRefreshSecretsMutation: enhanced.useConfigRefreshSecretsMutation,
80
+ useUpdateMutation: enhanced.useConfigUpdateMutation,
81
+ useValuesQuery: enhanced.useConfigValuesQuery,
69
82
  };
70
83
  };
@@ -1,10 +1,10 @@
1
- import type {Api} from "@reduxjs/toolkit/query/react";
2
1
  import {useMemo} from "react";
2
+ import type {AdminApi, EndpointBuilder} from "./types";
3
3
 
4
- export const useDocumentStorageApi = (api: Api<any, any, any, any>, basePath: string) => {
4
+ export const useDocumentStorageApi = (api: AdminApi, basePath: string) => {
5
5
  const enhancedApi = useMemo(() => {
6
6
  return api.injectEndpoints({
7
- endpoints: (build: any) => ({
7
+ endpoints: (build: EndpointBuilder) => ({
8
8
  documentStorageCreateFolder: build.mutation({
9
9
  invalidatesTags: ["documentStorage"],
10
10
  query: ({folderName, prefix}: {folderName: string; prefix?: string}) => ({
@@ -85,12 +85,14 @@ export const useDocumentStorageApi = (api: Api<any, any, any, any>, basePath: st
85
85
  });
86
86
  }, [api, basePath]);
87
87
 
88
+ // biome-ignore lint/suspicious/noExplicitAny: dynamic hook lookup on RTK Query enhanced API
89
+ const enhanced = enhancedApi as any;
88
90
  return {
89
- useCreateFolderMutation: (enhancedApi as any).useDocumentStorageCreateFolderMutation,
90
- useDeleteFolderMutation: (enhancedApi as any).useDocumentStorageDeleteFolderMutation,
91
- useDeleteMutation: (enhancedApi as any).useDocumentStorageDeleteMutation,
92
- useLazyDownloadQuery: (enhancedApi as any).useLazyDocumentStorageDownloadQuery,
93
- useListQuery: (enhancedApi as any).useDocumentStorageListQuery,
94
- useUploadMutation: (enhancedApi as any).useDocumentStorageUploadMutation,
91
+ useCreateFolderMutation: enhanced.useDocumentStorageCreateFolderMutation,
92
+ useDeleteFolderMutation: enhanced.useDocumentStorageDeleteFolderMutation,
93
+ useDeleteMutation: enhanced.useDocumentStorageDeleteMutation,
94
+ useLazyDownloadQuery: enhanced.useLazyDocumentStorageDownloadQuery,
95
+ useListQuery: enhanced.useDocumentStorageListQuery,
96
+ useUploadMutation: enhanced.useDocumentStorageUploadMutation,
95
97
  };
96
98
  };