sandforge 1.85.0 → 1.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +1 -1
  2. package/lib/{chunk-THYQOG24.mjs → chunk-22L43JMK.mjs} +1 -1
  3. package/lib/{chunk-U4S27YRP.mjs → chunk-2LSGWTWX.mjs} +1 -1
  4. package/lib/{chunk-MRN72UEO.mjs → chunk-2YJJTQNC.mjs} +1 -1
  5. package/lib/chunk-34SMB5PA.mjs +10 -0
  6. package/lib/chunk-35B73566.mjs +7 -0
  7. package/lib/{chunk-YZKE6D3K.mjs → chunk-35IJ4WEU.mjs} +1 -1
  8. package/lib/chunk-3EHPAFKV.mjs +7 -0
  9. package/lib/{chunk-3OKDWZ32.mjs → chunk-3HAVVEXF.mjs} +1 -1
  10. package/lib/{chunk-32ZB5ICW.mjs → chunk-3I6FXFCN.mjs} +1 -1
  11. package/lib/{chunk-JFVY66BS.mjs → chunk-3KJCSYXY.mjs} +1 -1
  12. package/lib/{chunk-ULEYGOZU.mjs → chunk-3L6DVNCR.mjs} +1 -1
  13. package/lib/chunk-3LRFPGYZ.mjs +7 -0
  14. package/lib/{chunk-GHUA6OQQ.mjs → chunk-3MVWGL5A.mjs} +1 -1
  15. package/lib/{chunk-SF52ZSIV.mjs → chunk-4CSBZZAL.mjs} +1 -1
  16. package/lib/{chunk-FBYFCKPG.mjs → chunk-4NSXPONF.mjs} +1 -1
  17. package/lib/{chunk-A3QNSALB.mjs → chunk-4VLP6RHC.mjs} +1 -1
  18. package/lib/{chunk-TWYNQ2OO.mjs → chunk-4XROG5CT.mjs} +1 -1
  19. package/lib/chunk-54V4FVEY.mjs +7 -0
  20. package/lib/chunk-55OJJT2Q.mjs +7 -0
  21. package/lib/{chunk-JRI6A24G.mjs → chunk-5EHHQ5UX.mjs} +1 -1
  22. package/lib/{chunk-VPGX5Z5D.mjs → chunk-5JMQXHJ2.mjs} +1 -1
  23. package/lib/{chunk-CI2O7WBH.mjs → chunk-65AMXOQU.mjs} +1 -1
  24. package/lib/{chunk-5T3LFDJ5.mjs → chunk-6HHSAPIM.mjs} +1 -1
  25. package/lib/chunk-6KVBCFVS.mjs +7 -0
  26. package/lib/chunk-6NG7C2U3.mjs +476 -0
  27. package/lib/{chunk-F2424IKX.mjs → chunk-6ROL3KBM.mjs} +1 -1
  28. package/lib/{chunk-7ZYCRIHE.mjs → chunk-72AWCN7U.mjs} +1 -1
  29. package/lib/{chunk-MQLTEXB7.mjs → chunk-7KHA5UIQ.mjs} +1 -1
  30. package/lib/chunk-7O6EFNQS.mjs +10 -0
  31. package/lib/{chunk-73SLYGWD.mjs → chunk-A2CH2QGX.mjs} +1 -1
  32. package/lib/chunk-A2TXLAC3.mjs +276 -0
  33. package/lib/chunk-ALWVNR34.mjs +7 -0
  34. package/lib/{chunk-JBOGAUGH.mjs → chunk-ATBQIE2V.mjs} +1 -1
  35. package/lib/{chunk-C2MHMI7U.mjs → chunk-ATQML7ZK.mjs} +1 -1
  36. package/lib/chunk-AVY742BJ.mjs +7 -0
  37. package/lib/{chunk-VLAU5QQT.mjs → chunk-AXTB2HJS.mjs} +1 -1
  38. package/lib/chunk-BBZUGKBZ.mjs +10 -0
  39. package/lib/chunk-BIDXK7KA.mjs +7 -0
  40. package/lib/{chunk-KYLHS74X.mjs → chunk-BLMJ4WVI.mjs} +1 -1
  41. package/lib/{chunk-A7YP27GQ.mjs → chunk-BNHJCJJM.mjs} +1 -1
  42. package/lib/{chunk-ZDMSTL2L.mjs → chunk-BNPQEQXC.mjs} +1 -1
  43. package/lib/chunk-C5AUNG6T.mjs +37 -0
  44. package/lib/{chunk-LY6EPMIP.mjs → chunk-C5EQ7GFC.mjs} +1 -1
  45. package/lib/{chunk-LOO42EW5.mjs → chunk-C7CKDZMC.mjs} +62 -62
  46. package/lib/{chunk-ZP3WJGS3.mjs → chunk-CB4U22NR.mjs} +1 -1
  47. package/lib/chunk-CJAWKLAL.mjs +7 -0
  48. package/lib/chunk-CL75DEMQ.mjs +9 -0
  49. package/lib/{chunk-7L6FE5PP.mjs → chunk-CLUNF4FK.mjs} +1 -1
  50. package/lib/chunk-CSMGP53U.mjs +7 -0
  51. package/lib/{chunk-S6BMJSLD.mjs → chunk-CT324C7I.mjs} +1 -1
  52. package/lib/{chunk-YXOPKGDX.mjs → chunk-CZXDJXQP.mjs} +1 -1
  53. package/lib/{chunk-PGG4ULEW.mjs → chunk-D2X6U3MS.mjs} +1 -1
  54. package/lib/{chunk-FG4Y4ZVL.mjs → chunk-DAUX63UB.mjs} +1 -1
  55. package/lib/chunk-DB7JNALQ.mjs +10 -0
  56. package/lib/chunk-DDNCJVZ2.mjs +17 -0
  57. package/lib/{chunk-YGE4AUXG.mjs → chunk-DLSU66MY.mjs} +1 -1
  58. package/lib/{chunk-DCJBP3LE.mjs → chunk-DO6PSHQZ.mjs} +1 -1
  59. package/lib/{chunk-ROTDZKOE.mjs → chunk-DUBECLZV.mjs} +1 -1
  60. package/lib/{chunk-SES5HPBZ.mjs → chunk-DYHF6DNT.mjs} +1 -1
  61. package/lib/chunk-E5FSPXYH.mjs +930 -0
  62. package/lib/{chunk-QAXKUEJT.mjs → chunk-EGL3I3IX.mjs} +1 -1
  63. package/lib/chunk-EIYMQPMG.mjs +7 -0
  64. package/lib/{chunk-AX3YF7SC.mjs → chunk-EUIALBMX.mjs} +1 -1
  65. package/lib/{chunk-57QRXYAZ.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
  66. package/lib/{chunk-FCZDWGQI.mjs → chunk-FM4QCTO7.mjs} +1 -1
  67. package/lib/{chunk-74HZ274R.mjs → chunk-FRSIEASH.mjs} +1 -1
  68. package/lib/{chunk-G6IYOZEH.mjs → chunk-FV6MOSHD.mjs} +1 -1
  69. package/lib/chunk-FYG47CNA.mjs +7 -0
  70. package/lib/chunk-GB6W4Q56.mjs +7 -0
  71. package/lib/chunk-GEV2DCMK.mjs +7 -0
  72. package/lib/{chunk-NZJXEULY.mjs → chunk-GFB2DNCB.mjs} +1 -1
  73. package/lib/chunk-GFGMGFSH.mjs +7 -0
  74. package/lib/{chunk-EFHDE7W4.mjs → chunk-GIFQXB2Q.mjs} +1 -1
  75. package/lib/{chunk-P6A22FMQ.mjs → chunk-GP5J3DGS.mjs} +1 -1
  76. package/lib/chunk-GQZEX7LH.mjs +231 -0
  77. package/lib/{chunk-BRN42U26.mjs → chunk-GYDTM62J.mjs} +1 -1
  78. package/lib/{chunk-GNCEHAJY.mjs → chunk-GYFIXUJG.mjs} +1 -1
  79. package/lib/chunk-GZW2GNFK.mjs +7 -0
  80. package/lib/chunk-H6BHWAX7.mjs +8 -0
  81. package/lib/{chunk-GUYEXPJ4.mjs → chunk-HDDJ3CVN.mjs} +1 -1
  82. package/lib/{chunk-3GATEVHC.mjs → chunk-HDWB4ZOG.mjs} +1 -1
  83. package/lib/chunk-HGVPBJR6.mjs +7 -0
  84. package/lib/{chunk-55VBV2WK.mjs → chunk-HLROVOR6.mjs} +1 -1
  85. package/lib/{chunk-HV3TDLFR.mjs → chunk-HUOR4M2L.mjs} +1 -1
  86. package/lib/chunk-HZCS6EED.mjs +8 -0
  87. package/lib/{chunk-WZX6VCIT.mjs → chunk-HZUI56KZ.mjs} +1 -1
  88. package/lib/chunk-IAB5H7WN.mjs +7 -0
  89. package/lib/{chunk-RY7WUJXH.mjs → chunk-IQ5UKRHU.mjs} +1 -1
  90. package/lib/{chunk-OUWR5M5G.mjs → chunk-IRQ4WANV.mjs} +1 -1
  91. package/lib/{chunk-F44EHXLI.mjs → chunk-IT3DGX37.mjs} +1 -1
  92. package/lib/chunk-J347SPU6.mjs +49 -0
  93. package/lib/{chunk-IZ2M2RGO.mjs → chunk-JANBNTR5.mjs} +1 -1
  94. package/lib/chunk-JFXQZPRY.mjs +9 -0
  95. package/lib/{chunk-VKA5OZBJ.mjs → chunk-JRLYWVF4.mjs} +1 -1
  96. package/lib/{chunk-FM5ESRH6.mjs → chunk-JSNMUTY6.mjs} +1 -1
  97. package/lib/chunk-JTNJKSAA.mjs +7 -0
  98. package/lib/{chunk-4D6OHSX3.mjs → chunk-JV2LAKWQ.mjs} +1 -1
  99. package/lib/{chunk-BY42YL4D.mjs → chunk-JV7K2ZHK.mjs} +1 -1
  100. package/lib/{chunk-A6IJUOLB.mjs → chunk-K4TQ7YHX.mjs} +1 -1
  101. package/lib/chunk-K5PUMHZU.mjs +7 -0
  102. package/lib/chunk-KH4KLCYG.mjs +7 -0
  103. package/lib/{chunk-FZF6FB65.mjs → chunk-KQVLZVOP.mjs} +1 -1
  104. package/lib/chunk-KWUS7UAV.mjs +19 -0
  105. package/lib/{chunk-2UUSF32M.mjs → chunk-L6G73FXM.mjs} +1 -1
  106. package/lib/{chunk-LUNGNCM3.mjs → chunk-LG466Q5H.mjs} +1 -1
  107. package/lib/{chunk-YTBM3TSW.mjs → chunk-LHNAR6FC.mjs} +1 -1
  108. package/lib/chunk-LT4GHEI2.mjs +7 -0
  109. package/lib/{chunk-P3OYE2FS.mjs → chunk-MR262Y3B.mjs} +1 -1
  110. package/lib/{chunk-TSTCHIBU.mjs → chunk-NCCHOV2N.mjs} +1 -1
  111. package/lib/chunk-NICRSGLS.mjs +7 -0
  112. package/lib/chunk-NV5QA2HY.mjs +7 -0
  113. package/lib/{chunk-6HAKOS6W.mjs → chunk-O3GIN5TU.mjs} +1 -1
  114. package/lib/chunk-O6FHK6NQ.mjs +13 -0
  115. package/lib/{chunk-OXIIKAUZ.mjs → chunk-O7YIEFG7.mjs} +1 -1
  116. package/lib/chunk-OCUVAA5E.mjs +7 -0
  117. package/lib/chunk-OLCS7JCT.mjs +14 -0
  118. package/lib/chunk-ON7Y63FK.mjs +9 -0
  119. package/lib/{chunk-K2WOT75I.mjs → chunk-OO2WY3UB.mjs} +1 -1
  120. package/lib/{chunk-3EOIAC2M.mjs → chunk-OT2NHL2V.mjs} +1 -1
  121. package/lib/{chunk-BK5SRDAD.mjs → chunk-P2M5ZXWU.mjs} +1 -1
  122. package/lib/{chunk-DCZYWMSA.mjs → chunk-P4YOHLZ4.mjs} +1 -1
  123. package/lib/chunk-PBHDPTT6.mjs +343 -0
  124. package/lib/chunk-PE7CHD2W.mjs +7 -0
  125. package/lib/{chunk-LU7M5URW.mjs → chunk-PIQ2I67B.mjs} +1 -1
  126. package/lib/chunk-PKYDNZJK.mjs +7 -0
  127. package/lib/chunk-PVZ72OOQ.mjs +7 -0
  128. package/lib/chunk-QACFTHJM.mjs +8 -0
  129. package/lib/{chunk-LNAZHI3J.mjs → chunk-QGVL5EW3.mjs} +1 -1
  130. package/lib/chunk-QHE2RUWX.mjs +7 -0
  131. package/lib/{chunk-4RNP65FV.mjs → chunk-RCW5BZNW.mjs} +1 -1
  132. package/lib/{chunk-OTKXTBTX.mjs → chunk-RJ6HHG7J.mjs} +1 -1
  133. package/lib/{chunk-IVDBVWKK.mjs → chunk-RPTEEI4R.mjs} +1 -1
  134. package/lib/chunk-RQW5S67A.mjs +7 -0
  135. package/lib/chunk-RTCMYMED.mjs +7 -0
  136. package/lib/chunk-RWVX7XSD.mjs +7 -0
  137. package/lib/{chunk-2UUS4IGB.mjs → chunk-RZOINFNL.mjs} +1 -1
  138. package/lib/chunk-SOOTWGMQ.mjs +7 -0
  139. package/lib/chunk-STQ2JMIZ.mjs +7 -0
  140. package/lib/{chunk-RC25QQVF.mjs → chunk-SUIPDW5O.mjs} +1 -1
  141. package/lib/{chunk-Z354SAEF.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
  142. package/lib/{chunk-45375WT5.mjs → chunk-T542Z54E.mjs} +1 -1
  143. package/lib/chunk-TAN2CIRI.mjs +21 -0
  144. package/lib/{chunk-BGJBYDRW.mjs → chunk-TCNBINOG.mjs} +1 -1
  145. package/lib/chunk-TFDF3DBN.mjs +7 -0
  146. package/lib/{chunk-B5A4JHNN.mjs → chunk-TICZXC53.mjs} +1 -1
  147. package/lib/chunk-TLX45X5U.mjs +7 -0
  148. package/lib/{chunk-W6SLQZKQ.mjs → chunk-TMIV3IWH.mjs} +1 -1
  149. package/lib/chunk-TQ6HEJ73.mjs +11 -0
  150. package/lib/chunk-TTU5EQZ6.mjs +7 -0
  151. package/lib/chunk-TYUYPFDJ.mjs +7 -0
  152. package/lib/chunk-TZXYVMZC.mjs +7 -0
  153. package/lib/{chunk-4N425UJC.mjs → chunk-UCUFLFNK.mjs} +1 -1
  154. package/lib/chunk-UK3QLBHW.mjs +7 -0
  155. package/lib/{chunk-SKGAERV4.mjs → chunk-UM2B4GR7.mjs} +1 -1
  156. package/lib/chunk-UZFTTNOP.mjs +7 -0
  157. package/lib/chunk-V3AXSKSU.mjs +7 -0
  158. package/lib/chunk-VA6EEI6X.mjs +21 -0
  159. package/lib/{chunk-LSEM2BZH.mjs → chunk-VFKG2G37.mjs} +1 -1
  160. package/lib/chunk-VJNEW5MQ.mjs +7 -0
  161. package/lib/{chunk-EYFP3NA6.mjs → chunk-VKREON6Q.mjs} +1 -1
  162. package/lib/{chunk-TIVI2KGB.mjs → chunk-VNNDYPBL.mjs} +1 -1
  163. package/lib/{chunk-J3FJ3BWE.mjs → chunk-VRBETPHY.mjs} +1 -1
  164. package/lib/{chunk-UX4AOSMU.mjs → chunk-VT6P3X6R.mjs} +1 -1
  165. package/lib/{chunk-CUOWQMGW.mjs → chunk-VUTQY76O.mjs} +1 -1
  166. package/lib/chunk-WF5S4FW5.mjs +7 -0
  167. package/lib/{chunk-JHJDDQDE.mjs → chunk-WJGK6VGU.mjs} +1 -1
  168. package/lib/{chunk-IZREPWYQ.mjs → chunk-WJHMB3SL.mjs} +1 -1
  169. package/lib/{chunk-XZRON54U.mjs → chunk-WQCXOZEJ.mjs} +1 -1
  170. package/lib/{chunk-N2MXYD67.mjs → chunk-WVVFR4E3.mjs} +1 -1
  171. package/lib/{chunk-GG5I52UT.mjs → chunk-XBYXT74L.mjs} +1 -1
  172. package/lib/chunk-XJE3LJHP.mjs +7 -0
  173. package/lib/{chunk-3QCUSZIZ.mjs → chunk-XV4CVZYD.mjs} +1 -1
  174. package/lib/chunk-Y37ED7AS.mjs +7 -0
  175. package/lib/{chunk-MN3XBJPE.mjs → chunk-YGBNZYT4.mjs} +1 -1
  176. package/lib/{chunk-SBDF4AE5.mjs → chunk-YGTOX7IL.mjs} +1 -1
  177. package/lib/{chunk-SQM32AOQ.mjs → chunk-YJ27WHKR.mjs} +1 -1
  178. package/lib/chunk-YRULC27A.mjs +7 -0
  179. package/lib/{chunk-RMFU4BAL.mjs → chunk-YSVAHT4Q.mjs} +4 -4
  180. package/lib/chunk-YTOTMJTY.mjs +15 -0
  181. package/lib/{chunk-SU24AE3H.mjs → chunk-YZKZC62O.mjs} +1 -1
  182. package/lib/{chunk-LJNRN7MY.mjs → chunk-YZQN7BRB.mjs} +1 -1
  183. package/lib/{chunk-NMF55UBQ.mjs → chunk-Z5IUK2QO.mjs} +1 -1
  184. package/lib/{chunk-6ZWY36LK.mjs → chunk-ZEGSMW5A.mjs} +1 -1
  185. package/lib/{chunk-YV7JYHJP.mjs → chunk-ZIKLQZBG.mjs} +1 -1
  186. package/lib/chunk-ZVU7MD2S.mjs +7 -0
  187. package/lib/sandforge-autopilot.mjs +33 -27
  188. package/lib/sandforge-backup.mjs +19 -19
  189. package/lib/sandforge-checkpoint.mjs +1 -1
  190. package/lib/sandforge-cleanup.mjs +1 -1
  191. package/lib/sandforge-clone.mjs +1 -1
  192. package/lib/sandforge-compare.mjs +29 -16
  193. package/lib/sandforge-dataops.mjs +1 -1
  194. package/lib/sandforge-empty.mjs +11 -13
  195. package/lib/sandforge-env.mjs +105 -105
  196. package/lib/sandforge-frozen.mjs +1 -1
  197. package/lib/sandforge-mcp.mjs +2 -2
  198. package/lib/sandforge-monitor.mjs +1 -1
  199. package/lib/sandforge-pipeline.mjs +13 -13
  200. package/lib/sandforge-seed.mjs +1 -1
  201. package/lib/sandforge-sync.mjs +1 -1
  202. package/lib/sandforge-users.mjs +13 -15
  203. package/lib/sandforge.mjs +1 -1
  204. package/lib/sf/sandforge/dataops.mjs +2 -2
  205. package/lib/sfPlugin.mjs +1 -1
  206. package/oclif.manifest.json +1 -1
  207. package/package.json +1 -1
  208. package/lib/chunk-26EGXYZ4.mjs +0 -21
  209. package/lib/chunk-2JRVBXJL.mjs +0 -7
  210. package/lib/chunk-2METQHGG.mjs +0 -7
  211. package/lib/chunk-3XU7CEJQ.mjs +0 -7
  212. package/lib/chunk-4BQPAVMP.mjs +0 -14
  213. package/lib/chunk-4KMKOE77.mjs +0 -156
  214. package/lib/chunk-4RPA7Z52.mjs +0 -7
  215. package/lib/chunk-5C7LQXYS.mjs +0 -7
  216. package/lib/chunk-5EESNYE3.mjs +0 -8
  217. package/lib/chunk-6ZW6BLV5.mjs +0 -7
  218. package/lib/chunk-AAOMUI7S.mjs +0 -15
  219. package/lib/chunk-AIUAEBHR.mjs +0 -7
  220. package/lib/chunk-BD724WOH.mjs +0 -7
  221. package/lib/chunk-CRPLDXJU.mjs +0 -48
  222. package/lib/chunk-CSSOLHE3.mjs +0 -7
  223. package/lib/chunk-D63HEQ3B.mjs +0 -7
  224. package/lib/chunk-DN7YBILC.mjs +0 -21
  225. package/lib/chunk-DNE7JI3A.mjs +0 -11
  226. package/lib/chunk-EFHM2U4D.mjs +0 -7
  227. package/lib/chunk-EINEGS6E.mjs +0 -7
  228. package/lib/chunk-EM5EFMHA.mjs +0 -272
  229. package/lib/chunk-FH5UR35W.mjs +0 -7
  230. package/lib/chunk-FN7TOBJR.mjs +0 -7
  231. package/lib/chunk-HGJFATSI.mjs +0 -10
  232. package/lib/chunk-HOEE3PE5.mjs +0 -7
  233. package/lib/chunk-HV63UGL5.mjs +0 -7
  234. package/lib/chunk-JKFCGYJE.mjs +0 -7
  235. package/lib/chunk-KATBU46O.mjs +0 -7
  236. package/lib/chunk-LD34JNCC.mjs +0 -7
  237. package/lib/chunk-LPN4WYTP.mjs +0 -478
  238. package/lib/chunk-MAOUFJ47.mjs +0 -7
  239. package/lib/chunk-MB2DG66I.mjs +0 -13
  240. package/lib/chunk-NCASRA7L.mjs +0 -9
  241. package/lib/chunk-NEKNAILD.mjs +0 -7
  242. package/lib/chunk-NN2IO4WE.mjs +0 -7
  243. package/lib/chunk-O3ZQSWDN.mjs +0 -10
  244. package/lib/chunk-OFQOKSEW.mjs +0 -7
  245. package/lib/chunk-PP7PJXRJ.mjs +0 -341
  246. package/lib/chunk-PT2E2HFD.mjs +0 -7
  247. package/lib/chunk-PZBZ7MNC.mjs +0 -7
  248. package/lib/chunk-QBYK5XIT.mjs +0 -8
  249. package/lib/chunk-RFD6NPWJ.mjs +0 -8
  250. package/lib/chunk-RIIJJRGF.mjs +0 -7
  251. package/lib/chunk-RKTFFCNS.mjs +0 -7
  252. package/lib/chunk-RM5G4IP6.mjs +0 -19
  253. package/lib/chunk-RTPNK7OB.mjs +0 -7
  254. package/lib/chunk-RZXEO5IE.mjs +0 -7
  255. package/lib/chunk-SAHGDSZQ.mjs +0 -37
  256. package/lib/chunk-SRPWW4A2.mjs +0 -10
  257. package/lib/chunk-SVNSAHG3.mjs +0 -7
  258. package/lib/chunk-T63U4OZJ.mjs +0 -7
  259. package/lib/chunk-TE2W76II.mjs +0 -10
  260. package/lib/chunk-TEIBWMJM.mjs +0 -7
  261. package/lib/chunk-TFGJDZFE.mjs +0 -7
  262. package/lib/chunk-TG52WNGV.mjs +0 -10
  263. package/lib/chunk-TQONVFI3.mjs +0 -7
  264. package/lib/chunk-TW3N6W5Z.mjs +0 -7
  265. package/lib/chunk-UZMLPKW6.mjs +0 -7
  266. package/lib/chunk-WB2RIVO3.mjs +0 -7
  267. package/lib/chunk-WQO7RXEB.mjs +0 -926
  268. package/lib/chunk-X3MBY2RX.mjs +0 -7
  269. package/lib/chunk-XMJRXXUN.mjs +0 -7
  270. package/lib/chunk-YNMU5I7P.mjs +0 -7
  271. package/lib/chunk-YSQJKIO6.mjs +0 -7
  272. package/lib/chunk-YVVPJRZC.mjs +0 -7
  273. package/lib/chunk-ZLQHBI6V.mjs +0 -9
  274. package/lib/chunk-ZRUDYB7O.mjs +0 -7
@@ -0,0 +1,476 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{b as bt}from"./chunk-SOOTWGMQ.mjs";import{c as mt,d as wt,s as gt,w as kt}from"./chunk-O6FHK6NQ.mjs";import{a as lt,b as z,c as ut,e as Z,g as ft,j as pt,l as be}from"./chunk-JFXQZPRY.mjs";import{f as ht}from"./chunk-BBZUGKBZ.mjs";import{a as ge,b as F,c as at,f as rt}from"./chunk-P4YOHLZ4.mjs";import{a as vt,b as At,d as ye,e as jt,f as $e,h as Rt,i as Ct,j as St,k as ve}from"./chunk-35IJ4WEU.mjs";import{q as yt}from"./chunk-VA6EEI6X.mjs";import{e as re}from"./chunk-UM2B4GR7.mjs";import{a as $t}from"./chunk-TLX45X5U.mjs";import{d as ke}from"./chunk-E5FSPXYH.mjs";import{c as X}from"./chunk-6FARZYMJ.mjs";import{kb as Qe}from"./chunk-CJAWKLAL.mjs";import{a as tt,n as nt,o as ot}from"./chunk-CL75DEMQ.mjs";import{b as ze,c as pe,d as Ke,f as se,h as Ve,k as Ye}from"./chunk-DDNCJVZ2.mjs";import{B as me,G}from"./chunk-3LRFPGYZ.mjs";import{I as it,L as st,e as J,i as we}from"./chunk-4CSBZZAL.mjs";import{a as ie,c as _e}from"./chunk-AL4C3GFT.mjs";import{a as Je}from"./chunk-WQCXOZEJ.mjs";import{r as He}from"./chunk-OT2NHL2V.mjs";import{Cc as dt,o as et,x as ae}from"./chunk-OLCS7JCT.mjs";import{b as Ge,f as B,h as ct}from"./chunk-LCDPCUXS.mjs";import{k as Ze}from"./chunk-DAUX63UB.mjs";import{da as Xe}from"./chunk-SZOJ7BEJ.mjs";import{A as ue,Ua as Ue,Ya as Me,ie as fe,le as qe,md as We}from"./chunk-J347SPU6.mjs";import{mkdtempSync as $n,readFileSync as vn,rmSync as An}from"node:fs";import{tmpdir as jn}from"node:os";import{join as Pt,resolve as Ae}from"node:path";var Rn=`sandforge checkpoint \u2014 take a checkpoint of an org's data, and rewind the org to it, without the editor.
8
+
9
+ Usage:
10
+ npx sandforge checkpoint <command> --org <alias> [options]
11
+
12
+ Commands:
13
+ take read the org's records and keep them as a checkpoint on this machine
14
+ list name the checkpoints kept, newest first, with what a rewind and an undo can still reach
15
+ preview say what a rewind would delete, give back and bring back, who last changed it, and what
16
+ it and an undo cannot take back; writes nothing
17
+ rewind return the org to a checkpoint: bring back from the recycle bin the records deleted
18
+ since, give the records changed since their values back, delete the records created
19
+ since, and put the files attached to its records back as they were \u2014 whoever made the
20
+ changes; keep what it changes so it can be undone; then read the org again
21
+ undo take back the org's last rewind: bring back what it deleted, give back what it wrote
22
+ over, send back to the bin what it brought back; what anyone changed since the rewind
23
+ stays, and is said
24
+ delete delete a checkpoint from this machine; the org is not touched
25
+ export write a checkpoint to a .sfcheckpoint file, encrypted, for a teammate who rewinds the
26
+ same org from another machine; the org is not contacted
27
+ import keep a .sfcheckpoint file a teammate exported as a checkpoint of the org on this
28
+ machine, once the org answers that it is the file's, and its user sees all data
29
+ replay set a checkpoint's records up again in another org, with new Ids \u2014 the sandbox its
30
+ org became once refreshed, another sandbox, a scratch org \u2014, its own org never
31
+ reached: its dry run first, then a question; nothing the other org holds is changed
32
+ or deleted, and --remove takes it back
33
+ replays name the replays kept on this machine, and what each left in its org; no org is
34
+ contacted
35
+
36
+ Required:
37
+ --org <alias> sf CLI alias of the org (list: every org of the store without it;
38
+ replay names --target instead)
39
+
40
+ take:
41
+ --name <text> what it is called (default: the date and time)
42
+ --object <ApiName> an object to keep; repeat for more (default: every object people
43
+ work in, empty ones included, setup and log objects left out)
44
+ --exclude-object <ApiName> leave an object out; repeat for more
45
+ --custom-setting <ApiName|all> keep a custom setting, or all of them, which a checkpoint leaves
46
+ out unless named: a rewind sets their rows back, an integration's
47
+ endpoint or an admin's switch among them; repeat for more; needs
48
+ Customize Application
49
+ --ignore-field <Object.Field> do not compare a field, nor write it back (one your automation sets
50
+ on every save); repeat for more
51
+ --max-total <n> refuse, before reading, more than <n> records (default: ${ge},
52
+ ${F} at most)
53
+ --keep-days <n> when it expires (default: ${J}; 0 keeps it until deleted)
54
+ --estimate say the records, API requests, time and disk it would take, then stop
55
+ preview, rewind, undo, delete, export:
56
+ --checkpoint <id|name|latest> which one (default: latest, for undo the one the last rewind went
57
+ back to; rewind and undo with --yes need it named, by id or name)
58
+ preview, rewind:
59
+ --object <ApiName> limit the rewind to an object of the checkpoint; repeat for more
60
+ (default: every object). It writes the others only to delete again
61
+ the records made since that come back with a record it brings
62
+ back, and never adds what the objects named depend on: what it
63
+ leaves of them for that is said, with the --object to add
64
+ preview:
65
+ --fail-on-change exit 3 when the org differs from the checkpoint
66
+ rewind:
67
+ --dry-run the preview, then stop
68
+ --accept-automation rewind even when the org runs flows, Apex triggers, processes or
69
+ workflow rules as records are updated, deleted or brought back;
70
+ without it such a rewind writes nothing, exit 1
71
+ --accept-emails rewind even when the org delivers every email its automation
72
+ sends (Setup > Deliverability: All email), or would not say
73
+ whether it does, and what still runs as it writes sends some:
74
+ they go to the addresses the records and the alerts name, and to
75
+ the records' owners. Without it such a rewind writes nothing,
76
+ exit 1. --accept-automation never stands for it. Read with one
77
+ line of anonymous Apex that sends nothing, only when something
78
+ that still runs sends an email; what Apex triggers send is not
79
+ read
80
+ --mute-automation mute the org's automation for the rewind through its own bypass:
81
+ assign the user it writes as, for the rewind alone, the permission
82
+ sets holding the custom permissions its flows, processes and
83
+ workflow rules test to stay quiet, and take them back as it ends;
84
+ what no bypass keeps quiet still runs, and still needs
85
+ --accept-automation. Refused on a production org and for a user
86
+ who cannot assign permission sets, exit 1; with --dry-run, says
87
+ what would be muted, or why it would be refused, and assigns
88
+ nothing
89
+ --accept-no-undo rewind even when undo could not bring back some records it deletes
90
+ (objects Salesforce undeletes only with their parent, such as
91
+ OpportunityLineItem); without it such a rewind writes nothing, exit 1
92
+ --accept-recreate make again, with new Ids, the records deleted since that the
93
+ recycle bin no longer gives back: what outside Salesforce names
94
+ their old Ids no longer finds them; without it a rewind that
95
+ counts such records writes nothing, exit 1, and one Salesforce
96
+ answers is no longer in the bin as it brings it back is left,
97
+ named
98
+ --accept-outside (a checkpoint of picked objects) also delete the records outside it
99
+ created under records it deletes, and the files it deletes that are
100
+ attached outside it too; without it those parents stay, and those
101
+ files are only removed from its records
102
+ --accept-unseen (a user without View All Data and Modify All Data) delete records
103
+ whose delete takes along records of objects the user is not
104
+ proven to see whole \u2014 tasks and events always: the preview names
105
+ those objects, and no count holds what goes with them; without it
106
+ such a rewind writes nothing, exit 1
107
+ --max-records <n> refuse, before it writes, a rewind that would delete, give back,
108
+ bring back and make again more than <n> records together, exit 1:
109
+ with --yes in a cron job or a CI step, what stands in for reading
110
+ the preview
111
+ --refuse-when-active refuse, before it writes, a rewind of an org where anyone but the
112
+ user it writes as and the org's Automated Process changed records
113
+ of the checkpoint's objects in the hour before it read the org,
114
+ whose work it would take back, exit 1; the refusal says how many
115
+ people. Where people sign in as the user SandForge connects as,
116
+ their changes are that user's, and are not told apart
117
+ --ignore-field <Object.Field> stop comparing a field from now on; kept in the checkpoint
118
+ --yes do not ask before writing; without it and with no terminal \u2014 a CI
119
+ step \u2014 it stops at its question, exit 2, having written nothing
120
+ undo:
121
+ --accept-automation as for rewind
122
+ --accept-emails as for rewind
123
+ --mute-automation as for rewind
124
+ --yes as for rewind
125
+ delete:
126
+ --all every checkpoint of the org
127
+ --yes do not ask
128
+ export:
129
+ --out <file> the file to write; refused when one is there already
130
+ --key-env <VAR> encrypt under the key this environment variable holds, one an
131
+ export showed (a CI step's secret); without it a new key is
132
+ drawn and shown once, on stderr
133
+ import:
134
+ --file <file> the .sfcheckpoint file
135
+ --key-env <VAR> read the key from this environment variable; without it the key
136
+ is asked on the terminal, not echoed, and with no terminal it
137
+ stops, exit 2, having imported nothing
138
+ --keep-days <n> when it expires on this machine (default: ${J}; 0 keeps it until
139
+ deleted)
140
+ replay:
141
+ --checkpoint <id|name|latest> which one: by its id, wherever it is kept (list names it); by its
142
+ name, or latest, with --from
143
+ --from <alias|username|00D\u2026> the org it was taken of, as list names it; refreshed or expired
144
+ since, it is not reached
145
+ --file <file> a .sfcheckpoint file a teammate sent, in place of --checkpoint:
146
+ replayed without its org, the key standing for the teammate's
147
+ consent; its checkpoint is kept on this machine apart from those
148
+ it rewinds. A file of a Partial Copy, a Full or a Staging sandbox
149
+ is refused unmasked before its key is read
150
+ --key-env <VAR> with --file: the environment variable that holds its key; without
151
+ it the key is asked on the terminal, not echoed, and with no
152
+ terminal it stops, exit 2
153
+ --keep-days <n> with --file: when its checkpoint expires here (default: ${J}; 0 keeps
154
+ it until deleted)
155
+ --target <alias> the org the records go into: a sandbox, a scratch org or a
156
+ Developer Edition org; never a production org nor the
157
+ checkpoint's own org, which rewind brings back. The Staging mark
158
+ the editor gives a sandbox is not seen here
159
+ --dry-run say what it would create, link, leave and refuse, and write
160
+ nothing
161
+ --objects <A,B> replay these objects alone (default: every object it holds);
162
+ separate with commas, or repeat
163
+ --exclude-object <ApiName> leave an object out; repeat for more
164
+ --owners same|me same (default): a record keeps its owner where the other org has
165
+ that user active \u2014 by its Id, or by its username without a
166
+ sandbox's suffix \u2014, and goes to the user who replays otherwise;
167
+ me: every record to the user who replays
168
+ --owner-map <file.json> {"<user Id there>": "<user Id here>"}: who owns the records of
169
+ each user of the checkpoint's org, an active user of the other org
170
+ --link <Object=Field[,Field]> link to the records of an object the other org holds with the
171
+ same values of these fields, rather than create them; repeat
172
+ --custom-settings set up the custom settings the checkpoint holds too; a row the
173
+ other org has already is kept, never written over
174
+ --mask mask personal data, as Forge's anonymization does; required of a
175
+ checkpoint of a Partial Copy, a Full or a Staging sandbox, told by
176
+ its data storage and its mark; the free text it does not read is
177
+ named
178
+ --no-real-data declare that a sandbox's checkpoint taken before SandForge 1.81,
179
+ which does not say which sandbox, holds no real data: replayed
180
+ unmasked, the declaration kept in the audit trail
181
+ --keep-contact-points keep emails and phone numbers as they are (default: made
182
+ unreachable, addresses in .invalid and numbers that ring nobody)
183
+ --replay-config <file.json> the load's part of a Frozen project's configuration: required field
184
+ defaults, lookup placeholders, picklist rules, identity keys, \u2026
185
+ --again replay over what the replays before created there, which goes
186
+ first; what they linked stays
187
+ --max-records <n> the most records it may create (default: the count of the dry run
188
+ it reads first)
189
+ --mute-automation mute what the other org runs as the replay writes, or as --remove
190
+ deletes, through its own bypass, for that run alone, as a Frozen
191
+ load does; what no bypass keeps quiet still needs
192
+ --accept-automation
193
+ --accept-automation write, or delete, although the other org runs flows, Apex
194
+ triggers, processes or workflow rules as it does: named first,
195
+ and without it such a replay writes nothing, exit 1
196
+ --accept-emails write although the other org delivers the emails what still runs
197
+ sends, or would not say: without it such a replay writes nothing,
198
+ exit 1
199
+ --checkpoint-first take a checkpoint of what the replay writes in the other org
200
+ before its first write: a rewind to it takes the replay back, and
201
+ the work of anyone else on those objects since
202
+ --checkpoint-keep-days <n> the days that checkpoint is kept on this machine (default: 7)
203
+ --checkpoint-exclude-object <ApiName>
204
+ leave an object out of that checkpoint; repeat for more
205
+ --yes do not ask before it writes, nor before --remove deletes; without
206
+ it and with no terminal, it stops at its question, exit 2
207
+ --verify verify the last replay into the other org: what it created there,
208
+ counted against what it said it created
209
+ --remove delete from the other org what the replays created there, children
210
+ first, the checkpoint kept or not; --preview says what it would
211
+ delete; --sweep takes too what the other org's automation made for
212
+ them, and --sweep-list lists it and deletes nothing;
213
+ --include-changed takes too what was changed since
214
+ --sweep-late with --sweep: take too what it lists as made late; with
215
+ --sweep-list, say what it would take
216
+ --sweep-untied with --sweep: take too what it lists as tied to nothing of the
217
+ replay, refused when another run of this machine wrote to the
218
+ other org meanwhile; with --sweep-list, say what it would take
219
+ replays:
220
+ --target <alias|00D\u2026> the replays into this org alone
221
+ Options:
222
+ --store <dir> where checkpoints live (default: ~/.sandforge/checkpoints, or
223
+ checkpoints/ in the folder SANDFORGE_JOURNAL_DIR names); the
224
+ replays of its checkpoints are kept in it too, in .replays
225
+ --json the answer alone on stdout, every other line on stderr
226
+ --help this text
227
+
228
+ A production org is refused before anything is read or written, exit 1. No flag lifts it.
229
+ With View All Data and Modify All Data, the user the alias connects as sees every record and
230
+ rewinds whoever changed it; import needs both. Without them, take holds only the objects the
231
+ user has View All and Modify All on, or, for an object with no permissions of its own, on every
232
+ record it hangs from \u2014 never tasks and events, products and price books, files or custom
233
+ settings \u2014 and preview, rewind and undo read those permissions again: an object no longer held
234
+ is not read, and is left as it is; what another user deleted since stays in the recycle bin,
235
+ named; undo takes back the user's own rewind alone. A checkpoint that keeps custom settings
236
+ needs Customize Application too: View All Custom Settings reads them, never writes them.
237
+ A checkpoint holds the records' values as the org held them, personal data among them,
238
+ unencrypted, in files only you can read; on Windows, which keeps no such modes, as private as
239
+ their folder: your user profile for the default store, the folder itself for a --store or a
240
+ SANDFORGE_JOURNAL_DIR outside it. Expired checkpoints are deleted as any command starts,
241
+ each named.
242
+ list and delete read this machine alone and never contact the org. An org's checkpoints are the
243
+ ones taken under its alias or username, and the others kept of the same Organization Id.
244
+ export never writes a checkpoint unencrypted: AES-256-GCM, under a key of 52 letters and digits
245
+ shown once and kept nowhere. Anyone who has the file and its key reads every record it holds:
246
+ send the key another way than the file, and only to people who already see all data in the org.
247
+ The file does not expire: delete it once it has served. It carries neither the journals of
248
+ rewinds nor their undo, which stay on this machine.
249
+ import reads the file's header, then asks the org: another org, a production org, a user without
250
+ View All Data and Modify All Data, a file a newer SandForge made, are each refused before the key
251
+ is asked. A wrong key, or a file changed since it was exported, is refused before anything is
252
+ kept. A checkpoint kept already the same is left as it is, exit 0; another of its id is refused.
253
+ The lock against two rewinds at once is per machine: agree on who rewinds the org.
254
+ replay never reaches the checkpoint's own org. It reads the other org, then creates copies of
255
+ the checkpoint's records there, parents first, with new Ids, and changes or deletes nothing that
256
+ org holds. A checkpoint keeps no file's content: files, attachments and documents are never
257
+ replayed, each named. Owners, record types, currencies, person accounts and the standard price
258
+ book are read from the other org, and every record that does not go across as it was is said,
259
+ with why: a checkpoint taken before SandForge 1.81 keeps no record types, users or price book,
260
+ and its records get the other org's. Its created and modified dates and users are the replay's.
261
+ A replay runs its dry run first, asks, then creates no more than that dry run counted. What it
262
+ wrote is kept on this machine apart from the checkpoint (replays/ beside checkpoints/, or .replays
263
+ in the folder --store names), and --remove takes it back once the checkpoint is deleted. A
264
+ checkpoint of a Partial Copy, a Full or a Staging sandbox replays masked only, but into that
265
+ sandbox refreshed; delete names the replays a checkpoint leaves in place.
266
+ rewind shows its preview and asks you to type the org's alias exactly as --org gives it before it
267
+ writes, then rewinds from that preview as it read the org: a record someone changes after it read
268
+ is left as they made it, and said. undo says what it takes back and asks the same before it
269
+ writes. A take, a rewind or an undo of the org under way on this machine, in the editor or in
270
+ another command line, refuses a rewind and an undo; other runs writing to the org are not seen
271
+ here, and what one of them changes after the preview read the org is left and said the same way.
272
+ Ctrl-C stops a take between two reads, and nothing of it is kept; a second Ctrl-C ends it at once,
273
+ and leaves a checkpoint listed as never taken, which delete removes. Ctrl-C stops a rewind or an
274
+ undo before its next call to the org, and leaves its journal: rewind again takes up from what still
275
+ differs, and undo still returns the org to how it was before the rewind. A rewind stopped before
276
+ it sent anything leaves none, and the undo of the rewind before it stays offered.
277
+
278
+ A record deleted since that the recycle bin no longer gives back is made again from the
279
+ checkpoint, with a new Id, once --accept-recreate says so: the lookups the checkpoint holds that
280
+ named it name the new Id, and undo deletes it again. Salesforce still lists a record emptied from
281
+ the bin as deleted, for minutes to hours, and says the bin no longer holds it only as the rewind
282
+ asks it back: such a record, with what was to come back with it, is made again then, or left
283
+ and named without --accept-recreate.
284
+ A record the checkpoint does not hold that took records of it along when it was deleted since is
285
+ brought back for a moment with them, then deleted again with what came back with it.
286
+ A custom setting is kept only when --custom-setting names it. A rewind brings a row of one back
287
+ only once no other row holds its owner (a hierarchy: the org's default, a profile, a user) or
288
+ its name (a list): it deletes the row made since first, then brings the row back with its Id.
289
+ A checkpoint holds the files attached to its records, Salesforce Files and classic attachments:
290
+ which records each is attached to, its latest version and its size, never its content. A rewind
291
+ deletes the files attached to them since, brings back those deleted since with their links,
292
+ removes the links added since and puts back those removed since, under new Ids; a file
293
+ attached to no record of the checkpoint, a user's own or a library's, is left and counted.
294
+ Bringing files back from the recycle bin takes file storage again: a rewind or an undo that would
295
+ take more than the org has left is refused before it writes. Without Query All Files, other
296
+ users' files that no record of the checkpoint is attached to are not seen.
297
+ What a rewind cannot undo: a file deleted since and no longer in the recycle bin, whose body the
298
+ checkpoint does not hold, a file given a new version since, which keeps it, a lead converted
299
+ since, a contract activated since, a record deleted with a parent created since that Salesforce
300
+ does not undelete on its own, or with its parent of an object the checkpoint does not hold
301
+ (preview counts them); without View All Data and Modify All Data, a record another user deleted
302
+ since, and a record of an object held through what it hangs from that the recycle bin does not
303
+ show the user (preview counts them too); a field added since, deleted since, or hidden since from
304
+ the user by field-level security, which the preview tells apart and names in an object something
305
+ changed in since \u2014 in an object nothing changed in, which a rewind writes nothing to, the fields
306
+ are not checked, and the preview counts those objects; the values the org computes or keeps
307
+ itself (formulas, roll-ups, auto-numbers, created and modified dates); what left the org
308
+ (emails, callouts, outbound messages, platform events); metadata; the files of a checkpoint taken
309
+ before SandForge 1.70, which holds none. A record the org refuses to put back, or to make again,
310
+ is named by rewind, with its words.
311
+
312
+ JSON (--json), one value on stdout:
313
+ list [{id, name, org, organizationId, takenAt, records, bytes, expiresAt,
314
+ expiresSoon, binReachSince, lastRewind?, valid, why?, refreshedAt?,
315
+ replayWith?}]
316
+ (name, org, takenAt, records and bytes are null for a damaged checkpoint;
317
+ expiresAt is null for one kept until deleted; replayWith, of one that no
318
+ longer rewinds its org, the dry run of its replay)
319
+ take {checkpoint, requests?, estimate}: the checkpoint as kept (its
320
+ checkpoint.json; files?, {documents, links, anchored, readByIds?}, for one
321
+ that holds files); requests, {total, byPhase}, the API requests the take sent
322
+ the org, SOAP calls among them; estimate, what it said before reading a record
323
+ take --estimate {mode, objects, leftOut, estimate, refusal?, files?, customSettings?}:
324
+ estimate.requestsByPhase splits the requests over a take's phases as
325
+ requests.byPhase does: guard, scope, start, counts, bin, snapshot, stability;
326
+ files, {held, queryAllFiles, addedToPicked}; customSettings, every custom
327
+ setting of the org, kept or not, [{objectApiName, label, kind?, records?}],
328
+ kind hierarchy or list, and objects[].customSetting for one kept; {mode,
329
+ refusal} for a take refused before its scope is read (a production org, a
330
+ user without the permissions)
331
+ preview {checkpoint: {id, name, takenAt, org}, toDelete, toGiveBack, toBringBack,
332
+ toRecreate, carriers, differs, diff, estimate, automation?, emails?,
333
+ emailsUncounted?, deliverability?, refusal?}: carriers, the records
334
+ brought back for a moment and deleted again, in none of the other numbers;
335
+ diff, estimate
336
+ and automation as the extension answers them; refusal, the first a rewind
337
+ given no flag would meet now, of those its lines name with what lifts
338
+ each, as rewind --dry-run lists them: the extension's own (the org's lock,
339
+ a run writing, the day's API requests or emails, file storage), then an
340
+ acceptance it needs (NO_UNDO, RECREATE, UNSEEN, AUTOMATION,
341
+ EMAILS_DELIVERED, in that order); emails, one per daily limit its writes send
342
+ against: {limit, emails, verdict, remaining?, max?, alertsCounted?,
343
+ objects: [{objectApiName, write, records, perRecord, sentBy}]};
344
+ emailsUncounted, what sends emails as it writes that could not be read \u2014 a
345
+ flow whose definition was refused, a package's, which no user reads \u2014 its
346
+ emails not counted, which --accept-automation covers; deliverability,
347
+ when something that still runs may send an email: {reading: {level: all
348
+ or withheld} or {unread}, senders: [{objectApiName, kind, name, why}]},
349
+ which --accept-emails answers for all and unread;
350
+ diff.objects[].schemaDrift, of an object whose fields changed since:
351
+ {removed, added, changed, hidden?, uncertain?: {fields, reason?}}, removed
352
+ the custom fields deleted since, hidden those field-level security hides
353
+ from the user, uncertain those the org would not say which of;
354
+ diff.described, {first, later}, the objects it described again, asked
355
+ whether their fields changed since the take: first those something moved
356
+ in, later those nothing moved in that hold fewer records than the
357
+ checkpoint; diff.fieldsNotChecked, the objects nothing changed in whose
358
+ fields it did not describe: a rewind writes nothing there, and a field
359
+ deleted or hidden since in one of them is not known; diff.files,
360
+ for a checkpoint that holds files: {unlink, relink, updateLinks,
361
+ outsideAdded, outsideDeleted, storage: {bringBack, remaining?, undo},
362
+ blindSpot?}, the links to remove, put back and give their sharing back, the
363
+ files left, and file storage in bytes; diff.access, {kind, requests?}, org
364
+ for a user with View All Data and Modify All Data, perObject for one read
365
+ object by object, with the API requests that read; diff.unseen, read
366
+ object by object: [{objectApiName, children, records}], of the records to
367
+ delete of an object, the objects whose records their delete takes along
368
+ out of the user's sight; with --object, objects, the objects named, and
369
+ selection, {objects, acts: [{objectApiName, picked, toDelete, withParent?,
370
+ toGiveBack, toBringBack, toRecreate}], left: [{objectApiName, reason,
371
+ count}], needs: [{objectApiName, records}], undoCannot}, what a rewind of
372
+ them alone would do and leave \u2014 withParent, of toDelete, the records that go
373
+ with a record it deletes, of an object named or not; reason
374
+ needsUnpickedParent, heldByUnpicked, outsideNotAccepted, holdsLeft,
375
+ contactKept or keyTaken \u2014 and the objects to add; the numbers, differs and
376
+ estimate are then the rewind's of those objects, diff the whole diff; of a
377
+ checkpoint of picked objects whose records outside it were made since under
378
+ records a rewind would delete, kept: [{objectApiName, reason, count}], what
379
+ a rewind without --accept-outside keeps for them \u2014 reason
380
+ outsideNotAccepted, holdsLeft or contactKept \u2014, the numbers then those of
381
+ what it writes, differs the whole diff's (preview previews that rewind)
382
+ rewind --dry-run as preview, with wouldBeRefused: ["refused (CODE): message"] and
383
+ wouldBeRefusedCodes: ["CODE"], one for each refusal a rewind with these
384
+ flags would meet, in order; asked to mute, emails and deliverability are
385
+ of what still runs, with mutedAutomation and mutePlan
386
+ rewind {checkpoint: {id, name, takenAt, org}, rewindId, status, deleted, givenBack,
387
+ broughtBack, recreated (each {planned, done, left}), cannotUndo: [{object,
388
+ reason, count}], carriers?: [{object, count}], draftsLeft?: [{object,
389
+ count, ids}], undo?: {until, cannot: [{object, count, reason?}]}, verify:
390
+ {differences, stable, passes, notCompared}, residual: [{object, reason,
391
+ by?, count, message?}], unread: [{object, reason}], objects: [{object,
392
+ deleted, givenBack, broughtBack, refused}], apiRequests: {used,
393
+ leftToday}, result}:
394
+ status success, partial, unstable, failure or cancelled; result as the
395
+ extension answers it; undo.cannot's reason deletedBeforeParent: deleted
396
+ before a record they point at, which the rewind deleted next; carriers, of
397
+ what it brought back and deleted, the records brought back for a moment;
398
+ draftsLeft, of a rewind stopped part way, the orders and contracts it made
399
+ again as drafts and had not given their status back yet, by their new Ids;
400
+ files?: {unlinked, relinked, linksUpdated, linksRefused}, the links between
401
+ files and records it wrote, when it wrote one; with --object, limitedTo,
402
+ the objects named, and notRewound, {objects, records}, the objects not
403
+ named that still differ and their records that do, which the status
404
+ does not count
405
+ undo as rewind, without recreated, cannotUndo, carriers, draftsLeft and undo,
406
+ with carriedAlone?: [{object, count}], the records sent back to the
407
+ recycle bin on their own that had gone there with a record the rewind
408
+ brought back for a moment
409
+ delete {deleted: [id], kept: [id], replaysInPlace?}: replaysInPlace, as replays
410
+ lists them, those of the checkpoints deleted that left records in their org
411
+ replay {command, action, dryRun, checkpoint: {id, name, organizationId, takenAt,
412
+ tier, annex}, target: {alias, organizationId}, choices?, file?, plan?,
413
+ replay?: {records, owners, recordTypes, notReplayed, filesLeft,
414
+ lookupsEmptied, refused, fieldsNotInTarget, customSettings?, currencies,
415
+ standardPricebook?, masked, contactPoints, archivedActivities?,
416
+ degraded, auditDates, storage?, requests}, result?, removal?, objects?,
417
+ status?, verdict?, mapping?, refusals?, refusalCodes?, refused?,
418
+ mutedAutomation?, mutePlan?, checkpointFirst?, removeWith, ended?, exit}:
419
+ plan, result and removal as a Frozen load and its removal answer them;
420
+ objects, status, verdict and refusals as a Frozen step gives them
421
+ replays [{checkpointId, checkpointName?, sourceOrganizationId, takenAt?, target:
422
+ {organizationId, name?}, choices?, replayedAt?, inPlace, inPlaceByObject,
423
+ removed?, removeWith}]
424
+ export {checkpoint: {id, name, takenAt, org}, file, bytes, sha256, records, objects,
425
+ keyShown}: keyShown, whether a new key was drawn and shown on stderr; never
426
+ the key itself
427
+ import {outcome, checkpoint: {id, name, takenAt, org}, records, objects, expiresAt,
428
+ warnings}: outcome imported, or alreadyKept for the same checkpoint kept here
429
+ already
430
+ refused or failed {refusal: {code, message}}; a rewind or an undo refused before it wrote
431
+ for more than one reason adds wouldBeRefused and wouldBeRefusedCodes, as
432
+ rewind --dry-run gives them: every refusal, the first among them, each other
433
+ also on a line of its own, refused (CODE): message
434
+ A bad command line (exit 2) prints nothing on stdout.
435
+
436
+ replay ends as a Frozen load ends: 0 its dry run said, or the replay done and verified; 1 refused
437
+ before it wrote (REPLAY_SAME_ORG, REPLAY_REAL_DATA, REPLAY_COPY_UNKNOWN, REPLAY_TOO_MANY,
438
+ REPLAY_NOTHING, a target refused, what it runs or sends unanswered) or failed; 2 a bad line or a
439
+ question with no terminal; 3 done with records refused or left, or its verification PARTIAL.
440
+ Exit codes: 0 done (take: every record of its objects is kept; rewind and undo: read again, the
441
+ org matches among the objects and fields compared \u2014 with --object, among the objects named,
442
+ whatever still differs in the others; preview, rewind --dry-run and list answered;
443
+ delete: every checkpoint named is deleted; export: the file is written; import: the checkpoint is
444
+ kept, or was already); 1 refused before it read or wrote (a production org,
445
+ missing permissions, automation without --accept-automation, emails the org delivers or would not
446
+ say it withholds without --accept-emails (refusal code EMAILS_DELIVERED), deletions undo could not
447
+ bring back without --accept-no-undo, records to make again with new Ids without --accept-recreate,
448
+ deletions taking along records the user is not proven to see without --accept-unseen, more than
449
+ --max-total records, more records to rewind than --max-records, people working in the org in the
450
+ hour before with --refuse-when-active, more API requests or emails than the org
451
+ has left today, files to bring back taking more file storage than it has left, a checkpoint of
452
+ the org before a refresh or of an expired scratch org, a SandForge run writing to it; an import
453
+ of another org's file, with the wrong key, of a file changed since its export), or nothing
454
+ done; 2 a bad command line, a --checkpoint name several checkpoints
455
+ have, an --object the checkpoint does not hold,
456
+ rewind or undo with --yes and no checkpoint named, or a question with no terminal (give
457
+ --yes; import's key: --key-env); 3 partial (rewind and undo: records still differ, each said
458
+ with why; with
459
+ --fail-on-change, the org differs: records to delete, give back, bring back or make again,
460
+ links between files and records to remove, put back or give their sharing back, records the
461
+ rewind cannot take back or the checkpoint does not hold although they are dated before it, files
462
+ added or deleted since that no record of it is attached to, a field it compares deleted or
463
+ hidden since in an object something moved in, an object that could not be read; delete: some
464
+ were kept, each said with why); 4 unstable (someone else changed
465
+ records during the rewind or the undo: left as they made them); 130, 143, 129 Ctrl-C, SIGTERM or
466
+ SIGHUP stopped it \u2014 run rewind again: it takes up from what still differs, and undo still reaches
467
+ the state before it.
468
+ `,Cn=["take","list","preview","rewind","undo","delete","export","import","replay","replays"],Sn=e=>Cn.includes(e),N={switches:["--json"],values:["--org","--store"]},On={take:{words:1,switches:[...N.switches,"--estimate"],values:[...N.values,"--name","--object","--exclude-object","--custom-setting","--ignore-field","--max-total","--keep-days"]},list:{words:1,...N},preview:{words:1,switches:[...N.switches,"--fail-on-change"],values:[...N.values,"--checkpoint","--object"]},rewind:{words:1,switches:[...N.switches,"--dry-run","--accept-automation","--accept-emails","--mute-automation","--accept-no-undo","--accept-recreate","--accept-outside","--accept-unseen","--refuse-when-active","--yes"],values:[...N.values,"--checkpoint","--ignore-field","--object","--max-records"]},undo:{words:1,switches:[...N.switches,"--accept-automation","--accept-emails","--mute-automation","--yes"],values:[...N.values,"--checkpoint"]},delete:{words:1,switches:[...N.switches,"--all","--yes"],values:[...N.values,"--checkpoint"]},export:{words:1,switches:N.switches,values:[...N.values,"--checkpoint","--out","--key-env"]},import:{words:1,switches:N.switches,values:[...N.values,"--file","--key-env","--keep-days"]},replay:{words:1,switches:["--json","--dry-run","--verify","--remove","--preview","--sweep","--sweep-list","--sweep-late","--sweep-untied","--include-changed","--custom-settings","--mask","--keep-contact-points","--no-real-data","--again","--mute-automation","--accept-automation","--accept-emails","--yes",...ke.switches],values:["--store","--checkpoint","--from","--file","--key-env","--keep-days","--target","--objects","--exclude-object","--owners","--owner-map","--link","--replay-config","--max-records",...ke.values]},replays:{words:1,switches:["--json"],values:["--store","--target"]}},xn={name:"--name",objects:"--object",excluded:"--exclude-object",customSettings:"--custom-setting",ignoredFields:"--ignore-field",maxTotal:"--max-total",keepDays:"--keep-days"},Nn=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function x(e){process.stderr.write(`${e}
469
+ `),process.exit(2)}function En(e){let n=e.toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function In(e,n=new Date){let t=e.slice(2);(t.includes("--help")||t.includes("-h"))&&(process.stdout.write(Rn),process.exit(0));let o=t[0];if(o===void 0||o.startsWith("-"))return x("Name the command first: take, list, preview, rewind, undo, delete, export, import, replay or replays. Run with --help.");if(!Sn(o))return x(`"${o}" is not a command of sandforge checkpoint: take, list, preview, rewind, undo, delete, export, import, replay or replays. Nothing was run. Run with --help.`);Ge(t,On[o]);let i=g=>{let c=[];for(let l=1;l<t.length;l++){if(t[l]!==g)continue;let k=t[l+1];if(k===void 0||k.startsWith("--"))return x(`${g} wants a value.`);c.push(k),l++}return c},a=g=>{let c=i(g);return c.length>1&&x(`${g} is given ${c.length} times: give it once.`),c[0]},r=g=>{let c=a(g);if(c!==void 0)return/^\d{1,15}$/.test(c)||x(`${g} takes a whole number, not "${c}".`),Number(c)},d=a("--store"),s={storeRoot:d!==void 0?Ae(d):we(),...d!==void 0?{storeNamed:!0}:{},json:t.includes("--json")},u=a("--org"),m=()=>u??x(`${o} needs --org. Run with --help.`),w=g=>{t.includes("--yes")&&(g===void 0&&x(`${o} --yes needs --checkpoint <id|name>: one that does not ask is told which checkpoint it acts on. Nothing was run.`),g==="latest"&&x(`${o} --yes needs the checkpoint named by its id or its name, not latest: a checkpoint taken since would be the one it acts on. Nothing was run.`))},j=()=>{let g=i("--object"),c=g.find(l=>!Nn.test(l));return c!==void 0&&x(`--object takes an object's API name, not "${c}".`),g.filter((l,k)=>g.findIndex(A=>A.toLowerCase()===l.toLowerCase())===k)};switch(o){case"list":return{...s,command:o,...u!==void 0?{org:u}:{}};case"replay":return{...s,command:o,replay:vt(t,x)};case"replays":return{...s,command:o,...At(t,x)};case"take":{let g=m(),c=i("--object"),l=i("--exclude-object"),k=i("--custom-setting"),A=k.includes("all")?"all":k,b=i("--ignore-field"),$=r("--max-total"),f={name:a("--name")??En(n),mode:c.length>0?"picked":"everything",...c.length>0?{objects:c}:{},...l.length>0?{excluded:l}:{},...A.length>0?{customSettings:A}:{},...b.length>0?{ignoredFields:b}:{},...$!==void 0?{maxTotal:$}:{},keepDays:r("--keep-days")??J},p=Qe.safeParse({...f,orgId:"command-line"});if(!p.success){let R=p.error.issues[0],O=String(R?.path[0]??"");return x(`${xn[O]??O}: ${R?.message??"not read"}. Nothing was run.`)}return{...s,command:o,org:g,take:{...f,name:p.data.name},estimate:t.includes("--estimate")}}case"preview":return{...s,command:o,org:m(),checkpoint:a("--checkpoint")??"latest",failOnChange:t.includes("--fail-on-change"),objects:j()};case"rewind":{let g=m(),c=a("--checkpoint");w(c);let l=i("--ignore-field"),k=Me.safeParse(l);if(!k.success)return x(`--ignore-field: ${k.error.issues[0]?.message??"not read"}. Nothing was run.`);let A=r("--max-records");return A===0&&x('--max-records takes a whole number of 1 or more, not "0". Nothing was run.'),{...s,command:o,org:g,checkpoint:c??"latest",objects:j(),dryRun:t.includes("--dry-run"),acceptAutomation:t.includes("--accept-automation"),acceptEmails:t.includes("--accept-emails"),muteAutomation:t.includes("--mute-automation"),acceptNoUndo:t.includes("--accept-no-undo"),acceptRecreate:t.includes("--accept-recreate"),acceptOutside:t.includes("--accept-outside"),acceptUnseen:t.includes("--accept-unseen"),...A!==void 0?{maxRecords:A}:{},refuseWhenActive:t.includes("--refuse-when-active"),ignoreFields:l,yes:t.includes("--yes")}}case"undo":{let g=m(),c=a("--checkpoint");return w(c),{...s,command:o,org:g,...c!==void 0?{checkpoint:c}:{},acceptAutomation:t.includes("--accept-automation"),acceptEmails:t.includes("--accept-emails"),muteAutomation:t.includes("--mute-automation"),yes:t.includes("--yes")}}case"delete":{let g=m(),c=a("--checkpoint"),l=t.includes("--all");return l&&c!==void 0&&x("Give --checkpoint or --all, not both."),{...s,command:o,org:g,...l?{}:{checkpoint:c??"latest"},all:l,yes:t.includes("--yes")}}case"export":{let g=m(),c=a("--out")??x("export needs --out <file>. Run with --help."),l=Ot(a("--key-env"));return{...s,command:o,org:g,checkpoint:a("--checkpoint")??"latest",out:Ae(c),...l!==void 0?{keyEnv:l}:{}}}case"import":{let g=m(),c=a("--file")??x("import needs --file <file>. Run with --help."),l=Ot(a("--key-env"));return{...s,command:o,org:g,file:Ae(c),...l!==void 0?{keyEnv:l}:{},keepDays:r("--keep-days")??J}}}}function Ot(e){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||re(e)!==void 0?x("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}function Lt(e,n){return e!==void 0&&n!==void 0&&e.length>=15&&e.slice(0,15)===n.slice(0,15)}function _(e,n,t){let o=t!==void 0?[t]:[];for(let i of e){let a=i.checkpoint?.org;a!==void 0&&(a.alias===n||a.username.toLowerCase()===n.toLowerCase())&&o.push(i.organizationId)}return e.filter(i=>o.some(a=>Lt(a,i.organizationId)))}var Tt="One kept in another folder is read with --store <folder>, or with SANDFORGE_JOURNAL_DIR set as when it was taken \u2014 in a CI job, a folder its cache restores; one taken on another machine comes here by export there, then import here.";function de(e){return`"${ie("checkpoint")} list --org ${e}" names those it holds. ${Tt}`}function K(e,n,t,o){if(Ue.safeParse(t).success){let a=e.find(r=>r.checkpointId===t);return a?{entry:a}:{none:`No checkpoint ${t} is kept in the folder read. ${de(o)}`}}if(t==="latest"){let a=n[0];return a?{entry:a}:{none:`No checkpoint of ${o} is kept in the folder read. ${de(o)}`}}let i=n.filter(a=>a.checkpoint?.name===t);return i.length===1?{entry:i[0]}:i.length===0?{none:`No checkpoint of ${o} named '${t}' is kept in the folder read. `+de(o)}:{ambiguous:`${i.length} checkpoints of ${o} are named '${t}': give the id of the one you mean with --checkpoint (${i.map(a=>a.checkpointId).join(", ")}).`}}function xe(e){if(e.valid)return;let n=e.checkpoint?`'${e.checkpoint.name}'`:e.checkpointId;switch(e.why){case"damaged":return{code:"DAMAGED",message:`The file of checkpoint ${e.checkpointId} cannot be read: it can only be deleted.`};case"taking":return{code:"TAKING",message:`The checkpoint ${n} is being taken, or its take never ended: it can be previewed once taken, or deleted.`};case"failed":return{code:"FAILED",message:`The take of checkpoint ${n} failed: it can only be deleted.`};case"refreshed":return{code:"OTHER_ORG",message:`This sandbox was refreshed${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}: it is another org now, and the checkpoint ${n} is of the org before it. It no longer rewinds. ${xt(e)}`};case"scratchExpired":return{code:"SCRATCH_EXPIRED",message:`The scratch org of checkpoint ${n} has expired: its checkpoints no longer rewind it. ${xt(e)}`};default:return{code:"INVALID",message:`The checkpoint ${n} cannot be previewed.`}}}function Ne(e){let n=e.checkpoint?.org,t=e.why==="refreshed"&&n!==void 0?n.alias??n.username:"<alias>";return`${$e(e.checkpointId,t)} --dry-run`}function xt(e){return`${ue.replace(/\.$/,"")}: ${Ne(e)}`}function Bt(e){return!e.valid&&(e.why==="refreshed"||e.why==="scratchExpired")}var h=e=>e.toLocaleString("en-US");function I(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function je(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,19)} UTC`}var U=e=>`${dt(e/(1024*1024))} MB`;function y(e,n=8){if(e.length===0)return"\u2014";let t=e.slice(0,n).join(", ");return e.length>n?`${t} \u2026 (+${e.length-n})`:t}function ee(e){return e.objects.reduce((n,t)=>n+t.records,0)}function Ee(e){return e===null?"kept until you delete it":`kept until ${I(e)}`}function V(e){return e.org.alias??e.org.username}var Dn=/^Left out(?::\s*|\s+(?=as asked\b))/;function Ft(e,n){let t=[...n,...e.flatMap(({code:a,records:r})=>a==="pastTheLimit"&&r!==void 0?[r]:[])],o=t.filter(a=>a<=F).reduce((a,r)=>a+r,0),i=new Map;for(let{objectApiName:a,reason:r,code:d,records:s}of e){let u=r;if(d==="pastTheLimit"&&s!==void 0&&s<=F){let m=rt(t,s);u=m>F?`${r} With it, every object no larger is kept, more than ${F} records in all, past any --max-total: --exclude-object <ApiName> leaves some out.`:`${r} --max-total ${m}${m===o?" or more":""} holds it.`}i.set(u,[...i.get(u)??[],a])}return[...i].map(([a,r])=>` left out: ${y(r)} \u2014 ${a.replace(Dn,"")}`)}var Pn={fls:"hidden from the user SandForge connects as by field-level security: Rewind won\u2019t put them back",encrypted:"encrypted, and the user SandForge connects as can\u2019t view encrypted data: Rewind won\u2019t touch them",base64:"the content of files and other binary values, which a checkpoint doesn\u2019t hold",compound:"compound fields, kept through the fields they are made of"};function _t(e){let n=new Map;for(let t of e)for(let{field:o,reason:i}of t.leftOutFields)n.set(i,[...n.get(i)??[],`${t.objectApiName}.${o}`]);return[...n].map(([t,o])=>` fields left out (${o.length}): ${y(o)} \u2014 ${Pn[t]??t}`)}function Ut(e){let n=e.filter(t=>!t.undeletable).map(t=>t.objectApiName);return n.length===0?[]:[` deleted ${y(n)} records come back from the recycle bin only with their parent`]}function Mt(e){return` about ${h(e.seconds)} s \xB7 about ${h(e.apiRequests)} API requests of the ${h(e.apiRequestsLeft)} left today`+(e.bytes>0?` \xB7 about ${U(e.bytes)} on this machine`:"")}var Nt={damaged:"its file cannot be read: it can only be deleted",taking:"being taken, or its take never ended: it can only be deleted unless it ends",failed:"its take failed: it can only be deleted",refreshed:"of the org before its refresh: it no longer rewinds, and replays into another org",scratchExpired:"its scratch org has expired: it no longer rewinds, and replays into another org"};function Ln(e,n,t){if(e.length===0&&t!==void 0){let i=t.kept===0?"":`, which keeps ${t.kept===1?"1 of another org":`${t.kept} of other orgs`}: "${ie("checkpoint")} list" names ${t.kept===1?"it":"them"}`;return[`No checkpoint of ${t.org} is kept in ${n}${i}. ${Tt}`]}if(e.length===0)return[`No checkpoint is kept in ${n}.`];let o=[];for(let i of e){let a=i.checkpoint;if(!a){o.push(`${i.checkpointId} ${Nt.damaged}`);continue}if(o.push(`${i.checkpointId} '${a.name}' ${V(a)} taken ${I(a.takenAt)} ${h(ee(a))} records in ${a.objects.length} objects ${U(a.bytes)} `+Ee(a.expiresAt)),!i.valid){let r=i.why==="refreshed"&&i.refreshedAt?`refreshed on ${i.refreshedAt.slice(0,10)}: `:"";o.push(` ${r}${Nt[i.why??""]??"it cannot be previewed"}`),Bt(i)&&(o.push(` replay it: ${Ne(i)}`),a.expiresAt!==null&&o.push(` deleted from this machine on ${I(a.expiresAt)}: to replay it after, Keep it in the editor, or export it and replay the file`))}i.scratchExpiresSoon&&a.org.scratchExpiresAt!==void 0&&o.push(` its scratch org expires on ${a.org.scratchExpiresAt.slice(0,10)}: its checkpoints then no longer rewind it, whatever --keep-days said, and still replay into another org`),i.expiresSoon&&a.expiresAt!==null&&o.push(` expires on ${I(a.expiresAt)}: take a new one, or keep this one in the editor`),i.binReachSince&&o.push(` records deleted before ${i.binReachSince.slice(0,10)} can't come back with their Id (recycle bin), sooner if the bin fills: a rewind makes them again, with new Ids`),i.undo&&o.push(` rewound: the rewind can be undone until ${I(i.undo.until)}`)}return o}function Tn(e){let n=e.checkpoint;return{id:e.checkpointId,name:n?.name??null,org:n?V(n):null,organizationId:e.organizationId,takenAt:n?.takenAt??null,records:n?ee(n):null,bytes:n?.bytes??null,expiresAt:n?n.expiresAt:null,expiresSoon:e.expiresSoon===!0,scratchExpiresSoon:e.scratchExpiresSoon===!0,binReachSince:e.binReachSince??null,...n?.lastRewind?{lastRewind:{...n.lastRewind,undoable:e.undo!==void 0}}:{},valid:e.valid,...e.why!==void 0?{why:e.why}:{},...e.refreshedAt!==void 0?{refreshedAt:e.refreshedAt}:{},...Bt(e)?{replayWith:Ne(e)}:{}}}function Wt(e){return e.refusal!==void 0&&e.objects.length===0&&e.leftOut.length===0}function Bn(e){return Wt(e)?{mode:e.mode,refusal:e.refusal}:{...e}}function Re(e){if(e.code!=="TOO_MANY_RECORDS")return e;let n="pick fewer objects (--exclude-object <ApiName> leaves one out)",t=`(${h(ge)} unless given)`,o=e.holdingLimit,i=o===void 0?`${n}, or raise the limit with --max-total <n> ${t}`:o>F?`${n}: no --max-total holds them all, ${h(F)} at most`:`${n}, or raise the limit with --max-total ${o} ${t}`;return{...e,message:e.message.replace(/: pick fewer objects\./,`: ${i}.`)}}function Fn(e,n){if(Wt(n))return[`refused: ${n.refusal.message}`];let t=n.objects.filter(i=>i.records>0).length,o=new Map;for(let{namespace:i}of n.objects)i!==void 0&&o.set(i,(o.get(i)??0)+1);return[`a checkpoint of ${e} would keep ${n.objects.length} objects (${t} hold records; ${n.objects.length-t} are empty \u2014 what is created there later is caught too), about ${h(n.estimate.records)} records`,...[...o].map(([i,a])=>` includes ${a} objects of the ${i} package`),Mt(n.estimate),...Ft(n.leftOut,n.objects.map(i=>i.records)),..._t(n.objects),...Ut(n.objects),...n.files?Un(n.files):[],..._n(n),...n.refusal?[`refused: ${Re(n.refusal).message}`]:[]]}function qt(e){let n=e.records===void 0?void 0:`${h(e.records)} ${e.records===1?"row":"rows"}`,t=[e.kind,n].filter(o=>o!==void 0);return t.length>0?`${e.objectApiName} (${t.join(", ")})`:e.objectApiName}function Ht(e){return qt({objectApiName:e.objectApiName,...e.customSetting!==void 0?{kind:e.customSetting}:{},records:e.records})}function _n(e){let n=e.objects.filter(i=>i.customSetting!==void 0),t=new Set(n.map(i=>i.objectApiName)),o=(e.customSettings??[]).filter(i=>!t.has(i.objectApiName));return[...n.length>0?[` custom settings kept: ${y(n.map(Ht))} \u2014 a rewind sets their rows back as the checkpoint holds them, whoever changed them since`]:[],...o.length>0?[` custom settings not kept: ${y(o.map(qt))} \u2014 --custom-setting <ApiName|all> keeps them`]:[]]}function Un(e){return e.held?[" files: it keeps which files are attached to its records (Salesforce Files, classic attachments) and each file's latest version, not its content; a rewind deletes the files attached to them since and brings back those deleted since. A file attached to no record it holds, a user's own or a library's, is left as it is",...Gt(e.addedToPicked),...e.queryAllFiles?[]:[Ie]]:[" files: not kept \u2014 a rewind leaves the files attached since as they are"]}function Gt(e){return e.length>0?[` added to the objects picked: ${e.join(", ")} \u2014 without them a rewind would leave the files attached since as they are`]:[]}var Ie=" the user the alias connects as doesn't have Query All Files: other users' files that no record of the checkpoint is attached to (in a library the user is not a member of, say) are not seen, nor counted among the files left; files attached to its records are seen";function Mn(e,n,t=[]){let o=e.movedWhileTaken,i=o.changed+o.deleted+o.created;return[`taken '${e.name}' (${e.checkpointId}) of ${V(e)}: ${h(ee(e))} records in ${e.objects.length} objects, ${U(e.bytes)} on this machine, ${Ee(e.expiresAt)}`,` of ${je(e.readFrom)}, read until ${je(e.takenAt)} on the org's clock`,...i>0?[` ${h(i)} records changed while it was taken (${o.changed} changed, ${o.deleted} deleted, ${o.created} created): it holds them as they were read, and a rewind treats them as changed since. Take checkpoints when nobody works in the org.`]:[],...Ft(e.scope.leftOut,e.objects.map(a=>a.records)),..._t(e.objects),...e.ignoredFields.length>0?[` not compared, nor written back (you chose): ${e.ignoredFields.join(", ")}`]:[],...Ut(e.objects),...Wn(e.objects),...e.files?qn(e,e.files,t):[],` it holds the records' values unencrypted, in files only you can read: ${n}`]}function Wn(e){let n=e.filter(t=>t.customSetting!==void 0);return n.length===0?[]:[` custom settings kept: ${y(n.map(Ht))} \u2014 a rewind sets their rows back as the checkpoint holds them`]}function qn(e,n,t){let o=n.readByIds??[],i=new Set(t.map(d=>d.toLowerCase())),a=new Set(e.objects.map(({objectApiName:d})=>d.toLowerCase())),r=e.scope.mode==="picked"?Ze.filter(d=>a.has(d.toLowerCase())&&!i.has(d.toLowerCase())):[];return[` files: ${h(n.anchored)} attached to its records by ${h(n.links)} link(s): a rewind takes back what is attached to them since`,...Gt(r),...o.length>0?[` the links of ${y(o)} were read by lists of record Ids: ${V(e)} refused one query, or answered too late`]:[],...e.takenBy.queryAllFiles===!1?[Ie]:[]]}function Hn(e,n){let t=Object.entries(e.byPhase).map(([i,a])=>{let r=n?.requestsByPhase?.[i];return r===void 0||r===a?`${i} ${a}`:`${i} ${a} (${r})`}),o=n?`, about ${h(n.apiRequests)} estimated`:"";return` sent ${h(e.total)} API requests to the org${o}: ${t.join(", ")}`}var Et=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,Y=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,Ce=e=>e.cannotUndo.reduce((n,t)=>n+t.count,0),Q=e=>e.toRecreate??0,ce=e=>e.toBringBack.carriers??0;function Jt(e){let n=e.files;return n===void 0?0:n.unlink+n.relink+n.updateLinks}function Gn(e){let n=e.files;return n===void 0?0:n.outsideAdded+n.outsideDeleted}function Jn(e){let n=e.schemaDrift;return n===void 0?0:n.removed.length+(n.hidden?.length??0)+(n.uncertain?.fields.length??0)}function De(e){let n=z(e);return n.toDelete+n.toGiveBack+n.toBringBack+n.toRecreate>0||Jt(e)+Gn(e)>0||e.objects.some(t=>Ce(t)>0||t.unexplained>0||Jn(t)>0)||e.unread.length>0}var zn={goneForGood:"deleted since and no longer in the recycle bin, and not made again \u2014 a file, whose body the checkpoint does not hold, or a record deleted while it was taken: they can\u2019t come back",convertedLead:"leads converted since: Salesforce can\u2019t unconvert a lead",activatedContract:"contracts activated since: Salesforce won\u2019t set them back to Draft",deletedWithCreatedParent:"deleted with a parent created since that Salesforce does not undelete on its own: they come back with that parent only",deletedWithParentOutside:"deleted with their parent, a record of an object the checkpoint does not hold: they come back with that parent only, which a checkpoint that holds its object brings back",newFileVersion:"files given a new version since: Salesforce deletes no version and won\u2019t make an older one the latest again, so they keep their new content; the content each had is still in its version history, and their titles are given back",deletedByOther:"deleted since by another user: only View All Data and Modify All Data restore those; they stay in the recycle bin, never made again",outOfReach:"out of reach: without View All Data and Modify All Data, nothing shows what others deleted of an object held through the records it hangs from; they may be in the recycle bin out of sight, and are never made again"},Kn=[{reason:"onlyWithParent",preview:"Salesforce undeletes them only with their parent, and their parent stays",result:"Salesforce undeletes them only with their parent"},{reason:"deletedBeforeParent",preview:"deleted before a record they point at, which the rewind deletes next: Salesforce cannot bring them back after that",result:"deleted before a record they point at, which the rewind deleted next: Salesforce cannot bring them back after that"}];function zt(e){return Kn.flatMap(n=>{let t=e.filter(o=>(o.reason??"onlyWithParent")===n.reason);return t.length>0?[{words:n,of:t}]:[]})}function Vn(e,n){let{automation:t,deliverability:o}=n;if(!t||!o)return[];let i=Z(n.diff),{line:a}=ot({act:"rewind",orgName:e,automation:t,steps:i,accepted:!0,mayMute:!1,...nt({automation:t,steps:i}),reading:o.reading}).gate;return a!==void 0?[` ${a}`]:[]}function Yn(e,n){return n.map(t=>{let o=[...new Set(t.objects.flatMap(a=>a.sentBy))],i=` emails: ${e}'s automation sends about ${tt(t.emails,t.limit)} as the rewind writes (${y(o,4)})`+(t.alertsCounted?`, its email alerts among them: ${e} counts them against its single emails, as a Developer Edition does`:"");return t.verdict==="unread"?`${i}; what it has left today could not be read (${t.unread??""})`:t.verdict==="fits"?`${i}; ${t.remaining??0} of ${t.max??0} left today`:`${i}, more than the ${t.remaining??0} of ${t.max??0} left today: a rewind is refused`})}function Xn(e,n){if(!e||n.length===0)return"";let t=fe(e,{giveBack:n}).map(o=>`${o.objectApiName}: '${o.name}'`);return t.length>0?`, on which runs ${y(t,4)}`:""}function Zn(e,n,t=[]){let o=e.objects.filter(d=>Xe[d.objectApiName]!==void 0),i=o.filter(d=>Q(d)>0),a=o.filter(d=>Y(d)>0&&!t.includes(d.objectApiName)),r=[];return i.length>0&&r.push(` made as drafts first: ${y(i.map(d=>`${d.objectApiName} ${h(Q(d))}`))} \u2014 Salesforce refuses an order or a contract made past Draft, and an order takes its products only as a draft: one past Draft at the checkpoint is made at the org's Draft status, the records under it next, then given its status back, an update`+Xn(n,i.map(d=>d.objectApiName))),a.length>0&&r.push(` if Salesforce answers that an order or a contract to bring back is no longer in the recycle bin, --accept-recreate makes it again as a draft, then gives it its status back, an update: ${y(a.map(d=>`${d.objectApiName} ${h(Y(d))}`))}`),r}function Qn(e,n,t=!1){if(!n)return{objects:[],fired:[]};let o=Z(e),i=[],a=new Set;for(let r of e.objects){if(Y(r)===0)continue;let d=ft(n,o,[r.objectApiName],t);if(!(d.fired.length===0&&!d.blind)){i.push(r.objectApiName);for(let s of d.fired)a.add(`${s.objectApiName}: '${s.name}'`)}}return{objects:i,fired:[...a]}}function eo(e,n,t){let o=fe(n,t),i=[];for(let r of n.objects){let d=o.filter(w=>w.objectApiName===r.objectApiName),s=[...new Set(d.filter(w=>w.kind!=="trigger").map(w=>`'${w.name}'`))],u=[...new Set(d.filter(w=>w.kind==="trigger").map(w=>w.name))],m=[...s.length>0?[`${s.length} flow(s) or rule(s): ${y(s,4)}`]:[],...u.length>0?[`${u.length} Apex trigger(s): ${y(u,4)}`]:[]];m.length>0&&i.push(` ${r.objectApiName}: ${m.join("; ")}`)}return[...i.length>0?[` what ${e} runs as a rewind writes (updates, deletes, records brought back):`]:[],...i,...n.unread.map(r=>` not read of its automation: ${r.part} \u2014 ${r.reason}`)]}function Kt(e,n,t,o="the user SandForge connects as",i=!1,a){let{diff:r}=t,d=z(r),s=[`Rewind ${e} to '${n.name}' (${I(n.takenAt)}), read at ${je(r.readAt)}:`,` ${h(d.toDelete)} to delete \xB7 ${h(d.toGiveBack)} to give back \xB7 ${h(d.toBringBack)} to bring back`+(d.toRecreate>0?` \xB7 ${h(d.toRecreate)} to make again`:""),...a?[so(a)]:[]];!De(r)&&!r.objects.some(f=>f.outside.length>0)&&a===void 0&&s.push(` ${e} is as it was at '${n.name}' among the objects and fields it holds: nothing to rewind.`);let u=f=>r.undoCannot.filter(p=>p.objectApiName===f.objectApiName).reduce((p,R)=>p+R.count,0),m=r.objects.filter(f=>Et(f)+f.toGiveBack.records+Y(f)+Q(f)+Ce(f)+u(f)>0);if(m.length>0){let f=Math.max(6,...m.map(p=>p.objectApiName.length));s.push(` ${"Object".padEnd(f)} ${"Delete".padStart(8)} ${"Give back".padStart(9)} ${"Bring back".padStart(10)} ${"Can't undo".padStart(10)}`);for(let p of m)s.push(` ${p.objectApiName.padEnd(f)} ${h(Et(p)).padStart(8)} ${h(p.toGiveBack.records).padStart(9)} ${h(Y(p)).padStart(10)} ${h(Ce(p)+u(p)).padStart(10)}`)}let w=new Map;for(let f of r.objects)for(let[p,R]of Object.entries(f.lastChangedBy))w.set(p,(w.get(p)??0)+R);w.size>0&&s.push(` last changed by: ${[...w].sort((f,p)=>p[1]-f[1]).map(([f,p])=>`${r.userNames[f]??f} ${h(p)}`).join(" \xB7 ")}`),r.activeLastHour.length>0&&s.push(` people working in ${e} in the last hour: ${r.activeLastHour.map(f=>r.userNames[f]??f).join(", ")}`);let j=r.objects.filter(f=>f.touched>0);j.length>0&&s.push(` touched since but holding their checkpoint values: ${y(j.map(f=>`${f.objectApiName} ${h(f.touched)}`))}`);let g=r.objects.filter(f=>ce(f)>0);g.length>0&&s.push(` brought back for a moment: ${y(g.map(f=>`${f.objectApiName} ${h(ce(f))}`))} \u2014 records the checkpoint does not hold that took records of it along when deleted since: Salesforce gives those back with them only, so they come back, then go back to the recycle bin with what came back with them; what the org runs on them runs twice`);let c=new Map;for(let f of r.objects)for(let p of f.cannotUndo)p.count!==0&&c.set(p.reason,[...c.get(p.reason)??[],`${f.objectApiName} ${h(p.count)}`]);for(let[f,p]of c)s.push(` can't be taken back: ${y(p)} \u2014 ${zn[f]??f}`);let l=r.objects.filter(f=>Q(f)>0);l.length>0&&s.push(` to make again, with new Ids: ${y(l.map(f=>`${f.objectApiName} ${h(Q(f))}`))} \u2014 deleted since and no longer in the recycle bin: made again from the checkpoint, the lookups it holds that named them naming the new Ids; anything outside Salesforce that names their old Ids no longer finds them`);let k=d.toBringBack>0?Qn(r,t.automation,i):void 0;if(k){let f=k.fired.length>0?`making them again runs ${y(k.fired,4)}`:"what runs as they are made again could not all be read";s.push(" if Salesforce answers that a record to bring back is no longer in the recycle bin \u2014 it still lists one emptied from it as deleted \u2014, --accept-recreate makes it again with a new Id, with what was to come back with it; without it, the rewind leaves them and names them"+(k.objects.length>0?`; ${y(k.objects)} records it leaves all the same, with what was to come back with them, and names them: ${f}, which this rewind does not ask about \u2014 a rewind after it counts them to make again, and asks`:""))}s.push(...Zn(r,t.automation,k?.objects));let A=r.objects.filter(f=>f.unexplained>0);A.length>0&&s.push(` left as they are: ${y(A.map(f=>`${f.objectApiName} ${h(f.unexplained)}`))} \u2014 records the checkpoint doesn't hold although they're dated before it (a load with back-dated creation dates?); a rewind deletes nothing it cannot prove was created since`);for(let{words:f,of:p}of zt(r.undoCannot))s.push(` undo couldn't bring back: ${y(p.map(R=>`${R.objectApiName} ${h(R.count)}`))} \u2014 ${f.preview}`);for(let{objectApiName:f,children:p,records:R}of r.unseen??[])s.push(` also deleted with them, out of sight: deleting ${h(R)} ${f} also deletes what ${o} can't see under them in ${y(p)}; Rewind can't count those, and deletes them only with --accept-unseen`);for(let f of r.objects)for(let p of f.outside){let R=a!==void 0;s.push(f.objectApiName===Vt&&p.objectApiName===to?` also attached outside the checkpoint: ${h(p.parents)} file(s) it deletes, by ${h(p.count)} link(s) to a library, a group or a record of another object \u2014 deleting them removes them from there as well`:p.objectApiName===G?R?` kept with them, outside the checkpoint: ${h(p.count)} ${G} in which ${e}'s duplicate rules reported ${h(p.parents)} ${f.objectApiName} since the checkpoint \u2014 --accept-outside deletes ${p.count===1?"it":"them"} with them`:` also deleted with them, outside the checkpoint: ${h(p.count)} ${G} in which ${e}'s duplicate rules reported ${h(p.parents)} ${f.objectApiName} since the checkpoint \u2014 an undo brings ${p.count===1?"it back without its":"them back without their"} items, which Salesforce does not return`:R?` kept with what they hang from, outside the checkpoint: ${h(p.count)} ${p.objectApiName} created under ${h(p.parents)} ${f.objectApiName} \u2014 --accept-outside deletes them with what they hang from`:` also deleted with them, outside the checkpoint: ${h(p.count)} ${p.objectApiName} created under ${h(p.parents)} ${f.objectApiName}`)}s.push(...no(e,r));let b=r.objects.flatMap(f=>{let p=f.schemaDrift,R=new Set([...p?.removed??[],...p?.hidden??[],...p?.uncertain?.fields??[]]);return f.notCompared.filter(O=>!R.has(O)).map(O=>`${f.objectApiName}.${O}`)});b.length>0&&s.push(` not compared (you chose): ${y(b)}`);for(let f of r.objects){let p=f.schemaDrift;if(!p)continue;let R=O=>O.map(H=>`${f.objectApiName}.${H}`);p.removed.length>0&&s.push(` fields deleted since: ${y(R(p.removed))} \u2014 restore them from Deleted Fields, then rewind`),(p.hidden??[]).length>0&&s.push(` fields hidden from ${o} by field-level security since: ${y(R(p.hidden??[]))} \u2014 rewind does not put them back; give ${o} read and edit access to them, then rewind again`),p.uncertain!==void 0&&p.uncertain.fields.length>0&&s.push(` fields gone from what ${e} shows ${o}: ${y(R(p.uncertain.fields))} \u2014 deleted since (restore them from Deleted Fields within 15 days), or hidden by field-level security (give ${o} read and edit access); rewind does not put them back`+(p.uncertain.reason!==void 0?` (which, ${e} would not say: ${p.uncertain.reason})`:"")),p.added.length>0&&s.push(` fields added since, their values left alone: ${y(R(p.added))}`),p.changed.length>0&&s.push(` fields changed since, tried one by one: ${y(R(p.changed))}`)}let $=r.fieldsNotChecked??0;$>0&&s.push(` fields not checked for changes in ${h($)} objects nothing changed in: a rewind writes nothing there`);for(let f of r.unread)s.push(` could not be read: ${f.objectApiName} \u2014 ${f.reason} (never taken for unchanged)`);return t.automation&&s.push(...eo(e,t.automation,Z(r))),t.emails&&s.push(...Yn(e,t.emails)),t.emailsUncounted!==void 0&&s.push(` emails: not counted, ${t.emailsUncounted} could not be read \u2014 what they send as the rewind writes is not known; --accept-automation covers it`),s.push(...Vn(e,t)),s.push(Mt(t.estimate)),t.refusal&&s.push(` a rewind now would be refused (${t.refusal.code}): ${t.refusal.message}`),s}var Vt="ContentDocument",to="ContentDocumentLink";function no(e,n){let t=n.files;if(t===void 0)return[];let o=[];t.unlink>0&&o.push(` links to remove: ${h(t.unlink)} added since between a file and a record that both stay \u2014 the file stays, no longer attached to that record`),t.relink>0&&o.push(` links to put back: ${h(t.relink)} removed since between a file and a record that both stay, each under a new Id: Salesforce keeps no removed link in the recycle bin`),t.updateLinks>0&&o.push(` links to give their sharing back: ${h(t.updateLinks)} \u2014 who sees the file from the record, and with what access; a link to an account keeps its access, which Salesforce doesn't let change`),t.outsideAdded>0&&o.push(` kept: ${h(t.outsideAdded)} file(s) added since, as no record of this checkpoint links to them (a user's own, a library's)`),t.outsideDeleted>0&&o.push(` left in the recycle bin: ${h(t.outsideDeleted)} file(s) deleted since, as no record of this checkpoint linked to them`);let i=n.objects.find(d=>d.objectApiName===Vt),a=i===void 0?0:Y(i),{storage:r}=t;return a>0&&r.bringBack>0&&o.push(` file storage: bringing back ${h(a)} file(s) takes ${U(r.bringBack)} again; `+(r.remaining===void 0?`${e} did not say how much it has left`:`${e} has ${U(r.remaining)} left`)),r.undo>0&&o.push(` undo would bring back the files this rewind deletes: ${U(r.undo)} of file storage again`),t.blindSpot&&o.push(Ie),o}function Yt(e,n,t,o,i){let a=o?.diff??i?.diff??t.diff;return{checkpoint:{id:n.checkpointId,name:n.name,takenAt:n.takenAt,org:e},...o?{objects:[...o.plan.objects]}:{},...z(a),carriers:a.objects.reduce((r,d)=>r+ce(d),0),differs:De(o?.diff??t.diff),...o?{selection:o.plan}:{},...i?{kept:i.plan.left}:{},diff:t.diff,estimate:t.estimate,...t.automation?{automation:t.automation}:{},...t.emails?{emails:t.emails}:{},...t.emailsUncounted!==void 0?{emailsUncounted:t.emailsUncounted}:{},...t.deliverability?{deliverability:t.deliverability}:{},...t.refusal?{refusal:t.refusal}:{}}}function oo(e,n){return n&&De(e)?3:0}var Xt={needsUnpickedParent:"they come back only with a parent this rewind leaves deleted, or look up a record it leaves deleted, which Salesforce refuses: those lookups are left, the rest written",heldByUnpicked:"records of an object not named made since hang from them and hold some of their values in place: given back but for those",outsideNotAccepted:"records of an object not named made since hang from them, which their deletion would take along: kept, unless --accept-outside",holdsLeft:"records this rewind leaves as they are hang from them, which their deletion would take along: kept",contactKept:"the relation of a contact made since to its own account, which Salesforce deletes only with the contact, and this rewind leaves the contact: kept with it",keyTaken:"rows of a custom setting whose owner or name a row made since holds: brought back once it is gone"},io=new Set(["outsideNotAccepted","holdsLeft","contactKept"]);function so(e){return` ${h(e.records)} kept of what it would delete: records made since outside ${e.limited?"the objects named":"the checkpoint"} hang from them, or from what they hold, which their deletion would take along \u2014 with --accept-outside, ${h(e.withFlag)} to delete, those records with them`}async function Zt(e,n,t,o,i,a){if(a||o===void 0)return;let r=o.plan.left;if(!r.some(m=>m.reason==="outsideNotAccepted"))return;let d=r.filter(m=>io.has(m.reason)).reduce((m,w)=>m+w.count,0),s=n.objects.map(({objectApiName:m})=>m),u=await he(e,t,i??s,!0);return{records:d,withFlag:z(u.diff).toDelete,limited:i!==void 0}}function Qt(e){let n=e.acts.filter(s=>!s.picked),t=s=>e.undoCannot.filter(u=>u.objectApiName===s).reduce((u,m)=>u+m.count,0),o=n.flatMap(s=>{let u=s.toDelete-(s.withParent??0)-t(s.objectApiName);return u>0?[`${s.objectApiName} ${h(u)}`]:[]}),i=n.flatMap(s=>(s.withParent??0)>0?[`${s.objectApiName} ${h(s.withParent??0)}`]:[]),a=n.flatMap(s=>{let u=t(s.objectApiName);return u>0?[`${s.objectApiName} ${h(u)}`]:[]}),r=[` limited to ${e.objects.join(", ")}: the other objects are left as they are`+(o.length+i.length+a.length>0?", but for the records said below":"")+", and what still differs in them is counted apart"];o.length>0&&r.push(` also deletes again ${y(o)} \u2014 made since, they come back with a record it brings back: leaving them would make a state that never existed`),i.length>0&&r.push(` also deleted with them, outside the objects named: ${y(i)} \u2014 made since under the records it deletes, they go to the recycle bin with them, and an undo brings them back with them`);let d=n.flatMap(s=>(s.withParent??0)>0&&me([s.objectApiName]).length>0?[`${s.objectApiName} ${h(s.withParent??0)}`]:[]);d.length>0&&r.push(` set back to Draft first: ${y(d)} \u2014 past Draft, an order keeps the record it goes with from its delete; an undo brings it back a draft`),a.length>0&&r.push(` also deleted on their own, outside the objects named: ${y(a)} \u2014 made since under the records it deletes, they point at a record it deletes after them, and Salesforce keeps them in the recycle bin for good once it goes: Undo couldn't bring them back`);for(let s of e.left)r.push(` left: ${h(s.count)} ${s.objectApiName} record(s) \u2014 ${Xt[s.reason]}`);return e.needs.length>0&&r.push(` to rewind those too, add ${e.needs.map(s=>`--object ${s.objectApiName} (${h(s.records)} record(s) need it)`).join(", ")}`),e.acts.some(s=>s.picked&&s.toDelete>0)&&r.push(" a record of an object not named that looks up a record it deletes has that lookup emptied by Salesforce, and is dated that second"),r}function en(e,n,t){return!t&&e.scope.mode==="picked"&&n.objects.some(o=>o.outside.length>0)}function tn(e){return e.left.map(n=>` kept: ${h(n.count)} ${n.objectApiName} record(s) \u2014 `+(n.reason==="outsideNotAccepted"?"records outside the checkpoint made since hang from them, which their deletion would take along: kept, unless --accept-outside":Xt[n.reason]))}async function nn(e,n,t,o){if(!en(n,t,o))return;let i=n.objects.map(({objectApiName:a})=>a);return he(e,t,i,!1)}function on(e,n){let t=new Map(e.objects.map(({objectApiName:i})=>[i.toLowerCase(),i])),o=n.filter(i=>!t.has(i.toLowerCase()));if(o.length>0)throw new v({code:"NOT_HELD",message:`--object: '${e.name}' holds no ${o.join(", ")}. It holds ${y(e.objects.map(i=>i.objectApiName))}. Nothing was run.`},2);return n.flatMap(i=>t.get(i.toLowerCase())??[])}async function he(e,n,t,o){let i=await e.request({type:"checkpoint:plan-selection",payload:{checkpointId:n.checkpointId,previewId:n.previewId,objects:[...t],acceptOutside:o},timeoutMs:le});if(i.outcome!=="answered")throw new v(L(i,"The plan of the objects named"));let a=D(i).plan;return{plan:a,diff:ut(n,a)}}var te={limit:e=>`--max-records ${e}`,mutes:!0,lift:{acceptAutomation:"give --accept-automation to rewind all the same",acceptEmails:"add --accept-emails to rewind all the same",acceptNoUndo:"give --accept-no-undo to rewind all the same",acceptRecreate:"give --accept-recreate to rewind all the same",acceptUnseen:"give --accept-unseen to rewind all the same",maxRecords:"read its preview (--dry-run), then give a --max-records that holds it",refuseWhenActive:"rewind once they are done, or without --refuse-when-active"}};function ao(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(gt,te.lift.acceptAutomation)}:e}function ro(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(bt,"give --accept-automation to undo the rewind all the same")}:e}function li(e,n,t,o="the user SandForge connects as"){return pt(e,n,t,te.lift,o,te.mutes)}var co={acceptAutomation:!1,acceptNoUndo:!1,acceptRecreate:!1};function sn(e,n){return[...e?[e]:[],...n.filter(t=>t.code!==e?.code)]}function ho(e,n,t,o){let i=o!==void 0&&o.length>0?`${o.join(", ")} of ${e}`:e,a=z(t),r=a.toRecreate>0?`, and makes ${h(a.toRecreate)} record(s) the recycle bin no longer holds again, with new Ids`:"",d=t.objects.reduce((w,j)=>w+ce(j),0),s=d>0?`, with ${h(d)} record(s) brought back for a moment that had taken records of the checkpoint along, then deleted again`:"",u=Jt(t),m=u>0?`, and puts ${h(u)} link(s) between files and records back as they were`:"";return`Rewind ${i} to '${n.name}': it deletes the ${h(a.toDelete)} record(s) created since ${I(n.takenAt)}, gives ${h(a.toGiveBack)} record(s) their values from then back, and brings back ${h(a.toBringBack)} record(s) from the recycle bin${s}${r}${m} \u2014 whoever made these changes. What it changes is kept, so it can be undone. Type ${e} to rewind it:`}var S=(e,n)=>e.reduce((t,o)=>t+n(o),0);function Pe(e){let n=S(e.deleted,d=>d.deleted),t=S(e.deleted,d=>d.planned),o=S(e.restored,d=>d.restored+(d.restoredWithout??0)),i=S(e.restored,d=>d.planned),a=S(e.undeleted,d=>d.undeleted+d.alreadyBack),r=S(e.undeleted,d=>d.planned);return{deleted:{planned:t,done:n,left:Math.max(0,t-n-S(e.deleted,d=>d.alreadyGone))},givenBack:{planned:i,done:o,left:Math.max(0,i-o-S(e.restored,d=>d.alreadyGone))},broughtBack:{planned:r,done:a,left:Math.max(0,r-a)}}}function an(e){let n=e.recreated??[],t=S(n,i=>i.planned),o=S(n,i=>i.created);return{planned:t,done:o,left:Math.max(0,t-o)}}function lo(e){return(e.remade??[]).reduce((n,t)=>{let o=S(e.deleted.filter(i=>i.objectApiName===t.objectApiName),i=>i.deleted);return n+Math.min(o,t.count)},0)}function rn(e,n){return e===void 0?"another user":n[e]??e}function uo(e,n,t){switch(n.reason){case"automation":return e==="rewind"?"kept by your automation, which sets them again on save: rewind --ignore-field <Object.Field> stops comparing such a field":"set again on save by your automation, since the undo gave them back their values";case"changedDuringRewind":return`changed during the ${e} by ${rn(n.by,t)}: left as they made them`;case"changedSincePreview":return"changed since the preview: rewind again to take them";case"refused":return`refused: ${n.message??"the org gave no reason"}`;case"notInBin":return"no longer in the recycle bin \u2014 emptied from it, or kept there for good \u2014: Salesforce still lists them as deleted but will not bring them back; --accept-recreate makes them again with new Ids";case"goneForGood":return"deleted since and no longer in the recycle bin, and not made again (a file, whose body the checkpoint does not hold, or a record deleted while it was taken): they can't come back";case"kept":return n.message??"kept as they are";case"notBack":return"brought back without their items, gone for good"+(n.message!==void 0?` (${n.message})`:"")+": Salesforce brings a deleted duplicate record set back without its items"}}function dn(e,n){return`Stopped before it wrote anything: ${e} is as it was before this rewind. Rewind again to rewind it to '${n}'.`}function fo(e,n,t,o={},i){let a=S(t.residual,c=>c.count),r=t.residual.filter(c=>c.reason==="changedDuringRewind"),d={success:`${e} is back at '${n.name}': read again, nothing differs among the objects and fields it holds.`,partial:`${e} is back at '${n.name}' but for ${h(a)} record(s) that still differ, each said with why:`,unstable:`Someone kept writing to ${e} during the rewind: ${[...new Set(r.map(c=>rn(c.by,o)))].join(", ")} changed ${h(S(r,c=>c.count))} record(s), left as they made them. Rewind again once they have stopped.`,failure:`Nothing of the rewind of ${e} to '${n.name}' went through: what still differs is said with why:`,cancelled:t.undo===void 0?dn(e,n.name):`Stopped part way: ${e} is between '${n.name}' and now. Rewind again to finish: it takes up from what still differs, and undo still returns ${e} to how it was before the rewind.`},s=t.scope;s!==void 0&&t.status==="success"&&(d.success=`${s.objects.join(", ")} of ${e} ${s.objects.length>1?"are":"is"} back at '${n.name}': read again, nothing differs among them.`);let u=Pe(t),m=S(t.undeleted,c=>c.alreadyBack),w=[d[t.status]];if(s!==void 0){let{objects:c,records:l}=s.notRewound;w.push(l>0?` not rewound: ${h(l)} record(s) of ${y(c)} still differ, left as they are \u2014 the rewind was limited to the objects named; add them with --object`:" the objects not named match the checkpoint too")}if(u.deleted.done>0){let c=S(t.wentAlong??[],l=>l.count);w.push(` deleted ${h(u.deleted.done)} record(s) added since the checkpoint \u2014 created, or brought back from the recycle bin they were in when it was taken \u2014`+(c>0?`, ${h(c)} of them with the record they hang from`:"")+" (in the recycle bin for up to 15 days)")}u.givenBack.done>0&&w.push(` gave ${h(u.givenBack.done)} record(s) back their checkpoint values`),u.broughtBack.done>0&&w.push(` brought back ${h(u.broughtBack.done-m)} record(s) deleted since the checkpoint, with their original Ids`+(m>0?`, and ${h(m)} that came back with them`:""));let j=t.status==="failure"?[]:t.carriers??[];if(j.length>0){let c=y(j.map(l=>`${l.objectApiName} ${h(l.count)}`));w.push(t.status==="cancelled"?` of them, brought back for a moment: ${c} \u2014 records the checkpoint does not hold that had taken records of it along; stopped before it was through, those it had not deleted again yet are still in the org: rewind again deletes them, with what came back with them`:` of them, brought back for a moment and deleted again: ${c} \u2014 records the checkpoint does not hold that had taken records of it along, back in the recycle bin with what came back with them`)}let g=an(t);g.done>0&&w.push(` made again ${h(g.done)} record(s) the recycle bin no longer held, with new Ids`);for(let c of t.draftsLeft??[])w.push(` left as drafts: ${c.objectApiName} ${h(c.count)} (${y(c.ids,3)}) \u2014 made again as drafts, the rewind stopped before it gave them back the status the checkpoint holds: rewind again gives it back to them, an update`);if(w.push(...hn("rewind",e,t)),w.push(...ln("rewind",t,o)),t.undo){w.push(` undo it until ${I(t.undo.until)}, sooner if the recycle bin fills: ${ie("checkpoint")} undo --org ${e} --checkpoint ${n.checkpointId}`+(i!==void 0?` --store ${_e(i)}`:""));for(let{words:c,of:l}of zt(t.undo.cannot))w.push(` undo couldn't bring back: ${y(l.map(k=>`${k.objectApiName} ${h(k.count)}`))} \u2014 ${c.result}`)}for(let c of t.removedJournals??[])w.push(` removed the journal of rewind ${c.rewindId} of '${c.name}': undo reaches the last rewind of the org alone`);return w.push(un(t)),w}function cn(e){return`Stopped before it wrote anything: ${e} is as the rewind left it, and the rewind can still be undone.`}function po(e,n,t){let o=S(t.restored,c=>c.keptChanged)+S(t.deleted,c=>c.keptChanged),i=S([...t.deleted,...t.restored,...t.undeleted],c=>c.refused),a=S(t.residual,c=>c.count)+i,r=`${e} is back as it was before its rewind to '${n.name}'`,d={success:`${r}.`,partial:o>0&&a===0?`${r}, except ${h(o)} record(s) changed since the rewind, left as they are now.`:`${r}, except ${h(a+o)} record(s), each said with why:`,unstable:`Someone changed records of ${e} during the undo: left as they made them, each said below.`,failure:`Nothing of the undo of ${e}'s rewind went through: its reasons are said below.`,cancelled:We(t)?cn(e):`Stopped part way: ${e} is between the rewind and how it was before it. Undo again to finish: it takes up what this one left.`},s=Pe(t),u=[d[t.status]],m=lo(t),w=S(t.wentAlong??[],c=>c.count),j=s.deleted.done-m-w;j>0&&u.push(` sent back to the recycle bin ${h(j)} record(s) the rewind brought back`+(w>0?", with what came back with them":"")),m>0&&u.push(` deleted again ${h(m)} record(s) the rewind made again, with what went with them`);let g=t.carriedAlone??[];if(g.length>0&&u.push(` of them, back in the recycle bin on their own: ${y(g.map(c=>`${c.objectApiName} ${h(c.count)}`))} \u2014 they had gone there with a record the rewind brought back for a moment, which stays there; they come back alone, under the parent the checkpoint gave them`),s.broughtBack.done>0){let c=S(t.cameBackAlong??[],l=>l.count);u.push(` brought back ${h(s.broughtBack.done)} record(s) the rewind deleted`+(c>0?`, ${h(c)} of them with the record they hang from`:""))}return s.givenBack.done>0&&u.push(` gave ${h(s.givenBack.done)} record(s) back the values they had before the rewind`),o>0&&u.push(` kept ${h(o)} record(s) changed since the rewind: undo leaves them as they are now`),u.push(...hn("undo",e,t)),u.push(...ln("undo",t,{})),u.push(un(t)),u}function hn(e,n,t){let o=t.files;if(o===void 0)return[];let i=e==="rewind"?{unlinked:"removed {n} link(s) added since between files and records: the files stay",relinked:"put back {n} link(s) removed since between files and records, under new Ids",linksUpdated:"gave {n} link(s) between files and records their sharing back"}:{unlinked:"removed again {n} link(s) between files and records the rewind put back",relinked:"put back {n} link(s) between files and records the rewind removed, under new Ids",linksUpdated:"gave {n} link(s) between files and records back the sharing they had before the rewind"},a=["unlinked","relinked","linksUpdated"].filter(r=>o[r]>0).map(r=>` ${i[r].replace("{n}",h(o[r]))}`);return o.linksRefused>0&&a.push(` ${n} refused to write ${h(o.linksRefused)} link(s) between files and records`),a}function ln(e,n,t){let o=n.residual.map(i=>` ${i.objectApiName} ${h(i.count)} \u2014 ${uo(e,i,t)}`);if(e==="rewind")for(let i of n.deleted){if(i.objectApiName!==G)continue;let a=i.refused+i.keptChanged+i.keptDependents;a!==0&&o.push(` left: ${h(a)} ${G} its preview named among what goes along`+(i.reasons.length>0?` \u2014 ${i.reasons.join("; ")}`:""))}if(e==="undo")for(let i of[...n.deleted,...n.restored,...n.undeleted])i.refused!==0&&o.push(` ${i.objectApiName} ${h(i.refused)} \u2014 refused: ${i.reasons[0]??"the org gave no reason"}`);for(let i of n.unread??[])o.push(` could not be read again: ${i.objectApiName} \u2014 ${i.reason} (never taken for unchanged)`);return o}function un(e){return` sent ${h(e.apiRequests.used)} API requests to the org; ${h(e.apiRequests.leftToday)} left today`}function fn(e,n,t,o,i){let a=new Map,r=s=>{let u=a.get(s);return u||(u={object:s,deleted:0,givenBack:0,broughtBack:0,refused:0},a.set(s,u)),u};for(let s of o.deleted)r(s.objectApiName).deleted+=s.deleted,r(s.objectApiName).refused+=s.refused;for(let s of o.restored)r(s.objectApiName).givenBack+=s.restored+(s.restoredWithout??0),r(s.objectApiName).refused+=s.refused;for(let s of o.undeleted)r(s.objectApiName).broughtBack+=s.undeleted+s.alreadyBack,r(s.objectApiName).refused+=s.refused;for(let s of o.recreated??[])r(s.objectApiName).refused+=s.refused;let d=(o.unread??[]).map(s=>({object:s.objectApiName,reason:s.reason}));return{checkpoint:{id:t.checkpointId,name:t.name,takenAt:t.takenAt,org:n},rewindId:o.rewindId,status:o.status,...o.scope?{limitedTo:[...o.scope.objects],notRewound:{...o.scope.notRewound}}:{},...Pe(o),...e==="rewind"?{recreated:an(o),cannotUndo:(i?.objects??[]).flatMap(s=>s.cannotUndo.filter(u=>u.count>0).map(u=>({object:s.objectApiName,reason:u.reason,count:u.count})))}:{},...e==="rewind"&&(o.carriers??[]).length>0?{carriers:(o.carriers??[]).map(s=>({object:s.objectApiName,count:s.count}))}:{},...e==="rewind"&&(o.draftsLeft??[]).length>0?{draftsLeft:(o.draftsLeft??[]).map(s=>({object:s.objectApiName,count:s.count,ids:[...s.ids]}))}:{},...e==="undo"&&(o.carriedAlone??[]).length>0?{carriedAlone:(o.carriedAlone??[]).map(s=>({object:s.objectApiName,count:s.count}))}:{},...o.files?{files:{...o.files}}:{},...o.undo?{undo:{until:o.undo.until,cannot:o.undo.cannot.map(s=>({object:s.objectApiName,count:s.count,...s.reason!==void 0?{reason:s.reason}:{}}))}}:{},verify:{differences:S(o.residual,s=>s.count)+d.length,stable:o.status!=="unstable",passes:o.passes,notCompared:[...t.ignoredFields]},residual:o.residual.map(s=>({object:s.objectApiName,reason:s.reason,...s.by!==void 0?{by:s.by}:{},count:s.count,...s.message!==void 0?{message:s.message}:{}})),unread:d,objects:[...a.values()],apiRequests:o.apiRequests,result:o}}function pn(e,n){switch(e){case"success":return 0;case"partial":return 3;case"unstable":return 4;case"failure":return 1;case"cancelled":return n!==void 0?se(n):1}}var mo=10*6e4,wo=720*6e4,mn=60*6e4,le=5*6e4,It=200,v=class extends Error{constructor(t,o=1,i=[]){super(t.message);this.refusal=t;this.code=o;this.also=i;this.name="Stop"}refusal;code;also};function go(e){let n=[e.refusal,...e.also];return{refusal:e.refusal,...e.also.length>0?{wouldBeRefused:n.map(t=>X(t)),wouldBeRefusedCodes:n.map(t=>t.code)}:{}}}function D(e){return e.message?.payload??{}}function L(e,n){let t=D(e);if(e.outcome==="unanswered")return{code:"UNANSWERED",message:`${n}: no answer came in time.`};let o=typeof t.message=="string"?t.message:JSON.stringify(t),i=typeof t.code=="string"?t.code:e.outcome.toUpperCase(),{holdingLimit:a}=t;return{code:i,message:o,...typeof a=="number"?{holdingLimit:a}:{}}}function ko(e){let n=D(e).alsoRefused;return e.outcome!=="failed"||!Array.isArray(n)?[]:n.flatMap(t=>{let{code:o,message:i}=t??{};return typeof o=="string"&&typeof i=="string"?[{code:o,message:i}]:[]})}async function bo(e=process.argv,n={}){let t=In(e),o=c=>{process[t.json?"stderr":"stdout"].write(`${c}
470
+ `)},i=c=>{t.json&&process.stdout.write(`${JSON.stringify(c,null,2)}
471
+ `)},a=st({root:t.storeRoot,...n.locksDir!==void 0?{locksDir:n.locksDir}:{}});if("refusal"in a){let c=`The checkpoints cannot be kept in ${a.refusal.path}: `+it(a.refusal,t.storeRoot,"--store <folder>");process.stderr.write(`${c}
472
+ `),i({refusal:{code:"STORE_REFUSED",message:c}}),B(1);return}let r=a.store,d=$n(Pt(jn(),"sandforge-checkpoint-")),s=new $t,u=!1,m,w=()=>Promise.resolve(),j,g;try{let c=(n.createHost??yt)({storeDir:d,log:b=>{u&&b.startsWith("[INFO] ")?o(b.slice(7)):b.startsWith("[WARN] ")&&o(`warning: ${b.slice(7)}`)},compose:b=>{b.handlers.setCheckpointStore(r),b.handlers.rewindCheckpointsFromPreviewsAnswered(),b.handlers.setInfraServices({backgroundRegistry:s}),w=()=>b.handlers.sweepCheckpoints(),j=b.handlers,g=b},onPost:b=>{if(b.type!=="operation:progress")return;let $=b.payload?.currentStep;typeof $!="string"||$===m||(m=$,o(` ${$}`))}});u=!0;try{await w()}finally{u=!1}let l=async()=>{let b=await c.request({type:"checkpoint:list",timeoutMs:le});if(b.outcome!=="answered")throw new v(L(b,"The list of checkpoints"));return D(b).checkpoints??[]},k=async b=>{try{return await c.connect(b)}catch($){throw new v({code:"NOT_CONNECTED",message:$ instanceof Je?$.message:`${b} could not be reached: ${$ instanceof Error?$.message:String($)}`})}},A=async b=>{if(g===void 0)throw new Error("The host composed no handlers.");return at(await He(b.id,g.orgRegistry,g.orgManager)).userId()};switch(t.command){case"list":{let b=await l(),$=t.org!==void 0?_(b,t.org):b,f=t.org!==void 0?{org:t.org,kept:b.length}:void 0;for(let p of Ln($,r.root,f))o(p);i($.map(Tn));return}case"take":await jo(t,c,await k(t.org),r,s,o,i);return;case"preview":{let b=await l(),$=ne(K(b,_(b,t.org),t.checkpoint,t.org)),f=xe($);if(f)throw new v(f);let p=$.checkpoint,R=t.objects.length>0?on(p,t.objects):void 0,O=await k(t.org);Le(O,$,p,t.org,"preview");let H=await c.request({type:"checkpoint:preview",payload:{checkpointId:$.checkpointId,...R?{objects:R}:{},acceptOutside:!1},timeoutMs:mn});if(H.outcome!=="answered")throw new v(L(H,"The preview"));let E=D(H),W=R?await he(c,E.diff,R,!1):void 0,q=R?void 0:await nn(c,p,E.diff,!1),P=W??q,oe=P?{...E,diff:P.diff}:E,C=await Zt(c,p,E.diff,P,R,!1),Be=sn(E.refusal,await be({orgName:t.org,preview:oe,bounds:{refuseWhenActive:!1},accepted:co,writers:()=>Promise.resolve([]),words:te,user:O.username})),[Fe]=Be;for(let T of Kt(t.org,p,oe,O.username,!1,C))o(T);for(let T of W?Qt(W.plan):[])o(T);for(let T of q?tn(q.plan):[])o(T);for(let T of Be.slice(E.refusal?1:0))o(` a rewind now would be refused (${T.code}): ${T.message}`);i(Yt(t.org,p,{...E,...Fe?{refusal:Fe}:{}},W,q)),B(oo(W?.diff??E.diff,t.failOnChange));return}case"rewind":case"undo":{let b={host:c,registry:s,store:r,listAll:l,connect:k,userIdOf:A,say:o,answerJson:i};t.command==="rewind"?await Co(t,b):await xo(t,b);return}case"delete":await Ro(t,c,l,o,i);return;case"export":await $o(t,{transfers:Dt(j),listAll:l,say:o,answerJson:i});return;case"import":await vo(t,{transfers:Dt(j),connect:k,say:o,answerJson:i});return;case"replay":await Rt(t.replay,{storeRoot:t.storeRoot,storeNamed:t.storeNamed===!0,store:r,...n.locksDir!==void 0?{locksDir:n.locksDir}:{},listAll:l,checkpointsOf:_,resolve:K,say:o,json:t.json});return;case"replays":await St(t.target,{storeRoot:t.storeRoot,storeNamed:t.storeNamed===!0,say:o,answerJson:i});return}}catch(c){let l=c instanceof v?c:c instanceof ye?new v(c.refusal,c.code):new v({code:"FAILED",message:c instanceof Error?c.message:String(c)});process.stderr.write(`${c instanceof ye?X(c.refusal):l.message}
473
+ `);for(let k of l.also)process.stderr.write(`${X(k)}
474
+ `);l.code!==2&&i(go(l)),B(l.code)}finally{s.dispose(),An(d,{recursive:!0,force:!0})}}function Dt(e){if(e===void 0)throw new Error("The host composed no handlers.");return e}function yo(){try{let e=JSON.parse(vn(Pt(__dirname,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function wn(e){let n=process.env[e];if(n===void 0||n.trim()==="")throw new v({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let t=re(n);if(t===void 0)throw new v({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return t}function gn(e,n){return{id:e.checkpointId,name:e.name,takenAt:e.takenAt,org:n}}async function $o(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?wn(e.keyEnv):void 0,a=await n.listAll(),r=ne(K(a,_(a,e.org),e.checkpoint,e.org)),d=await n.transfers.exportCheckpoint({checkpointId:r.checkpointId,out:e.out,...i!==void 0?{key:i}:{},sandforgeVersion:yo()});if(!d.exported)throw new v(d.refusal);let{checkpoint:s,header:u}=d;t(`exported '${s.name}' (${s.checkpointId}) of ${e.org}, taken ${I(s.takenAt)}: ${h(u.records)} record(s) of ${h(u.objects)} object(s), ${U(d.bytes)}, to ${e.out}`),t(` sha256 ${d.sha256}`),d.key!==void 0&&process.stderr.write(` key, shown this once and kept nowhere: ${d.key}
475
+ `),t(` Anyone who has this file and its key can read the ${h(u.records)} records it holds of ${e.org}, personal data among them. Send the key another way than the file, and only to people who already see all data in ${e.org}.`),t(" The file does not expire: delete it once it has served."),o({checkpoint:gn(s,e.org),file:e.out,bytes:d.bytes,sha256:d.sha256,records:u.records,objects:u.objects,keyShown:d.key!==void 0})}async function vo(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?wn(e.keyEnv):void 0,a=await n.connect(e.org),r=await n.transfers.readCheckpointImport({orgId:a.id,file:e.file});if(r.header!==void 0){let{header:m}=r;t(`the file holds checkpoint ${m.checkpointId}, taken ${I(m.takenAt)}: ${h(m.records)} record(s) of ${h(m.objects)} object(s), ${U(m.bytes)}, exported by SandForge ${m.sandforgeVersion}`)}if(!r.allowed)throw new v(r.refusal.code==="OTHER_ORG"?{...r.refusal,message:`${r.refusal.message} Its replay into ${e.org}: ${jt(e.file,e.org)} --dry-run`}:r.refusal);let d=i??await Ao(),s=await n.transfers.importCheckpoint({orgId:a.id,file:e.file,key:d,keepDays:e.keepDays});if(!s.imported)throw new v(s.refusal);let{checkpoint:u}=s;t(s.outcome==="imported"?`imported '${u.name}' (${u.checkpointId}) of ${e.org}: ${h(ee(u))} record(s) of ${h(u.objects.length)} object(s), ${Ee(u.expiresAt)}`:`'${u.name}' (${u.checkpointId}) is kept on this machine already, the same: left as it is`);for(let m of s.warnings)t(` ${m}`);o({outcome:s.outcome,checkpoint:gn(u,e.org),records:ee(u),objects:u.objects.length,expiresAt:u.expiresAt,warnings:s.warnings})}async function Ao(){let e=await Ke("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new v({code:"DECLINED",message:"No key was typed. Nothing was imported."});let n=re(e);if(n===void 0)throw new v({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was imported."});return n}function ne(e){if("entry"in e)return e.entry;throw"ambiguous"in e?new v({code:"AMBIGUOUS",message:e.ambiguous},2):new v({code:"NOT_FOUND",message:e.none})}async function jo(e,n,t,o,i,a,r){let{take:d}=e;if(e.estimate){let l={orgId:t.id,mode:d.mode,...d.objects?{objects:d.objects}:{},...d.excluded?{excluded:d.excluded}:{},...d.customSettings?{customSettings:d.customSettings}:{},...d.maxTotal!==void 0?{maxTotal:d.maxTotal}:{}},k=await n.request({type:"checkpoint:scope",payload:l,timeoutMs:mo});if(k.outcome!=="answered")throw new v(L(k,"The estimate"));let A=D(k),b={mode:A.mode,objects:A.objects,leftOut:A.leftOut,estimate:A.estimate,...A.refusal?{refusal:Re(A.refusal)}:{},...A.files?{files:A.files}:{},...A.customSettings?{customSettings:A.customSettings}:{}};for(let $ of Fn(e.org,b))a($);r(Bn(b)),B(b.refusal?1:0);return}a(`taking a checkpoint of ${e.org}: it reads every record of its objects (Ctrl-C stops it, and nothing of it is kept)`);let{answer:s,stoppedBy:u}=await Te(i,"the take stops after the read under way, and keeps nothing",()=>n.request({type:"checkpoint:take",payload:{orgId:t.id,...d},timeoutMs:wo}));if(s.outcome!=="answered"){let l=Re(L(s,"The take"));throw u!==void 0&&l.code==="CANCELLED"?new v(l,se(u)):new v(l)}let m=D(s),w=m.checkpoint,j=m.requests,g=m.estimate,c=o.folderOf(w.org.organizationId,w.checkpointId).dir;for(let l of Mn(w,c,d.objects??[]))a(l);j&&a(Hn(j,g)),r({checkpoint:w,...j?{requests:j}:{},...g?{estimate:g}:{}})}async function Ro(e,n,t,o,i){let a=await t(),r=_(a,e.org),d=e.checkpoint===void 0?r:[ne(K(a,r,e.checkpoint,e.org))];if(d.length===0)throw new v({code:"NOT_FOUND",message:`No checkpoint of ${e.org} is kept in the folder read. ${de(e.org)} Nothing was deleted.`});let s=l=>l.checkpoint?`'${l.checkpoint.name}' (${l.checkpointId})`:l.checkpointId;if(!e.yes){let l=d.filter($=>$.undo!==void 0),k=d.length===1?`Delete ${s(d[0])}${d[0].checkpoint?`, taken ${I(d[0].checkpoint.takenAt)},`:""} from this machine? ${e.org} can no longer be rewound to it`:`Delete the ${d.length} checkpoints of ${e.org} from this machine (${y(d.map(s),4)})? ${e.org} can no longer be rewound to them`,A=(await ve(d,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0})).entries,b=`${k}${l.length>0?", and its last rewind can no longer be undone":""}. The org is not touched`+(A.length>0?`, nor the ${A.length===1?"org it was":"orgs they were"} replayed into (${y(A.map($=>$.target.name??$.target.organizationId),4)}), each replay still taken back with --remove`:"")+".";if(!await ze(b))throw new v({code:"DECLINED",message:"Nothing was deleted."})}let u=d.map(l=>l.checkpointId);for(let l=0;l<u.length;l+=It){let k=await n.request({type:"checkpoint:delete",payload:{checkpointIds:u.slice(l,l+It)},timeoutMs:le});if(k.outcome!=="answered"){let A=L(k,"The delete");if(l===0)throw new v(A);o(`refused: ${A.message}`);break}}let m=new Set((await t()).map(l=>l.checkpointId)),w=d.filter(l=>!m.has(l.checkpointId)),j=d.filter(l=>m.has(l.checkpointId));for(let l of w)o(`deleted ${s(l)}`);for(let l of j)o(`kept ${s(l)}: a take, a rewind or an undo of its org is running; delete it once it has ended`);let g=await ve(w,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0});for(let l of g.lines)o(l);let c=e.storeNamed?e.storeRoot:void 0;i({deleted:w.map(l=>l.checkpointId),kept:j.map(l=>l.checkpointId),...g.entries.length>0?{replaysInPlace:g.entries.map(l=>Ct(l,c))}:{}}),j.length>0&&B(w.length>0?3:1)}function Le(e,n,t,o,i){if(Lt(e.orgId,n.organizationId))return;let a=_([n],o).length>0,r=i==="preview"?"preview it":i==="rewind"?"rewind to it":"undo it";throw new v({code:"OTHER_ORG",message:a?`${o} answers as another org than the one '${t.name}' was taken of: a sandbox refreshed since is another org, and this checkpoint no longer rewinds it. ${ue.replace(/\.$/,"")}: ${$e(n.checkpointId,o)} --dry-run. No record was read.`:`'${t.name}' is a checkpoint of ${V(t)}, not of ${o}: ${r} with --org ${V(t)}. No record was read.`})}async function Te(e,n,t){let o,i=e.onEvent((r,d,s)=>{o!==void 0&&d==="started"&&s.module==="checkpoint"&&e.abort(r)}),a=Ye(r=>{o=r,Ve(n,r);for(let d of e.getRunning())d.module==="checkpoint"&&e.abort(d.operationId)});try{let r=await t();return o!==void 0?{answer:r,stoppedBy:o}:{answer:r}}finally{a(),i()}}var kn=720*6e4;function bn(e,n,t=o=>o){let{answer:o,stoppedBy:i}=e;if(o.outcome!=="answered"){let a=t(L(o,n));throw i!==void 0&&a.code==="CANCELLED"?new v(a,se(i)):new v(a,1,ko(o).map(t))}return D(o).result}async function Co(e,n){let{host:t,say:o,answerJson:i}=n,a=await n.listAll(),r=ne(K(a,_(a,e.org),e.checkpoint,e.org)),d=xe(r);if(d)throw new v(d);let s=r.checkpoint,u=e.ignoreFields.filter(C=>!s.ignoredFields.includes(C));if(u.length>0){let C=await t.request({type:"checkpoint:ignore-fields",payload:{checkpointId:r.checkpointId,fields:[...s.ignoredFields,...u]},timeoutMs:le});if(C.outcome!=="answered")throw new v(L(C,"The fields not to compare"));s=D(C).checkpoint,o(`not compared from now on, nor written back: ${u.join(", ")} (kept in '${s.name}')`)}let m=e.objects.length>0?on(s,e.objects):void 0,w=await n.connect(e.org);Le(w,r,s,e.org,"rewind");let j=await t.request({type:"checkpoint:preview",payload:{checkpointId:r.checkpointId,...m?{objects:m}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptOutside:e.acceptOutside},timeoutMs:mn});if(j.outcome!=="answered")throw new v(L(j,"The preview"));let g=D(j),c=m?await he(t,g.diff,m,e.acceptOutside):void 0,l=m?void 0:await nn(t,s,g.diff,e.acceptOutside),k=c??l,A=k?{...g,diff:k.diff}:g,b=await Zt(t,s,g.diff,k,m,e.acceptOutside),$=e.muteAutomation&&A.automation?et(A.automation,qe(Z(A.diff))):void 0,f=$?{...A,automation:$.automation}:A;for(let C of Kt(e.org,s,f,w.username,e.acceptAutomation,b))o(C);for(let C of c?Qt(c.plan):[])o(C);for(let C of l?tn(l.plan):[])o(C);for(let C of $?ae($.planned,e.org):[])o(` ${C}`);let p=lt(f.diff).length>0,R=await be({orgName:e.org,preview:f,bounds:{...e.maxRecords!==void 0?{maxRecords:e.maxRecords}:{},refuseWhenActive:e.refuseWhenActive},accepted:e,writers:async()=>ht(s.takenBy,await n.userIdOf(w)),words:te,user:w.username}),O=sn(f.refusal,R);if(en(s,f.diff,e.acceptOutside)&&o(" without --accept-outside, the records they hang from stay, and so do they: each is said once the rewind is through"),e.dryRun){for(let C of O.slice(f.refusal?1:0))o(` a rewind now would be refused (${C.code}): ${C.message}`);i({...Yt(e.org,s,g,c,l),...$?{mutedAutomation:$.planned,mutePlan:$.plan}:{},...O.length>0?{wouldBeRefused:O.map(C=>X(C)),wouldBeRefusedCodes:O.map(C=>C.code)}:{}});return}let[E,...W]=O;if(E)throw new v(E,1,W);if(p&&!e.yes&&await pe(ho(e.org,s,f.diff,m))!==e.org)throw new v({code:"DECLINED",message:"Nothing was written."});let q=await Te(n.registry,"the rewind stops before its next call to the org, and leaves its journal: rewind again takes up from what still differs",()=>t.request({type:"checkpoint:rewind",payload:{checkpointId:r.checkpointId,previewId:f.diff.previewId,...m?{objects:m}:{},acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptNoUndo:e.acceptNoUndo,acceptRecreate:e.acceptRecreate,acceptOutside:e.acceptOutside,acceptUnseen:e.acceptUnseen},timeoutMs:kn})),P=bn(q,"The rewind",C=>C.code==="CANCELLED"?{...C,message:dn(e.org,s.name)}:ao(C)),oe=e.storeRoot!==we()?e.storeRoot:void 0;for(let C of fo(e.org,s,P,f.diff.userNames,oe))o(C);for(let C of P.mutedAutomation?ae(P.mutedAutomation,e.org):[])o(C);i(fn("rewind",e.org,s,P,f.diff)),B(pn(P.status,q.stoppedBy))}function So(e,n,t,o,i){return`undo the rewind ${t} of ${e} to '${n.name}' (open until ${I(o)}, sooner if the recycle bin fills)`+(i?`: it brings back ${h(i.bringBack-(i.cannot??0))} record(s) the rewind deleted`+((i.bringBackAlong??0)>0?`, with the ${h(i.bringBackAlong??0)} that went with them`:"")+((i.cannot??0)>0?` \u2014 and tries ${h(i.cannot??0)} more, which the rewind said Undo couldn't bring back \u2014`:"")+`, gives ${h(i.giveBack)} record(s) back the values they had before it, and sends ${h(i.remove-i.remade)} record(s) it brought back to the recycle bin`+(i.along>0?", with what came back with them":"")+(i.remade>0?`, deleting again the ${h(i.remade)} record(s) it made again`:"")+(i.drafted>0?` \u2014 of them, ${h(i.drafted)} order(s) set back to Draft first if past it, the one way Salesforce deletes one: an update, which what runs on an order's update fires on`:"")+"; what anyone changed since the rewind stays":"")}async function Oo(e,n,t,o){try{let i=e.folderOf(n.organizationId,n.checkpointId),a=await wt(i,o,t.objects);try{let r=kt(await mt(i,o),t.objects).reduce((d,{count:s})=>d+s,0);return{...r>0?{cannot:r}:{},bringBack:a.bringBack.count,bringBackAlong:a.comesWithParent.count,giveBack:a.giveBack.count,remove:a.remove.spool.count,along:a.goesWithParent.count,remade:a.remade.keys.size,drafted:a.remade.objects.filter(({objectApiName:d})=>me([d]).length>0).reduce((d,{count:s})=>d+s,0)}}finally{await a.dispose()}}catch{return}}async function xo(e,n){let{host:t,say:o,answerJson:i}=n,a=await n.listAll(),r=_(a,e.org),d=e.checkpoint===void 0?r.find(k=>k.undo!==void 0):ne(K(a,r,e.checkpoint,e.org));if(!d)throw new v({code:"NOT_FOUND",message:`No rewind of ${e.org} can be undone from this machine: Undo is offered for the last rewind of an org, for 15 days after it, until it is undone. Nothing was written.`});let s=xe(d);if(s)throw new v(s);let u=d.checkpoint;if(!d.undo)throw new v({code:"UNDO_CLOSED",message:`'${u.name}' has no rewind that can be undone: Undo is offered for the last rewind of an org only, for 15 days after it, until it is undone. Nothing was written.`});let{rewindId:m,until:w}=d.undo,j=await Oo(n.store,d,u,m);o(So(e.org,u,m,w,j));let g=await n.connect(e.org);if(Le(g,d,u,e.org,"undo"),!e.yes&&await pe(`Type ${e.org} to undo its rewind:`)!==e.org)throw new v({code:"DECLINED",message:"Nothing was written."});let c=await Te(n.registry,"the undo stops before its next call to the org: undo again takes up what it left",()=>t.request({type:"checkpoint:undo",payload:{checkpointId:d.checkpointId,rewindId:m,acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}},timeoutMs:kn})),l=bn(c,"The undo",k=>k.code==="CANCELLED"?{...k,message:cn(e.org)}:ro(k));for(let k of po(e.org,u,l))o(k);for(let k of l.mutedAutomation?ae(l.mutedAutomation,e.org):[])o(k);i(fn("undo",e.org,u,l)),B(pn(l.status,c.stoppedBy))}process.argv[1]?.includes("sandforge-checkpoint")&&(ct(),bo().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
476
+ `),process.exit(1)}));export{En as a,In as b,_ as c,K as d,xe as e,Ne as f,Ln as g,Tn as h,Bn as i,Re as j,Fn as k,Mn as l,Hn as m,Jt as n,De as o,Kt as p,Yt as q,oo as r,so as s,Qt as t,en as u,tn as v,on as w,li as x,ho as y,fo as z,po as A,fn as B,pn as C,bo as D,So as E};