nolo-cli 0.149.0-alpha.1 → 0.151.0-alpha.3

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 (258) hide show
  1. package/{_executeModel-OW3H7ICR.js → _executeModel-T7ANHTUW.js} +134 -91
  2. package/accountResolver-7RYB4D2P.js +300 -0
  3. package/action-SXJD5N5R.js +23 -0
  4. package/{addContentAction-B2DRF7P6.js → addContentAction-ZV774PHH.js} +20 -14
  5. package/{addDialogAgentAction-2P2FLTLD.js → addDialogAgentAction-A6SMKAGH.js} +26 -22
  6. package/{agentDeleteCommand-7IDWF6E3.js → agentDeleteCommand-4L5KCKFY.js} +181 -93
  7. package/{agentEmailCommands-A6XBQZBN.js → agentEmailCommands-2IMMIRO2.js} +132 -112
  8. package/{agentGrantCommands-M3XFO6EN.js → agentGrantCommands-HOJ3JBBQ.js} +3 -3
  9. package/agentListCommands-TWFLUYIZ.js +802 -0
  10. package/{agentMachineCommands-DQPUIMAC.js → agentMachineCommands-KIWXWT6L.js} +58 -62
  11. package/{agentProviderCommands-YK2BIIXZ.js → agentProviderCommands-HL6MBLCL.js} +149 -2
  12. package/{agentPullCommand-HF4A42D4.js → agentPullCommand-FA43RBRU.js} +7 -7
  13. package/agentRecordCommands-727NPCRW.js +154 -0
  14. package/agentRunCommand-JASIG3FZ.js +183 -0
  15. package/{agentRunControl-2SKCR4SB.js → agentRunControl-IFM7IGMG.js} +10 -2
  16. package/{agentRuntimeLocal-AK2QVJHY.js → agentRuntimeLocal-KKSQJMTE.js} +47 -50
  17. package/{agentSlice-O4RUQUMT.js → agentSlice-SLV57QGU.js} +23 -16
  18. package/{appDeleteCommands-N3XEVVYC.js → appDeleteCommands-4PL4KYRN.js} +58 -59
  19. package/{appDeployCommands-AWFIXYVW.js → appDeployCommands-EEEXCEB6.js} +67 -63
  20. package/{appDeployStatusCommands-CZRON2FO.js → appDeployStatusCommands-35ZX7T66.js} +56 -56
  21. package/{appGetCommands-XQIUY4TD.js → appGetCommands-WFCHXJWF.js} +56 -56
  22. package/{appListCommands-NNG4H36Y.js → appListCommands-XY2U6DPF.js} +57 -59
  23. package/{authCommand-UBJ4EWYZ.js → authCommand-QYN47CQD.js} +371 -68
  24. package/{authCommands-H6WKKCRW.js → authCommands-77CHYBGF.js} +12 -9
  25. package/{builtinSkillRegistry-ZMF6YGNO.js → builtinSkillRegistry-TDQ6JB2E.js} +13 -11
  26. package/{chromeCommands-2N6MEWRU.js → chromeCommands-OBBNJCLS.js} +314 -13
  27. package/chromeOpsCommands-3Z34RKSE.js +472 -0
  28. package/{chunk-ALXHV7NK.js → chunk-2GGXHQIW.js} +43 -4
  29. package/{localRuntimeAuthority-5W6IJRAD.js → chunk-2IXDJNZI.js} +154 -75
  30. package/{chunk-IVZJWTDI.js → chunk-36OMEXXR.js} +89 -21
  31. package/{chunk-H6A6X4EK.js → chunk-3MZAGMYY.js} +16 -0
  32. package/chunk-3PVYUPXK.js +40 -0
  33. package/chunk-3SZA4U64.js +1192 -0
  34. package/{chunk-ID7LNBWR.js → chunk-3T4ZG6AC.js} +1920 -644
  35. package/{chunk-GNMAFAIS.js → chunk-44WXLHFI.js} +1 -1
  36. package/{chunk-AGGIDPCZ.js → chunk-4JH2UMJR.js} +6 -0
  37. package/chunk-4LCOCOR5.js +50 -0
  38. package/chunk-4YRTZIVN.js +871 -0
  39. package/{chunk-N7J63Q6C.js → chunk-56GBUMO5.js} +10 -1
  40. package/{chunk-W7XHHYWM.js → chunk-5BHQICF2.js} +5 -1
  41. package/{chunk-XUWRURDF.js → chunk-5EBLANFT.js} +1 -1
  42. package/{chunk-3AH7LNUB.js → chunk-5EMSBTQ6.js} +33 -14
  43. package/{chunk-YRRASA5Q.js → chunk-5MM7NNO6.js} +113 -52
  44. package/chunk-5MMAK75Q.js +15 -0
  45. package/{chunk-TXH4IWJL.js → chunk-626KHJNX.js} +20 -11
  46. package/{chunk-M5PVFLD4.js → chunk-64K7WX26.js} +90 -21
  47. package/{chunk-AKG5W4LG.js → chunk-6CCFTVBP.js} +76 -221
  48. package/chunk-6MJNEXUU.js +614 -0
  49. package/{chunk-62IL3KQV.js → chunk-6MXDOUMH.js} +15 -3
  50. package/{chunk-QOKAKDPE.js → chunk-6Q7UTJKR.js} +6 -94
  51. package/chunk-6QDYSCPW.js +223 -0
  52. package/{chunk-HYZIYH2H.js → chunk-74RAWNQN.js} +56 -63
  53. package/chunk-7DPNBQSV.js +9 -0
  54. package/{chunk-IAESIMK7.js → chunk-A4MW3YZL.js} +10 -14
  55. package/{chunk-OMRJYNCI.js → chunk-AG7MCDLR.js} +26 -31
  56. package/chunk-AGIM7IMJ.js +147 -0
  57. package/{chunk-7CHC4W22.js → chunk-AIZE5TDM.js} +3 -3
  58. package/chunk-AJ3G7X2K.js +7012 -0
  59. package/{chunk-5GVBDNTO.js → chunk-AU7AXHUL.js} +1 -1
  60. package/{chunk-4H22P2JV.js → chunk-AUIJZACN.js} +2073 -1275
  61. package/{chunk-CIF4X6ZM.js → chunk-AWVFQMOV.js} +25 -3
  62. package/{chunk-YAQJJDC2.js → chunk-BJEZC5RA.js} +214 -51
  63. package/{chunk-RYZINGPM.js → chunk-BPMPOFWP.js} +347 -235
  64. package/{chunk-YUNJN43V.js → chunk-BU2YQBV4.js} +215 -28
  65. package/{chunk-XPRWFQQK.js → chunk-CBHGZRCE.js} +38 -12
  66. package/{chunk-Y3PMXGLH.js → chunk-CHCS6XPJ.js} +365 -144
  67. package/chunk-CHOZJMJS.js +78 -0
  68. package/chunk-CYJWI3NH.js +119 -0
  69. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  70. package/{chunk-3SV7RM24.js → chunk-D2QN6CTI.js} +117 -72
  71. package/{chunk-TZZ2WRBL.js → chunk-DFDXM2Y4.js} +20 -16
  72. package/{chunk-5TEEECZM.js → chunk-E2AKSW7L.js} +10 -7
  73. package/{chunk-RSEEDUMS.js → chunk-EDX5XSJM.js} +2 -2
  74. package/{chunk-QDSINZM3.js → chunk-EUGTFFO6.js} +2 -23
  75. package/{chunk-UNYJU5L6.js → chunk-EYLGAEB4.js} +5 -1
  76. package/{chunk-CU3QB4HW.js → chunk-EYWJT7A2.js} +12 -12
  77. package/{chunk-BNGW5ASC.js → chunk-EZVK3N5L.js} +66 -18
  78. package/{chunk-6FGTMQCL.js → chunk-F32Z66T4.js} +6 -10
  79. package/{chunk-ZOVKKMF6.js → chunk-FY4SDK2E.js} +1 -1
  80. package/chunk-G6OOUQWJ.js +417 -0
  81. package/{chunk-PQWU42UQ.js → chunk-GCKHQECX.js} +6 -6
  82. package/chunk-GKXCHNTE.js +15 -0
  83. package/{chunk-P6GMCCAT.js → chunk-GQV5KHJU.js} +78 -12
  84. package/{chunk-B2XUQXQX.js → chunk-HIQ4GF53.js} +191 -68
  85. package/{chunk-GMZLP5DV.js → chunk-HNUWUO75.js} +30 -19
  86. package/{chunk-UASIEDKM.js → chunk-I2XLRXVX.js} +36 -31
  87. package/{chunk-5UTFL4QJ.js → chunk-I2ZMGXXF.js} +10 -5
  88. package/chunk-I42VC5KR.js +15 -0
  89. package/{chunk-3BXNTXYI.js → chunk-I4SN4NUQ.js} +1199 -56
  90. package/chunk-IA7TRNNR.js +11 -0
  91. package/{chunk-WIWM4FE3.js → chunk-IJERIUXS.js} +55 -748
  92. package/{chunk-BIDGLJQ3.js → chunk-IK2TSJQA.js} +45 -8
  93. package/{chunk-CPUFH46E.js → chunk-ILU2NPWY.js} +10 -10
  94. package/{chunk-SLLGJZDT.js → chunk-ISQL4V7C.js} +4 -4
  95. package/chunk-IT3ZZRJE.js +12 -0
  96. package/{chunk-DY7ANLKG.js → chunk-JKMLSTZK.js} +43 -12
  97. package/{chunk-6TPOEJMQ.js → chunk-JZX2XLKC.js} +64 -23
  98. package/{chunk-27ONFIEY.js → chunk-K2AER7RX.js} +19 -12
  99. package/{chunk-O2OWEFII.js → chunk-KFHQQ3NO.js} +1 -1
  100. package/{chunk-QXGPFY6J.js → chunk-LGN377P3.js} +27 -17
  101. package/{chunk-L36OWPP3.js → chunk-LIQJTQRN.js} +118 -139
  102. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  103. package/{chunk-5J3PYNUP.js → chunk-NYYFIKHI.js} +17 -3
  104. package/{chunk-6O4IK4V2.js → chunk-OFFL4DCR.js} +1 -1
  105. package/{chunk-B6SAMB33.js → chunk-OWYYDMGJ.js} +209 -9
  106. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  107. package/{chunk-CTUQJVQM.js → chunk-P5QACQDK.js} +1 -1
  108. package/{chunk-TB3MIBRC.js → chunk-PIDUNDFS.js} +572 -430
  109. package/{chunk-4JMDLJAD.js → chunk-PJNFNEJE.js} +114 -37
  110. package/chunk-PKZKOVA5.js +11507 -0
  111. package/{chunk-Z4CSIXYP.js → chunk-PLSVXHSA.js} +3 -3
  112. package/chunk-PWTNI4N7.js +47 -0
  113. package/chunk-QFEW2ULV.js +42 -0
  114. package/{chunk-RGNEEJ3Y.js → chunk-QLQ573SU.js} +35 -9
  115. package/chunk-QQ56R7KS.js +88 -0
  116. package/chunk-QYPE3TS3.js +43 -0
  117. package/{chunk-HTVYCXBP.js → chunk-RN2GPWN6.js} +354 -120
  118. package/{chunk-ATLTFRYJ.js → chunk-ROCUB2H2.js} +280 -98
  119. package/{chunk-4DPP773Q.js → chunk-RSHPU4PD.js} +59 -11
  120. package/chunk-RVWMAFIT.js +134 -0
  121. package/{chunk-ESHYE7WU.js → chunk-S73EPYNC.js} +10 -7
  122. package/{chunk-UQNS32WZ.js → chunk-SCMHQUMK.js} +1 -1
  123. package/chunk-SW4S4XYB.js +1794 -0
  124. package/{chunk-ZUEK6A6C.js → chunk-TTH4HOJD.js} +1973 -754
  125. package/chunk-TY3TIUJK.js +89 -0
  126. package/{chunk-X2QRZXZH.js → chunk-TYJ5XFEA.js} +4 -4
  127. package/{chunk-ALFH24P3.js → chunk-TYYRSFBG.js} +197 -155
  128. package/{chunk-MST6R3E4.js → chunk-U5GPBQDG.js} +34 -22
  129. package/chunk-U5ICMAFV.js +14110 -0
  130. package/{chunk-7KVZ5LDQ.js → chunk-UBUH2TCC.js} +18 -4
  131. package/chunk-UEILX4EV.js +15 -0
  132. package/chunk-UHTDNB5Y.js +140 -0
  133. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  134. package/{chunk-OHOVNO7I.js → chunk-UOKFKFPO.js} +6 -3
  135. package/{chunk-XISEYOGH.js → chunk-USHQX6VT.js} +5 -5
  136. package/chunk-UUPR3TD7.js +53 -0
  137. package/{chunk-3DAVPNFT.js → chunk-V4EE3D54.js} +122 -107
  138. package/{chunk-HDLLCBRF.js → chunk-VEA7H5FG.js} +2 -2
  139. package/chunk-VHGD6FHV.js +116 -0
  140. package/chunk-VIWDGTDA.js +8 -0
  141. package/{chunk-GOH6RW6F.js → chunk-VJXHL6MH.js} +34 -11
  142. package/{chunk-4XEYAFLY.js → chunk-VL5KOY2C.js} +623 -94
  143. package/{chunk-EADNWBAZ.js → chunk-VP3BINY7.js} +13 -0
  144. package/{chunk-DXHL7G2L.js → chunk-VWW6O2TL.js} +274 -93
  145. package/{chunk-EOARMOVD.js → chunk-W4S6OTSC.js} +6 -3
  146. package/chunk-WD4XYDYC.js +567 -0
  147. package/chunk-WJZOQR2J.js +151 -0
  148. package/{chunk-AUDNYVRC.js → chunk-XETG4RIX.js} +5 -5
  149. package/{chunk-MX574M24.js → chunk-XI7DGLUK.js} +4 -4
  150. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  151. package/chunk-XRUSXPCQ.js +514 -0
  152. package/{chunk-I4OPU5TK.js → chunk-XS47QOFV.js} +273 -11
  153. package/{chunk-S5XGT6GB.js → chunk-XZNCX52W.js} +30 -9
  154. package/{chunk-5OA5HMTL.js → chunk-YLMMECCH.js} +1 -1
  155. package/{chunk-CFT5HBGW.js → chunk-YVLQXTUB.js} +448 -12
  156. package/chunk-YVPQATSC.js +709 -0
  157. package/chunk-ZEZC7IIM.js +126 -0
  158. package/{chunk-ALGORS6Y.js → chunk-ZF6526IQ.js} +43 -8
  159. package/chunk-ZIWPQEFU.js +165 -0
  160. package/chunk-ZRAU6T47.js +56 -0
  161. package/{cliExecutor-AWYR3T33.js → cliExecutor-BWBF2MTI.js} +4 -3
  162. package/{clipboardy-BX4NMYHE.js → clipboardy-GCO3GT3I.js} +3 -8
  163. package/{commandRegistry-2KBOXZQC.js → commandRegistry-NBLZEMCW.js} +183 -107
  164. package/contentThunks-6AIWNSGO.js +84 -0
  165. package/{cooldownCommands-ZLEPIB4A.js → cooldownCommands-JFKTYS2D.js} +2 -2
  166. package/{createAgentAutomationAction-5UGTB26P.js → createAgentAutomationAction-4BUS65DZ.js} +53 -44
  167. package/createDialogAction-QAIKSCG4.js +76 -0
  168. package/{createPageAction-CDLDKPRM.js → createPageAction-DXCZ334C.js} +65 -54
  169. package/cursorProvider-YGGNMVWX.js +6123 -0
  170. package/{db-VQSAOWAO.js → db-2QOTXYGH.js} +11 -5
  171. package/{dbSlice-DQ32LYTJ.js → dbSlice-J37OGIXH.js} +19 -13
  172. package/{deleteFile-NX6QHCWZ.js → deleteFile-6JWDDRVP.js} +10 -6
  173. package/dialogCommands-YZLSJB6X.js +113 -0
  174. package/{dialogSlice-N3YB65G5.js → dialogSlice-PVUSMKFW.js} +53 -39
  175. package/{docCreateCommands-ZSLGVBZT.js → docCreateCommands-JB2RRMRJ.js} +54 -57
  176. package/{docDeleteCommands-5N4GVZBG.js → docDeleteCommands-AQENULNM.js} +56 -58
  177. package/{docReadCommands-YJSAA7AV.js → docReadCommands-DYD25YLQ.js} +53 -56
  178. package/{docStore-E3CEOV5Q.js → docStore-CSEBEMKP.js} +25 -16
  179. package/{docUpdateCommands-WEMLSW6W.js → docUpdateCommands-3GVS23QL.js} +54 -57
  180. package/{fetchMessages-67MEFPZR.js → fetchMessages-IIJWQ3HR.js} +5 -4
  181. package/{getPricing-NMMFT3YI.js → getPricing-FKK3F5EJ.js} +11 -9
  182. package/{handleSendMessageAction-DQAD5ERJ.js → handleSendMessageAction-G2TLYGC4.js} +422 -118
  183. package/index.js +11 -7
  184. package/{lib-FRRS27KN.js → lib-4YTWAGY7.js} +581 -248
  185. package/{localDialogRead-EBRS242U.js → localDialogRead-FSOMOPDZ.js} +2 -2
  186. package/localRuntimeAdapter-B4TAYYA7.js +244 -0
  187. package/localRuntimeAuthority-JDAD7CB6.js +16 -0
  188. package/{localRuntimeDb-3LRMNLCM.js → localRuntimeDb-CVC62PM5.js} +1 -1
  189. package/{machineCommands-HAP75VSG.js → machineCommands-6OBFD3XF.js} +503 -161
  190. package/{machineInfo-66ZFUMLE.js → machineInfo-UKPTZO5Y.js} +2 -2
  191. package/machineWsRunDispatch-OO7N3O3Y.js +169 -0
  192. package/{memberThunks-5ZXPR63F.js → memberThunks-66DH6ABQ.js} +25 -18
  193. package/{models-ZPU5EDF4.js → models-LAS4B2B5.js} +2 -2
  194. package/package.json +1 -1
  195. package/{providerPresetApply-DD6NGWW6.js → providerPresetApply-MY66I6NT.js} +10 -10
  196. package/{providerRegistry-XDRLMYGJ.js → providerRegistry-QOE2FT57.js} +13 -9
  197. package/{read-EPTJRAEF.js → read-DC4NUGN6.js} +12 -8
  198. package/{readDocTool-W4NDXNEX.js → readDocTool-NCJ5NT25.js} +1 -1
  199. package/{readlineWorkspace-7BC66QSX.js → readlineWorkspace-UIQN7JUR.js} +5017 -915
  200. package/{removeDialogAgentAction-OSYNZRX7.js → removeDialogAgentAction-E2H3OZU6.js} +29 -28
  201. package/{runAgentClientLoop-6E6UC3CE.js → runAgentClientLoop-GS3SGG37.js} +154 -97
  202. package/{runtimeDoctorCommands-ID23PNNZ.js → runtimeDoctorCommands-GIOGC5SC.js} +17 -17
  203. package/secretCommands-ZXZRLR3R.js +700 -0
  204. package/setDialogExtraReferencesAction-SITRPMYU.js +37 -0
  205. package/{setPrimaryDialogAgentAction-WZ7KI3YA.js → setPrimaryDialogAgentAction-U7N45TGC.js} +30 -29
  206. package/{chunk-SONWNI3L.js → settingThunks-Y7SVJOMZ.js} +223 -928
  207. package/{skillDiscovery-ZBU76COE.js → skillDiscovery-QC35EQY4.js} +2 -2
  208. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  209. package/{spaceCommands-UJOVU4XI.js → spaceCommands-ZR5BR3GX.js} +59 -59
  210. package/{streamAgentChatTurn-3UXPYFNX.js → streamAgentChatTurn-4XYC33KE.js} +309 -165
  211. package/{switchDialogAgentAction-GMR7WN3P.js → switchDialogAgentAction-OMGBD3N2.js} +26 -22
  212. package/{tableCommands-G7RV3RU3.js → tableCommands-U3QDY4L6.js} +19 -17
  213. package/{toolApiClient-CVGWM4PN.js → toolApiClient-7WSJJJBV.js} +6 -5
  214. package/tools-P77EE7Q4.js +124 -0
  215. package/tuiSummaryLlmCaller-BM3VSTBU.js +130 -0
  216. package/{updateCommands-4EHDLF5J.js → updateCommands-NQXAGFM7.js} +3 -3
  217. package/{updateDialogTitleAction-UPFV7TDT.js → updateDialogTitleAction-CIANVPZC.js} +102 -57
  218. package/workloadLifecycle-36DXRZKU.js +320 -0
  219. package/action-GI44T4DR.js +0 -31
  220. package/agentListCommands-IW3GQVUP.js +0 -427
  221. package/agentRecordCommands-VCA76W6B.js +0 -134
  222. package/agentRunCommand-YNLDKVR7.js +0 -161
  223. package/browser-image-compression-MFDTD7K6.js +0 -1763
  224. package/chatQueueReduxAdapter-TJRMXMYA.js +0 -186
  225. package/chromeOpsCommands-IXRLN57H.js +0 -289
  226. package/chunk-36KZDDO5.js +0 -2415
  227. package/chunk-ACQD6YI2.js +0 -25363
  228. package/chunk-CQ3WA2NE.js +0 -299
  229. package/chunk-CYSYR67N.js +0 -93
  230. package/chunk-JBTJAPUF.js +0 -35
  231. package/chunk-K2CSUCHJ.js +0 -620
  232. package/chunk-LTRXGFMS.js +0 -83
  233. package/chunk-M76ECQRD.js +0 -13658
  234. package/chunk-MEYIRKDN.js +0 -8967
  235. package/chunk-OCZKATRC.js +0 -129
  236. package/chunk-OTGFTBLI.js +0 -13
  237. package/chunk-PUOC4YRO.js +0 -394
  238. package/chunk-PZZTFEKK.js +0 -34
  239. package/chunk-URMS4XY2.js +0 -10
  240. package/chunk-UV6VISQJ.js +0 -20
  241. package/chunk-VJVNU77E.js +0 -83
  242. package/chunk-XYJSY4KG.js +0 -13807
  243. package/chunk-Y5GCAMGP.js +0 -9
  244. package/chunk-YPREESF4.js +0 -225
  245. package/contentThunks-BDIQRZR6.js +0 -73
  246. package/createDialogAction-B7VGVEVU.js +0 -66
  247. package/dialogCommands-G7YBVAMC.js +0 -102
  248. package/levelLazyShim-GZBKODGI.js +0 -7
  249. package/machineWsRunDispatch-L32G7C4P.js +0 -149
  250. package/serverStoreFactory-YMXDF4NI.js +0 -20
  251. package/setDialogExtraReferencesAction-M32UYNCG.js +0 -30
  252. package/settingSlice-Q6EKL7EQ.js +0 -204
  253. package/syncMapping-N6RGXGBW.js +0 -437
  254. package/tools-MKYDMWA4.js +0 -111
  255. package/tuiSummaryLlmCaller-3YFNHCTW.js +0 -128
  256. package/{chunk-SV5IJK6K.js → chunk-NBTY7YJF.js} +3 -3
  257. package/{chunk-2SYTUTLI.js → chunk-YBNHPX4S.js} +3 -3
  258. package/{offlineMarxistsAgentCommand-HGXZV4XJ.js → offlineMarxistsAgentCommand-2QTHJCHV.js} +4 -4
