@terreno/admin-frontend 57.2.0 → 57.4.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 (390) hide show
  1. package/.ai/guidelines/core.md +14 -7
  2. package/README.md +6 -2
  3. package/dist/AdminConflictSheet.d.ts +16 -0
  4. package/dist/AdminConflictSheet.js +52 -0
  5. package/dist/AdminConflictSheet.js.map +1 -0
  6. package/dist/AdminHome.js +2 -1
  7. package/dist/AdminHome.js.map +1 -1
  8. package/dist/AdminMigrations.d.ts +3 -0
  9. package/dist/AdminMigrations.js +19 -0
  10. package/dist/AdminMigrations.js.map +1 -0
  11. package/dist/AdminMigrationsView.d.ts +10 -0
  12. package/dist/AdminMigrationsView.js +94 -0
  13. package/dist/AdminMigrationsView.js.map +1 -0
  14. package/dist/AdminModelForm.js +190 -44
  15. package/dist/AdminModelForm.js.map +1 -1
  16. package/dist/AdminModelTable.js +315 -27
  17. package/dist/AdminModelTable.js.map +1 -1
  18. package/dist/AdminObjectPicker.js +30 -6
  19. package/dist/AdminObjectPicker.js.map +1 -1
  20. package/dist/AdminProvider.d.ts +6 -2
  21. package/dist/AdminProvider.js +29 -7
  22. package/dist/AdminProvider.js.map +1 -1
  23. package/dist/AdminScreenPage.d.ts +18 -0
  24. package/dist/AdminScreenPage.js +35 -0
  25. package/dist/AdminScreenPage.js.map +1 -0
  26. package/dist/AdminScreenRouter.d.ts +1 -1
  27. package/dist/AdminScreenRouter.js +8 -3
  28. package/dist/AdminScreenRouter.js.map +1 -1
  29. package/dist/AdminShell.d.ts +7 -3
  30. package/dist/AdminShell.js +53 -24
  31. package/dist/AdminShell.js.map +1 -1
  32. package/dist/AdminVersionConfig.js +21 -2
  33. package/dist/AdminVersionConfig.js.map +1 -1
  34. package/dist/AnnouncementEditor.d.ts +45 -0
  35. package/dist/AnnouncementEditor.js +370 -0
  36. package/dist/AnnouncementEditor.js.map +1 -0
  37. package/dist/AnnouncementList.d.ts +15 -0
  38. package/dist/AnnouncementList.js +97 -0
  39. package/dist/AnnouncementList.js.map +1 -0
  40. package/dist/AnnouncementOverview.d.ts +46 -0
  41. package/dist/AnnouncementOverview.js +101 -0
  42. package/dist/AnnouncementOverview.js.map +1 -0
  43. package/dist/AnnouncementOverviewScreenWidget.d.ts +4 -0
  44. package/dist/AnnouncementOverviewScreenWidget.js +28 -0
  45. package/dist/AnnouncementOverviewScreenWidget.js.map +1 -0
  46. package/dist/ConsentFormEditor.js +20 -3
  47. package/dist/ConsentFormEditor.js.map +1 -1
  48. package/dist/DocumentStorageBrowser.js +6 -89
  49. package/dist/DocumentStorageBrowser.js.map +1 -1
  50. package/dist/adminApiQueryParams.d.ts +5 -0
  51. package/dist/adminApiQueryParams.js +25 -0
  52. package/dist/adminApiQueryParams.js.map +1 -0
  53. package/dist/adminConflictSheetStack.d.ts +17 -0
  54. package/dist/adminConflictSheetStack.js +64 -0
  55. package/dist/adminConflictSheetStack.js.map +1 -0
  56. package/dist/adminContext.d.ts +3 -0
  57. package/dist/adminContext.js +6 -0
  58. package/dist/adminContext.js.map +1 -0
  59. package/dist/adminModelListQueryParams.d.ts +3 -2
  60. package/dist/adminModelListQueryParams.js +74 -27
  61. package/dist/adminModelListQueryParams.js.map +1 -1
  62. package/dist/adminRequest.d.ts +51 -0
  63. package/dist/adminRequest.js +161 -0
  64. package/dist/adminRequest.js.map +1 -0
  65. package/dist/adminRpc.d.ts +7 -0
  66. package/dist/adminRpc.js +21 -0
  67. package/dist/adminRpc.js.map +1 -0
  68. package/dist/adminShellNav.d.ts +17 -1
  69. package/dist/adminShellNav.js +41 -9
  70. package/dist/adminShellNav.js.map +1 -1
  71. package/dist/adminWindowRefresh.d.ts +31 -0
  72. package/dist/adminWindowRefresh.js +48 -0
  73. package/dist/adminWindowRefresh.js.map +1 -0
  74. package/dist/adminWindowedTable.d.ts +13 -0
  75. package/dist/adminWindowedTable.js +33 -0
  76. package/dist/adminWindowedTable.js.map +1 -0
  77. package/dist/comms/CommsDashboardScreen.d.ts +10 -0
  78. package/dist/comms/CommsDashboardScreen.js +183 -0
  79. package/dist/comms/CommsDashboardScreen.js.map +1 -0
  80. package/dist/comms/CommsDashboardScreenWidget.d.ts +4 -0
  81. package/dist/comms/CommsDashboardScreenWidget.js +11 -0
  82. package/dist/comms/CommsDashboardScreenWidget.js.map +1 -0
  83. package/dist/comms/CommsMessageDetail.d.ts +8 -0
  84. package/dist/comms/CommsMessageDetail.js +50 -0
  85. package/dist/comms/CommsMessageDetail.js.map +1 -0
  86. package/dist/comms/CommsStatCard.d.ts +17 -0
  87. package/dist/comms/CommsStatCard.js +14 -0
  88. package/dist/comms/CommsStatCard.js.map +1 -0
  89. package/dist/comms/CommsStatusBadge.d.ts +5 -0
  90. package/dist/comms/CommsStatusBadge.js +14 -0
  91. package/dist/comms/CommsStatusBadge.js.map +1 -0
  92. package/dist/comms/commsDashboardParams.d.ts +13 -0
  93. package/dist/comms/commsDashboardParams.js +71 -0
  94. package/dist/comms/commsDashboardParams.js.map +1 -0
  95. package/dist/comms/commsMessagePayload.d.ts +50 -0
  96. package/dist/comms/commsMessagePayload.js +43 -0
  97. package/dist/comms/commsMessagePayload.js.map +1 -0
  98. package/dist/comms/commsRetrySummary.d.ts +4 -0
  99. package/dist/comms/commsRetrySummary.js +12 -0
  100. package/dist/comms/commsRetrySummary.js.map +1 -0
  101. package/dist/comms/useCommsDashboardApi.d.ts +78 -0
  102. package/dist/comms/useCommsDashboardApi.js +101 -0
  103. package/dist/comms/useCommsDashboardApi.js.map +1 -0
  104. package/dist/comms/useCommsDashboardUrlFilters.d.ts +5 -0
  105. package/dist/comms/useCommsDashboardUrlFilters.js +16 -0
  106. package/dist/comms/useCommsDashboardUrlFilters.js.map +1 -0
  107. package/dist/index.d.ts +31 -2
  108. package/dist/index.js +30 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/isAuditLogModel.d.ts +2 -0
  111. package/dist/isAuditLogModel.js +8 -0
  112. package/dist/isAuditLogModel.js.map +1 -0
  113. package/dist/jobs/JobsDashboardScreen.d.ts +10 -0
  114. package/dist/jobs/JobsDashboardScreen.js +155 -0
  115. package/dist/jobs/JobsDashboardScreen.js.map +1 -0
  116. package/dist/jobs/JobsDashboardScreenWidget.d.ts +4 -0
  117. package/dist/jobs/JobsDashboardScreenWidget.js +11 -0
  118. package/dist/jobs/JobsDashboardScreenWidget.js.map +1 -0
  119. package/dist/jobs/JobsHomeWidget.d.ts +4 -0
  120. package/dist/jobs/JobsHomeWidget.js +21 -0
  121. package/dist/jobs/JobsHomeWidget.js.map +1 -0
  122. package/dist/jobs/JobsJobDetail.d.ts +8 -0
  123. package/dist/jobs/JobsJobDetail.js +78 -0
  124. package/dist/jobs/JobsJobDetail.js.map +1 -0
  125. package/dist/jobs/JobsStatusBadge.d.ts +5 -0
  126. package/dist/jobs/JobsStatusBadge.js +16 -0
  127. package/dist/jobs/JobsStatusBadge.js.map +1 -0
  128. package/dist/jobs/jobPayload.d.ts +62 -0
  129. package/dist/jobs/jobPayload.js +54 -0
  130. package/dist/jobs/jobPayload.js.map +1 -0
  131. package/dist/jobs/jobsDashboardParams.d.ts +11 -0
  132. package/dist/jobs/jobsDashboardParams.js +70 -0
  133. package/dist/jobs/jobsDashboardParams.js.map +1 -0
  134. package/dist/jobs/useJobsDashboardApi.d.ts +60 -0
  135. package/dist/jobs/useJobsDashboardApi.js +88 -0
  136. package/dist/jobs/useJobsDashboardApi.js.map +1 -0
  137. package/dist/jobs/useJobsDashboardUrlFilters.d.ts +5 -0
  138. package/dist/jobs/useJobsDashboardUrlFilters.js +16 -0
  139. package/dist/jobs/useJobsDashboardUrlFilters.js.map +1 -0
  140. package/dist/orgs/OrgDirectoryScreen.d.ts +16 -0
  141. package/dist/orgs/OrgDirectoryScreen.js +81 -0
  142. package/dist/orgs/OrgDirectoryScreen.js.map +1 -0
  143. package/dist/orgs/OrgMembersScreen.d.ts +9 -0
  144. package/dist/orgs/OrgMembersScreen.js +115 -0
  145. package/dist/orgs/OrgMembersScreen.js.map +1 -0
  146. package/dist/orgs/OrgSettingsScreen.d.ts +9 -0
  147. package/dist/orgs/OrgSettingsScreen.js +80 -0
  148. package/dist/orgs/OrgSettingsScreen.js.map +1 -0
  149. package/dist/orgs/OrgSwitcher.d.ts +8 -0
  150. package/dist/orgs/OrgSwitcher.js +58 -0
  151. package/dist/orgs/OrgSwitcher.js.map +1 -0
  152. package/dist/orgs/adminModelEndpoints.d.ts +18 -0
  153. package/dist/orgs/adminModelEndpoints.js +73 -0
  154. package/dist/orgs/adminModelEndpoints.js.map +1 -0
  155. package/dist/orgs/normalizeListData.d.ts +9 -0
  156. package/dist/orgs/normalizeListData.js +8 -0
  157. package/dist/orgs/normalizeListData.js.map +1 -0
  158. package/dist/orgs/organizationSettings.d.ts +17 -0
  159. package/dist/orgs/organizationSettings.js +6 -0
  160. package/dist/orgs/organizationSettings.js.map +1 -0
  161. package/dist/orgs/shouldSkipOrgScopedAdminQuery.d.ts +4 -0
  162. package/dist/orgs/shouldSkipOrgScopedAdminQuery.js +2 -0
  163. package/dist/orgs/shouldSkipOrgScopedAdminQuery.js.map +1 -0
  164. package/dist/orgs/sortOrganizations.d.ts +6 -0
  165. package/dist/orgs/sortOrganizations.js +9 -0
  166. package/dist/orgs/sortOrganizations.js.map +1 -0
  167. package/dist/orgs/useOrgContext.d.ts +20 -0
  168. package/dist/orgs/useOrgContext.js +57 -0
  169. package/dist/orgs/useOrgContext.js.map +1 -0
  170. package/dist/orgs/useOrganizationsApi.d.ts +14 -0
  171. package/dist/orgs/useOrganizationsApi.js +103 -0
  172. package/dist/orgs/useOrganizationsApi.js.map +1 -0
  173. package/dist/pdfUtils.d.ts +0 -2
  174. package/dist/pdfUtils.js +2 -2
  175. package/dist/pdfUtils.js.map +1 -1
  176. package/dist/types.d.ts +102 -4
  177. package/dist/types.js.map +1 -1
  178. package/dist/useAdminApi.js +7 -61
  179. package/dist/useAdminApi.js.map +1 -1
  180. package/dist/useAdminBackgroundTask.d.ts +11 -3
  181. package/dist/useAdminBackgroundTask.js +18 -3
  182. package/dist/useAdminBackgroundTask.js.map +1 -1
  183. package/dist/useAdminConfig.js +16 -1
  184. package/dist/useAdminConfig.js.map +1 -1
  185. package/dist/useAdminMigrations.d.ts +40 -0
  186. package/dist/useAdminMigrations.js +43 -0
  187. package/dist/useAdminMigrations.js.map +1 -0
  188. package/dist/useAdminRoles.d.ts +1 -0
  189. package/dist/useAdminRoles.js +34 -0
  190. package/dist/useAdminRoles.js.map +1 -1
  191. package/dist/useAdminRpc.d.ts +28 -0
  192. package/dist/useAdminRpc.js +128 -0
  193. package/dist/useAdminRpc.js.map +1 -0
  194. package/dist/useAdminScripts.js +51 -0
  195. package/dist/useAdminScripts.js.map +1 -1
  196. package/dist/useConfigurationApi.d.ts +13 -15
  197. package/dist/useConfigurationApi.js +23 -0
  198. package/dist/useConfigurationApi.js.map +1 -1
  199. package/dist/useConsentHistory.js +9 -1
  200. package/dist/useConsentHistory.js.map +1 -1
  201. package/dist/useDocumentStorageApi.js +72 -0
  202. package/dist/useDocumentStorageApi.js.map +1 -1
  203. package/dist/widgets/AIRequestsScreenWidget.js +21 -10
  204. package/dist/widgets/AIRequestsScreenWidget.js.map +1 -1
  205. package/dist/widgets/DocumentsScreenWidget.js +2 -2
  206. package/dist/widgets/DocumentsScreenWidget.js.map +1 -1
  207. package/dist/widgets/ModelsGridWidget.js +10 -3
  208. package/dist/widgets/ModelsGridWidget.js.map +1 -1
  209. package/dist/widgets/RecentActivityWidget.js +11 -4
  210. package/dist/widgets/RecentActivityWidget.js.map +1 -1
  211. package/dist/widgets/builtInWidgets.js +6 -9
  212. package/dist/widgets/builtInWidgets.js.map +1 -1
  213. package/dist/widgets/homeWidgetUtils.d.ts +0 -1
  214. package/dist/widgets/homeWidgetUtils.js +0 -8
  215. package/dist/widgets/homeWidgetUtils.js.map +1 -1
  216. package/package.json +21 -5
  217. package/src/AdminActionMenu.test.tsx +168 -1
  218. package/src/AdminBreadcrumbs.test.tsx +22 -2
  219. package/src/AdminConflictSheet.test.tsx +173 -0
  220. package/src/AdminConflictSheet.tsx +102 -0
  221. package/src/AdminFieldRenderer.test.tsx +6 -1
  222. package/src/AdminHome.test.tsx +11 -12
  223. package/src/AdminHome.tsx +2 -4
  224. package/src/AdminMigrations.tsx +45 -0
  225. package/src/AdminMigrationsView.tsx +225 -0
  226. package/src/{AdminModelForm.test.tsx → AdminModelForm.isolated.tsx} +462 -155
  227. package/src/AdminModelForm.orgSkip.test.tsx +81 -0
  228. package/src/AdminModelForm.tsx +227 -56
  229. package/src/AdminModelForm.updateDepth.test.tsx +427 -0
  230. package/src/AdminModelList.test.tsx +13 -3
  231. package/src/AdminModelTable.test.tsx +561 -58
  232. package/src/AdminModelTable.tsx +430 -73
  233. package/src/AdminModelTable.windowed.test.tsx +897 -0
  234. package/src/AdminObjectPicker.tsx +32 -6
  235. package/src/AdminPrimitiveArrayField.test.tsx +179 -1
  236. package/src/AdminProvider.test.tsx +213 -3
  237. package/src/AdminProvider.tsx +39 -7
  238. package/src/AdminRolesList.test.tsx +198 -1
  239. package/src/AdminScreenPage.test.tsx +81 -0
  240. package/src/AdminScreenPage.tsx +37 -0
  241. package/src/AdminScreenRouter.test.tsx +395 -37
  242. package/src/AdminScreenRouter.tsx +24 -6
  243. package/src/AdminScriptList.test.tsx +181 -1
  244. package/src/AdminShell.test.tsx +596 -2
  245. package/src/AdminShell.tsx +110 -22
  246. package/src/AdminVersionConfig.test.tsx +1 -1
  247. package/src/AdminVersionConfig.tsx +31 -3
  248. package/src/AnnouncementEditor.test.tsx +603 -0
  249. package/src/AnnouncementEditor.tsx +673 -0
  250. package/src/AnnouncementList.test.tsx +198 -0
  251. package/src/AnnouncementList.tsx +214 -0
  252. package/src/AnnouncementOverview.test.tsx +325 -0
  253. package/src/AnnouncementOverview.tsx +325 -0
  254. package/src/AnnouncementOverviewScreenWidget.test.tsx +69 -0
  255. package/src/AnnouncementOverviewScreenWidget.tsx +51 -0
  256. package/src/CheckboxListEditor.test.tsx +9 -2
  257. package/src/ConfigurationScreen.test.tsx +1 -1
  258. package/src/ConsentFormEditor.test.tsx +29 -30
  259. package/src/ConsentFormEditor.tsx +27 -3
  260. package/src/ConsentFormList.test.tsx +13 -12
  261. package/src/ConsentHistory.test.tsx +1 -1
  262. package/src/ConsentResponseViewer.test.tsx +11 -12
  263. package/src/DocumentStorageBrowser.test.tsx +1 -1
  264. package/src/DocumentStorageBrowser.tsx +12 -142
  265. package/src/LocaleContentEditor.test.tsx +1 -1
  266. package/src/adminApiQueryParams.ts +33 -0
  267. package/src/adminConflictSheetStack.ts +87 -0
  268. package/src/adminContext.ts +8 -0
  269. package/src/adminModelListQueryParams.test.ts +118 -0
  270. package/src/adminModelListQueryParams.ts +89 -30
  271. package/src/adminRequest.test.ts +216 -0
  272. package/src/adminRequest.ts +213 -0
  273. package/src/adminRpc.test.ts +18 -0
  274. package/src/adminRpc.ts +31 -0
  275. package/src/adminScriptsHarness.test.ts +21 -0
  276. package/src/adminShellNav.test.ts +72 -6
  277. package/src/adminShellNav.ts +55 -10
  278. package/src/adminWindowRefresh.test.ts +65 -0
  279. package/src/adminWindowRefresh.ts +76 -0
  280. package/src/adminWindowedTable.test.ts +90 -0
  281. package/src/adminWindowedTable.ts +55 -0
  282. package/src/comms/CommsDashboardScreen.test.tsx +397 -0
  283. package/src/comms/CommsDashboardScreen.tsx +500 -0
  284. package/src/comms/CommsDashboardScreenWidget.test.tsx +62 -0
  285. package/src/comms/CommsDashboardScreenWidget.tsx +20 -0
  286. package/src/comms/CommsMessageDetail.test.tsx +245 -0
  287. package/src/comms/CommsMessageDetail.tsx +239 -0
  288. package/src/comms/CommsStatCard.test.tsx +69 -0
  289. package/src/comms/CommsStatCard.tsx +60 -0
  290. package/src/comms/CommsStatusBadge.tsx +14 -0
  291. package/src/comms/commsDashboardParams.test.ts +75 -0
  292. package/src/comms/commsDashboardParams.ts +91 -0
  293. package/src/comms/commsMessagePayload.test.ts +22 -0
  294. package/src/comms/commsMessagePayload.ts +83 -0
  295. package/src/comms/commsRetrySummary.ts +10 -0
  296. package/src/comms/useCommsDashboardApi.test.tsx +144 -0
  297. package/src/comms/useCommsDashboardApi.tsx +181 -0
  298. package/src/comms/useCommsDashboardUrlFilters.test.tsx +58 -0
  299. package/src/comms/useCommsDashboardUrlFilters.tsx +31 -0
  300. package/src/dynamicHookApi.ts +1 -1
  301. package/src/index.tsx +93 -1
  302. package/src/isAuditLogModel.test.ts +14 -0
  303. package/src/isAuditLogModel.ts +11 -0
  304. package/src/isolated/AIRequestsScreenWidget.isolated.tsx +84 -0
  305. package/src/isolated/AdminFieldRenderer.isolated.tsx +161 -1
  306. package/src/isolated/AdminFilterDrawer.isolated.tsx +308 -0
  307. package/src/isolated/AdminFilterDrawerMobile.isolated.tsx +172 -0
  308. package/src/isolated/AdminHomeWidgets.isolated.tsx +73 -0
  309. package/src/isolated/AdminNestedArrayField.isolated.tsx +1 -1
  310. package/src/isolated/AdminObjectPicker.isolated.tsx +8 -1
  311. package/src/isolated/AdminRefField.isolated.tsx +1 -1
  312. package/src/isolated/AdminScriptList.isolated.tsx +124 -0
  313. package/src/isolated/AdminScriptRunModal.isolated.tsx +275 -5
  314. package/src/isolated/DocumentStorageBrowser.isolated.tsx +14 -1
  315. package/src/isolated/RecentActivityWidget.isolated.tsx +138 -0
  316. package/src/isolated/adminWidgets.isolated.tsx +190 -0
  317. package/src/isolated/generateConsentHistoryPdf.isolated.ts +251 -0
  318. package/src/isolated/generateConsentPdfMobile.isolated.ts +87 -0
  319. package/src/isolated/generateConsentPdfsMobile.isolated.ts +129 -0
  320. package/src/isolated/hooks.isolated.tsx +246 -4
  321. package/src/isolated/rpcDualRun.isolated.tsx +449 -0
  322. package/src/isolated/useAdminScripts.isolated.tsx +156 -0
  323. package/src/isolated/useJobsDashboardApi.isolated.tsx +60 -0
  324. package/src/jobs/JobsDashboardScreen.test.tsx +310 -0
  325. package/src/jobs/JobsDashboardScreen.tsx +461 -0
  326. package/src/jobs/JobsDashboardScreenWidget.test.tsx +83 -0
  327. package/src/jobs/JobsDashboardScreenWidget.tsx +20 -0
  328. package/src/jobs/JobsHomeWidget.test.tsx +92 -0
  329. package/src/jobs/JobsHomeWidget.tsx +53 -0
  330. package/src/jobs/JobsJobDetail.test.tsx +253 -0
  331. package/src/jobs/JobsJobDetail.tsx +278 -0
  332. package/src/jobs/JobsStatusBadge.tsx +16 -0
  333. package/src/jobs/jobPayload.ts +114 -0
  334. package/src/jobs/jobsDashboardParams.test.ts +80 -0
  335. package/src/jobs/jobsDashboardParams.ts +84 -0
  336. package/src/jobs/useJobsDashboardApi.test.tsx +152 -0
  337. package/src/jobs/useJobsDashboardApi.tsx +132 -0
  338. package/src/jobs/useJobsDashboardUrlFilters.test.tsx +31 -0
  339. package/src/jobs/useJobsDashboardUrlFilters.tsx +31 -0
  340. package/src/orgs/OrgDirectoryScreen.test.tsx +184 -0
  341. package/src/orgs/OrgDirectoryScreen.tsx +200 -0
  342. package/src/orgs/OrgManagementScreens.test.tsx +270 -0
  343. package/src/orgs/OrgMembersScreen.tsx +254 -0
  344. package/src/orgs/OrgSettingsScreen.tsx +145 -0
  345. package/src/orgs/OrgSwitcher.test.tsx +145 -0
  346. package/src/orgs/OrgSwitcher.tsx +101 -0
  347. package/src/orgs/adminModelEndpoints.test.ts +156 -0
  348. package/src/orgs/adminModelEndpoints.ts +96 -0
  349. package/src/orgs/normalizeListData.test.ts +17 -0
  350. package/src/orgs/normalizeListData.ts +13 -0
  351. package/src/orgs/orgSwitcherOscillation.test.tsx +107 -0
  352. package/src/orgs/organizationSettings.test.ts +11 -0
  353. package/src/orgs/organizationSettings.ts +22 -0
  354. package/src/orgs/shouldSkipOrgScopedAdminQuery.test.ts +22 -0
  355. package/src/orgs/shouldSkipOrgScopedAdminQuery.ts +7 -0
  356. package/src/orgs/sortOrganizations.test.ts +13 -0
  357. package/src/orgs/sortOrganizations.ts +14 -0
  358. package/src/orgs/useOrgContext.test.tsx +94 -0
  359. package/src/orgs/useOrgContext.tsx +90 -0
  360. package/src/orgs/useOrganizationsApi.test.tsx +165 -0
  361. package/src/orgs/useOrganizationsApi.ts +118 -0
  362. package/src/pdfUtils.test.ts +37 -0
  363. package/src/pdfUtils.ts +2 -2
  364. package/src/testing/useAdminApiDouble.ts +70 -0
  365. package/src/types.ts +94 -4
  366. package/src/useAdminApi.test.ts +88 -0
  367. package/src/useAdminApi.ts +7 -65
  368. package/src/useAdminBackgroundTask.ts +26 -8
  369. package/src/useAdminConfig.ts +20 -2
  370. package/src/useAdminMigrations.test.tsx +75 -0
  371. package/src/useAdminMigrations.ts +77 -0
  372. package/src/useAdminRoles.test.ts +28 -0
  373. package/src/useAdminRoles.ts +40 -0
  374. package/src/useAdminRpc.test.tsx +250 -0
  375. package/src/useAdminRpc.ts +173 -0
  376. package/src/useAdminScripts.ts +67 -0
  377. package/src/useConfigurationApi.ts +37 -16
  378. package/src/useConsentHistory.ts +15 -2
  379. package/src/useDocumentStorageApi.ts +77 -0
  380. package/src/widgets/AIRequestsScreenWidget.test.tsx +154 -0
  381. package/src/widgets/AIRequestsScreenWidget.tsx +26 -11
  382. package/src/widgets/DocumentsScreenWidget.tsx +9 -2
  383. package/src/widgets/ModelsGridWidget.test.tsx +91 -0
  384. package/src/widgets/ModelsGridWidget.tsx +11 -1
  385. package/src/widgets/RecentActivityWidget.tsx +10 -3
  386. package/src/widgets/builtInFieldWidgets.test.tsx +166 -0
  387. package/src/widgets/builtInWidgets.ts +8 -0
  388. package/src/widgets/homeWidgetUtils.ts +0 -9
  389. package/src/widgets/pluginWidgets.test.tsx +12 -1
  390. package/src/AdminFilterDrawer.test.tsx +0 -89
