@hot-updater/console 1.2.0-rc.4 → 1.2.0-rc.40

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 (387) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/-native-builds-search-qeto9-fq.js +1 -0
  3. package/.output/public/assets/BundleIdDisplay-BKaGARD1.js +1 -0
  4. package/.output/public/assets/ChannelBadge-CPc1M44L.js +1 -0
  5. package/.output/public/assets/CompositeItem-B541MSYC.js +1 -0
  6. package/.output/public/assets/{ConsoleFeatureUnavailable-CUtcXuY2.js → ConsoleFeatureUnavailable-C6aryy7j.js} +1 -1
  7. package/.output/public/assets/{EventDetails-Dl2RvPAk.js → EventDetails-BdqU96Wu.js} +1 -1
  8. package/.output/public/assets/HashValueDisplay-BHL4xWSY.js +1 -0
  9. package/.output/public/assets/InsightsPageHeader-D0Nxcccp.js +1 -0
  10. package/.output/public/assets/IosInstall-CgNa8B4v.js +1 -0
  11. package/.output/public/assets/NativeBuildsNav-BxAmQr2E.js +1 -0
  12. package/.output/public/assets/{NotFoundPage-DZ3DxyRA.js → NotFoundPage-haKPLHiT.js} +1 -1
  13. package/.output/public/assets/{PlatformIcon-BBWQlWm9.js → PlatformIcon-DYsYaYt6.js} +1 -1
  14. package/.output/public/assets/QrCode-BSNEn_M-.js +1 -0
  15. package/.output/public/assets/RelativeTime-CdQ86VoP.js +1 -0
  16. package/.output/public/assets/RolloutPercentageBadge-Cd1UNLL0.js +1 -0
  17. package/.output/public/assets/RowReason-CEI-_T6G.js +1 -0
  18. package/.output/public/assets/SandboxBadge-CqGX5DiH.js +1 -0
  19. package/.output/public/assets/TargetDisplay-DMZHMgWk.js +1 -0
  20. package/.output/public/assets/alert-dialog-Cj7AOTIE.js +1 -0
  21. package/.output/public/assets/api-keys-B9XQLCZ8.js +1 -0
  22. package/.output/public/assets/api-keys-D4tjInrB.js +1 -0
  23. package/.output/public/assets/api-tJRzijjy.js +1 -0
  24. package/.output/public/assets/arrow-left-68S4uy4I.js +1 -0
  25. package/.output/public/assets/arrow-right-DjRwIoF1.js +1 -0
  26. package/.output/public/assets/arrow-up-right-C_1ALUCD.js +1 -0
  27. package/.output/public/assets/badge-zMibJGR5.js +1 -0
  28. package/.output/public/assets/card-pYZSDIxg.js +1 -0
  29. package/.output/public/assets/check-C3VCvMOV.js +1 -0
  30. package/.output/public/assets/chevron-right-RAuPv9r1.js +1 -0
  31. package/.output/public/assets/{circle-off-C7Muo0ss.js → circle-off-DvYMC5yF.js} +1 -1
  32. package/.output/public/assets/{clipboard-DQbOcrL7.js → clipboard-D0JWZ1KF.js} +1 -1
  33. package/.output/public/assets/{console-features-api-DEXSwFtc.js → console-features-api-CtbGqKyr.js} +1 -1
  34. package/.output/public/assets/{uuidv7-zXMtwR9Q.js → constants-zSb7FXDh.js} +1 -1
  35. package/.output/public/assets/{copy-DsuLj3oj.js → copy-BjVLMKbo.js} +1 -1
  36. package/.output/public/assets/dialog-DlAv6zou.js +1 -0
  37. package/.output/public/assets/dist-BEmib-ZM.js +1 -0
  38. package/.output/public/assets/{download-Cf24LBde.js → download-CgpaZb23.js} +1 -1
  39. package/.output/public/assets/empty-Bwao2ztZ.js +1 -0
  40. package/.output/public/assets/field-BiSGCVoS.js +1 -0
  41. package/.output/public/assets/git-branch-BGatQV8Q.js +1 -0
  42. package/.output/public/assets/history-Ci4dhphE.js +1 -0
  43. package/.output/public/assets/index-D7PWINwc.js +10 -0
  44. package/.output/public/assets/input-group-CPboh0Rx.js +1 -0
  45. package/.output/public/assets/insights-B7GL298D.js +1 -0
  46. package/.output/public/assets/insights-BzKbxWIo.js +42 -0
  47. package/.output/public/assets/insights-Q2nAkSMz.js +2 -0
  48. package/.output/public/assets/insights-api-D4-FZeEI.js +1 -0
  49. package/.output/public/assets/insights-search-DkovoDrZ.js +1 -0
  50. package/.output/public/assets/insights-usage-rpc-DkJgbAYm.js +1 -0
  51. package/.output/public/assets/insights_.distribution-BafQuEd0.js +1 -0
  52. package/.output/public/assets/insights_.distribution-DHU1udei.js +2 -0
  53. package/.output/public/assets/insights_.distribution-DmeI9XZw.js +1 -0
  54. package/.output/public/assets/installations-ClsF2q6A.js +2 -0
  55. package/.output/public/assets/installations-CmuNX_Ok.js +1 -0
  56. package/.output/public/assets/installations-oGkAO7nb.js +1 -0
  57. package/.output/public/assets/{key-round-DwNKkHhy.js → key-round-BkeLvA1m.js} +1 -1
  58. package/.output/public/assets/{link-DTEyW70e.js → link-CRMwpc7-.js} +2 -2
  59. package/.output/public/assets/{list--NIee1FZ.js → list-DQ9YBIDW.js} +1 -1
  60. package/.output/public/assets/loader-circle-8lunBReu.js +1 -0
  61. package/.output/public/assets/native-builds-DJlYvvPY.js +2 -0
  62. package/.output/public/assets/native-builds-NyGMlBx2.js +1 -0
  63. package/.output/public/assets/native-builds-uKuvmyXZ.js +1 -0
  64. package/.output/public/assets/native-builds_._buildId-DZqylSRq.js +1 -0
  65. package/.output/public/assets/native-builds_._buildId-Dza7vEcy.js +2 -0
  66. package/.output/public/assets/native-builds_.devices-BykEftlY.js +1 -0
  67. package/.output/public/assets/native-builds_.devices-DH1JB1zr.js +2 -0
  68. package/.output/public/assets/plus-DztQIXYL.js +1 -0
  69. package/.output/public/assets/preload-helper-CE9OukVC.js +1 -0
  70. package/.output/public/assets/{relativeTime-YQt84dYr.js → relativeTime-Dbefsycs.js} +1 -1
  71. package/.output/public/assets/remote-config-BiD075AT.js +1 -0
  72. package/.output/public/assets/remote-config-CBirPcRR.js +6 -0
  73. package/.output/public/assets/remote-config-r945bivi.js +1 -0
  74. package/.output/public/assets/{rotate-cw-Cv2aVbYr.js → rotate-cw-BFQcpUTO.js} +1 -1
  75. package/.output/public/assets/routes-5U4k3N1_.js +1 -0
  76. package/.output/public/assets/routes-DWjGfLRs.js +2 -0
  77. package/.output/public/assets/search-BfEqtE64.js +1 -0
  78. package/.output/public/assets/select-DIyG5G-V.js +1 -0
  79. package/.output/public/assets/sidebar-BmzmPGuv.js +3 -0
  80. package/.output/public/assets/smartphone-Dy13ukaU.js +1 -0
  81. package/.output/public/assets/styles-C_9Rf75p.css +2 -0
  82. package/.output/public/assets/switch-B_7OwJhK.js +1 -0
  83. package/.output/public/assets/table-Bo1jU9-v.js +1 -0
  84. package/.output/public/assets/tabs-DARDj-XC.js +1 -0
  85. package/.output/public/assets/trash-2-DI0biNI-.js +1 -0
  86. package/.output/public/assets/{undo-2-CUX96_BG.js → undo-2-CxhBbgJw.js} +1 -1
  87. package/.output/public/assets/{useCompositeListItem-JmyDfo3-.js → useCompositeListItem-Cbk_weKW.js} +1 -1
  88. package/.output/public/assets/{useMutation-DbYw7boA.js → useMutation-D7IuoOLE.js} +1 -1
  89. package/.output/public/assets/valueToPercent-Db73Kirz.js +1 -0
  90. package/.output/server/{__23tanstack-start-server-fn-resolver-X9YQcrQI.mjs → __23tanstack-start-server-fn-resolver-CSEErUrV.mjs} +94 -46
  91. package/.output/server/_chunks/ssr-renderer.mjs +2 -2
  92. package/.output/server/_libs/@base-ui/react+[...].mjs +1488 -183
  93. package/.output/server/_libs/@tanstack/react-router+[...].mjs +1 -1
  94. package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +1 -1
  95. package/.output/server/_libs/_.mjs +2 -0
  96. package/.output/server/_libs/lucide-react.mjs +34 -28
  97. package/.output/server/_libs/next-themes.mjs +1 -1
  98. package/.output/server/_libs/react-redux+[...].mjs +1 -1
  99. package/.output/server/_libs/recharts+[...].mjs +1 -1
  100. package/.output/server/_libs/sonner.mjs +1 -1
  101. package/.output/server/_libs/tanstack__react-query.mjs +1 -1
  102. package/.output/server/_ssr/-native-builds-search-Bwt8tQzp.mjs +55 -0
  103. package/.output/server/_ssr/{BundleIdDisplay-BVrZXzTm.mjs → BundleIdDisplay-BfMtMws8.mjs} +3 -3
  104. package/.output/server/_ssr/ChannelBadge-CyjOxlfr.mjs +23 -0
  105. package/.output/server/_ssr/{ConsoleFeatureUnavailable-CULyV3nR.mjs → ConsoleFeatureUnavailable-D5a8SXzu.mjs} +8 -8
  106. package/.output/server/_ssr/{EventDetails-DeI1rOQc.mjs → EventDetails-XaXslOac.mjs} +9 -9
  107. package/.output/server/_ssr/{HashValueDisplay-DpnPD3U2.mjs → HashValueDisplay-CtrIkPNM.mjs} +7 -7
  108. package/.output/server/_ssr/{InsightsPageHeader-Dwmdtelg.mjs → InsightsPageHeader-CK76Vycr.mjs} +13 -13
  109. package/.output/server/_ssr/IosInstall-BD2HpMsh.mjs +751 -0
  110. package/.output/server/_ssr/NativeBuildsNav-DvFscYEN.mjs +38 -0
  111. package/.output/server/_ssr/{NotFoundPage-Dddp1HSc.mjs → NotFoundPage-CQc5Envb.mjs} +3 -3
  112. package/.output/server/_ssr/{PlatformIcon-CFLiTjh1.mjs → PlatformIcon-C22qEcwo.mjs} +13 -3
  113. package/.output/server/_ssr/QrCode-VPGDhoTy.mjs +50 -0
  114. package/.output/server/_ssr/RelativeTime-D6qU9XeU.mjs +242 -0
  115. package/.output/server/_ssr/{git-CTA8Aqr0.mjs → RolloutPercentageBadge-7HdtPPd8.mjs} +20 -4
  116. package/.output/server/_ssr/RowReason-CR2C_0d9.mjs +186 -0
  117. package/.output/server/_ssr/SandboxBadge-HQv4waT2.mjs +85 -0
  118. package/.output/server/_ssr/TargetDisplay-BQ3rf-jt.mjs +105 -0
  119. package/.output/server/_ssr/{alert-dialog-ei2c1b6A.mjs → alert-dialog-DZfV4jo0.mjs} +4 -4
  120. package/.output/server/_ssr/{api-CvwqILEx.mjs → api-C3S89RIl.mjs} +174 -37
  121. package/.output/server/_ssr/{api-keys-BLHCygD_.mjs → api-keys-DhgkyA5L.mjs} +2 -2
  122. package/.output/server/_ssr/{api-keys-rpc-CLZsTwih.mjs → api-keys-rpc-PnrzjW84.mjs} +4 -4
  123. package/.output/server/_ssr/{api-keys-CVi7E0qS.mjs → api-keys-tydhn1tu.mjs} +14 -11
  124. package/.output/server/_ssr/{api-rpc-p-7EhGIG.mjs → api-rpc-D8qYGyez.mjs} +83 -35
  125. package/.output/server/_ssr/{auth-rpc-B1W4-hxa.mjs → auth-rpc-rMdoXrTW.mjs} +5 -5
  126. package/.output/server/_ssr/{auth.server-CVKs7SWJ.mjs → auth.server-YE2ZZC0j.mjs} +833 -179
  127. package/.output/server/_ssr/{badge-nS9EbEA0.mjs → badge-NON1cyRV.mjs} +4 -45
  128. package/.output/server/_ssr/{bundleActivity-MLrjNJCT.mjs → bundleActivity-CjE9yslP.mjs} +1 -1
  129. package/.output/server/_ssr/card-CVw7zPaM.mjs +49 -0
  130. package/.output/server/_ssr/{config.server-BAdvotbH.mjs → config.server-BYkojQAW.mjs} +4 -4
  131. package/.output/server/_ssr/{console-access-BiuC2QFp.mjs → console-access-CRyGs-sb.mjs} +2 -2
  132. package/.output/server/_ssr/{console-features-BTV-XuhQ.mjs → console-features-DTYyXrWO.mjs} +1 -1
  133. package/.output/server/_ssr/{console-features-api-FvbqhbTg.mjs → console-features-api-DwbIx8oM.mjs} +4 -4
  134. package/.output/server/_ssr/{console-features-rpc-Cl3J66aP.mjs → console-features-rpc-erZu7BIN.mjs} +4 -4
  135. package/.output/server/_ssr/constants-BjsJZqaU.mjs +10 -0
  136. package/.output/server/_ssr/{createServerRpc-BVvRVOz5.mjs → createServerRpc-DJZel12M.mjs} +1 -1
  137. package/.output/server/_ssr/{databaseConfig-B_Bg7qS5.mjs → databaseConfig-B56IJxlu.mjs} +1 -1
  138. package/.output/server/_ssr/{databaseJsonValue-kS7cvEtz.mjs → databaseJsonValue-DuUoft8j.mjs} +1 -1
  139. package/.output/server/_ssr/{databaseRows-B6H8Cmgq.mjs → databaseRows-BZMFl5QV.mjs} +3 -3
  140. package/.output/server/_ssr/deviceProfileToken-Eeltr-o0.mjs +98 -0
  141. package/.output/server/_ssr/{dialog-GmTPeUS4.mjs → dialog-ZuUCxUNo.mjs} +5 -5
  142. package/.output/server/_ssr/dist-CiOq3ygH.mjs +148 -0
  143. package/.output/server/_ssr/{downloadBundle-DCmr7vsj.mjs → downloadBundle-DLkb7A7E.mjs} +1 -1
  144. package/.output/server/_ssr/{empty-CXWKv24M.mjs → empty-4FbiMhrz.mjs} +3 -3
  145. package/.output/server/_ssr/{empty-plugin-adapters-zrZ0xs6n.mjs → empty-plugin-adapters-BYBYBaxo.mjs} +1 -1
  146. package/.output/server/_ssr/{failureReports-Cn_zU9S8.mjs → failureReports-Bd7CaadE.mjs} +3 -3
  147. package/.output/server/_ssr/{field-lwIHAwLc.mjs → field-B9YWRLoo.mjs} +3 -3
  148. package/.output/server/_ssr/foldedPage-DrxWt5XS.mjs +176 -0
  149. package/.output/server/_ssr/{getBundleChildren-rtkEEJw5.mjs → getBundleChildren-DA9zbUBD.mjs} +2 -2
  150. package/.output/server/_ssr/{input-group-Dgr4DNbE.mjs → input-group-sETcyyLC.mjs} +3 -3
  151. package/.output/server/_ssr/{insights-DSnQTQw1.mjs → insights-BjtOex57.mjs} +38 -31
  152. package/.output/server/_ssr/{insights-BxtyBLt0.mjs → insights-CkJWItoo.mjs} +2 -2
  153. package/.output/server/_ssr/{insights-B9NvjAWc.mjs → insights-K6CFztcF.mjs} +5 -5
  154. package/.output/server/_ssr/{insights-api-PN_9ilr8.mjs → insights-api-9jE9dp-3.mjs} +5 -5
  155. package/.output/server/_ssr/{insights-errors-7BCwFybo.mjs → insights-errors-BrToSfI9.mjs} +2 -2
  156. package/.output/server/_ssr/{insights-failures-B9VPkzZE.mjs → insights-failures-lmcxwKb3.mjs} +2 -2
  157. package/.output/server/_ssr/{insights-failures-rpc-Cxu3UtyB.mjs → insights-failures-rpc-XxbDFtKo.mjs} +11 -11
  158. package/.output/server/_ssr/{insights-recovery-BtXVU3ro.mjs → insights-recovery-Dhg3WGpC.mjs} +1 -1
  159. package/.output/server/_ssr/{insights-recovery-rpc--c6kBp3k.mjs → insights-recovery-rpc-CFeoyZEw.mjs} +7 -7
  160. package/.output/server/_ssr/{insights-rpc-oTMaAqc1.mjs → insights-rpc-TAS-cemx.mjs} +4 -4
  161. package/.output/server/_ssr/{insights-search-r-Z50f0Y.mjs → insights-search-DL8LLP6s.mjs} +6 -8
  162. package/.output/server/_ssr/{insights-usage-DiGnuxW8.mjs → insights-usage-gW3T5N6N.mjs} +1 -1
  163. package/.output/server/_ssr/{insights-usage-rpc-B00vjt0a.mjs → insights-usage-rpc-CrAA5_Wn.mjs} +5 -5
  164. package/.output/server/_ssr/{insights-usage-rpc-DoElOI5b.mjs → insights-usage-rpc-DGSVT5eB.mjs} +7 -7
  165. package/.output/server/_ssr/{insightsUsage-ClAmoUz8.mjs → insightsUsage-B_7pM9wp.mjs} +3 -3
  166. package/.output/server/_ssr/{insights_.distribution-B8AMBp-Q.mjs → insights_.distribution-C9nMSRtr.mjs} +5 -5
  167. package/.output/server/_ssr/{insights_.distribution-CnYddZ2Y.mjs → insights_.distribution-CK5_wfLT.mjs} +2 -2
  168. package/.output/server/_ssr/{insights_.distribution-mpZ0wS_R.mjs → insights_.distribution-DDr3vglh.mjs} +16 -15
  169. package/.output/server/_ssr/{installations-CWTRzcR7.mjs → installations-BvGL_EXM.mjs} +2 -2
  170. package/.output/server/_ssr/{installations-BfhcY_XQ.mjs → installations-CRHGd6SX.mjs} +4 -4
  171. package/.output/server/_ssr/{installations-O6Jzc5PO.mjs → installations-CWutybSC.mjs} +13 -13
  172. package/.output/server/_ssr/ios-devices-rpc-CCx4TvyR.mjs +137 -0
  173. package/.output/server/_ssr/iosDeviceCookie-B3FPj65l.mjs +155 -0
  174. package/.output/server/_ssr/iosDeviceProfile-Cclrfk8N.mjs +176 -0
  175. package/.output/server/_ssr/iosDevices-DMXaKH8F.mjs +113 -0
  176. package/.output/server/_ssr/listReleases-B2Q9xwFv.mjs +94 -0
  177. package/.output/server/_ssr/{request-guard-CPdRBuGW.mjs → local-console-Dtxlsav0.mjs} +2 -9
  178. package/.output/server/_ssr/native-artifact-BurROe05.mjs +1573 -0
  179. package/.output/server/_ssr/{native-builds-UIgRLMb8.mjs → native-builds-BGDsGYAp.mjs} +3 -3
  180. package/.output/server/_ssr/native-builds-BPiSm8HX.mjs +724 -0
  181. package/.output/server/_ssr/native-builds-Bnx0fVWs.mjs +264 -0
  182. package/.output/server/_ssr/native-builds_._buildId-B749BEMp.mjs +1148 -0
  183. package/.output/server/_ssr/{native-builds_._buildId-DjUqI5sa.mjs → native-builds_._buildId-CS9w0JIp.mjs} +3 -3
  184. package/.output/server/_ssr/native-builds_.devices-BPT8_91w.mjs +10 -0
  185. package/.output/server/_ssr/native-builds_.devices-w_jDlH8K.mjs +820 -0
  186. package/.output/server/_ssr/nativeBuildDownloadLink-CXibRgym.mjs +96 -0
  187. package/.output/server/_ssr/nativeBuildInstall-BLuyTfXE.mjs +252 -0
  188. package/.output/server/_ssr/nativeBuilds-WKdqgemR.mjs +287 -0
  189. package/.output/server/_ssr/plistText-DkzlCfPI.mjs +15 -0
  190. package/.output/server/_ssr/{plugins-RIryUNWj.mjs → plugins-D9CCkDjn.mjs} +7 -6
  191. package/.output/server/_ssr/publicConsoleBase-C3sNbafy.mjs +15 -0
  192. package/.output/server/_ssr/{release-adoption-DoAtNPED.mjs → release-adoption-D2719HVh.mjs} +2 -2
  193. package/.output/server/_ssr/{release-adoption-rpc-PLyiDnas.mjs → release-adoption-rpc-DOdELZNl.mjs} +9 -9
  194. package/.output/server/_ssr/{releaseAdoption-a2byXMfz.mjs → releaseAdoption-CxGKmUXx.mjs} +4 -4
  195. package/.output/server/_ssr/{releaseCatalogCompiler-DLcean2k.mjs → releaseCatalogCompiler-CJ2Shida.mjs} +4 -3
  196. package/.output/server/_ssr/{releaseManagement-DHUux2az.mjs → releaseManagement-CqIc-SDE.mjs} +1 -1
  197. package/.output/server/_ssr/{releaseReachability-DZOK_dH-.mjs → releaseReachability-sWr0bLRk.mjs} +2 -2
  198. package/.output/server/_ssr/{remote-config-C5j4CfGa.mjs → remote-config-C5mPNt0s.mjs} +3 -3
  199. package/.output/server/_ssr/{remote-config-eNxv5Kzc.mjs → remote-config-DuOo-AFR.mjs} +23 -22
  200. package/.output/server/_ssr/{remote-config-rpc-Cy4VwdMt.mjs → remote-config-rpc-rEe5HBxX.mjs} +5 -5
  201. package/.output/server/_ssr/{remote-config-tOdzsFMi.mjs → remote-config-xbBIsBh1.mjs} +2 -2
  202. package/.output/server/_ssr/request-guard-BPLyogIN.mjs +11 -0
  203. package/.output/server/_ssr/{router-DaQ6OkIp.mjs → router-Bc5Zx-dc.mjs} +136 -63
  204. package/.output/server/_ssr/{routes-BYmUIYfN.mjs → routes-CUQ96XR2.mjs} +49 -17
  205. package/.output/server/_ssr/{routes-Drni4c1E.mjs → routes-DCOnxOlA.mjs} +469 -456
  206. package/.output/server/_ssr/{runtime.server-BdMY1blX.mjs → runtime.server-BUbb281Z.mjs} +4 -4
  207. package/.output/server/_ssr/{schema-ChlRtZIo.mjs → schema-CaIuQCXb.mjs} +1 -1
  208. package/.output/server/_ssr/{schema-migration-rpc-mZ_19Wt_.mjs → schema-migration-rpc-DK_ceMAg.mjs} +4 -4
  209. package/.output/server/_ssr/{select-Cjrp1Sl9.mjs → select-dGQiTkaZ.mjs} +12 -10
  210. package/.output/server/_ssr/{server-y3KoaSil.mjs → server-l-C5qBnr.mjs} +7 -7
  211. package/.output/server/_ssr/{sidebar-tRHVNWpo.mjs → sidebar-Ccd4WNjQ.mjs} +17 -10
  212. package/.output/server/_ssr/ssr.mjs +1 -1
  213. package/.output/server/_ssr/{start-BvDsQehg.mjs → start-BXlykDIg.mjs} +2 -2
  214. package/.output/server/_ssr/{switch-YrqCYfP-.mjs → switch-CC7UK0Nw.mjs} +4 -4
  215. package/.output/server/_ssr/{table-NHakBPSp.mjs → table-BAlgZdxo.mjs} +2 -2
  216. package/.output/server/_ssr/tabs-Bm7PWhQk.mjs +45 -0
  217. package/.output/server/_ssr/{updateFailures-n-tGv90S.mjs → updateFailures-DGuFoK6A.mjs} +3 -3
  218. package/.output/server/_ssr/{dist-TEpM_UAD.mjs → uuid-kZvLA0Ly-DNL0qBSj.mjs} +2 -147
  219. package/.output/server/_ssr/{uuidv7-BIF4nb_q.mjs → uuidv7-C0jNe2Om.mjs} +2 -2
  220. package/.output/server/_ssr/{version-CQ98ZBpL-CWSkTT9J.mjs → version-CQ98ZBpL-zW2fpHOZ.mjs} +1 -1
  221. package/.output/server/_tanstack-start-manifest_v-C_zDNaKT.mjs +223 -0
  222. package/.output/server/index.mjs +482 -391
  223. package/lib/index.d.mts +9 -0
  224. package/package.json +7 -30
  225. package/src/components/AppSidebar.tsx +11 -2
  226. package/src/components/ChannelBadge.tsx +9 -9
  227. package/src/components/DataTable.tsx +363 -0
  228. package/src/components/FoldedRows.tsx +219 -0
  229. package/src/components/HashValueDisplay.tsx +6 -3
  230. package/src/components/PlatformIcon.tsx +10 -0
  231. package/src/components/RelativeTime.tsx +31 -0
  232. package/src/components/RowReason.tsx +56 -0
  233. package/src/components/TargetDisplay.tsx +95 -0
  234. package/src/components/ThemeProvider.tsx +11 -2
  235. package/src/components/features/api-keys/ApiKeysPage.tsx +5 -3
  236. package/src/components/features/bundles/BundleMetadata.tsx +1 -1
  237. package/src/components/features/bundles/RolloutCohortsDialog.tsx +8 -1
  238. package/src/components/features/channels/ChannelManagementDialog.tsx +10 -11
  239. package/src/components/features/insights/AppUsage.tsx +3 -5
  240. package/src/components/features/insights/FailureReports.tsx +3 -2
  241. package/src/components/features/insights/InsightsControls.tsx +2 -2
  242. package/src/components/features/insights/InsightsOverview.tsx +7 -1
  243. package/src/components/features/insights/InsightsPageHeader.tsx +10 -15
  244. package/src/components/features/insights/ReleaseActivity.tsx +6 -2
  245. package/src/components/features/insights/ReleaseCombobox.tsx +1 -1
  246. package/src/components/features/insights/UpdateFailures.tsx +1 -0
  247. package/src/components/features/native-builds/BuiltInBundleCard.tsx +122 -61
  248. package/src/components/features/native-builds/CommitLink.tsx +3 -2
  249. package/src/components/features/native-builds/ImportBuild.tsx +1 -1
  250. package/src/components/features/native-builds/InstallCard.tsx +316 -91
  251. package/src/components/features/native-builds/IosDevicesPage.tsx +1100 -0
  252. package/src/components/features/native-builds/IosInstall.tsx +732 -0
  253. package/src/components/features/native-builds/IpaDevicesCard.tsx +111 -0
  254. package/src/components/features/native-builds/NativeBuildDetailPage.tsx +30 -6
  255. package/src/components/features/native-builds/NativeBuildsNav.tsx +44 -0
  256. package/src/components/features/native-builds/NativeBuildsPage.tsx +138 -89
  257. package/src/components/features/native-builds/NativeBuildsTable.tsx +649 -323
  258. package/src/components/features/native-builds/OlderBuildLabel.tsx +61 -0
  259. package/src/components/features/native-builds/PatchesCard.tsx +28 -19
  260. package/src/components/features/native-builds/ReleaseNativeBuildLink.tsx +5 -5
  261. package/src/components/features/native-builds/SandboxBadge.tsx +21 -0
  262. package/src/components/features/native-builds/ServedNowCard.tsx +33 -1
  263. package/src/components/features/native-builds/ShortHash.tsx +6 -3
  264. package/src/components/features/native-builds/StoreSubmission.tsx +18 -12
  265. package/src/components/features/native-builds/playTracks.ts +7 -0
  266. package/src/components/features/releases/ReleaseEditorSheet.tsx +8 -6
  267. package/src/components/features/remote-config/PublishDialog.tsx +4 -1
  268. package/src/components/features/remote-config/VersionsCard.tsx +5 -2
  269. package/src/components/ui/alert-dialog.tsx +2 -2
  270. package/src/components/ui/badge.tsx +2 -0
  271. package/src/components/ui/button.tsx +11 -2
  272. package/src/components/ui/dialog.tsx +3 -3
  273. package/src/components/ui/input.tsx +1 -1
  274. package/src/components/ui/select.tsx +15 -7
  275. package/src/components/ui/sheet.tsx +1 -1
  276. package/src/components/ui/sidebar.tsx +2 -2
  277. package/src/components/ui/slider.tsx +1 -1
  278. package/src/components/ui/sonner.tsx +3 -1
  279. package/src/components/ui/switch.tsx +1 -1
  280. package/src/components/ui/tabs.tsx +1 -1
  281. package/src/components/ui/textarea.tsx +1 -1
  282. package/src/index.ts +9 -0
  283. package/src/lib/api-rpc.ts +125 -35
  284. package/src/lib/api.ts +160 -16
  285. package/src/lib/constants.ts +15 -0
  286. package/src/lib/insights-search.ts +0 -3
  287. package/src/lib/ios-devices-api.ts +290 -0
  288. package/src/lib/ios-devices-rpc.ts +188 -0
  289. package/src/lib/native-builds.ts +263 -20
  290. package/src/lib/server/console-runtime.server.ts +9 -2
  291. package/src/lib/server/deviceProfileToken.ts +221 -0
  292. package/src/lib/server/foldedPage.ts +360 -0
  293. package/src/lib/server/iosDeviceCookie.ts +239 -0
  294. package/src/lib/server/iosDeviceProfile.ts +232 -0
  295. package/src/lib/server/iosDevices.ts +193 -0
  296. package/src/lib/server/listReleases.ts +101 -62
  297. package/src/lib/server/local-console.ts +1 -1
  298. package/src/lib/server/nativeBuildDownloadLink.ts +193 -0
  299. package/src/lib/server/nativeBuildInstall.ts +497 -0
  300. package/src/lib/server/nativeBuilds.ts +314 -58
  301. package/src/lib/server/plistText.ts +17 -0
  302. package/src/lib/server/publicConsoleBase.ts +17 -0
  303. package/src/routeTree.gen.ts +129 -18
  304. package/src/routes/-native-builds-search.ts +52 -4
  305. package/src/routes/-releases-search.ts +63 -2
  306. package/src/routes/[_]hot-updater/devices/device-response.ts +21 -0
  307. package/src/routes/[_]hot-updater/devices/device[.]mobileconfig.ts +17 -0
  308. package/src/routes/[_]hot-updater/devices/receipt.ts +28 -0
  309. package/src/routes/[_]hot-updater/devices/request.ts +28 -0
  310. package/src/routes/[_]hot-updater/native-builds/$buildId/manifest[.]plist.ts +22 -0
  311. package/src/routes/api/native-builds/$buildId/download.ts +22 -1
  312. package/src/routes/index.tsx +645 -552
  313. package/src/routes/insights.tsx +3 -5
  314. package/src/routes/insights_.distribution.tsx +2 -2
  315. package/src/routes/native-builds_.devices.tsx +21 -0
  316. package/src/styles.css +24 -0
  317. package/.output/public/assets/-native-builds-search-C-TGpFAm.js +0 -1
  318. package/.output/public/assets/HashValueDisplay-6lNRxDJX.js +0 -1
  319. package/.output/public/assets/InsightsPageHeader-DHhqY3DT.js +0 -1
  320. package/.output/public/assets/RolloutPercentageBadge-Cxogpi8F.js +0 -1
  321. package/.output/public/assets/StoreSubmission-ViTkW4eJ.js +0 -1
  322. package/.output/public/assets/alert-dialog-BqYScr9y.js +0 -1
  323. package/.output/public/assets/api-P2g8dCNg.js +0 -1
  324. package/.output/public/assets/api-keys-DWQC2q6y.js +0 -1
  325. package/.output/public/assets/api-keys-FueRkF9q.js +0 -1
  326. package/.output/public/assets/arrow-left-g9cKqXuC.js +0 -1
  327. package/.output/public/assets/arrow-right-CNII8TYn.js +0 -1
  328. package/.output/public/assets/arrow-up-right-DK8Zdg40.js +0 -1
  329. package/.output/public/assets/badge-DWFcDWho.js +0 -1
  330. package/.output/public/assets/check-CXVR3s3X.js +0 -1
  331. package/.output/public/assets/chevron-right-BoUXo82O.js +0 -1
  332. package/.output/public/assets/dialog-CNUPxNxH.js +0 -1
  333. package/.output/public/assets/dist-CPlO6ko9.js +0 -1
  334. package/.output/public/assets/empty-B3Uwdd6k.js +0 -1
  335. package/.output/public/assets/field-D-2-mnNh.js +0 -1
  336. package/.output/public/assets/history-DqHlgSuV.js +0 -1
  337. package/.output/public/assets/index-CqP5HPV6.js +0 -10
  338. package/.output/public/assets/input-group-D3OUBk4n.js +0 -1
  339. package/.output/public/assets/insights-B-0odqpt.js +0 -42
  340. package/.output/public/assets/insights-BSVGfxSL.js +0 -1
  341. package/.output/public/assets/insights-NK5B6ReS.js +0 -2
  342. package/.output/public/assets/insights-api-BVCXJsoV.js +0 -1
  343. package/.output/public/assets/insights-search-DghCbEnk.js +0 -1
  344. package/.output/public/assets/insights-usage-rpc-CKQH0pUS.js +0 -1
  345. package/.output/public/assets/insights_.distribution-CJvgwcVZ.js +0 -2
  346. package/.output/public/assets/insights_.distribution-DblZM0mO.js +0 -1
  347. package/.output/public/assets/insights_.distribution-dvk6vYDM.js +0 -1
  348. package/.output/public/assets/installations-B674P5Z5.js +0 -2
  349. package/.output/public/assets/installations-BWxczZ2t.js +0 -1
  350. package/.output/public/assets/installations-Dv4kWQYz.js +0 -1
  351. package/.output/public/assets/native-builds-BOC71grI.js +0 -1
  352. package/.output/public/assets/native-builds-D6rldpSh.js +0 -2
  353. package/.output/public/assets/native-builds-DAy2678K.js +0 -1
  354. package/.output/public/assets/native-builds_._buildId-DD58_Phd.js +0 -1
  355. package/.output/public/assets/native-builds_._buildId-DvQDKnUQ.js +0 -2
  356. package/.output/public/assets/plus-BReVKct-.js +0 -1
  357. package/.output/public/assets/preload-helper-B44EvKhG.js +0 -1
  358. package/.output/public/assets/refresh-cw-B9HHjLej.js +0 -1
  359. package/.output/public/assets/remote-config-B7ujqhLa.js +0 -6
  360. package/.output/public/assets/remote-config-WjpozBG5.js +0 -1
  361. package/.output/public/assets/remote-config-gXeH6PBW.js +0 -1
  362. package/.output/public/assets/routes-BDdBIxYS.js +0 -1
  363. package/.output/public/assets/routes-CCD33Azv.js +0 -2
  364. package/.output/public/assets/search-BCel4Oy6.js +0 -1
  365. package/.output/public/assets/select-CBIU0_M1.js +0 -1
  366. package/.output/public/assets/sidebar-Di9SN47G.js +0 -3
  367. package/.output/public/assets/smartphone-CMaSy_ir.js +0 -1
  368. package/.output/public/assets/styles-uK-0vUMk.css +0 -2
  369. package/.output/public/assets/switch-BpdiHL_t.js +0 -1
  370. package/.output/public/assets/table-Bpy3SvSo.js +0 -1
  371. package/.output/public/assets/tabs-Xmt7tZeG.js +0 -1
  372. package/.output/public/assets/useInfiniteQuery-DX4WpBRG.js +0 -1
  373. package/.output/public/assets/valueToPercent-BLwGy_xK.js +0 -1
  374. package/.output/server/_ssr/-native-builds-search-CwNcoXf4.mjs +0 -37
  375. package/.output/server/_ssr/RolloutPercentageBadge-CoBhJtv9.mjs +0 -21
  376. package/.output/server/_ssr/StoreSubmission-CPg_Rn5E.mjs +0 -139
  377. package/.output/server/_ssr/listReleases-D_GY00SQ.mjs +0 -79
  378. package/.output/server/_ssr/native-builds-BDcOlKnd.mjs +0 -510
  379. package/.output/server/_ssr/native-builds-DhXL5zf_.mjs +0 -137
  380. package/.output/server/_ssr/native-builds_._buildId-BjsdQO93.mjs +0 -813
  381. package/.output/server/_ssr/nativeBuildQr-84cnFQPX.mjs +0 -59
  382. package/.output/server/_ssr/nativeBuilds-B_7BPjt_.mjs +0 -133
  383. package/.output/server/_ssr/qr-code-C7kNRIDX.mjs +0 -22
  384. package/.output/server/_ssr/tabs-BgTTFotk.mjs +0 -45
  385. package/.output/server/_tanstack-start-manifest_v-B5nsO5L4.mjs +0 -184
  386. package/src/lib/server/nativeBuildQr.ts +0 -73
  387. package/src/routes/[_]hot-updater/native-builds/qr.ts +0 -14