@@ -1,36 +1,12 @@
1
1
  import {
2
- getAllServers,
3
- getIsDesktopApp,
4
- isAbortError
5
- } from "./chunk-QOKAKDPE.js";
6
- import {
7
- selectIdentityToken,
8
- selectIdentityUser,
9
- selectIdentityUserId
2
+ selectIdentityToken
10
3
  } from "./chunk-SEJ5OS6F.js";
11
4
  import {
12
- isRecord
13
- } from "./chunk-KUG52IAP.js";
14
- import {
15
- asTrimmedString
16
- } from "./chunk-3EUW3WEO.js";
17
- import {
18
- asOptionalPositiveFiniteNumber
19
- } from "./chunk-U6VC4MU4.js";
5
+ isAbortError
6
+ } from "./chunk-7DPNBQSV.js";
20
7
  import {
21
- API_ENDPOINTS,
22
- SERVERS,
23
- normalizeKnownServerOrigin
8
+ API_ENDPOINTS
24
9
  } from "./chunk-LCBAMY2M.js";
25
- import {
26
- isLocalServerUrl
27
- } from "./chunk-4SN6J65J.js";
28
- import {
29
- normalizeServerOrigin
30
- } from "./chunk-CF7PE763.js";
31
- import {
32
- asOptionalTrimmedString
33
- } from "./chunk-G3SUCT4W.js";
34
10
 