@@ -0,0 +1,75 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import {
3
+ parseCommsDashboardSearchParams,
4
+ serializeCommsDashboardSearchParams,
5
+ withDefaultCommsDashboardDates,
6
+ } from "./commsDashboardParams";
7
+ import {summarizeSkippedReasons} from "./commsRetrySummary";
8
+
9
+ describe("commsDashboardParams", () => {
10
+ it("round-trips filters through the URL query object", () => {
11
+ const filters = {
12
+ channel: "mail",
13
+ endDate: "2026-08-20T00:00:00.000Z",
14
+ errorClass: "transient",
15
+ page: 3,
16
+ provider: "sendgrid",
17
+ q: "timeout",
18
+ startDate: "2026-08-13T00:00:00.000Z",
19
+ status: "failed",
20
+ };
21
+ const serialized = serializeCommsDashboardSearchParams(filters);
22
+ expect(parseCommsDashboardSearchParams(serialized)).toEqual(filters);
23
+ });
24
+
25
+ it("fills a trailing seven-day range when both dates are omitted", () => {
26
+ const withDefaults = withDefaultCommsDashboardDates({status: "failed"});
27
+ expect(withDefaults.status).toBe("failed");
28
+ expect(withDefaults.startDate).toBeTruthy();
29
+ expect(withDefaults.endDate).toBeTruthy();
30
+ expect(withDefaultCommsDashboardDates({startDate: "2026-08-01T00:00:00.000Z"}).startDate).toBe(
31
+ "2026-08-01T00:00:00.000Z"
32
+ );
33
+ });
34
+
35
+ it("drops empty values and page 1 from the URL", () => {
36
+ expect(
37
+ serializeCommsDashboardSearchParams({
38
+ channel: "",
39
+ page: 1,
40
+ q: " ",
41
+ })
42
+ ).toEqual({});
43
+ });
44
+
45
+ it("reads the first value when expo-router supplies arrays", () => {
46
+ expect(
47
+ parseCommsDashboardSearchParams({
48
+ channel: ["sms", "mail"],
49
+ page: ["2"],
50
+ })
51
+ ).toEqual({
52
+ channel: "sms",
53
+ endDate: undefined,
54
+ errorClass: undefined,
55
+ page: 2,
56
+ provider: undefined,
57
+ q: undefined,
58
+ startDate: undefined,
59
+ status: undefined,
60
+ });
61
+ });
62
+ });
63
+
64
+ describe("summarizeSkippedReasons", () => {
65
+ it("groups skipped retry reasons for the result toast", () => {
66
+ expect(summarizeSkippedReasons([])).toBe("none skipped");
67
+ expect(
68
+ summarizeSkippedReasons([
69
+ {id: "a", reason: "Permanent failures cannot be retried"},
70
+ {id: "b", reason: "Permanent failures cannot be retried"},
71
+ {id: "c", reason: "Verification messages are not retryable"},
72
+ ])
73
+ ).toBe("2× Permanent failures cannot be retried; 1× Verification messages are not retryable");
74
+ });
75
+ });
@@ -0,0 +1,91 @@
1
+ import {DateTime} from "luxon";
2
+
3
+ export interface CommsDashboardFilters {
4
+ channel?: string;
5
+ endDate?: string;
6
+ errorClass?: string;
7
+ page?: number;
8
+ provider?: string;
9
+ q?: string;
10
+ startDate?: string;
11
+ status?: string;
12
+ }
13
+
14
+ const asString = (value: unknown): string | undefined => {
15
+ if (Array.isArray(value)) {
16
+ return asString(value[0]);
17
+ }
18
+ if (typeof value !== "string") {
19
+ return undefined;
20
+ }
21
+ const trimmed = value.trim();
22
+ return trimmed.length > 0 ? trimmed : undefined;
23
+ };
24
+
25
+ export const parseCommsDashboardSearchParams = (
26
+ params: Record<string, unknown>
27
+ ): CommsDashboardFilters => {
28
+ const pageValue = asString(params.page);
29
+ const page = pageValue ? Number.parseInt(pageValue, 10) : undefined;
30
+ return {
31
+ channel: asString(params.channel),
32
+ endDate: asString(params.endDate),
33
+ errorClass: asString(params.errorClass),
34
+ page: page && page > 0 ? page : undefined,
35
+ provider: asString(params.provider),
36
+ q: asString(params.q),
37
+ startDate: asString(params.startDate),
38
+ status: asString(params.status),
39
+ };
40
+ };
41
+
42
+ export const serializeCommsDashboardSearchParams = (
43
+ filters: CommsDashboardFilters
44
+ ): Record<string, string> => {
45
+ const params: Record<string, string> = {};
46
+ if (filters.channel) {
47
+ params.channel = filters.channel;
48
+ }
49
+ if (filters.provider) {
50
+ params.provider = filters.provider;
51
+ }
52
+ if (filters.status) {
53
+ params.status = filters.status;
54
+ }
55
+ if (filters.errorClass) {
56
+ params.errorClass = filters.errorClass;
57
+ }
58
+ if (filters.q?.trim()) {
59
+ params.q = filters.q.trim();
60
+ }
61
+ if (filters.startDate) {
62
+ params.startDate = filters.startDate;
63
+ }
64
+ if (filters.endDate) {
65
+ params.endDate = filters.endDate;
66
+ }
67
+ if (filters.page && filters.page > 1) {
68
+ params.page = String(filters.page);
69
+ }
70
+ return params;
71
+ };
72
+
73
+ const DEFAULT_STATS_DAYS = 7;
74
+
75
+ const defaultCommsDashboardDateRange = (): {endDate: string; startDate: string} => {
76
+ const endDate = DateTime.utc();
77
+ const startDate = endDate.minus({days: DEFAULT_STATS_DAYS});
78
+ return {
79
+ endDate: endDate.toISO() ?? "",
80
+ startDate: startDate.toISO() ?? "",
81
+ };
82
+ };
83
+
84
+ export const withDefaultCommsDashboardDates = (
85
+ filters: CommsDashboardFilters
86
+ ): CommsDashboardFilters => {
87
+ if (filters.startDate || filters.endDate) {
88
+ return filters;
89
+ }
90
+ return {...filters, ...defaultCommsDashboardDateRange()};
91
+ };
@@ -0,0 +1,22 @@
1
+ import {describe, it} from "bun:test";
2
+ import {assert} from "chai";
3
+ import {DateTime} from "luxon";
4
+ import {formatCommsTimestamp} from "./commsMessagePayload";
5
+
6
+ describe("formatCommsTimestamp", () => {
7
+ it("prints a valid ISO timestamp in the local locale", () => {
8
+ const value = "2026-08-20T00:00:00.000Z";
9
+ const expected = DateTime.fromISO(value).toLocal().toLocaleString(DateTime.DATETIME_MED);
10
+ assert.equal(formatCommsTimestamp({value}), expected);
11
+ assert.notInclude(formatCommsTimestamp({value}), "T00:00:00");
12
+ });
13
+
14
+ it("returns the empty fallback when the value is missing", () => {
15
+ assert.equal(formatCommsTimestamp({empty: "—"}), "—");
16
+ assert.equal(formatCommsTimestamp({}), "");
17
+ });
18
+
19
+ it("keeps an unparseable string so a bad provider clock still shows", () => {
20
+ assert.equal(formatCommsTimestamp({value: "not-a-timestamp"}), "not-a-timestamp");
21
+ });
22
+ });
@@ -0,0 +1,83 @@
1
+ import {DateTime} from "luxon";
2
+
3
+ interface CommsMessageAttempt {
4
+ at?: string;
5
+ error?: string;
6
+ errorClass?: string;
7
+ errorCode?: string;
8
+ provider?: string;
9
+ providerMessageId?: string;
10
+ }
11
+
12
+ export interface CommsMessageRow {
13
+ _id?: string;
14
+ attemptCount?: number;
15
+ attempts?: CommsMessageAttempt[];
16
+ channel: string;
17
+ created?: string;
18
+ error?: string;
19
+ errorClass?: string;
20
+ errorCode?: string;
21
+ id?: string;
22
+ metadata?: Record<string, unknown>;
23
+ payload?: unknown;
24
+ provider: string;
25
+ retriedById?: string;
26
+ retriedFromId?: string;
27
+ retryDisabledReason?: string;
28
+ retryable?: boolean;
29
+ retries?: CommsMessageRow[];
30
+ status: string;
31
+ subject?: string;
32
+ templateId?: string;
33
+ to: string;
34
+ userId?: string;
35
+ }
36
+
37
+ /**
38
+ * Reads a message row out of a dashboard response.
39
+ *
40
+ * Hosts differ in how they unwrap responses: the example app's Better Auth base query
41
+ * strips `{data}` envelopes unless the body carries `more`, so detail and retry hooks
42
+ * yield the row itself while list responses stay wrapped. Accept both shapes.
43
+ */
44
+ export const unwrapCommsMessage = (payload: unknown): CommsMessageRow | undefined => {
45
+ if (!payload || typeof payload !== "object") {
46
+ return undefined;
47
+ }
48
+ const record = payload as Record<string, unknown>;
49
+ if (record.data && typeof record.data === "object" && !Array.isArray(record.data)) {
50
+ return unwrapCommsMessage(record.data);
51
+ }
52
+ const rawId = record._id ?? record.id;
53
+ const id = typeof rawId === "string" ? rawId : rawId != null ? String(rawId) : "";
54
+ if (id.length === 0) {
55
+ return undefined;
56
+ }
57
+ return {...record, _id: id} as CommsMessageRow;
58
+ };
59
+
60
+ export const commsMessageId = (row: CommsMessageRow): string => {
61
+ return row._id ?? row.id ?? "";
62
+ };
63
+
64
+ /**
65
+ * Prints a comms timestamp for operators. Invalid or missing values stay as-is so a
66
+ * bad provider clock does not blank the cell.
67
+ */
68
+ export const formatCommsTimestamp = ({
69
+ empty = "",
70
+ value,
71
+ }: {
72
+ empty?: string;
73
+ value?: string;
74
+ }): string => {
75
+ if (!value) {
76
+ return empty;
77
+ }
78
+ const parsed = DateTime.fromISO(value);
79
+ if (!parsed.isValid) {
80
+ return value;
81
+ }
82
+ return parsed.toLocal().toLocaleString(DateTime.DATETIME_MED);
83
+ };
@@ -0,0 +1,10 @@
1
+ export const summarizeSkippedReasons = (skipped: Array<{id: string; reason: string}>): string => {
2
+ if (skipped.length === 0) {
3
+ return "none skipped";
4
+ }
5
+ const counts = new Map<string, number>();
6
+ for (const row of skipped) {
7
+ counts.set(row.reason, (counts.get(row.reason) ?? 0) + 1);
8
+ }
9
+ return [...counts.entries()].map(([reason, count]) => `${count}× ${reason}`).join("; ");
10
+ };
@@ -0,0 +1,144 @@
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {renderHook} from "@testing-library/react-native";
3
+ import type {AdminApi, EndpointBuilder} from "../types";
4
+ import {commsMessageId, unwrapCommsMessage} from "./commsMessagePayload";
5
+ import {useCommsDashboardApi} from "./useCommsDashboardApi";
6
+
7
+ interface CapturedQuery {
8
+ body?: Record<string, unknown>;
9
+ method: string;
10
+ params?: Record<string, unknown>;
11
+ url: string;
12
+ }
13
+
14
+ interface CapturedEndpoint {
15
+ invalidatesTags?: string[];
16
+ providesTags?: unknown;
17
+ query: (arg: never) => CapturedQuery;
18
+ }
19
+
20
+ /**
21
+ * Stands in for the host RTK Query API. `injectEndpoints` is invoked eagerly so the
22
+ * endpoint definitions can be asserted, then hook names are returned the way RTK Query
23
+ * generates them from endpoint keys.
24
+ */
25
+ const createApiDouble = (): {
26
+ addTagTypes: string[][];
27
+ api: AdminApi;
28
+ endpoints: Record<string, CapturedEndpoint>;
29
+ } => {
30
+ const endpoints: Record<string, CapturedEndpoint> = {};
31
+ const addTagTypes: string[][] = [];
32
+ const api = {
33
+ enhanceEndpoints: ({addTagTypes: tags}: {addTagTypes: string[]}) => {
34
+ addTagTypes.push(tags);
35
+ return api;
36
+ },
37
+ injectEndpoints: ({
38
+ endpoints: build,
39
+ }: {
40
+ endpoints: (builder: EndpointBuilder) => Record<string, CapturedEndpoint>;
41
+ }) => {
42
+ const builder = {
43
+ mutation: (spec: CapturedEndpoint) => spec,
44
+ query: (spec: CapturedEndpoint) => spec,
45
+ } as unknown as EndpointBuilder;
46
+ Object.assign(endpoints, build(builder));
47
+ return {
48
+ useCommsDashboardDetailQuery: mock(() => ({isLoading: false})),
49
+ useCommsDashboardListQuery: mock(() => ({isLoading: false})),
50
+ useCommsDashboardRetryManyMutation: mock(() => [mock(() => ({})), {isLoading: false}]),
51
+ useCommsDashboardRetryMutation: mock(() => [mock(() => ({})), {isLoading: false}]),
52
+ useCommsDashboardStatsQuery: mock(() => ({isLoading: false})),
53
+ };
54
+ },
55
+ } as unknown as AdminApi & {injectEndpoints: unknown};
56
+ return {addTagTypes, api: api as AdminApi, endpoints};
57
+ };
58
+
59
+ describe("useCommsDashboardApi", () => {
60
+ it("injects every dashboard endpoint against the comms base path", () => {
61
+ const {addTagTypes, api, endpoints} = createApiDouble();
62
+ const {result} = renderHook(() => useCommsDashboardApi(api));
63
+
64
+ expect(addTagTypes[0]).toEqual(["commsMessages"]);
65
+ expect(endpoints.commsDashboardList.query({} as never)).toEqual({
66
+ method: "GET",
67
+ params: {},
68
+ url: "/comms/messages",
69
+ });
70
+ expect(endpoints.commsDashboardDetail.query("m1" as never)).toEqual({
71
+ method: "GET",
72
+ url: "/comms/messages/m1",
73
+ });
74
+ expect(endpoints.commsDashboardRetry.query("m1" as never)).toEqual({
75
+ method: "POST",
76
+ url: "/comms/messages/m1/retry",
77
+ });
78
+ expect(endpoints.commsDashboardRetryMany.query({limit: 5} as never)).toEqual({
79
+ body: {limit: 5},
80
+ method: "POST",
81
+ url: "/comms/messages/retryMany",
82
+ });
83
+ expect(endpoints.commsDashboardStats.query({} as never)).toEqual({
84
+ method: "GET",
85
+ params: {},
86
+ url: "/comms/stats",
87
+ });
88
+
89
+ expect(typeof result.current.useListQuery).toBe("function");
90
+ expect(typeof result.current.useDetailQuery).toBe("function");
91
+ expect(typeof result.current.useStatsQuery).toBe("function");
92
+ expect(typeof result.current.useRetryMutation).toBe("function");
93
+ expect(typeof result.current.useRetryManyMutation).toBe("function");
94
+ });
95
+
96
+ it("invalidates the collection on both retry mutations and tags detail reads by id", () => {
97
+ const {api, endpoints} = createApiDouble();
98
+ renderHook(() => useCommsDashboardApi(api));
99
+
100
+ expect(endpoints.commsDashboardRetry.invalidatesTags).toEqual(["commsMessages"]);
101
+ expect(endpoints.commsDashboardRetryMany.invalidatesTags).toEqual(["commsMessages"]);
102
+ expect(endpoints.commsDashboardList.providesTags).toEqual(["commsMessages"]);
103
+ expect(endpoints.commsDashboardStats.providesTags).toEqual(["commsMessages"]);
104
+
105
+ const providesTags = endpoints.commsDashboardDetail.providesTags as (
106
+ result: unknown,
107
+ error: unknown,
108
+ id: string
109
+ ) => unknown;
110
+ expect(providesTags(undefined, undefined, "m1")).toEqual([{id: "m1", type: "commsMessages"}]);
111
+ });
112
+ });
113
+
114
+ describe("unwrapCommsMessage", () => {
115
+ it("reads the row out of a {data} envelope or an already-unwrapped row", () => {
116
+ expect(unwrapCommsMessage({_id: "a"})?._id).toBe("a");
117
+ expect(unwrapCommsMessage({data: {_id: "b"}})?._id).toBe("b");
118
+ expect(unwrapCommsMessage({data: {data: {id: "c"}}})?._id).toBe("c");
119
+ });
120
+
121
+ it("normalizes a non-string id", () => {
122
+ expect(unwrapCommsMessage({id: 42})?._id).toBe("42");
123
+ });
124
+
125
+ it("returns undefined for payloads without an id", () => {
126
+ expect(unwrapCommsMessage(undefined)).toBeUndefined();
127
+ expect(unwrapCommsMessage("row")).toBeUndefined();
128
+ expect(unwrapCommsMessage({status: "failed"})).toBeUndefined();
129
+ expect(unwrapCommsMessage({_id: ""})).toBeUndefined();
130
+ expect(unwrapCommsMessage({data: []})).toBeUndefined();
131
+ });
132
+ });
133
+
134
+ describe("commsMessageId", () => {
135
+ it("prefers _id, falls back to id, and degrades to an empty string", () => {
136
+ expect(
137
+ commsMessageId({_id: "a", channel: "mail", provider: "p", status: "failed", to: "t"})
138
+ ).toBe("a");
139
+ expect(
140
+ commsMessageId({channel: "mail", id: "b", provider: "p", status: "failed", to: "t"})
141
+ ).toBe("b");
142
+ expect(commsMessageId({channel: "mail", provider: "p", status: "failed", to: "t"})).toBe("");
143
+ });
144
+ });
@@ -0,0 +1,181 @@
1
+ import {useMemo} from "react";
2
+ import {withQueryString} from "../adminRpc";
3
+ import {asDynamicHookApi} from "../dynamicHookApi";
4
+ import type {AdminApi, EndpointBuilder} from "../types";
5
+ import {useAdminRpc, useAdminRpcMutation, useAdminRpcQuery} from "../useAdminRpc";
6
+ import type {CommsDashboardFilters} from "./commsDashboardParams";
7
+ import type {CommsMessageRow} from "./commsMessagePayload";
8
+
9
+ interface CommsListResponse {
10
+ data: CommsMessageRow[];
11
+ limit: number;
12
+ more: boolean;
13
+ page: number;
14
+ total: number;
15
+ }
16
+
17
+ export interface CommsStatsResponse {
18
+ buckets: Array<{channel: string; count: number; day: string; provider: string; status: string}>;
19
+ byProvider: Array<{
20
+ bounced: number;
21
+ delivered: number;
22
+ failed: number;
23
+ failureRate: number;
24
+ provider: string;
25
+ sent: number;
26
+ total: number;
27
+ }>;
28
+ totals: {
29
+ bounced: number;
30
+ cancelled: number;
31
+ delivered: number;
32
+ failed: number;
33
+ failureRate: number;
34
+ sent: number;
35
+ total: number;
36
+ };
37
+ }
38
+
39
+ interface CommsRetryManyResponse {
40
+ retried: CommsMessageRow[];
41
+ skipped: Array<{id: string; reason: string}>;
42
+ }
43
+
44
+ const LIST_KEY = "commsDashboardList";
45
+ const DETAIL_KEY = "commsDashboardDetail";
46
+ const STATS_KEY = "commsDashboardStats";
47
+ const RETRY_KEY = "commsDashboardRetry";
48
+ const RETRY_MANY_KEY = "commsDashboardRetryMany";
49
+ const COMMS_MESSAGE_TAGS = ["commsMessages"] as const;
50
+
51
+ export const useCommsDashboardApi = (api: AdminApi) => {
52
+ const rpc = useAdminRpc();
53
+ const enhancedApi = useMemo(
54
+ () =>
55
+ api.enhanceEndpoints({addTagTypes: ["commsMessages"]}).injectEndpoints({
56
+ endpoints: (build: EndpointBuilder) => ({
57
+ [DETAIL_KEY]: build.query({
58
+ providesTags: (_result: unknown, _error: unknown, id: string) => [
59
+ {id, type: "commsMessages"},
60
+ ],
61
+ query: (id: string) => ({method: "GET", url: `/comms/messages/${id}`}),
62
+ }),
63
+ [LIST_KEY]: build.query({
64
+ providesTags: ["commsMessages"],
65
+ query: (params: Record<string, unknown>) => ({
66
+ method: "GET",
67
+ params,
68
+ url: "/comms/messages",
69
+ }),
70
+ }),
71
+ [RETRY_KEY]: build.mutation({
72
+ invalidatesTags: ["commsMessages"],
73
+ query: (id: string) => ({
74
+ method: "POST",
75
+ url: `/comms/messages/${id}/retry`,
76
+ }),
77
+ }),
78
+ [RETRY_MANY_KEY]: build.mutation({
79
+ invalidatesTags: ["commsMessages"],
80
+ query: (body: Record<string, unknown>) => ({
81
+ body,
82
+ method: "POST",
83
+ url: "/comms/messages/retryMany",
84
+ }),
85
+ }),
86
+ [STATS_KEY]: build.query({
87
+ providesTags: ["commsMessages"],
88
+ query: (params: Record<string, unknown>) => ({
89
+ method: "GET",
90
+ params,
91
+ url: "/comms/stats",
92
+ }),
93
+ }),
94
+ }),
95
+ overrideExisting: true,
96
+ }),
97
+ [api]
98
+ );
99
+
100
+ const hooks = asDynamicHookApi(enhancedApi);
101
+ if (rpc) {
102
+ return {
103
+ useDetailQuery: (id: string) =>
104
+ useAdminRpcQuery<CommsMessageRow | {data: CommsMessageRow}>({
105
+ providesTags: COMMS_MESSAGE_TAGS,
106
+ rpc,
107
+ url: `/comms/messages/${id}`,
108
+ }),
109
+ useListQuery: (
110
+ params: CommsDashboardFilters & {
111
+ limit?: number;
112
+ }
113
+ ) =>
114
+ useAdminRpcQuery<CommsListResponse>({
115
+ providesTags: COMMS_MESSAGE_TAGS,
116
+ rpc,
117
+ url: withQueryString({params: params as Record<string, unknown>, url: "/comms/messages"}),
118
+ }),
119
+ useRetryManyMutation: () => {
120
+ const [trigger, meta] = useAdminRpcMutation(rpc, {
121
+ invalidatesTags: COMMS_MESSAGE_TAGS,
122
+ });
123
+ return [
124
+ (body: Record<string, unknown>) =>
125
+ trigger({body, method: "POST", url: "/comms/messages/retryMany"}),
126
+ meta,
127
+ ] as [
128
+ (body: Record<string, unknown>) => {unwrap: () => Promise<CommsRetryManyResponse>},
129
+ {isLoading: boolean},
130
+ ];
131
+ },
132
+ useRetryMutation: () => {
133
+ const [trigger, meta] = useAdminRpcMutation(rpc, {
134
+ invalidatesTags: COMMS_MESSAGE_TAGS,
135
+ });
136
+ return [
137
+ (id: string) => trigger({method: "POST", url: `/comms/messages/${id}/retry`}),
138
+ meta,
139
+ ] as [
140
+ (id: string) => {unwrap: () => Promise<CommsMessageRow | {data: CommsMessageRow}>},
141
+ {isLoading: boolean},
142
+ ];
143
+ },
144
+ useStatsQuery: (params: CommsDashboardFilters) =>
145
+ useAdminRpcQuery<CommsStatsResponse>({
146
+ providesTags: COMMS_MESSAGE_TAGS,
147
+ rpc,
148
+ url: withQueryString({params: params as Record<string, unknown>, url: "/comms/stats"}),
149
+ }),
150
+ };
151
+ }
152
+ return {
153
+ useDetailQuery: hooks.useCommsDashboardDetailQuery as (id: string) => {
154
+ data?: CommsMessageRow | {data: CommsMessageRow};
155
+ error?: unknown;
156
+ isLoading: boolean;
157
+ },
158
+ useListQuery: hooks.useCommsDashboardListQuery as (
159
+ params: CommsDashboardFilters & {
160
+ limit?: number;
161
+ }
162
+ ) => {
163
+ data?: CommsListResponse;
164
+ error?: unknown;
165
+ isLoading: boolean;
166
+ },
167
+ useRetryManyMutation: hooks.useCommsDashboardRetryManyMutation as () => [
168
+ (body: Record<string, unknown>) => {unwrap: () => Promise<CommsRetryManyResponse>},
169
+ {isLoading: boolean},
170
+ ],
171
+ useRetryMutation: hooks.useCommsDashboardRetryMutation as () => [
172
+ (id: string) => {unwrap: () => Promise<CommsMessageRow | {data: CommsMessageRow}>},
173
+ {isLoading: boolean},
174
+ ],
175
+ useStatsQuery: hooks.useCommsDashboardStatsQuery as (params: CommsDashboardFilters) => {
176
+ data?: CommsStatsResponse;
177
+ error?: unknown;
178
+ isLoading: boolean;
179
+ },
180
+ };
181
+ };
@@ -0,0 +1,58 @@
1
+ import {beforeEach, describe, expect, it, mock} from "bun:test";
2
+ import {renderHook} from "@testing-library/react-native";
3
+
4
+ const replaceMock = mock((_href: string) => {});
5
+ let searchParams: Record<string, unknown> = {};
6
+
7
+ mock.module("expo-router", () => ({
8
+ router: {push: mock(() => {}), replace: replaceMock},
9
+ useLocalSearchParams: () => searchParams,
10
+ }));
11
+
12
+ import {useCommsDashboardUrlFilters} from "./useCommsDashboardUrlFilters";
13
+
14
+ const lastHref = (): string => String(replaceMock.mock.calls.at(-1)?.[0] ?? "");
15
+
16
+ describe("useCommsDashboardUrlFilters", () => {
17
+ beforeEach(() => {
18
+ searchParams = {};
19
+ replaceMock.mockClear();
20
+ });
21
+
22
+ it("parses the current query into filters", () => {
23
+ searchParams = {channel: "mail", page: "2", q: "timeout"};
24
+ const {result} = renderHook(() => useCommsDashboardUrlFilters("/admin"));
25
+ expect(result.current.filters).toEqual({
26
+ channel: "mail",
27
+ endDate: undefined,
28
+ errorClass: undefined,
29
+ page: 2,
30
+ provider: undefined,
31
+ q: "timeout",
32
+ startDate: undefined,
33
+ status: undefined,
34
+ });
35
+ });
36
+
37
+ it("writes filters back onto the route as a query string", () => {
38
+ const {result} = renderHook(() => useCommsDashboardUrlFilters("/admin"));
39
+ result.current.onFiltersChange({channel: "sms", page: 3, status: "failed"});
40
+ const href = lastHref();
41
+ expect(href.startsWith("/admin/comms?")).toBe(true);
42
+ expect(href).toContain("channel=sms");
43
+ expect(href).toContain("status=failed");
44
+ expect(href).toContain("page=3");
45
+ });
46
+
47
+ it("drops the query entirely when no filters remain", () => {
48
+ const {result} = renderHook(() => useCommsDashboardUrlFilters("/admin"));
49
+ result.current.onFiltersChange({page: 1});
50
+ expect(lastHref()).toBe("/admin/comms");
51
+ });
52
+
53
+ it("defaults to a root-relative route when the host has no route base", () => {
54
+ const {result} = renderHook(() => useCommsDashboardUrlFilters());
55
+ result.current.onFiltersChange({});
56
+ expect(lastHref()).toBe("/comms");
57
+ });
58
+ });