@@ -1,14 +1,15 @@
1
- import { n as DatabaseBundleNotFoundError, r as DatabaseRowReferencedError } from "./databaseJsonValue-kS7cvEtz.mjs";
2
- import { O as parseReleaseCatalogScopeKey, a as RELEASE_CATALOG_FALLBACK_POLICY, c as createReleaseCatalogScopeKey, d as getAssetBaseStorageUri, f as getBundlePatch, h as getManifestStorageUri, l as decodeChannelKey, m as getManifestFileHash, r as NIL_UUID, s as canonicalizeAppVersion, u as encodeChannelKey, w as isUUIDv7 } from "./dist-TEpM_UAD.mjs";
3
- import { i as rowToBundle, n as bundleToRow, r as releaseRowToRelease, t as bundleToPatchRows } from "./databaseRows-B6H8Cmgq.mjs";
4
- import { t as ReleaseManagementError } from "./releaseManagement-DHUux2az.mjs";
5
- import { n as createUUIDv7After, t as createUUIDv7 } from "./uuidv7-BIF4nb_q.mjs";
6
- import { i as normalizeRange } from "./version-CQ98ZBpL-CWSkTT9J.mjs";
7
- import { n as projectCompiledCatalog, r as projectCompiledRollbackCatalog, t as compileReleaseCatalog } from "./releaseCatalogCompiler-DLcean2k.mjs";
8
- import { t as isRemoteDatabase } from "./databaseConfig-B_Bg7qS5.mjs";
9
- import { n as defineTable, t as defineAggregate } from "./schema-ChlRtZIo.mjs";
1
+ import { n as DatabaseBundleNotFoundError, r as DatabaseRowReferencedError } from "./databaseJsonValue-DuUoft8j.mjs";
2
+ import { a as getAssetBaseStorageUri, c as getManifestFileHash, i as RELEASE_CATALOG_FALLBACK_POLICY, l as getManifestStorageUri, o as getBundlePatch } from "./dist-CiOq3ygH.mjs";
3
+ import { i as rowToBundle, n as bundleToRow, r as releaseRowToRelease, t as bundleToPatchRows } from "./databaseRows-BZMFl5QV.mjs";
4
+ import { a as decodeChannelKey, c as parseReleaseCatalogScopeKey, i as createReleaseCatalogScopeKey, o as encodeChannelKey, r as canonicalizeAppVersion, s as isUUIDv7, t as NIL_UUID } from "./uuid-kZvLA0Ly-DNL0qBSj.mjs";
5
+ import { t as ReleaseManagementError } from "./releaseManagement-CqIc-SDE.mjs";
6
+ import { n as createUUIDv7After, t as createUUIDv7 } from "./uuidv7-C0jNe2Om.mjs";
7
+ import { i as normalizeRange } from "./version-CQ98ZBpL-zW2fpHOZ.mjs";
8
+ import { n as projectCompiledCatalog, r as projectCompiledRollbackCatalog, t as compileReleaseCatalog } from "./releaseCatalogCompiler-CJ2Shida.mjs";
9
+ import { t as isRemoteDatabase } from "./databaseConfig-B56IJxlu.mjs";
10
+ import { n as defineTable, t as defineAggregate } from "./schema-CaIuQCXb.mjs";
10
11
  import { r as rangesIntersect } from "../_libs/verkit.mjs";