35
11
  // node_modules/reselect/dist/reselect.mjs
36
12
  var CACHE_SIZE_CHECK_THRESHOLD = 1e3;
@@ -2171,97 +2147,6 @@ function formatProdErrorMessage(code) {
2171
2147
  return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2172
2148
  }
2173
2149
 
2174
- // packages/app/stateViews/runtime.ts
2175
- var selectCurrentToken = (state) => {
2176
- const token = selectIdentityToken(state);
2177
- return typeof token === "string" ? token : void 0;
2178
- };
2179
- var selectCurrentUserId = (state) => {
2180
- const userId = selectIdentityUserId(state);
2181
- return typeof userId === "string" ? userId : void 0;
2182
- };
2183
- var EMPTY_SYNC_SERVERS = [];
2184
- var selectRuntimeRemoteServer = (state) => {
2185
- const configuredServer = normalizeKnownServerOrigin(state.settings?.currentServer) ?? void 0;
2186
- if (!getIsDesktopApp()) return configuredServer || SERVERS.MAIN;
2187
- return isLocalServerUrl(configuredServer) ? SERVERS.MAIN : configuredServer || SERVERS.MAIN;
2188
- };
2189
- var selectConfiguredSyncServers = (state) => state.settings?.syncServers;
2190
- var selectRuntimeRemoteSyncServers = createSelector(
2191
- [selectConfiguredSyncServers],
2192
- (syncServers) => {
2193
- if (!Array.isArray(syncServers) || syncServers.length === 0) {
2194
- return EMPTY_SYNC_SERVERS;
2195
- }
2196
- const normalized = syncServers.map(normalizeKnownServerOrigin).filter((server) => !!server);
2197
- if (!getIsDesktopApp()) return normalized;
2198
- return normalized.filter((server) => !isLocalServerUrl(server));
2199
- }
2200
- );
2201
- var selectLocalRuntimeOrigin = () => {
2202
- if (typeof window !== "undefined" && typeof window.location?.origin === "string" && /^https?:\/\//.test(window.location.origin)) {
2203
- return window.location.origin.replace(/\/+$/, "");
2204
- }
2205
- return void 0;
2206
- };
2207
- var selectRuntimeSnapshot = createSelector(
2208
- [
2209
- selectCurrentToken,
2210
- selectCurrentUserId,
2211
- selectRuntimeRemoteServer,
2212
- selectRuntimeRemoteSyncServers,
2213
- selectLocalRuntimeOrigin
2214
- ],
2215
- (currentToken, currentUserId, currentServer, syncServers, localRuntimeOrigin) => ({
2216
- currentToken,
2217
- currentUserId,
2218
- currentServer,
2219
- syncServers,
2220
- localRuntimeOrigin
2221
- })
2222
- );
2223
- var selectRuntimeCurrentServer = createSelector(
2224
- [selectRuntimeSnapshot],
2225
- (runtime) => runtime.currentServer
2226
- );
2227
- var selectRuntimeRemoteServers = createSelector(
2228
- [selectRuntimeSnapshot],
2229
- (runtime) => getAllServers(runtime.currentServer, runtime.syncServers)
2230
- );
2231
-
2232
- // packages/database/runtimeServerContext.ts
2233
- var getRuntimeServerContext = (state, preferredServerOrigin) => {
2234
- const {
2235
- currentToken,
2236
- currentUserId,
2237
- currentServer,
2238
- syncServers = []
2239
- } = selectRuntimeSnapshot(state);
2240
- return {
2241
- currentToken,
2242
- currentUserId,
2243
- currentServer,
2244
- syncServers,
2245
- userAuthorityRegistry: resolveRuntimeUserAuthorityRegistry(state),
2246
- remoteServers: getAllServers(
2247
- currentServer,
2248
- syncServers,
2249
- preferredServerOrigin
2250
- )
2251
- };
2252
- };
2253
- var resolveRuntimeUserAuthorityRegistry = (state) => {
2254
- const settingsRegistry = state.settings?.userAuthorityRegistry;
2255
- if (settingsRegistry && typeof settingsRegistry === "object") {
2256
- return settingsRegistry;
2257
- }
2258
- const userRegistry = selectIdentityUser(state)?.authorityRegistry;
2259
- if (userRegistry && typeof userRegistry === "object") {
2260
- return userRegistry;
2261
- }
2262
- return void 0;
2263
- };
2264
-
2265
2150
  // packages/database/requests.ts
2266
2151
  var TIMEOUT = 5e3;
2267
2152
  var logRequestFailure = (level, message) => {
@@ -2355,7 +2240,38 @@ var noloWriteRequest = async (server, writeConfig, state, signal, options) => {
2355
2240
  }
2356
2241
  };
2357
2242
  var rnUploadAdapter = null;
2358
- var noloUploadRequest = async (server, uploadConfig, state, signal) => {
2243
+ var xhrUploadRequest = (url, formData, state, onProgress, signal) => new Promise((resolve, reject) => {
2244
+ if (signal?.aborted) {
2245
+ reject(new DOMException("Upload aborted", "AbortError"));
2246
+ return;
2247
+ }
2248
+ const xhr = new XMLHttpRequest();
2249
+ xhr.open("POST", url);
2250
+ const token = selectIdentityToken(state) ?? null;
2251
+ if (token) {
2252
+ xhr.setRequestHeader("Authorization", `Bearer ${token}`);
2253
+ }
2254
+ const onAbortSignal = () => xhr.abort();
2255
+ signal?.addEventListener("abort", onAbortSignal, { once: true });
2256
+ const cleanup = () => signal?.removeEventListener("abort", onAbortSignal);
2257
+ xhr.upload.onprogress = (event) => {
2258
+ if (event.lengthComputable) onProgress(event.loaded, event.total);
2259
+ };
2260
+ xhr.onload = () => {
2261
+ cleanup();
2262
+ resolve({ ok: xhr.status >= 200 && xhr.status < 300, status: xhr.status });
2263
+ };
2264
+ xhr.onerror = () => {
2265
+ cleanup();
2266
+ reject(new Error("Network error during upload"));
2267
+ };
2268
+ xhr.onabort = () => {
2269
+ cleanup();
2270
+ reject(new DOMException("Upload aborted", "AbortError"));
2271
+ };
2272
+ xhr.send(formData);
2273
+ });
2274
+ var noloUploadRequest = async (server, uploadConfig, state, signal, onProgress) => {
2359
2275
  const { file, metadata, customKey, userId } = uploadConfig;
2360
2276
  try {
2361
2277
  const isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
@@ -2383,6 +2299,21 @@ var noloUploadRequest = async (server, uploadConfig, state, signal) => {
2383
2299
  if (userId) {
2384
2300
  formData.append("userId", userId);
2385
2301
  }
2302
+ if (onProgress && typeof XMLHttpRequest !== "undefined") {
2303
+ const result = await xhrUploadRequest(
2304
+ server + `${API_ENDPOINTS.DATABASE}/upload`,
2305
+ formData,
2306
+ state,
2307
+ onProgress,
2308
+ signal
2309
+ );
2310
+ if (!result.ok) {
2311
+ console.error(
2312
+ `Upload request failed for ${customKey} on ${server}: HTTP ${result.status}`
2313
+ );
2314
+ }
2315
+ return result.ok;
2316
+ }
2386
2317
  const response = await noloRequest(
2387
2318
  server,
2388
2319
  {
@@ -2468,606 +2399,6 @@ var noloDeleteRequest = async (server, dbKey, options, state, signal) => {
2468
2399
  }
2469
2400
  };
2470
2401
 
2471
- // packages/database/authority/ownerKey.ts
2472
- var USER_OWNED_SECOND_SEGMENT_PREFIXES = /* @__PURE__ */ new Set([
2473
- "agent",
2474
- "dialog",
2475
- "page",
2476
- "doc",
2477
- "notification",
2478
- "email",
2479
- "meta",
2480
- "row",
2481
- "view",
2482
- "file",
2483
- "job"
2484
- ]);
2485
- var PUBLIC_OWNER_SENTINELS = /* @__PURE__ */ new Set(["pub", "id", "stats", "index"]);
2486
- var cleanSegment = (value) => {
2487
- const trimmed = asTrimmedString(value);
2488
- return trimmed.length > 0 ? trimmed : null;
2489
- };
2490
- var normalizeCandidateOwners = (candidateOwnerUserIds) => {
2491
- const out = [];
2492
- for (const candidate of candidateOwnerUserIds ?? []) {
2493
- const normalized = cleanSegment(candidate ?? void 0);
2494
- if (!normalized || PUBLIC_OWNER_SENTINELS.has(normalized)) continue;
2495
- if (!out.includes(normalized)) out.push(normalized);
2496
- }
2497
- return out.sort((left, right) => right.length - left.length);
2498
- };
2499
- var resolveCandidateOwnerFromKeyRemainder = (remainder, candidateOwnerUserIds) => {
2500
- const normalizedRemainder = cleanSegment(remainder);
2501
- if (!normalizedRemainder) return null;
2502
- for (const candidate of normalizeCandidateOwners(candidateOwnerUserIds)) {
2503
- if (normalizedRemainder === candidate || normalizedRemainder.startsWith(`${candidate}-`)) {
2504
- return candidate;
2505
- }
2506
- }
2507
- return null;
2508
- };
2509
- var parseOwnerUserIdFromDbKey = (dbKey, options = {}) => {
2510
- const normalized = cleanSegment(dbKey);
2511
- if (!normalized) return null;
2512
- const parts = normalized.split("-");
2513
- const [prefix] = parts;
2514
- if (!prefix) return null;
2515
- if (!USER_OWNED_SECOND_SEGMENT_PREFIXES.has(prefix)) {
2516
- if (prefix === "grant" && parts[1] === "agent" && parts.length >= 5) {
2517
- const ownerAndRest2 = normalized.slice(prefix.length + 1 + parts[1].length + 1);
2518
- const [owner2] = ownerAndRest2.split("-");
2519
- return cleanSegment(owner2);
2520
- }
2521
- return null;
2522
- }
2523
- if (parts[0] === "dialog" && parts[2] === "msg") {
2524
- return null;
2525
- }
2526
- const ownerAndRest = normalized.slice(prefix.length + 1);
2527
- const candidateOwner = resolveCandidateOwnerFromKeyRemainder(
2528
- ownerAndRest,
2529
- options.candidateOwnerUserIds
2530
- );
2531
- if (candidateOwner) return candidateOwner;
2532
- const [owner] = ownerAndRest.split("-");
2533
- const ownerUserId = cleanSegment(owner);
2534
- if (!ownerUserId) return null;
2535
- if (PUBLIC_OWNER_SENTINELS.has(ownerUserId)) return null;
2536
- return ownerUserId;
2537
- };
2538
-
2539
- // packages/database/authority/userAuthorityRegistry.ts
2540
- var normalizeAuthorityServerOrigin = (value) => {
2541
- const normalized = normalizeServerOrigin(value);
2542
- return /^https?:\/\//i.test(normalized) ? normalized : null;
2543
- };
2544
- var normalizeUserId = (value) => asOptionalTrimmedString(value) ?? null;
2545
- var readEntryAuthorityServer = (entry) => {
2546
- if (typeof entry === "string") {
2547
- return normalizeAuthorityServerOrigin(entry);
2548
- }
2549
- if (!isRecord(entry)) {
2550
- return null;
2551
- }
2552
- return normalizeAuthorityServerOrigin(entry.authorityServer) ?? normalizeAuthorityServerOrigin(entry.homeServer) ?? normalizeAuthorityServerOrigin(entry.primaryServer);
2553
- };
2554
- var resolveUserAuthorityServer = ({
2555
- ownerUserId,
2556
- registry
2557
- }) => {
2558
- const normalizedOwner = normalizeUserId(ownerUserId);
2559
- if (!normalizedOwner || !registry || typeof registry !== "object") {
2560
- return null;
2561
- }
2562
- return readEntryAuthorityServer(registry[normalizedOwner]);
2563
- };
2564
-
2565
- // packages/database/authority/recordAuthority.ts
2566
- var normalizeUserId2 = (value) => asOptionalTrimmedString(value) ?? null;
2567
- var getRegistryOwnerCandidates = (registry) => isRecord(registry) ? Object.keys(registry) : [];
2568
- var resolveRecordAuthority = ({
2569
- dbKey,
2570
- record,
2571
- currentUserId,
2572
- currentServer,
2573
- userAuthorityRegistry
2574
- }) => {
2575
- const ownerUserId = parseOwnerUserIdFromDbKey(dbKey, {
2576
- candidateOwnerUserIds: [
2577
- normalizeUserId2(record?.userId),
2578
- normalizeUserId2(currentUserId),
2579
- ...getRegistryOwnerCandidates(userAuthorityRegistry)
2580
- ]
2581
- }) ?? normalizeUserId2(record?.userId);
2582
- const serverOrigin = normalizeAuthorityServerOrigin(record?.serverOrigin);
2583
- const explicitAuthority = normalizeAuthorityServerOrigin(record?.authorityServer);
2584
- const registryAuthority = resolveUserAuthorityServer({
2585
- ownerUserId,
2586
- registry: userAuthorityRegistry
2587
- });
2588
- const currentUserAuthority = ownerUserId && ownerUserId === normalizeUserId2(currentUserId) ? normalizeAuthorityServerOrigin(currentServer) : null;
2589
- return {
2590
- ownerUserId,
2591
- authorityServer: explicitAuthority ?? registryAuthority ?? currentUserAuthority ?? serverOrigin,
2592
- serverOrigin
2593
- };
2594
- };
2595
-
2596
- // packages/database/actions/readResolution.ts
2597
- var toComparableTimestamp = (data) => {
2598
- if (!data || typeof data !== "object") return 0;
2599
- const updatedAtMs = asOptionalPositiveFiniteNumber(
2600
- new Date(data.updatedAt).getTime()
2601
- );
2602
- if (updatedAtMs !== void 0) return updatedAtMs;
2603
- const createdAtMs = asOptionalPositiveFiniteNumber(
2604
- new Date(data.createdAt).getTime()
2605
- );
2606
- if (createdAtMs !== void 0) return createdAtMs;
2607
- return asOptionalPositiveFiniteNumber(Number(data?.meta?.createdAt)) ?? 0;
2608
- };
2609
- var partitionReadServers = ({
2610
- allServers,
2611
- preferredServerOrigin
2612
- }) => {
2613
- const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
2614
- const fallbackServers = preferredServer ? allServers.filter(
2615
- (server) => normalizeServerOrigin(server) !== preferredServer
2616
- ) : allServers;
2617
- return {
2618
- preferredServer,
2619
- fallbackServers,
2620
- orderedServersForLocalHit: preferredServer ? [preferredServer, ...fallbackServers] : fallbackServers
2621
- };
2622
- };
2623
- var compareRemoteRecordsByComparableTime = (left, right) => toComparableTimestamp(left) - toComparableTimestamp(right);
2624
- var pickBestSettledRemoteRecord = ({
2625
- settledResults,
2626
- isBetterCandidate
2627
- }) => {
2628
- const validResults = settledResults.map((result, index) => ({
2629
- data: result.status === "fulfilled" ? result.value : null,
2630
- index
2631
- })).filter((item) => item.data !== null && typeof item.data === "object");
2632
- if (validResults.length === 0) return null;
2633
- const latest2 = validResults.reduce(
2634
- (best, current2) => isBetterCandidate(current2.data, best.data) ? current2 : best
2635
- );
2636
- return { index: latest2.index, data: latest2.data };
2637
- };
2638
- var shouldReplaceLocalWithRemoteRecord = ({
2639
- localData,
2640
- remoteData,
2641
- isRemoteNewer
2642
- }) => {
2643
- if (!remoteData || typeof remoteData !== "object") return false;
2644
- if (!localData || typeof localData !== "object") return true;
2645
- return isRemoteNewer(remoteData, localData);
2646
- };
2647
- var shouldReplicateLocalRecord = ({
2648
- localData,
2649
- remoteData,
2650
- remoteTargetCount
2651
- }) => !!localData && !remoteData && remoteTargetCount > 0;
2652
- var compactUniqueServers = (servers) => {
2653
- const out = [];
2654
- for (const server of servers) {
2655
- if (typeof server !== "string" || server.trim().length === 0) continue;
2656
- const normalized = normalizeServerOrigin(server);
2657
- if (!out.includes(normalized)) out.push(normalized);
2658
- }
2659
- return out;
2660
- };
2661
- var planAuthorityReadServers = ({
2662
- allServers,
2663
- authorityServer,
2664
- serverOrigin
2665
- }) => compactUniqueServers([authorityServer, serverOrigin, ...allServers]);
2666
-
2667
- // packages/core/fnv1a32.ts
2668
- var fnv1a32 = (str) => {
2669
- let hash = 2166136261;
2670
- for (let i = 0; i < str.length; i++) {
2671
- hash ^= str.charCodeAt(i);
2672
- hash = hash * 16777619 >>> 0;
2673
- }
2674
- return hash >>> 0;
2675
- };
2676
- var fnv1a32Hex = (str) => fnv1a32(str).toString(16).padStart(8, "0");
2677
-
2678
- // packages/database/fileRing.ts
2679
- var chooseServersByKey = (allServers, key, replicaCount) => {
2680
- if (!allServers.length || replicaCount <= 0) return [];
2681
- const uniqueServers = Array.from(new Set(allServers)).filter((s) => !!s);
2682
- if (uniqueServers.length === 0) return [];
2683
- const scored = uniqueServers.map((server) => ({
2684
- server,
2685
- score: fnv1a32(`${server}::${key}`)
2686
- }));
2687
- scored.sort((a, b) => a.score - b.score);
2688
- const limit = Math.min(replicaCount, scored.length);
2689
- return scored.slice(0, limit).map((item) => item.server);
2690
- };
2691
-
2692
- // packages/database/tenantPlacement.ts
2693
- var TENANT_REPLICA_COUNT = 2;
2694
- var planServersForTenant = (allServers, currentServer, tenantId) => {
2695
- const uniqueServers = Array.from(new Set(allServers)).filter(Boolean);
2696
- if (!uniqueServers.length) return [];
2697
- const key = asOptionalTrimmedString(tenantId) ?? "default-tenant";
2698
- const fromRing = chooseServersByKey(
2699
- uniqueServers,
2700
- key,
2701
- TENANT_REPLICA_COUNT
2702
- );
2703
- const set2 = new Set(fromRing);
2704
- if (currentServer && uniqueServers.includes(currentServer)) {
2705
- set2.add(currentServer);
2706
- }
2707
- return Array.from(set2);
2708
- };
2709
-
2710
- // packages/database/authority/deviceLocal.ts
2711
- var DEVICE_LOCAL_OWNER_ID = "local";
2712
- var DEVICE_LOCAL_DB_KEY_PREFIXES = [
2713
- "dialog-local-",
2714
- "agent-local-"
2715
- ];
2716
- var clean = (value) => asOptionalTrimmedString(value) ?? null;
2717
- var isDeviceLocalOwnerId = (userId) => clean(userId) === DEVICE_LOCAL_OWNER_ID;
2718
- var resolveEffectiveSpaceActorId = (accountUserId) => {
2719
- const cleaned = clean(accountUserId);
2720
- if (!cleaned || isDeviceLocalOwnerId(cleaned)) {
2721
- return DEVICE_LOCAL_OWNER_ID;
2722
- }
2723
- return cleaned;
2724
- };
2725
- var isDeviceLocalSpaceMembership = (membership) => isDeviceLocalOwnerId(membership?.userId);
2726
- var isDeviceLocalSpaceBody = (space) => isDeviceLocalOwnerId(space?.userId) || isDeviceLocalOwnerId(space?.ownerId);
2727
- var isDeviceLocalDbKey = (dbKey) => {
2728
- const key = clean(dbKey);
2729
- if (!key) return false;
2730
- for (const prefix of DEVICE_LOCAL_DB_KEY_PREFIXES) {
2731
- if (key.startsWith(prefix)) return true;
2732
- }
2733
- return parseOwnerUserIdFromDbKey(key, {
2734
- candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
2735
- }) === DEVICE_LOCAL_OWNER_ID;
2736
- };
2737
- var resolveRecordOwnerUserId = (record) => {
2738
- if (!record) return null;
2739
- const explicit = clean(record.userId);
2740
- if (explicit) return explicit;
2741
- if (isDeviceLocalDbKey(record.dbKey) || isDeviceLocalDbKey(record.id)) {
2742
- return DEVICE_LOCAL_OWNER_ID;
2743
- }
2744
- const fromKey = parseOwnerUserIdFromDbKey(clean(record.dbKey) ?? "", {
2745
- candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
2746
- }) ?? parseOwnerUserIdFromDbKey(clean(record.id) ?? "", {
2747
- candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
2748
- });
2749
- return fromKey;
2750
- };
2751
-
2752
- // packages/database/actions/replication.ts
2753
- var isReadonlyPublicRecordKey = (dbKey) => dbKey.startsWith("agent-pub-");
2754
- var normalizeCurrentUserId = (state) => {
2755
- const userId = selectIdentityUserId(state);
2756
- return asOptionalTrimmedString(userId) ?? null;
2757
- };
2758
- var resolveReplicationServers = (currentServer, syncServers, preferredServerOrigin) => getAllServers(currentServer, syncServers, preferredServerOrigin);
2759
- var resolveAuthorityReplicationServers = ({
2760
- currentServer,
2761
- syncServers,
2762
- preferredServerOrigin,
2763
- dbKey,
2764
- record,
2765
- state
2766
- }) => {
2767
- const allServers = resolveReplicationServers(
2768
- currentServer,
2769
- syncServers,
2770
- preferredServerOrigin
2771
- );
2772
- const authority = resolveRecordAuthority({
2773
- dbKey,
2774
- record,
2775
- currentUserId: selectIdentityUserId(state),
2776
- currentServer,
2777
- userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
2778
- });
2779
- if (isDeviceLocalOwnerId(authority.ownerUserId) || isDeviceLocalOwnerId(record?.userId) || isDeviceLocalDbKey(dbKey)) {
2780
- return [];
2781
- }
2782
- return planAuthorityReadServers({
2783
- allServers,
2784
- authorityServer: preferredServerOrigin ?? authority.authorityServer,
2785
- serverOrigin: authority.serverOrigin
2786
- });
2787
- };
2788
- var scheduleWriteReplication = (servers, request, state) => {
2789
- if (servers.length === 0) return;
2790
- Promise.resolve().then(async () => {
2791
- const [primaryServer, ...backupServers] = servers;
2792
- const primarySucceeded = await noloWriteRequest(primaryServer, request, state);
2793
- if (!primarySucceeded) {
2794
- console.warn(`Primary write sync failed for ${request.customKey} on ${primaryServer}`);
2795
- }
2796
- if (backupServers.length === 0) {
2797
- return;
2798
- }
2799
- syncWithServers(
2800
- backupServers,
2801
- (server, requestConfig, requestState, signal) => noloWriteRequest(server, requestConfig, requestState, signal, {
2802
- failureLogLevel: "info"
2803
- }),
2804
- `Backup write sync failed for ${request.customKey} on`,
2805
- request,
2806
- state
2807
- );
2808
- });
2809
- };
2810
- var resolveTenantReplicationServers = ({
2811
- currentServer,
2812
- syncServers,
2813
- tenantId
2814
- }) => {
2815
- const allServers = resolveReplicationServers(currentServer, syncServers);
2816
- if (allServers.length === 0) {
2817
- return [];
2818
- }
2819
- return planServersForTenant(allServers, currentServer, tenantId);
2820
- };
2821
- var resolveUploadReplicationServers = ({
2822
- currentServer,
2823
- syncServers,
2824
- tenantId,
2825
- uploadConfig,
2826
- state
2827
- }) => {
2828
- const allServers = resolveReplicationServers(currentServer, syncServers);
2829
- const authority = resolveRecordAuthority({
2830
- dbKey: uploadConfig.customKey,
2831
- record: uploadConfig.metadata,
2832
- currentUserId: selectIdentityUserId(state),
2833
- currentServer,
2834
- userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
2835
- });
2836
- if (authority.ownerUserId || authority.authorityServer) {
2837
- return planAuthorityReadServers({
2838
- allServers,
2839
- authorityServer: authority.authorityServer,
2840
- serverOrigin: authority.serverOrigin
2841
- });
2842
- }
2843
- return resolveTenantReplicationServers({
2844
- currentServer,
2845
- syncServers,
2846
- tenantId
2847
- });
2848
- };
2849
- var scheduleExistingRecordReplication = ({
2850
- currentServer,
2851
- syncServers,
2852
- preferredServerOrigin,
2853
- dbKey,
2854
- localData,
2855
- state
2856
- }) => {
2857
- if (isReadonlyPublicRecordKey(dbKey)) {
2858
- return [];
2859
- }
2860
- const currentUserId = normalizeCurrentUserId(state);
2861
- const authority = resolveRecordAuthority({
2862
- dbKey,
2863
- record: localData,
2864
- currentUserId,
2865
- currentServer,
2866
- userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
2867
- });
2868
- if (authority.ownerUserId && currentUserId && authority.ownerUserId !== currentUserId) {
2869
- return [];
2870
- }
2871
- const servers = resolveAuthorityReplicationServers({
2872
- currentServer,
2873
- syncServers,
2874
- preferredServerOrigin,
2875
- dbKey,
2876
- record: localData,
2877
- state
2878
- });
2879
- if (servers.length === 0) {
2880
- return [];
2881
- }
2882
- scheduleWriteReplication(
2883
- servers,
2884
- {
2885
- data: localData,
2886
- customKey: dbKey,
2887
- userId: typeof localData?.userId === "string" ? localData.userId : selectIdentityUserId(state)
2888
- },
2889
- state
2890
- );
2891
- return servers;
2892
- };
2893
- var schedulePatchReplication = ({
2894
- servers,
2895
- dbKey,
2896
- changes,
2897
- state,
2898
- preferredServerOrigin
2899
- }) => {
2900
- if (servers.length === 0) return;
2901
- Promise.resolve().then(async () => {
2902
- const primaryServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : servers[0];
2903
- const backupServers = servers.filter(
2904
- (server) => normalizeServerOrigin(server) !== primaryServer
2905
- );
2906
- const primarySucceeded = await noloPatchRequest(primaryServer, dbKey, changes, state, void 0, {
2907
- failureLogLevel: "warn"
2908
- });
2909
- if (!primarySucceeded) {
2910
- console.warn(`Primary patch sync failed for ${dbKey} on ${primaryServer}`);
2911
- }
2912
- if (backupServers.length > 0) {
2913
- syncWithServers(
2914
- backupServers,
2915
- (server, targetDbKey, nextChanges, requestState, signal) => noloPatchRequest(server, targetDbKey, nextChanges, requestState, signal, {
2916
- failureLogLevel: "info"
2917
- }),
2918
- `Backup patch sync failed for ${dbKey} on`,
2919
- dbKey,
2920
- changes,
2921
- state
2922
- );
2923
- }
2924
- });
2925
- };
2926
- var scheduleConfiguredPatchReplication = ({
2927
- currentServer,
2928
- syncServers,
2929
- preferredServerOrigin,
2930
- dbKey,
2931
- changes,
2932
- state
2933
- }) => {
2934
- const servers = resolveAuthorityReplicationServers({
2935
- currentServer,
2936
- syncServers,
2937
- preferredServerOrigin,
2938
- dbKey,
2939
- record: changes,
2940
- state
2941
- });
2942
- if (servers.length === 0) {
2943
- return [];
2944
- }
2945
- schedulePatchReplication({
2946
- servers,
2947
- dbKey,
2948
- changes,
2949
- state,
2950
- preferredServerOrigin
2951
- });
2952
- return servers;
2953
- };
2954
- var scheduleUploadReplication = ({
2955
- currentServer,
2956
- syncServers,
2957
- tenantId,
2958
- uploadConfig,
2959
- state,
2960
- excludeServers = []
2961
- }) => {
2962
- const servers = resolveUploadReplicationServers({
2963
- currentServer,
2964
- syncServers,
2965
- tenantId,
2966
- uploadConfig,
2967
- state
2968
- });
2969
- const excluded = new Set(
2970
- excludeServers.filter((server) => typeof server === "string").map((server) => normalizeServerOrigin(server))
2971
- );
2972
- const remainingServers = servers.filter(
2973
- (server) => !excluded.has(normalizeServerOrigin(server))
2974
- );
2975
- if (remainingServers.length === 0) {
2976
- return [];
2977
- }
2978
- Promise.resolve().then(() => {
2979
- syncWithServers(
2980
- remainingServers,
2981
- noloUploadRequest,
2982
- `Upload sync failed for ${uploadConfig.customKey} on`,
2983
- uploadConfig,
2984
- state
2985
- );
2986
- });
2987
- return remainingServers;
2988
- };
2989
- var uploadToCurrentServer = async ({
2990
- currentServer,
2991
- uploadConfig,
2992
- state
2993
- }) => {
2994
- if (!currentServer) {
2995
- return false;
2996
- }
2997
- return noloUploadRequest(currentServer, uploadConfig, state);
2998
- };
2999
- var deleteFromReplicationServers = async ({
3000
- servers,
3001
- dbKey,
3002
- deleteOptions = { type: "single" },
3003
- state,
3004
- preferredServerOrigin
3005
- }) => {
3006
- if (!servers.length) {
3007
- return { succeeded: [], failed: [] };
3008
- }
3009
- const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
3010
- const remainingServers = preferredServer ? servers.filter((server) => normalizeServerOrigin(server) !== preferredServer) : servers;
3011
- const succeeded = [];
3012
- const failed = [];
3013
- if (preferredServer) {
3014
- const ok = await noloDeleteRequest(preferredServer, dbKey, deleteOptions, state);
3015
- if (ok) {
3016
- succeeded.push(preferredServer);
3017
- } else {
3018
- failed.push(preferredServer);
3019
- }
3020
- }
3021
- if (remainingServers.length > 0) {
3022
- const results = await Promise.all(
3023
- remainingServers.map(async (server) => ({
3024
- server,
3025
- ok: await noloDeleteRequest(server, dbKey, deleteOptions, state)
3026
- }))
3027
- );
3028
- results.forEach(({ server, ok }) => {
3029
- if (ok) succeeded.push(server);
3030
- else failed.push(server);
3031
- });
3032
- }
3033
- return { succeeded, failed };
3034
- };
3035
- var scheduleDeleteReplication = ({
3036
- currentServer,
3037
- syncServers,
3038
- preferredServerOrigin,
3039
- dbKey,
3040
- deleteOptions,
3041
- state,
3042
- onResult,
3043
- onError
3044
- }) => {
3045
- const servers = resolveAuthorityReplicationServers({
3046
- currentServer,
3047
- syncServers,
3048
- preferredServerOrigin,
3049
- dbKey,
3050
- state
3051
- });
3052
- if (servers.length === 0) {
3053
- return [];
3054
- }
3055
- void Promise.resolve().then(
3056
- () => deleteFromReplicationServers({
3057
- servers,
3058
- dbKey,
3059
- deleteOptions,
3060
- state,
3061
- preferredServerOrigin
3062
- })
3063
- ).then((result) => {
3064
- onResult?.(result);
3065
- }).catch((error) => {
3066
- onError?.(error);
3067
- });
3068
- return servers;
3069
- };
3070
-
3071
2402
  export {
3072
2403
  createSelector,
3073
2404
  createAction,
@@ -3075,33 +2406,9 @@ export {
3075
2406
  asyncThunkCreator,
3076
2407
  buildCreateSlice,
3077
2408
  createEntityAdapter,
3078
- selectRuntimeSnapshot,
3079
- selectRuntimeCurrentServer,
3080
- getRuntimeServerContext,
2409
+ noloPatchRequest,
3081
2410
  noloWriteRequest,
3082
- noloDeleteRequest,
3083
- fnv1a32Hex,
3084
- parseOwnerUserIdFromDbKey,
3085
- DEVICE_LOCAL_OWNER_ID,
3086
- isDeviceLocalOwnerId,
3087
- resolveEffectiveSpaceActorId,
3088
- isDeviceLocalSpaceMembership,
3089
- isDeviceLocalSpaceBody,
3090
- resolveRecordOwnerUserId,
3091
- resolveRecordAuthority,
3092
- partitionReadServers,
3093
- compareRemoteRecordsByComparableTime,
3094
- pickBestSettledRemoteRecord,
3095
- shouldReplaceLocalWithRemoteRecord,
3096
- shouldReplicateLocalRecord,
3097
- planAuthorityReadServers,
3098
- resolveReplicationServers,
3099
- resolveAuthorityReplicationServers,
3100
- scheduleWriteReplication,
3101
- resolveUploadReplicationServers,
3102
- scheduleExistingRecordReplication,
3103
- scheduleConfiguredPatchReplication,
3104
- scheduleUploadReplication,
3105
- uploadToCurrentServer,
3106
- scheduleDeleteReplication
2411
+ noloUploadRequest,
2412
+ syncWithServers,
2413
+ noloDeleteRequest
3107
2414
  };