11
- //#region node_modules/.nitro/vite/services/ssr/assets/auth.server-CVKs7SWJ.js
12
+ //#region node_modules/.nitro/vite/services/ssr/assets/auth.server-YE2ZZC0j.js
12
13
  var SHA256_FILE_HASH_RE = /^[0-9a-f]{64}$/;
13
14
  var isContentAddressedAssetFileHash = (value) => {
14
15
  return typeof value === "string" && SHA256_FILE_HASH_RE.test(value);
@@ -1007,6 +1008,27 @@ var channels = defineTable({
1007
1008
  * or `versionCode`. `submitted_to`, `submitted_at_ms` and
1008
1009
  * `submitted_version` record the store track a build went to, when, and
1009
1010
  * the store's label of the build; they stay null for a build no store took.
1011
+ * `is_store_build` is true on the build a person or a job says the store
1012
+ * sells, and false on every other: deploys patch from it over the scope's
1013
+ * newest build. The engine copies the scope key into `store_build_scope_key`
1014
+ * for that build alone, so `byStoreBuild` holds one entry per scope at most,
1015
+ * on every store, while any number of a scope's builds hold none.
1016
+ * `is_sandbox` is true on a sandbox build, set when it registers and never
1017
+ * changed, and `sandbox_url_scheme` is the URL scheme its artifact registers,
1018
+ * which its preview links open; null on any other build, and on a sandbox
1019
+ * build registered before the column, which registered the derived one.
1020
+ * `export_method` is how an `.ipa` was exported, read from its profile when
1021
+ * it registers and never changed; null on any other artifact, on an `.ipa`
1022
+ * whose profile couldn't be read, and on one registered before the column.
1023
+ * `native_app_version` is the app version the artifact itself reports, its
1024
+ * `CFBundleShortVersionString` or `versionName`, read from the artifact when
1025
+ * it registers and never changed, whatever the update strategy; `app_version`
1026
+ * stays the version OTAs target, null on a fingerprint build. It is null
1027
+ * when the artifact's can't be read, and on a build registered before the
1028
+ * column.
1029
+ * Boolean columns follow one rule: `is_*` for a fact about the row or
1030
+ * `should_*` for an instruction to the client, never null; a unique index over
1031
+ * the rows where one is true keys a derived slot, not the boolean.
1010
1032
  */
1011
1033
  var nativeBuilds = defineTable({
1012
1034
  id: {
@@ -1083,9 +1105,32 @@ var nativeBuilds = defineTable({
1083
1105
  type: "string",
1084
1106
  maxLength: 255,
1085
1107
  required: false
1108
+ },
1109
+ is_store_build: { type: "boolean" },
1110
+ is_sandbox: { type: "boolean" },
1111
+ sandbox_url_scheme: {
1112
+ type: "string",
1113
+ maxLength: 255,
1114
+ ascii: true,
1115
+ required: false
1116
+ },
1117
+ export_method: {
1118
+ type: "string",
1119
+ maxLength: 16,
1120
+ required: false
1121
+ },
1122
+ native_app_version: {
1123
+ type: "string",
1124
+ required: false
1086
1125
  }
1087
1126
  }, {
1088
1127
  key: ["id"],
1128
+ derived: { store_build_scope_key: {
1129
+ type: "string",
1130
+ maxLength: 2048,
1131
+ ascii: true,
1132
+ compute: (row) => row.is_store_build ? row.scope_key : null
1133
+ } },
1089
1134
  indexes: {
1090
1135
  byScope: {
1091
1136
  eq: ["scope_key"],
@@ -1095,6 +1140,11 @@ var nativeBuilds = defineTable({
1095
1140
  eq: ["scope_key", "build_key"],
1096
1141
  sort: ["id"]
1097
1142
  },
1143
+ byStoreBuild: {
1144
+ eq: ["store_build_scope_key"],
1145
+ sort: [],
1146
+ unique: true
1147
+ },
1098
1148
  byChannel: {
1099
1149
  eq: ["channel_id"],
1100
1150
  sort: ["id"],
@@ -1106,6 +1156,115 @@ var nativeBuilds = defineTable({
1106
1156
  }
1107
1157
  }
1108
1158
  });
1159
+ /**
1160
+ * The iPhones a team asks to install ad hoc builds on. A row decides what the
1161
+ * CLI registers with Apple, not what an export includes: Xcode's automatic ad
1162
+ * hoc profile lists every device the Apple account has enabled. `status` is
1163
+ * `pending` until someone approves it, `approved` until a build or
1164
+ * `native-build devices add` registers it with Apple, then `registered`;
1165
+ * declining or removing one deletes its row. `udid` is the UDID in lower case.
1166
+ * `apple_issuer_id` is the App Store Connect issuer whose key registered it,
1167
+ * set once: a build signed by another account never registers these rows.
1168
+ * `apple_error` is Apple's refusal of the device, or why it stopped counting
1169
+ * it, cleared by the next success. `build_id` is the newest native build whose
1170
+ * .ipa the CLI checked lists it; deleting that build never touches the row.
1171
+ * It holds personal data: a UDID, a name, and the emails of who asked and who
1172
+ * approved, null for the CLI.
1173
+ */
1174
+ var iosDevices = defineTable({
1175
+ id: {
1176
+ type: "string",
1177
+ maxLength: 36
1178
+ },
1179
+ udid: {
1180
+ type: "string",
1181
+ maxLength: 40,
1182
+ ascii: true,
1183
+ unique: true
1184
+ },
1185
+ name: {
1186
+ type: "string",
1187
+ maxLength: 100
1188
+ },
1189
+ status: {
1190
+ type: "string",
1191
+ maxLength: 16
1192
+ },
1193
+ requested_by: {
1194
+ type: "string",
1195
+ maxLength: 320,
1196
+ required: false
1197
+ },
1198
+ created_at_ms: { type: "integer" },
1199
+ approved_by: {
1200
+ type: "string",
1201
+ maxLength: 320,
1202
+ required: false
1203
+ },
1204
+ approved_at_ms: {
1205
+ type: "integer",
1206
+ required: false
1207
+ },
1208
+ registered_at_ms: {
1209
+ type: "integer",
1210
+ required: false
1211
+ },
1212
+ apple_issuer_id: {
1213
+ type: "string",
1214
+ maxLength: 64,
1215
+ ascii: true,
1216
+ required: false
1217
+ },
1218
+ apple_error: {
1219
+ type: "string",
1220
+ maxLength: 512,
1221
+ required: false
1222
+ },
1223
+ build_id: {
1224
+ type: "string",
1225
+ maxLength: 36,
1226
+ required: false
1227
+ }
1228
+ }, {
1229
+ key: ["id"],
1230
+ indexes: {
1231
+ byStatus: {
1232
+ eq: ["status"],
1233
+ sort: ["id"]
1234
+ },
1235
+ all: {
1236
+ eq: [],
1237
+ sort: ["id"]
1238
+ }
1239
+ }
1240
+ });
1241
+ /**
1242
+ * The Apple account the iOS device registry belongs to: one row, keyed
1243
+ * `registry`, holding the App Store Connect issuer that first registered a
1244
+ * device. A build claims it before it sends Apple anything, and its key makes
1245
+ * the claim atomic on every store, so two builds of two accounts can't both
1246
+ * spend a slot; another account's build then registers nothing. Removing
1247
+ * devices never releases it.
1248
+ */
1249
+ var iosDeviceAccount = defineTable({
1250
+ id: {
1251
+ type: "string",
1252
+ maxLength: 16,
1253
+ ascii: true
1254
+ },
1255
+ apple_issuer_id: {
1256
+ type: "string",
1257
+ maxLength: 64,
1258
+ ascii: true
1259
+ },
1260
+ claimed_at_ms: { type: "integer" }
1261
+ }, {
1262
+ key: ["id"],
1263
+ indexes: { all: {
1264
+ eq: [],
1265
+ sort: ["id"]
1266
+ } }
1267
+ });
1109
1268
  /** Core's module: always installed, never a plugin. */
1110
1269
  var coreModule = {
1111
1270
  id: "core",
@@ -1126,7 +1285,9 @@ var coreModule = {
1126
1285
  sort: []
1127
1286
  } }
1128
1287
  }),
1129
- native_builds: nativeBuilds
1288
+ native_builds: nativeBuilds,
1289
+ ios_devices: iosDevices,
1290
+ ios_device_account: iosDeviceAccount
1130
1291
  }
1131
1292
  };
1132
1293
  var encoder = new TextEncoder();
@@ -1286,15 +1447,8 @@ var LEASE_TABLE = "aggregate_lease";
1286
1447
  var LEASE = { id: "compaction" };
1287
1448
  /** How long a compaction holds the lease before another process may take it. */
1288
1449
  var LEASE_MS = 3e4;
1289
- /**
1290
- * Default windows: log mode compacts every 60 seconds, since reads compact
1291
- * first; memory mode flushes every 15, since its window is what a crash
1292
- * loses.
1293
- */
1294
- var WINDOW_MS = {
1295
- log: 6e4,
1296
- memory: 15e3
1297
- };
1450
+ /** A commit compacts once this has passed since the last compaction. */
1451
+ var WINDOW_MS = 6e4;
1298
1452
  /** Log rows a compaction reads from each log table for one group. */
1299
1453
  var LOG_PAGE = 200;
1300
1454
  /**
@@ -1308,8 +1462,6 @@ var GROUPS = {
1308
1462
  };
1309
1463
  /** Tries per write after a conflict or a transient error. */
1310
1464
  var ATTEMPTS = 5;
1311
- /** Aggregate rows a memory buffer holds before a commit waits for a flush. */
1312
- var MAX_BUFFERED = 1e4;
1313
1465
  var log = defineTable({
1314
1466
  id: {
1315
1467
  type: "string",
@@ -1358,7 +1510,7 @@ var valuesOf = ({ deltas, sketches }) => ({
1358
1510
  /**
1359
1511
  * Merges `values` into the change for `key`'s identity as `tx.aggregate`
1360
1512
  * does: deltas add up and sketches merge. One constant `shardBy` keys each
1361
- * identity to one entry; the write picks the shard.
1513
+ * identity to one entry; `compile` writes it to shard 0.
1362
1514
  */
1363
1515
  var merge = (into, model, key, values) => recordAggregate(into, model, Object.fromEntries(shapeOf(model).key.map((field, at) => [field, key[at]])), values, "");
1364
1516
  var mergeAll = (into, changes) => {
@@ -1392,7 +1544,7 @@ var increment = ({ model, deltas }, key) => Object.values(deltas).some((delta) =
1392
1544
  /**
1393
1545
  * The guarded write that merges `change` into `current`: insert, patch, or
1394
1546
  * delete at zero. Unlike a transaction's, a gauge may go below zero here: a
1395
- * shard row holds one writer's net changes, and reads sum every shard.
1547
+ * group can hold a loss without the gain before it, and reads sum every shard.
1396
1548
  */
1397
1549
  var rewrite = (change, key, current) => {
1398
1550
  const { model } = change;
@@ -1430,12 +1582,12 @@ var rewrite = (change, key, current) => {
1430
1582
  };
1431
1583
  };
1432
1584
  /**
1433
- * The write for each change on its shard: a blind increment that creates
1434
- * the row for counters, and a guarded rewrite for gauges and sketches, whose
1435
- * rows are read in one batch per table.
1585
+ * The write for each change on shard 0, since one compaction runs at a time:
1586
+ * a blind increment that creates the row for counters, and a guarded rewrite
1587
+ * for gauges and sketches, whose rows are read in one batch per table.
1436
1588
  */
1437
- var compile = async (adapter, changes, shard) => {
1438
- const keys = changes.map(({ model, key }) => [...key.slice(0, -1), shard(model)]);
1589
+ var compile = async (adapter, changes) => {
1590
+ const keys = changes.map(({ key }) => [...key.slice(0, -1), 0]);
1439
1591
  const reads = /* @__PURE__ */ new Map();
1440
1592
  changes.forEach((change, at) => {
1441
1593
  if (rewrites(change)) reads.set(change.model, [...reads.get(change.model) ?? [], at]);
@@ -1489,14 +1641,13 @@ var encode = async (changes) => {
1489
1641
  return zipped !== void 0 && zipped.length < json.length ? `z${zipped}` : json;
1490
1642
  };
1491
1643
  /**
1492
- * Batches changes to aggregates declared `batched`. A transaction records
1493
- * them without writing their rows; once it commits, "memory" mode keeps
1494
- * them in this process until its timer flushes them, and "log" mode has
1495
- * written them as one log row in the same atomic write, which a compaction
1496
- * later merges into the aggregates and deletes, atomically again, so each
1497
- * applies exactly once. One lease row keeps compactions one at a time.
1644
+ * Batches changes to aggregates declared `batched`. A transaction writes
1645
+ * them as one log row in its own atomic write, in place of their rows; a
1646
+ * compaction later merges log rows into the aggregates and deletes them,
1647
+ * atomically again, so each applies exactly once. One lease row keeps
1648
+ * compactions one at a time.
1498
1649
  */
1499
- var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log", windowMs = WINDOW_MS[mode] }, now }) => {
1650
+ var createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs = WINDOW_MS }, now }) => {
1500
1651
  if (!schema.models.has(LEASE_TABLE)) throw new DatabaseTransactionError("An engine that batches aggregates needs aggregateBatchingModule in its schema.");
1501
1652
  const holder = crypto.randomUUID().replaceAll("-", "");
1502
1653
  const table = (name) => schema.models.get(name).table;
@@ -1524,68 +1675,6 @@ var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log
1524
1675
  }
1525
1676
  return changes;
1526
1677
  };
1527
- /**
1528
- * Writes changes in atomic chunks within `fits`, and returns the ones it
1529
- * could not apply. A write whose outcome is unknown is dropped, never
1530
- * resent, so no change applies twice.
1531
- */
1532
- const apply = async (changes, shard) => {
1533
- let rest = changes;
1534
- let ops = [];
1535
- let read = true;
1536
- for (let failures = 0; rest.length > 0 && failures < ATTEMPTS;) try {
1537
- if (read) ops = await compile(adapter, rest, shard);
1538
- let size = rest.length;
1539
- const chunk = () => ops.slice(0, size).filter(isOp);
1540
- while (size > 1 && !adapter.fits(chunk())) size = Math.ceil(size / 2);
1541
- let result = { ok: true };
1542
- if (chunk().length > 0) result = await adapter.write(chunk()).catch((error) => {
1543
- warn("flush")(error);
1544
- return { ok: true };
1545
- });
1546
- read = !result.ok && !("retry" in result);
1547
- if (result.ok) {
1548
- rest = rest.slice(size);
1549
- ops = ops.slice(size);
1550
- failures = 0;
1551
- } else {
1552
- failures += 1;
1553
- if (!read) await sleep(failures);
1554
- }
1555
- } catch (error) {
1556
- warn("flush")(error);
1557
- return rest;
1558
- }
1559
- return rest;
1560
- };
1561
- let buffer = /* @__PURE__ */ new Map();
1562
- let timer;
1563
- let flushing;
1564
- const shards = /* @__PURE__ */ new Map();
1565
- /** Each process writes its own shard, so flushes of two processes rarely meet. */
1566
- const processShard = (model) => {
1567
- if (!shards.has(model)) shards.set(model, Math.floor(Math.random() * shapeOf(model).shards));
1568
- return shards.get(model);
1569
- };
1570
- const schedule = () => {
1571
- if (timer !== void 0 || buffer.size === 0) return;
1572
- timer = setTimeout(() => {
1573
- timer = void 0;
1574
- flushBuffer();
1575
- }, windowMs);
1576
- timer.unref?.();
1577
- };
1578
- /** Never rejects: what it cannot apply goes back into the buffer. */
1579
- const flushBuffer = () => flushing ??= (async () => {
1580
- clearTimeout(timer);
1581
- timer = void 0;
1582
- const pending = [...buffer.values()];
1583
- buffer = /* @__PURE__ */ new Map();
1584
- mergeAll(buffer, await apply(pending, processShard));
1585
- })().catch(warn("flush")).finally(() => {
1586
- flushing = void 0;
1587
- schedule();
1588
- });
1589
1678
  let nextDue = 0;
1590
1679
  let compacting;
1591
1680
  /** Log rows this process read, by `[log table's index, id]`, for the deletes after a group. */
@@ -1720,7 +1809,7 @@ var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log
1720
1809
  more
1721
1810
  };
1722
1811
  };
1723
- const rowsFor = async (changes) => (await compile(adapter, changes, () => 0)).filter(isOp);
1812
+ const rowsFor = async (changes) => (await compile(adapter, changes)).filter(isOp);
1724
1813
  /**
1725
1814
  * Applies the oldest pending log rows whose merged changes fit in one
1726
1815
  * atomic write with the lease, which lists them as applied; the rows are
@@ -1814,20 +1903,6 @@ var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log
1814
1903
  }))).then((pages) => pages.some((page) => page.rows.length > 0)).finally(() => {
1815
1904
  checking = void 0;
1816
1905
  });
1817
- /** Takes a committed transaction's changes; never rejects, since the transaction already committed. */
1818
- const committed = async (changes) => {
1819
- if (mode === "log") {
1820
- if (now() >= nextDue) await compact(false, GROUPS.commit);
1821
- return;
1822
- }
1823
- mergeAll(buffer, changes.values());
1824
- schedule();
1825
- if (buffer.size >= MAX_BUFFERED) await flushBuffer();
1826
- };
1827
- const flush = async () => {
1828
- await flushBuffer();
1829
- if (mode === "log" && await hasPending()) await compact(true, GROUPS.flush);
1830
- };
1831
1906
  return {
1832
1907
  async transaction(fn) {
1833
1908
  let changes = /* @__PURE__ */ new Map();
@@ -1853,7 +1928,7 @@ var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log
1853
1928
  aggregate
1854
1929
  });
1855
1930
  if (failure) throw failure.error;
1856
- if (mode === "log" && attempt.size > 0) {
1931
+ if (attempt.size > 0) {
1857
1932
  const id = `${now().toString(36).padStart(9, "0")}${holder.slice(0, 8)}${crypto.randomUUID().slice(0, 8)}`;
1858
1933
  const shard = Math.floor(Math.random() * LOG_TABLES.length);
1859
1934
  const merged = mergeAll(/* @__PURE__ */ new Map(), attempt.values());
@@ -1867,24 +1942,18 @@ var createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "log
1867
1942
  open = false;
1868
1943
  }
1869
1944
  });
1870
- if (changes.size > 0) await committed(changes);
1945
+ if (changes.size > 0 && now() >= nextDue) await compact(false, GROUPS.commit);
1871
1946
  return result;
1872
1947
  },
1873
1948
  async beforeRead(name) {
1874
1949
  if (!isBatched(schema.models.get(name))) return;
1875
- if (buffer.size > 0 || flushing !== void 0) await flushBuffer();
1876
- if (mode === "log") {
1877
- if (await hasPending().catch((error) => {
1878
- warn("read")(error);
1879
- return false;
1880
- })) await compact(true, GROUPS.read);
1881
- }
1950
+ if (await hasPending().catch((error) => {
1951
+ warn("read")(error);
1952
+ return false;
1953
+ })) await compact(true, GROUPS.read);
1882
1954
  },
1883
- flush,
1884
- async dispose() {
1885
- clearTimeout(timer);
1886
- timer = void 0;
1887
- await flush();
1955
+ async flush() {
1956
+ if (await hasPending()) await compact(true, GROUPS.flush);
1888
1957
  }
1889
1958
  };
1890
1959
  };
@@ -2022,7 +2091,8 @@ var fieldProblems = (definition, add) => {
2022
2091
  else if (field.required === false) add(`key field "${name}" is nullable`);
2023
2092
  else if (field.type === "json") add(`key field "${name}" is json`);
2024
2093
  }
2025
- for (const [name, { type, maxLength, ascii }] of Object.entries(definition.fields)) {
2094
+ const bounded = [...Object.entries(definition.fields), ...definition.kind === "table" ? Object.entries(definition.derived) : []];
2095
+ for (const [name, { type, maxLength, ascii }] of bounded) {
2026
2096
  if (maxLength !== void 0 && (type !== "string" || !Number.isSafeInteger(maxLength) || maxLength < 1)) add(`field "${name}" has an invalid maxLength`);
2027
2097
  if (ascii && type !== "string") add(`field "${name}" is ascii but not a string`);
2028
2098
  }
@@ -2139,11 +2209,13 @@ var resolveSchema = (modules) => {
2139
2209
  ...maxLength === void 0 ? {} : { maxLength },
2140
2210
  ...ascii ? { ascii } : {}
2141
2211
  }));
2142
- if (definition.kind === "table") for (const [field, { type, multi }] of Object.entries(definition.derived)) columns.push({
2212
+ if (definition.kind === "table") for (const [field, { type, multi, maxLength, ascii }] of Object.entries(definition.derived)) columns.push({
2143
2213
  name: field,
2144
2214
  type,
2145
2215
  nullable: true,
2146
- ...multi ? { multi } : {}
2216
+ ...multi ? { multi } : {},
2217
+ ...maxLength === void 0 ? {} : { maxLength },
2218
+ ...ascii ? { ascii } : {}
2147
2219
  });
2148
2220
  else columns.push(integer(SHARD_COLUMN), ...[...definition.counters, ...definition.gauges].map((metric) => integer(metric)), ...definition.distinct.map((metric) => ({
2149
2221
  name: metric,
@@ -2801,9 +2873,6 @@ var createDatabaseEngine = ({ batching, now = Date.now, meter, ...options }) =>
2801
2873
  flush: async () => {
2802
2874
  await batches?.flush();
2803
2875
  },
2804
- dispose: async () => {
2805
- await batches?.dispose();
2806
- },
2807
2876
  database(module) {
2808
2877
  const name = (model) => module.namespace ? `${module.namespace}_${model}` : model;
2809
2878
  return {
@@ -2882,11 +2951,10 @@ var createEngine = (database, { plugins = [], now = Date.now } = {}) => {
2882
2951
  if (module === void 0) throw new HotUpdaterConfigError(`Plugin "${plugin.id}" is not one of this engine's plugins.`);
2883
2952
  return engine.database(module);
2884
2953
  },
2885
- flush: () => engine.flush(),
2886
- dispose: () => engine.dispose()
2954
+ flush: () => engine.flush()
2887
2955
  };
2888
2956
  };
2889
- var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.4";
2957
+ var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.40";
2890
2958
  /**
2891
2959
  * `/version` on both mounts. The admin mount also lists the ids of the
2892
2960
  * plugins the server runs, sorted; apps never learn which plugins a server
@@ -3321,8 +3389,8 @@ var baseBundleIdsOf = (row, range, bundleId, limit) => {
3321
3389
  return ids;
3322
3390
  };
3323
3391
  var PAGE$2 = 500;
3324
- var pick$1 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
3325
- var toBundleRow = pick$1([
3392
+ var pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
3393
+ var toBundleRow = pick$2([
3326
3394
  "id",
3327
3395
  "platform",
3328
3396
  "git_commit_hash",
@@ -3331,7 +3399,7 @@ var toBundleRow = pick$1([
3331
3399
  "manifest_file_hash",
3332
3400
  "asset_base_storage_uri"
3333
3401
  ]);
3334
- var toPatchRow = pick$1([
3402
+ var toPatchRow = pick$2([
3335
3403
  "id",
3336
3404
  "bundle_id",
3337
3405
  "base_bundle_id",
@@ -3341,7 +3409,7 @@ var toPatchRow = pick$1([
3341
3409
  "byte_size",
3342
3410
  "order_index"
3343
3411
  ]);
3344
- var toReleaseRow = pick$1([
3412
+ var toReleaseRow = pick$2([
3345
3413
  "id",
3346
3414
  "revision",
3347
3415
  "scope_key",
@@ -3362,7 +3430,7 @@ var toReleaseRow = pick$1([
3362
3430
  "created_at_ms",
3363
3431
  "updated_at_ms"
3364
3432
  ]);
3365
- var toCatalogRow = pick$1([
3433
+ var toCatalogRow = pick$2([
3366
3434
  "scope_key",
3367
3435
  "catalog_id",
3368
3436
  "strategy",
@@ -3377,7 +3445,7 @@ var toCatalogRow = pick$1([
3377
3445
  "is_tombstone",
3378
3446
  "updated_at_ms"
3379
3447
  ]);
3380
- var toChannelRow = pick$1(["id", "name"]);
3448
+ var toChannelRow = pick$2(["id", "name"]);
3381
3449
  /** Every page of one read, in order. */
3382
3450
  var drain = async (read) => {
3383
3451
  const rows = [];
@@ -3390,7 +3458,15 @@ var drain = async (read) => {
3390
3458
  return rows;
3391
3459
  };
3392
3460
  /** A keyset page's range: the keys strictly after `after`, in `order`. */
3393
- var after = (input) => input.after === void 0 ? {} : { range: (input.order ?? "asc") === "asc" ? { gt: input.after } : { lt: input.after } };
3461
+ /** A keyset read's range on its index's order: past `after`, up to `through`. */
3462
+ var after = (input) => {
3463
+ const asc = (input.order ?? "asc") === "asc";
3464
+ const range = {
3465
+ ...input.after === void 0 ? {} : asc ? { gt: input.after } : { lt: input.after },
3466
+ ...input.through === void 0 ? {} : asc ? { lte: input.through } : { gte: input.through }
3467
+ };
3468
+ return Object.keys(range).length === 0 ? {} : { range };
3469
+ };
3394
3470
  /** Core's reads, each through one declared index or key. */
3395
3471
  var createCoreReads = (db, storage) => {
3396
3472
  /** A bundle row's patches, exactly as many as its reference counter holds. */
@@ -3582,6 +3658,317 @@ var createCoreReads = (db, storage) => {
3582
3658
  }
3583
3659
  };
3584
3660
  };
3661
+ /**
3662
+ * A device's UDID: 40 hex digits, or 8 and 16 joined by a hyphen. The same
3663
+ * rule as `normalizeIosUdid` of `@hot-updater/protocol/native-artifact`,
3664
+ * implemented here so the server's runtime never loads the artifact readers.
3665
+ */
3666
+ var UDID = /^(?:[0-9a-f]{40}|[0-9a-f]{8}-[0-9a-f]{16})$/iu;
3667
+ /** The form the registry stores and compares a UDID in, or null for text that isn't one. */
3668
+ var normalizeIosUdid = (value) => {
3669
+ const trimmed = value.trim();
3670
+ return UDID.test(trimmed) ? trimmed.toLowerCase() : null;
3671
+ };
3672
+ /** `ios_devices.name`'s bound in core's schema. */
3673
+ var NAME_MAX_LENGTH = 100;
3674
+ /** `ios_devices.requested_by` and `approved_by`'s bound: an email address. */
3675
+ var EMAIL_MAX_LENGTH = 320;
3676
+ /** `ios_devices.apple_issuer_id`'s bound. */
3677
+ var ISSUER_MAX_LENGTH = 64;
3678
+ /** How many registry rows one read takes while finding its account. */
3679
+ var ACCOUNT_SCAN_PAGE = 200;
3680
+ /** The one row of `ios_device_account`. */
3681
+ var ACCOUNT_ROW = "registry";
3682
+ /** `ios_devices.apple_error`'s bound. */
3683
+ var ERROR_MAX_LENGTH = 512;
3684
+ var STATUSES = [
3685
+ "pending",
3686
+ "approved",
3687
+ "registered"
3688
+ ];
3689
+ var OUTCOMES = [
3690
+ "registered",
3691
+ "refused",
3692
+ "disabled",
3693
+ "missing"
3694
+ ];
3695
+ /** The `apple_error` of a device Apple has disabled. */
3696
+ var IOS_DEVICE_DISABLED_ERROR = "Disabled in the Apple account.";
3697
+ /** The `apple_error` of a registered device Apple no longer lists. */
3698
+ var IOS_DEVICE_MISSING_ERROR = "Gone from the Apple account. Approve it again to register it.";
3699
+ /** A device or registry request core cannot store: the caller's input. */
3700
+ var IosDeviceInputError = class extends TypeError {
3701
+ name = "IosDeviceInputError";
3702
+ };
3703
+ var pick$1 = (row) => ({
3704
+ id: row.id,
3705
+ udid: row.udid,
3706
+ name: row.name,
3707
+ status: row.status,
3708
+ requested_by: row.requested_by ?? null,
3709
+ created_at_ms: row.created_at_ms,
3710
+ approved_by: row.approved_by ?? null,
3711
+ approved_at_ms: row.approved_at_ms ?? null,
3712
+ registered_at_ms: row.registered_at_ms ?? null,
3713
+ apple_issuer_id: row.apple_issuer_id ?? null,
3714
+ apple_error: row.apple_error ?? null,
3715
+ build_id: row.build_id ?? null
3716
+ });
3717
+ var udidOf = (udid) => {
3718
+ const key = typeof udid === "string" ? normalizeIosUdid(udid) : null;
3719
+ if (key === null) throw new IosDeviceInputError("Invalid iOS device: udid must be 40 hex digits, or 8 and 16 joined by a hyphen.");
3720
+ return key;
3721
+ };
3722
+ var nameOf = (name) => {
3723
+ const trimmed = typeof name === "string" ? name.trim() : "";
3724
+ if (trimmed.length === 0 || trimmed.length > NAME_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: name must be 1 to ${NAME_MAX_LENGTH} characters.`);
3725
+ return trimmed;
3726
+ };
3727
+ /** An email, lower-cased, or null for the CLI. */
3728
+ var personOf = (value, field) => {
3729
+ if (value === null) return null;
3730
+ const email = typeof value === "string" ? value.trim().toLowerCase() : "";
3731
+ if (email.length === 0 || email.length > EMAIL_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: ${field} must be an email of at most ${EMAIL_MAX_LENGTH} characters, or null.`);
3732
+ return email;
3733
+ };
3734
+ /** Apple's words, on one line and within the column's bound. */
3735
+ var errorText = (text) => {
3736
+ const line = text.replace(/\s+/gu, " ").trim();
3737
+ return line.length > ERROR_MAX_LENGTH ? `${line.slice(0, 511)}…` : line;
3738
+ };
3739
+ /**
3740
+ * The iOS device registry: the iPhones and iPads a team asked to install ad hoc
3741
+ * builds on. The Console writes requests and approvals, and the CLI what Apple
3742
+ * said, each over the row it read.
3743
+ */
3744
+ var createIosDeviceApi = (db, { now = Date.now } = {}) => {
3745
+ const findIosDevice = async (udid) => {
3746
+ const key = normalizeIosUdid(udid);
3747
+ if (key === null) return null;
3748
+ const row = await db.findOne("ios_devices", { udid: key });
3749
+ return row === null ? null : pick$1(row);
3750
+ };
3751
+ /**
3752
+ * The issuer of the registry's earliest registration among its rows, by
3753
+ * when and then by ID, or null when no row names one: read only while the
3754
+ * registry has no account yet, a page at a time.
3755
+ */
3756
+ const accountOfRows = async () => {
3757
+ let earliest = null;
3758
+ for (let after;;) {
3759
+ const { rows } = await db.findMany("ios_devices", {
3760
+ index: "all",
3761
+ where: {},
3762
+ order: "asc",
3763
+ limit: ACCOUNT_SCAN_PAGE,
3764
+ ...after === void 0 ? {} : { range: { gt: after } }
3765
+ });
3766
+ for (const row of rows.map(pick$1)) {
3767
+ if (row.apple_issuer_id === null) continue;
3768
+ if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
3769
+ }
3770
+ if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
3771
+ after = rows.at(-1).id;
3772
+ }
3773
+ };
3774
+ return {
3775
+ async listIosDevices(input) {
3776
+ if (input.status !== void 0 && !STATUSES.includes(input.status)) throw new IosDeviceInputError(`Invalid iOS device status: ${String(input.status)}. Expected ${STATUSES.join(", ")}.`);
3777
+ const page = {
3778
+ order: input.order ?? "asc",
3779
+ limit: input.limit,
3780
+ ...after(input)
3781
+ };
3782
+ const { rows } = input.status === void 0 ? await db.findMany("ios_devices", {
3783
+ index: "all",
3784
+ where: {},
3785
+ ...page
3786
+ }) : await db.findMany("ios_devices", {
3787
+ index: "byStatus",
3788
+ where: { status: input.status },
3789
+ ...page
3790
+ });
3791
+ return rows.map(pick$1);
3792
+ },
3793
+ findIosDevice,
3794
+ async requestIosDevice(input) {
3795
+ const udid = udidOf(input.udid);
3796
+ const name = nameOf(input.name);
3797
+ const requestedBy = personOf(input.requestedBy, "requestedBy");
3798
+ const existing = await db.findOne("ios_devices", { udid });
3799
+ if (existing !== null) return {
3800
+ device: pick$1(existing),
3801
+ created: false
3802
+ };
3803
+ const device = {
3804
+ id: createUUIDv7(),
3805
+ udid,
3806
+ name,
3807
+ status: "pending",
3808
+ requested_by: requestedBy,
3809
+ created_at_ms: now(),
3810
+ approved_by: null,
3811
+ approved_at_ms: null,
3812
+ registered_at_ms: null,
3813
+ apple_issuer_id: null,
3814
+ apple_error: null,
3815
+ build_id: null
3816
+ };
3817
+ try {
3818
+ await db.transaction(async (tx) => {
3819
+ tx.create("ios_devices", device);
3820
+ });
3821
+ } catch (error) {
3822
+ if (error instanceof DatabaseConstraintError && error.reason === "unique") {
3823
+ const winner = await db.findOne("ios_devices", { udid });
3824
+ if (winner !== null) return {
3825
+ device: pick$1(winner),
3826
+ created: false
3827
+ };
3828
+ }
3829
+ throw error;
3830
+ }
3831
+ return {
3832
+ device,
3833
+ created: true
3834
+ };
3835
+ },
3836
+ async approveIosDevice(id, input) {
3837
+ const name = input.name === void 0 ? void 0 : nameOf(input.name);
3838
+ const approvedBy = personOf(input.approvedBy, "approvedBy");
3839
+ return db.transaction(async (tx) => {
3840
+ const row = await tx.findOne("ios_devices", { id });
3841
+ if (row === null) return null;
3842
+ const device = pick$1(row);
3843
+ const set = {
3844
+ ...name === void 0 || name === device.name ? {} : { name },
3845
+ ...device.status === "pending" ? {
3846
+ status: "approved",
3847
+ approved_by: approvedBy,
3848
+ approved_at_ms: now()
3849
+ } : {}
3850
+ };
3851
+ if (Object.keys(set).length === 0) return device;
3852
+ tx.update("ios_devices", row, set);
3853
+ return {
3854
+ ...device,
3855
+ ...set
3856
+ };
3857
+ });
3858
+ },
3859
+ async renameIosDevice(id, input) {
3860
+ const name = nameOf(input);
3861
+ return db.transaction(async (tx) => {
3862
+ const row = await tx.findOne("ios_devices", { id });
3863
+ if (row === null) return null;
3864
+ const device = pick$1(row);
3865
+ if (device.name === name) return device;
3866
+ tx.update("ios_devices", row, { name });
3867
+ return {
3868
+ ...device,
3869
+ name
3870
+ };
3871
+ });
3872
+ },
3873
+ async recordIosDeviceOutcome({ id, seen, issuerId, outcome, reason }) {
3874
+ if (!OUTCOMES.includes(outcome)) throw new IosDeviceInputError(`Invalid iOS device outcome: ${String(outcome)}. Expected ${OUTCOMES.join(", ")}.`);
3875
+ if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device outcome: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
3876
+ return db.transaction(async (tx) => {
3877
+ const row = await tx.findOne("ios_devices", { id });
3878
+ if (row === null) return null;
3879
+ const device = pick$1(row);
3880
+ if (device.status !== seen.status || device.approved_at_ms !== seen.approvedAtMs || device.apple_issuer_id !== null && device.apple_issuer_id !== issuerId) return null;
3881
+ let set;
3882
+ switch (outcome) {
3883
+ case "registered":
3884
+ if (device.status === "pending") return null;
3885
+ set = {
3886
+ status: "registered",
3887
+ registered_at_ms: device.registered_at_ms ?? now(),
3888
+ apple_issuer_id: issuerId,
3889
+ apple_error: null
3890
+ };
3891
+ break;
3892
+ case "refused":
3893
+ if (device.status !== "approved") return null;
3894
+ set = { apple_error: errorText(reason === void 0 || reason.trim() === "" ? "Apple refused it." : reason) };
3895
+ break;
3896
+ case "disabled":
3897
+ if (device.status === "pending") return null;
3898
+ set = { apple_error: IOS_DEVICE_DISABLED_ERROR };
3899
+ break;
3900
+ case "missing":
3901
+ if (device.status !== "registered") return null;
3902
+ set = {
3903
+ status: "pending",
3904
+ approved_by: null,
3905
+ approved_at_ms: null,
3906
+ apple_error: IOS_DEVICE_MISSING_ERROR
3907
+ };
3908
+ }
3909
+ if (Object.entries(set).some(([column, value]) => device[column] !== (value ?? null))) tx.update("ios_devices", row, set);
3910
+ return {
3911
+ ...device,
3912
+ ...set
3913
+ };
3914
+ });
3915
+ },
3916
+ async markIosDevicesInBuild({ buildId, ids }) {
3917
+ for (const id of new Set(ids)) await db.transaction(async (tx) => {
3918
+ const row = await tx.findOne("ios_devices", { id });
3919
+ if (row === null || typeof row.build_id === "string" && row.build_id >= buildId) return;
3920
+ tx.update("ios_devices", row, { build_id: buildId });
3921
+ });
3922
+ },
3923
+ async claimIosDeviceAccount(issuerId) {
3924
+ if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device account: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
3925
+ const answer = (held) => ({
3926
+ issuerId: held,
3927
+ claimed: held === issuerId
3928
+ });
3929
+ const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
3930
+ if (existing !== null) return answer(existing.apple_issuer_id);
3931
+ const holder = await accountOfRows() ?? issuerId;
3932
+ try {
3933
+ await db.transaction(async (tx) => {
3934
+ tx.create("ios_device_account", {
3935
+ id: ACCOUNT_ROW,
3936
+ apple_issuer_id: holder,
3937
+ claimed_at_ms: now()
3938
+ });
3939
+ });
3940
+ return answer(holder);
3941
+ } catch (error) {
3942
+ if (error instanceof DatabaseConstraintError && (error.reason === "exists" || error.reason === "unique")) {
3943
+ const winner = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
3944
+ if (winner !== null) return answer(winner.apple_issuer_id);
3945
+ }
3946
+ throw error;
3947
+ }
3948
+ },
3949
+ async deleteIosDevice(id, only) {
3950
+ const requestedBy = only?.requestedBy === void 0 ? void 0 : personOf(only.requestedBy, "requestedBy");
3951
+ return db.transaction(async (tx) => {
3952
+ const row = await tx.findOne("ios_devices", { id });
3953
+ if (row === null) return null;
3954
+ const device = pick$1(row);
3955
+ if (only?.status !== void 0 && device.status !== only.status || requestedBy !== void 0 && device.requested_by !== requestedBy) return null;
3956
+ await tx.delete("ios_devices", row);
3957
+ return device;
3958
+ });
3959
+ }
3960
+ };
3961
+ };
3962
+ /** Store destinations accepted for each native platform. */
3963
+ var NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
3964
+ android: [
3965
+ "play-internal",
3966
+ "play-closed",
3967
+ "play-open",
3968
+ "play-production"
3969
+ ],
3970
+ ios: ["testflight"]
3971
+ };
3585
3972
  var PAGE$1 = 500;
3586
3973
  /** Moves one bundle into or out of its platform's total and the overall total. */
3587
3974
  var countBundle = (tx, platform, delta) => {
@@ -3610,8 +3997,10 @@ var deleteBundle = async (tx, current) => {
3610
3997
  /**
3611
3998
  * Replaces a bundle's patches with `rows`: kept patches are updated where
3612
3999
  * they changed, others deleted or created, so no key is written twice.
4000
+ * `checkNew` sees each patch it is about to create, and refuses one by
4001
+ * throwing, which leaves the transaction's writes undone.
3613
4002
  */
3614
- var replaceBundlePatches = async (tx, bundle, rows) => {
4003
+ var replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
3615
4004
  const wanted = new Map(rows.map((row) => [row.id, row]));
3616
4005
  const count = bundle._refs_bundle_patches_bundle_id ?? 0;
3617
4006
  let cursor;
@@ -3636,6 +4025,7 @@ var replaceBundlePatches = async (tx, bundle, rows) => {
3636
4025
  if (page.next === void 0) break;
3637
4026
  cursor = page.next;
3638
4027
  }
4028
+ if (checkNew !== void 0) for (const row of wanted.values()) await checkNew(row);
3639
4029
  for (const row of wanted.values()) tx.create("bundle_patches", row);
3640
4030
  };
3641
4031
  /** A channel by name, created when missing; a concurrent creator's row is returned instead. */
@@ -3696,6 +4086,13 @@ var GIT_COMMIT_HASH_MAX_LENGTH = 255;
3696
4086
  * and looks up nothing else.
3697
4087
  */
3698
4088
  var BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
4089
+ /** `native_builds.sandbox_url_scheme`'s bound in core's schema. */
4090
+ var SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
4091
+ /**
4092
+ * A URL scheme as RFC 3986 spells it, in lower case: what a sandbox build's
4093
+ * artifact registers, as `@hot-updater/protocol/native-artifact` reads it.
4094
+ */
4095
+ var URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
3699
4096
  /** A native build or scope core cannot store or look up: the caller's input. */
3700
4097
  var NativeBuildInputError = class extends TypeError {
3701
4098
  name = "NativeBuildInputError";
@@ -3717,13 +4114,33 @@ var pick = (row) => ({
3717
4114
  build_number: row.build_number ?? null,
3718
4115
  submitted_to: row.submitted_to ?? null,
3719
4116
  submitted_at_ms: row.submitted_at_ms ?? null,
3720
- submitted_version: row.submitted_version ?? null
4117
+ submitted_version: row.submitted_version ?? null,
4118
+ is_store_build: row.is_store_build === true,
4119
+ is_sandbox: row.is_sandbox === true,
4120
+ sandbox_url_scheme: row.sandbox_url_scheme ?? null,
4121
+ export_method: row.export_method ?? null,
4122
+ native_app_version: row.native_app_version ?? null
3721
4123
  });
3722
- /** The store track each platform's builds are submitted to. */
3723
- var SUBMISSION_DESTINATIONS = {
3724
- android: "play-internal",
3725
- ios: "testflight"
3726
- };
4124
+ /** The export methods an `.ipa` registers with. */
4125
+ var EXPORT_METHODS = /* @__PURE__ */ new Set([
4126
+ "app-store",
4127
+ "ad-hoc",
4128
+ "development",
4129
+ "enterprise"
4130
+ ]);
4131
+ /**
4132
+ * The channels only sandbox builds register on: a registration's `sandbox`
4133
+ * must agree with it. The registry's convention, as
4134
+ * `@hot-updater/protocol/native-artifact` checks it for a build's artifact.
4135
+ */
4136
+ var SANDBOX_CHANNEL_PREFIX = "sandbox-";
4137
+ /**
4138
+ * How many older builds of a scope one read takes, looking for one older than
4139
+ * a bundle when a build made after the bundle is the newest.
4140
+ */
4141
+ var OLDER_BUILDS_PAGE = 20;
4142
+ /** How many times a mark runs again after losing its scope's mark to another. */
4143
+ var MARK_ATTEMPTS = 8;
3727
4144
  /** `native_builds.build_number`'s bound in core's schema. */
3728
4145
  var BUILD_NUMBER_MAX_LENGTH = 64;
3729
4146
  /** `native_builds.submitted_version`'s bound in core's schema. */
@@ -3754,19 +4171,40 @@ var nativeBuildScopeKey = (scope) => {
3754
4171
  if (scopeKey.length > SCOPE_KEY_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build scope: its key is longer than ${SCOPE_KEY_MAX_LENGTH} characters; shorten the channel or app version.`);
3755
4172
  return scopeKey;
3756
4173
  };
4174
+ /**
4175
+ * Refuses a patch from a sandbox build's built-in bundle: no deploy patches
4176
+ * from one, so no store or test install of the app gets a patch made for a
4177
+ * sandbox build. One unique read of the base.
4178
+ */
4179
+ var refuseSandboxPatchBase = async (db, baseBundleId) => {
4180
+ if ((await db.findOne("native_builds", { min_bundle_id: baseBundleId }))?.is_sandbox === true) throw new NativeBuildInputError("A sandbox build's built-in bundle is no patch base.");
4181
+ };
3757
4182
  /** Whether `bundleId` is a native build's built-in bundle: one unique read. */
3758
4183
  var isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
3759
- var problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, artifact }) => {
4184
+ var problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, nativeAppVersion, artifact }) => {
3760
4185
  if (!isUUIDv7(id)) return "id must be a UUIDv7";
3761
4186
  if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
3762
4187
  if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
3763
4188
  if (channel.trim().length === 0) return "channel is required";
4189
+ if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
4190
+ const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
4191
+ if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
4192
+ if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
4193
+ if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
4194
+ if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
4195
+ if (typeof sandboxUrlScheme !== "string" || !URL_SCHEME.test(sandboxUrlScheme)) return `sandboxUrlScheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters, or null`;
4196
+ }
3764
4197
  if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
3765
4198
  if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
3766
4199
  if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
3767
4200
  if (buildNumber !== void 0 && buildNumber !== null && (buildNumber.trim().length === 0 || buildNumber.length > BUILD_NUMBER_MAX_LENGTH)) return `buildNumber must be the artifact's build number, up to ${BUILD_NUMBER_MAX_LENGTH} characters, or null`;
4201
+ if (nativeAppVersion !== void 0 && nativeAppVersion !== null && (typeof nativeAppVersion !== "string" || nativeAppVersion.trim().length === 0)) return "nativeAppVersion must be the artifact's app version, or null";
3768
4202
  const kinds = ARTIFACT_KINDS[platform];
3769
4203
  if (!kinds.includes(artifact.kind)) return `artifact.kind of an ${platform} build must be ${kinds.join(" or ")}`;
4204
+ if (exportMethod !== void 0 && exportMethod !== null) {
4205
+ if (artifact.kind !== "ipa") return "exportMethod is an .ipa's, and this artifact isn't one";
4206
+ if (!EXPORT_METHODS.has(exportMethod)) return `exportMethod must be ${[...EXPORT_METHODS].join(", ")}, or null`;
4207
+ }
3770
4208
  if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
3771
4209
  return null;
3772
4210
  };
@@ -3795,7 +4233,12 @@ var createNativeBuildApi = (db, { now = Date.now } = {}) => ({
3795
4233
  build_number: registration.buildNumber ?? null,
3796
4234
  submitted_to: null,
3797
4235
  submitted_at_ms: null,
3798
- submitted_version: null
4236
+ submitted_version: null,
4237
+ is_store_build: false,
4238
+ is_sandbox: registration.isSandbox === true,
4239
+ sandbox_url_scheme: registration.sandboxUrlScheme ?? null,
4240
+ export_method: registration.exportMethod ?? null,
4241
+ native_app_version: registration.nativeAppVersion ?? null
3799
4242
  };
3800
4243
  for (let attempt = 1;; attempt += 1) {
3801
4244
  await insertChannel(db, {
@@ -3833,21 +4276,43 @@ var createNativeBuildApi = (db, { now = Date.now } = {}) => ({
3833
4276
  const scopeKey = nativeBuildScopeKey(scope);
3834
4277
  const buildKey = options?.buildKey;
3835
4278
  if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
3836
- const { rows } = buildKey === void 0 ? await db.findMany("native_builds", {
3837
- index: "byScope",
3838
- where: { scope_key: scopeKey },
3839
- order: "desc",
3840
- limit: 1
3841
- }) : await db.findMany("native_builds", {
3842
- index: "byBuildKey",
3843
- where: {
3844
- scope_key: scopeKey,
3845
- build_key: buildKey
3846
- },
3847
- order: "desc",
3848
- limit: 1
3849
- });
3850
- return rows[0] === void 0 ? null : pick(rows[0]);
4279
+ if (options?.storeBuild) {
4280
+ const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
4281
+ return marked === null ? null : pick(marked);
4282
+ }
4283
+ const read = (limit, before) => {
4284
+ const page = {
4285
+ order: "desc",
4286
+ limit,
4287
+ ...before === void 0 ? {} : { range: { lt: before } }
4288
+ };
4289
+ return buildKey === void 0 ? db.findMany("native_builds", {
4290
+ index: "byScope",
4291
+ where: { scope_key: scopeKey },
4292
+ ...page
4293
+ }) : db.findMany("native_builds", {
4294
+ index: "byBuildKey",
4295
+ where: {
4296
+ scope_key: scopeKey,
4297
+ build_key: buildKey
4298
+ },
4299
+ ...page
4300
+ });
4301
+ };
4302
+ const bundleId = options?.builtInOlderThan;
4303
+ if (bundleId !== void 0 && scope.channel.startsWith(SANDBOX_CHANNEL_PREFIX)) return null;
4304
+ const { rows } = await read(1);
4305
+ const newest = rows[0];
4306
+ if (newest === void 0) return null;
4307
+ if (bundleId === void 0 || newest.min_bundle_id < bundleId) return pick(newest);
4308
+ for (let before = newest.id;;) {
4309
+ const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
4310
+ const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
4311
+ if (usable !== void 0) return pick(usable);
4312
+ const last = older.at(-1);
4313
+ if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
4314
+ before = last.id;
4315
+ }
3851
4316
  },
3852
4317
  async recordNativeBuildSubmission(id, { destination, version }) {
3853
4318
  if (version.trim().length === 0 || version.length > SUBMITTED_VERSION_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build submission: version must be the store's label of the build, up to ${SUBMITTED_VERSION_MAX_LENGTH} characters.`);
@@ -3855,7 +4320,8 @@ var createNativeBuildApi = (db, { now = Date.now } = {}) => ({
3855
4320
  const row = await tx.findOne("native_builds", { id });
3856
4321
  if (row === null) return null;
3857
4322
  const build = pick(row);
3858
- if (SUBMISSION_DESTINATIONS[build.platform] !== destination) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${SUBMISSION_DESTINATIONS[build.platform]}, not ${destination}.`);
4323
+ if (!NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].includes(destination)) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].join(" or ")}, not ${destination}.`);
4324
+ if (build.is_sandbox && destination !== "testflight" && destination !== "play-internal") throw new NativeBuildInputError("A sandbox build can submit only to TestFlight or Play internal testing.");
3859
4325
  const set = {
3860
4326
  submitted_to: destination,
3861
4327
  submitted_at_ms: now(),
@@ -3868,6 +4334,46 @@ var createNativeBuildApi = (db, { now = Date.now } = {}) => ({
3868
4334
  };
3869
4335
  });
3870
4336
  },
4337
+ async markNativeBuild(id, { storeBuild }) {
4338
+ for (let attempt = 1;; attempt += 1) try {
4339
+ return await db.transaction(async (tx) => {
4340
+ const row = await tx.findOne("native_builds", { id });
4341
+ if (row === null) return null;
4342
+ const build = pick(row);
4343
+ if (!storeBuild) {
4344
+ if (build.is_store_build) tx.update("native_builds", row, { is_store_build: false });
4345
+ return {
4346
+ nativeBuild: {
4347
+ ...build,
4348
+ is_store_build: false
4349
+ },
4350
+ previous: null
4351
+ };
4352
+ }
4353
+ if (build.is_sandbox) throw new NativeBuildInputError("A sandbox build can't be the store build.");
4354
+ if (build.is_store_build) return {
4355
+ nativeBuild: build,
4356
+ previous: null
4357
+ };
4358
+ const holder = await tx.findOne("native_builds", { store_build_scope_key: build.scope_key });
4359
+ if (holder !== null) tx.update("native_builds", holder, { is_store_build: false });
4360
+ tx.update("native_builds", row, { is_store_build: true });
4361
+ return {
4362
+ nativeBuild: {
4363
+ ...build,
4364
+ is_store_build: true
4365
+ },
4366
+ previous: holder === null ? null : {
4367
+ ...pick(holder),
4368
+ is_store_build: false
4369
+ }
4370
+ };
4371
+ });
4372
+ } catch (error) {
4373
+ if (attempt < MARK_ATTEMPTS && error instanceof DatabaseConstraintError && error.reason === "unique") continue;
4374
+ throw error;
4375
+ }
4376
+ },
3871
4377
  async deleteNativeBuild(id) {
3872
4378
  return db.transaction(async (tx) => {
3873
4379
  const row = await tx.findOne("native_builds", { id });
@@ -4209,7 +4715,11 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
4209
4715
  for (const { release } of deployments) if (!channels.has(release.channel)) channels.set(release.channel, await ensureChannel(release.channel));
4210
4716
  const platforms = /* @__PURE__ */ new Map();
4211
4717
  for (const deployment of deployments) {
4212
- if (!("bundleId" in deployment) || platforms.has(deployment.bundleId)) continue;
4718
+ if (!("bundleId" in deployment)) {
4719
+ for (const { baseBundleId } of deployment.bundle.patches ?? []) await refuseSandboxPatchBase(db, baseBundleId);
4720
+ continue;
4721
+ }
4722
+ if (platforms.has(deployment.bundleId)) continue;
4213
4723
  const row = await db.findOne("bundles", { id: deployment.bundleId });
4214
4724
  if (row === null) throw new DatabaseBundleNotFoundError(deployment.bundleId);
4215
4725
  if (await isBuiltInBundle(db, deployment.bundleId)) throw new ReleaseManagementError("TARGET_RELEASE_INVALID", `Bundle "${deployment.bundleId}" is a native build's built-in bundle, which no release publishes.`);
@@ -4412,7 +4922,7 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
4412
4922
  if (patches !== void 0) await replaceBundlePatches(tx, current, bundleToPatchRows({
4413
4923
  ...next,
4414
4924
  patches
4415
- }));
4925
+ }), (row) => refuseSandboxPatchBase(tx, row.base_bundle_id));
4416
4926
  }),
4417
4927
  deleteBundles: async (ids) => {
4418
4928
  try {
@@ -4472,6 +4982,7 @@ var createCoreApi = (db, storage, options = {}) => {
4472
4982
  ...reads,
4473
4983
  ...createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
4474
4984
  ...createNativeBuildApi(db, options),
4985
+ ...createIosDeviceApi(db, options),
4475
4986
  ready: async () => {
4476
4987
  await reads.listReleaseCatalogs({ limit: 1 });
4477
4988
  }
@@ -4682,10 +5193,12 @@ var keyset = (url, maxValue = LIMITS.maxValue) => {
4682
5193
  const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
4683
5194
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
4684
5195
  const cursor = url.searchParams.get("cursor");
5196
+ const through = url.searchParams.get("through");
4685
5197
  return {
4686
5198
  order,
4687
5199
  limit,
4688
- ...cursor === null ? {} : { after: cursor }
5200
+ ...cursor === null ? {} : { after: cursor },
5201
+ ...through === null ? {} : { through }
4689
5202
  };
4690
5203
  };
4691
5204
  /** A page and the cursor of the next one, when the page is full. */
@@ -4800,11 +5313,11 @@ var refusingInvalid = async (operation) => {
4800
5313
  try {
4801
5314
  return await operation();
4802
5315
  } catch (error) {
4803
- if (error instanceof NativeBuildInputError) throw new HandlerBadRequestError(error.message);
5316
+ if (error instanceof NativeBuildInputError || error instanceof IosDeviceInputError) throw new HandlerBadRequestError(error.message);
4804
5317
  throw error;
4805
5318
  }
4806
5319
  };
4807
- var isNativeBuildRegistration = (value) => isRecord$1(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && isRecord$1(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$1(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$1(value.embeddedBundle.metadata));
5320
+ var isNativeBuildRegistration = (value) => isRecord$1(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull(value.sandboxUrlScheme)) && (value.exportMethod === void 0 || isTextOrNull(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull(value.nativeAppVersion)) && isRecord$1(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$1(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$1(value.embeddedBundle.metadata));
4808
5321
  var scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
4809
5322
  /** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
4810
5323
  var createAdminRouteHandlers = () => ({
@@ -4880,7 +5393,8 @@ var createAdminRouteHandlers = () => ({
4880
5393
  rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
4881
5394
  updateBundle: onCore(async (core, request, params) => {
4882
5395
  const bundleId = requireRouteParam(params, "id");
4883
- await core.updateBundle(bundleId, bundleUpdateOf(await request.json(), bundleId));
5396
+ const update = bundleUpdateOf(await request.json(), bundleId);
5397
+ await refusingInvalid(() => core.updateBundle(bundleId, update));
4884
5398
  return noContent();
4885
5399
  }),
4886
5400
  countBundles: onCore(async (core, request) => json({ data: await core.countBundles(platformOf(new URL(request.url))) })),
@@ -4903,7 +5417,7 @@ var createAdminRouteHandlers = () => ({
4903
5417
  deployReleases: onCore(async (core, request) => {
4904
5418
  const { deployments } = await body(request);
4905
5419
  if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
4906
- return json({ data: await core.deploy(deployments) }, 201);
5420
+ return json({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
4907
5421
  }),
4908
5422
  promoteRelease: onCore(async (core, request, params) => {
4909
5423
  const input = await body(request);
@@ -4926,7 +5440,13 @@ var createAdminRouteHandlers = () => ({
4926
5440
  const url = new URL(request.url);
4927
5441
  const scope = nativeBuildScopeOf(url);
4928
5442
  const buildKey = url.searchParams.get("buildKey");
4929
- return json({ data: await refusingInvalid(() => buildKey === null ? core.findNativeBuild(scope) : core.findNativeBuild(scope, { buildKey })) });
5443
+ const builtInOlderThan = url.searchParams.get("builtInOlderThan");
5444
+ const options = {
5445
+ ...buildKey === null ? {} : { buildKey },
5446
+ ...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
5447
+ ...builtInOlderThan === null ? {} : { builtInOlderThan }
5448
+ };
5449
+ return json({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
4930
5450
  }),
4931
5451
  getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
4932
5452
  listNativeBuilds: onCore(async (core, request) => {
@@ -4940,14 +5460,95 @@ var createAdminRouteHandlers = () => ({
4940
5460
  }),
4941
5461
  recordNativeBuildSubmission: onCore(async (core, request, params) => {
4942
5462
  const input = await body(request);
4943
- if (!isRecord$1(input) || input.destination !== "testflight" && input.destination !== "play-internal" || !isText(input.version)) throw new HandlerBadRequestError("A native build submission needs destination (testflight or play-internal) and version.");
5463
+ if (!isRecord$1(input) || !Object.values(NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText(input.version)) throw new HandlerBadRequestError("A native build submission needs a valid store destination and version.");
4944
5464
  const submission = {
4945
5465
  destination: input.destination,
4946
5466
  version: input.version
4947
5467
  };
4948
5468
  return json({ data: await refusingInvalid(() => core.recordNativeBuildSubmission(requireRouteParam(params, "id"), submission)) });
4949
5469
  }),
5470
+ markNativeBuild: onCore(async (core, request, params) => {
5471
+ const input = await body(request);
5472
+ if (!isRecord$1(input) || typeof input.storeBuild !== "boolean") throw new HandlerBadRequestError("A native build's store build mark needs storeBuild, true or false.");
5473
+ const mark = { storeBuild: input.storeBuild };
5474
+ return json({ data: await refusingInvalid(() => core.markNativeBuild(requireRouteParam(params, "id"), mark)) });
5475
+ }),
4950
5476
  deleteNativeBuild: onCore(async (core, _request, params) => json({ data: await core.deleteNativeBuild(requireRouteParam(params, "id")) })),
5477
+ listIosDevices: onCore(async (core, request) => {
5478
+ const url = new URL(request.url);
5479
+ const input = keyset(url);
5480
+ const status = url.searchParams.get("status");
5481
+ return page(await refusingInvalid(() => core.listIosDevices({
5482
+ ...input,
5483
+ ...status === null ? {} : { status }
5484
+ })), input, ({ id }) => id);
5485
+ }),
5486
+ findIosDevice: onCore(async (core, _request, params) => json({ data: await core.findIosDevice(requireRouteParam(params, "udid")) })),
5487
+ requestIosDevice: onCore(async (core, request) => {
5488
+ const input = await body(request);
5489
+ if (!isText(input.udid) || !isText(input.name) || !isTextOrNull(input.requestedBy)) throw new HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
5490
+ const device = {
5491
+ udid: input.udid,
5492
+ name: input.name,
5493
+ requestedBy: input.requestedBy
5494
+ };
5495
+ return json({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
5496
+ }),
5497
+ approveIosDevice: onCore(async (core, request, params) => {
5498
+ const input = await body(request);
5499
+ if (!isTextOrNull(input.approvedBy) || input.name !== void 0 && !isText(input.name)) throw new HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
5500
+ const approval = {
5501
+ approvedBy: input.approvedBy,
5502
+ ...input.name === void 0 ? {} : { name: input.name }
5503
+ };
5504
+ return json({ data: await refusingInvalid(() => core.approveIosDevice(requireRouteParam(params, "id"), approval)) });
5505
+ }),
5506
+ renameIosDevice: onCore(async (core, request, params) => {
5507
+ const input = await body(request);
5508
+ if (!isText(input.name)) throw new HandlerBadRequestError("An iOS device's new name is required.");
5509
+ const name = input.name;
5510
+ return json({ data: await refusingInvalid(() => core.renameIosDevice(requireRouteParam(params, "id"), name)) });
5511
+ }),
5512
+ recordIosDeviceOutcome: onCore(async (core, request, params) => {
5513
+ const input = await body(request);
5514
+ const seen = input.seen;
5515
+ if (!isRecord$1(seen) || typeof seen.status !== "string" || !(seen.approvedAtMs === null || Number.isSafeInteger(seen.approvedAtMs)) || !isText(input.issuerId) || typeof input.outcome !== "string" || input.reason !== void 0 && typeof input.reason !== "string") throw new HandlerBadRequestError("An iOS device outcome needs seen { status, approvedAtMs }, issuerId, outcome, and an optional reason.");
5516
+ const outcome = {
5517
+ id: requireRouteParam(params, "id"),
5518
+ seen: {
5519
+ status: seen.status,
5520
+ approvedAtMs: seen.approvedAtMs
5521
+ },
5522
+ issuerId: input.issuerId,
5523
+ outcome: input.outcome,
5524
+ ...input.reason === void 0 ? {} : { reason: input.reason }
5525
+ };
5526
+ return json({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
5527
+ }),
5528
+ claimIosDeviceAccount: onCore(async (core, request) => {
5529
+ const { issuerId } = await body(request);
5530
+ if (!isText(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
5531
+ return json({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
5532
+ }),
5533
+ markIosDevicesInBuild: onCore(async (core, request) => {
5534
+ const { buildId, ids } = await body(request);
5535
+ if (!isText(buildId) || !Array.isArray(ids) || !ids.every((id) => isText(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
5536
+ await core.markIosDevicesInBuild({
5537
+ buildId,
5538
+ ids
5539
+ });
5540
+ return noContent();
5541
+ }),
5542
+ deleteIosDevice: onCore(async (core, request, params) => {
5543
+ const url = new URL(request.url);
5544
+ const status = url.searchParams.get("status");
5545
+ const requestedBy = url.searchParams.get("requestedBy");
5546
+ const only = {
5547
+ ...status === null ? {} : { status },
5548
+ ...requestedBy === null ? {} : { requestedBy }
5549
+ };
5550
+ return json({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(requireRouteParam(params, "id")) : core.deleteIosDevice(requireRouteParam(params, "id"), only)) });
5551
+ }),
4951
5552
  deleteBundles: onCore(async (core, request) => {
4952
5553
  const { ids } = await body(request);
4953
5554
  if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new HandlerBadRequestError("Bundle deletion needs ids");
@@ -5092,10 +5693,60 @@ var ADMIN_ROUTES = [
5092
5693
  path: "/native-builds/:id/submission",
5093
5694
  handler: "recordNativeBuildSubmission"
5094
5695
  },
5696
+ {
5697
+ method: "POST",
5698
+ path: "/native-builds/:id/store-build",
5699
+ handler: "markNativeBuild"
5700
+ },
5095
5701
  {
5096
5702
  method: "DELETE",
5097
5703
  path: "/native-builds/:id",
5098
5704
  handler: "deleteNativeBuild"
5705
+ },
5706
+ {
5707
+ method: "GET",
5708
+ path: "/ios-devices",
5709
+ handler: "listIosDevices"
5710
+ },
5711
+ {
5712
+ method: "POST",
5713
+ path: "/ios-devices",
5714
+ handler: "requestIosDevice"
5715
+ },
5716
+ {
5717
+ method: "GET",
5718
+ path: "/ios-devices/udid/:udid",
5719
+ handler: "findIosDevice"
5720
+ },
5721
+ {
5722
+ method: "POST",
5723
+ path: "/ios-devices/in-build",
5724
+ handler: "markIosDevicesInBuild"
5725
+ },
5726
+ {
5727
+ method: "POST",
5728
+ path: "/ios-devices/account",
5729
+ handler: "claimIosDeviceAccount"
5730
+ },
5731
+ {
5732
+ method: "POST",
5733
+ path: "/ios-devices/:id/approval",
5734
+ handler: "approveIosDevice"
5735
+ },
5736
+ {
5737
+ method: "POST",
5738
+ path: "/ios-devices/:id/outcome",
5739
+ handler: "recordIosDeviceOutcome"
5740
+ },
5741
+ {
5742
+ method: "PATCH",
5743
+ path: "/ios-devices/:id",
5744
+ handler: "renameIosDevice"
5745
+ },
5746
+ {
5747
+ method: "DELETE",
5748
+ path: "/ios-devices/:id",
5749
+ handler: "deleteIosDevice"
5099
5750
  }
5100
5751
  ];
5101
5752
  var CATALOG_CONTENT_TYPE = "application/vnd.hot-updater.release-catalog+json; version=1";
@@ -5603,8 +6254,11 @@ var resolveConsoleConfig = async (request) => {
5603
6254
  const { default: source } = await import("./config-CjIBFhJX.mjs");
5604
6255
  const config = typeof source === "function" ? await source(request) : source;
5605
6256
  const { database, storage, plugins = [] } = config;
5606
- const { gitUrl } = config.console ?? {};
5607
- const consoleOptions = gitUrl === void 0 ? {} : { gitUrl };
6257
+ const { gitUrl, deviceApprovers = [] } = config.console ?? {};
6258
+ const consoleOptions = {
6259
+ ...gitUrl === void 0 ? {} : { gitUrl },
6260
+ deviceApprovers: deviceApprovers.map((email) => email.trim().toLowerCase()).filter((email) => email.length > 0)
6261
+ };
5608
6262
  if (isRemoteDatabase(database)) {
5609
6263
  const checked = assemble({
5610
6264
  name: "memory",