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
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f}from"./chunk-SRPWW4A2.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-NTOVCTRS.mjs";export{c as DEFAULT_READ_BUDGET,d as MetadataCompare,f as firstDifference,b as installedByPackage,a as isInstalledByPackage,e as planReads};
7
+ import{a,b,c,d,e}from"./chunk-DB7JNALQ.mjs";import"./chunk-PE7CHD2W.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-NTOVCTRS.mjs";export{c as MetadataCompare,e as firstDifference,b as installedByPackage,a as isInstalledByPackage,d as planReads};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f}from"./chunk-YV7JYHJP.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Z354SAEF.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-THYQOG24.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CRPLDXJU.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
7
+ import{a,b,c,d,e,f}from"./chunk-ZIKLQZBG.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SZOJ7BEJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{b as c,j as o,k as d}from"./chunk-3EOIAC2M.mjs";import{b as i}from"./chunk-CA5NAXSU.mjs";import{o as a}from"./chunk-CRPLDXJU.mjs";var u=6e4,g=class{tokenCache=new Map;sfdxBridge;setSfdxBridge(e){this.sfdxBridge=e}async authenticate(e){switch(e.method){case"oauth_web":return this.authenticateOAuth(e);case"oauth_device":return{success:!1,error:"OAuth device flow handled via DeviceLogin and SfdxBridge.loginWithRefreshToken()"};case"jwt":return this.authenticateJwt(e);case"usernamePassword":return this.authenticateUsernamePassword(e);case"sfdx_import":return this.importFromSfdx(e.username);default:return{success:!1,error:`Unsupported auth method: ${e.method}`}}}buildConnectionConfig(e,r){return{loginUrl:e.loginUrl,clientId:e.clientId,clientSecret:e.clientSecret,accessToken:r.accessToken,refreshToken:r.refreshToken,instanceUrl:r.instanceUrl,username:e.username}}async validateConnection(e,r){let t=await o({accessToken:e,instanceUrl:r}),{identity:s,orgResult:h}=await c(t,async()=>({identity:await t.identity(),orgResult:await t.query(`SELECT Id, Name, OrganizationType, IsSandbox FROM Organization LIMIT ${a.singleRecord}`)})),n=h.records[0];return{userId:s.user_id,username:s.username,displayName:s.display_name,orgId:n.Id,orgName:n.Name,orgType:n.OrganizationType,isSandbox:n.IsSandbox}}isTokenValid(e){let r=this.tokenCache.get(e);return r?Date.now()<r.expiresAt:!1}cacheToken(e,r,t){this.tokenCache.set(e,{token:r,expiresAt:Date.now()+t})}getCachedToken(e){let r=this.tokenCache.get(e);if(!r||Date.now()>=r.expiresAt){this.tokenCache.delete(e);return}return r.token}clearTokenCache(e){this.tokenCache.delete(e)}clearAllTokens(){this.tokenCache.clear()}async authenticateOAuth(e){return{success:!1,error:"OAuth handled via SfdxBridge.loginWeb()"}}async authenticateJwt(e){return{success:!1,error:"JWT handled via SfdxBridge.loginJwt()"}}async authenticateUsernamePassword(e){if(!e.username||!e.password)return{success:!1,error:"Username and password are required"};try{let r=await o({loginUrl:e.loginUrl}),t=await d(r.login(e.username,e.password+(e.securityToken??"")),u,`${new URL(e.loginUrl).host} did not answer within ${u/1e3} s: check that this machine reaches it, through its proxy if it has one`);return{success:!0,accessToken:r.accessToken??void 0,instanceUrl:r.instanceUrl,userId:t.id,orgId:t.organizationId}}catch(r){return{success:!1,error:`Login failed: ${i(r)}`}}}async importFromSfdx(e){if(!this.sfdxBridge)return{success:!1,error:"SFDX bridge not configured"};if(!e)return{success:!1,error:"An SFDX import needs the username of the org to import"};try{let r=await this.sfdxBridge.findOrg(e);return r?{success:!0,accessToken:r.credentials.accessToken,instanceUrl:r.credentials.instanceUrl,orgId:r.org.orgId}:{success:!1,error:`No connected org for ${e} found in SF CLI`}}catch(r){return{success:!1,error:`SFDX import failed: ${i(r)}`}}}};export{g as a};
7
+ import{b as c,j as o,k as d}from"./chunk-OT2NHL2V.mjs";import{b as i}from"./chunk-CA5NAXSU.mjs";import{o as a}from"./chunk-J347SPU6.mjs";var u=6e4,g=class{tokenCache=new Map;sfdxBridge;setSfdxBridge(e){this.sfdxBridge=e}async authenticate(e){switch(e.method){case"oauth_web":return this.authenticateOAuth(e);case"oauth_device":return{success:!1,error:"OAuth device flow handled via DeviceLogin and SfdxBridge.loginWithRefreshToken()"};case"jwt":return this.authenticateJwt(e);case"usernamePassword":return this.authenticateUsernamePassword(e);case"sfdx_import":return this.importFromSfdx(e.username);default:return{success:!1,error:`Unsupported auth method: ${e.method}`}}}buildConnectionConfig(e,r){return{loginUrl:e.loginUrl,clientId:e.clientId,clientSecret:e.clientSecret,accessToken:r.accessToken,refreshToken:r.refreshToken,instanceUrl:r.instanceUrl,username:e.username}}async validateConnection(e,r){let t=await o({accessToken:e,instanceUrl:r}),{identity:s,orgResult:h}=await c(t,async()=>({identity:await t.identity(),orgResult:await t.query(`SELECT Id, Name, OrganizationType, IsSandbox FROM Organization LIMIT ${a.singleRecord}`)})),n=h.records[0];return{userId:s.user_id,username:s.username,displayName:s.display_name,orgId:n.Id,orgName:n.Name,orgType:n.OrganizationType,isSandbox:n.IsSandbox}}isTokenValid(e){let r=this.tokenCache.get(e);return r?Date.now()<r.expiresAt:!1}cacheToken(e,r,t){this.tokenCache.set(e,{token:r,expiresAt:Date.now()+t})}getCachedToken(e){let r=this.tokenCache.get(e);if(!r||Date.now()>=r.expiresAt){this.tokenCache.delete(e);return}return r.token}clearTokenCache(e){this.tokenCache.delete(e)}clearAllTokens(){this.tokenCache.clear()}async authenticateOAuth(e){return{success:!1,error:"OAuth handled via SfdxBridge.loginWeb()"}}async authenticateJwt(e){return{success:!1,error:"JWT handled via SfdxBridge.loginJwt()"}}async authenticateUsernamePassword(e){if(!e.username||!e.password)return{success:!1,error:"Username and password are required"};try{let r=await o({loginUrl:e.loginUrl}),t=await d(r.login(e.username,e.password+(e.securityToken??"")),u,`${new URL(e.loginUrl).host} did not answer within ${u/1e3} s: check that this machine reaches it, through its proxy if it has one`);return{success:!0,accessToken:r.accessToken??void 0,instanceUrl:r.instanceUrl,userId:t.id,orgId:t.organizationId}}catch(r){return{success:!1,error:`Login failed: ${i(r)}`}}}async importFromSfdx(e){if(!this.sfdxBridge)return{success:!1,error:"SFDX bridge not configured"};if(!e)return{success:!1,error:"An SFDX import needs the username of the org to import"};try{let r=await this.sfdxBridge.findOrg(e);return r?{success:!0,accessToken:r.credentials.accessToken,instanceUrl:r.credentials.instanceUrl,orgId:r.org.orgId}:{success:!1,error:`No connected org for ${e} found in SF CLI`}}catch(r){return{success:!1,error:`SFDX import failed: ${i(r)}`}}}};export{g as a};
@@ -0,0 +1,10 @@
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{G as Me,m as xe,n as Ie}from"./chunk-3LRFPGYZ.mjs";import{e as S,f as G,g as Fe,l as v,m as Le}from"./chunk-DLSU66MY.mjs";import{a as le}from"./chunk-ATQML7ZK.mjs";import{b as W}from"./chunk-GP5J3DGS.mjs";import{dc as We,nb as $e,pb as te,rb as Ue}from"./chunk-OLCS7JCT.mjs";import{l as Te}from"./chunk-TQ6HEJ73.mjs";import{a as Be,b as ue,f as Ne}from"./chunk-INIT2UKJ.mjs";import{k as Pe,l as ve,m as _e}from"./chunk-ATBQIE2V.mjs";import{da as ee,ea as De}from"./chunk-SZOJ7BEJ.mjs";import{b as T}from"./chunk-CA5NAXSU.mjs";import{$c as je}from"./chunk-J347SPU6.mjs";import{b as P,e as Z,f as z,k as Ee,l as B}from"./chunk-WZQEK4WT.mjs";var Et={hipaa:"PHI",pci:"PCI",gdpr:"PII",ccpa:"PII",pii:"PII",coppa:"PII",personalinfo:"PII"},jt=["PHI","PCI","PII"],Dt=["Public","Internal"];function Tt(e){if(e.complianceGroups.length>0){let r=new Set(e.complianceGroups.map(i=>Et[i.toLowerCase()]??"PII"));return jt.find(i=>r.has(i))??"PII"}let t=e.securityClassification?.trim();return t===void 0||t===""||Dt.some(r=>r.toLowerCase()===t.toLowerCase())?void 0:"Confidential"}function Bt(e){let t=Tt(e);if(t!==void 0)return{complianceGroups:[...e.complianceGroups],...e.securityClassification!==void 0?{sensitivityLevel:e.securityClassification}:{},classification:t}}function Ge(e){if(/__pc$/i.test(e))return e.replace(/__pc$/i,"__c");let t=/^Person([A-Z]\w*)$/.exec(e);if(!(t===null||/__/.test(e)))return t[1]}function qe(e){for(let t of e.fields.values())if(Ge(t.name)!==void 0)return!0;return!1}function He(e,t,n){let r=new Map,i=e.toLowerCase()==="account";for(let[o,s]of t.fields){let a=s,l=i?Ge(s.name):void 0,c=l!==void 0?n?.fields.get(l.toLowerCase()):void 0;if(c!==void 0){let b=[...s.complianceGroups];for(let h of c.complianceGroups)b.some(D=>D.toLowerCase()===h.toLowerCase())||b.push(h);let j=c.securityClassification??s.securityClassification;a={complianceGroups:b,...j!==void 0?{securityClassification:j}:{}}}let f=Bt(a);f!==void 0&&r.set(o,{name:s.name,classification:f})}return r}var vt=B({EntityDefinition:B({QualifiedApiName:P()}).loose().nullish(),QualifiedApiName:P(),ComplianceGroup:P().nullish(),SecurityClassification:P().nullish(),BusinessStatus:P().nullish(),IsFieldHistoryTracked:z().nullish()}).loose(),_t="SELECT EntityDefinition.QualifiedApiName, QualifiedApiName, ComplianceGroup, SecurityClassification, BusinessStatus, IsFieldHistoryTracked FROM FieldDefinition";function Ke(e){let t=e.map(n=>`'${je(n)}'`).join(", ");return`${_t} WHERE EntityDefinition.QualifiedApiName IN (${t})`}var xt=10;function It(e){let t=[],n=[];for(let r of e){let i=[...n,r],o=n.length>=xt||Be(Ke(i))>14e3;n.length>0&&o?(t.push(n),n=[r]):n=i}return n.length>0&&t.push(n),t}function Mt(e){return e==null?[]:e.split(";").map(t=>t.trim()).filter(t=>t!=="")}function Qe(e){return e==null||e.trim()===""?void 0:e}function Ft(e){let t={name:e.QualifiedApiName,complianceGroups:Mt(e.ComplianceGroup),historyTracked:e.IsFieldHistoryTracked===!0},n=Qe(e.SecurityClassification);n!==void 0&&(t.securityClassification=n);let r=Qe(e.BusinessStatus);return r!==void 0&&(t.businessStatus=r),t}async function ze(e,t,n){n();let r=await e.query(Ke(t)),i=[...r.records];for(;!r.done;){if(r.nextRecordsUrl===void 0||e.more===void 0)throw new Error("FieldDefinition answered more than one page");n(),r=await e.more(r.nextRecordsUrl),i.push(...r.records)}let o=new Map(t.map(a=>[a.toLowerCase(),a])),s=new Map(t.map(a=>[a,new Map]));for(let a of i){let l=vt.safeParse(a);if(!l.success)throw new Error("FieldDefinition answered a row with no field name");let c=l.data.EntityDefinition?.QualifiedApiName,f=c!==void 0?o.get(c.toLowerCase()):t.length===1?t[0]:void 0;if(f===void 0)throw new Error("FieldDefinition answered a row of no object asked for");let b=Ft(l.data);s.get(f)?.set(b.name.toLowerCase(),b)}return s}async function fe(e,t){let n=new Map,r=0,i=()=>{r++};for(let o of It([...new Set(t)])){try{for(let[s,a]of await ze(e,o,i))n.set(s,{fields:a});continue}catch(s){if(o.length===1){n.set(o[0],{fields:new Map,refused:T(s)});continue}}for(let s of o)try{n.set(s,{fields:(await ze(e,[s],i)).get(s)??new Map})}catch(a){n.set(s,{fields:new Map,refused:T(a)})}}return{objects:n,requests:r}}function Ve(e,t){return{objects:new Map(e.map(n=>[n,{fields:new Map,refused:t}])),requests:0}}async function lr(e,t){let n=[...new Set(t)];if(e===void 0)return Ve(n,"The org connection cannot read the Tooling API.");let r,i;try{({objects:r,requests:i}=await fe(e,n))}catch(c){return Ve(n,T(c))}let o=n.find(c=>c.toLowerCase()==="account"),s=o!==void 0?r.get(o):void 0,a=n.filter(c=>c.toLowerCase()==="contact").map(c=>r.get(c)).find(c=>c!==void 0);if(s!==void 0&&a===void 0&&qe(s)){let c=await fe(e,["Contact"]);i+=c.requests,a=c.objects.get("Contact")}let l=new Map;for(let c of n){let f=r.get(c);if(f===void 0||f.refused!==void 0){l.set(c,{fields:new Map,refused:f?.refused??"The org did not answer for this object."});continue}l.set(c,{fields:He(c,f,a?.refused===void 0?a:void 0)})}return{objects:l,requests:i,definitions:r}}function fr(e){return{query:async t=>e.tooling.query(t),more:async t=>e.tooling.queryMore(t)}}function Lt(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function gr(e,t){return t?"cancelled":e.every(n=>Lt(n)===0)?"success":e.some(n=>n.deleted>0)?"partial":"failure"}function br(e,t){return e!=="success"||!t||t.status==="success"?e:t.status==="cancelled"?"cancelled":"partial"}function hr(e){return e.status}function Rr(e){return e.filter(t=>t.deleted+t.refused+(t.notReached??0)>0).map(t=>({...Te(t.objectApiName),deleted:t.deleted,failed:t.refused,...(t.notReached??0)>0?{notSent:t.notReached}:{}}))}function yr(e,t,n,r=!1){let i=h=>e.objects.reduce((D,N)=>D+h(N),0),o=i(h=>h.deleted),s=i(h=>h.alreadyGone),a=i(h=>h.keptChanged+h.keptDependents),l=i(h=>h.refused),c=i(h=>h.notVisible??0);if(o+s===0&&(!r||e.status==="cancelled"||a+l+c===0))return;let f=r?void 0:n,b=i(h=>h.platformCopies??0),j=e.status==="cancelled"?Math.max(0,t+b-o-s-a-l-c):0;return{removedAt:e.finishedAt,deleted:(f?.deleted??0)+o,alreadyGone:(f?.alreadyGone??0)+s,kept:a,refused:l,...j>0?{notReached:j}:{},...c>0?{notVisible:c}:{}}}function wr(e,t){let n=i=>e.objects.reduce((o,s)=>o+i(s),0),r=n(i=>i.notVisible??0);return{removedAt:e.finishedAt,deleted:t.deleted,alreadyGone:t.alreadyGone,kept:n(i=>i.keptChanged+i.keptDependents),refused:n(i=>i.refused),...r>0?{notVisible:r}:{}}}function Or(...e){let t=new Set,n=[];for(let r of e.flatMap(i=>i??[])){let i=`${r.first}|${r.last}|${r.userId.slice(0,15)}`;t.has(i)||(t.add(i),n.push(r))}return n.sort((r,i)=>Date.parse(r.first)-Date.parse(i.first))}var me=5;function F(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function M(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Je(e,t){if(!(!e&&!t))return{count:(e?.count??0)+(t?.count??0),objects:F(e?.objects??[],t?.objects??[])}}function Cr(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n});continue}let i={notVisible:M(r.notVisible,n.notVisible),notReached:M(r.notReached,n.notReached),heldByAutomation:M(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:M(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:M(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:M(r.platformCopies,n.platformCopies)},o=F(r.automationHolders??[],n.automationHolders??[]),s=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:F(r.filesLeft?.names??[],n.filesLeft?.names??[],me)}:void 0,a=Je(r.tookAlong,n.tookAlong),l=Je(r.cameAlong,n.cameAlong);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,deleted:r.deleted+n.deleted,alreadyGone:r.alreadyGone+n.alreadyGone,keptChanged:r.keptChanged+n.keptChanged,keptDependents:r.keptDependents+n.keptDependents,refused:r.refused+n.refused,...Object.fromEntries(Object.entries(i).filter(([,c])=>c!==void 0)),heldBy:F(r.heldBy,n.heldBy),...o.length>0?{automationHolders:o}:{},unchecked:F(r.unchecked,n.unchecked),reasons:F(r.reasons,n.reasons,me),...s?{filesLeft:s}:{},...a?{tookAlong:a}:{},...l?{cameAlong:l}:{}})}return[...t.values()]}function Sr(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n,changedBy:{...n.changedBy}});continue}let i={...r.changedBy};for(let[s,a]of Object.entries(n.changedBy))i[s]=(i[s]??0)+a;let o=M(r.platformCopies,n.platformCopies);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,toDelete:r.toDelete+n.toDelete,alreadyGone:r.alreadyGone+n.alreadyGone,changedSince:r.changedSince+n.changedSince,keptChanged:r.keptChanged+n.keptChanged,changedBy:i,undeletable:r.undeletable+n.undeletable,notVisible:r.notVisible+n.notVisible,unread:r.unread+n.unread,...o!==void 0?{platformCopies:o}:{},reasons:F(r.reasons,n.reasons,me)})}return[...t.values()]}import{AsyncLocalStorage as $t}from"node:async_hooks";var Ye=new Set(["delete","hardDelete"]),he=1e4,et=5e4;function Er(e){switch(e){case"production":return;case"staging":return he;case"development":case"scratch":return et}}var tt=new $t;function pe(){let e=tt.getStore();return e?.live?e:void 0}async function jr(e,t){let n={approved:e.approved,live:!0};try{return await tt.run(n,t)}finally{n.live=!1}}var Xe=class{overrides=new Map;options;constructor(t){this.options=t??{}}check(t){let n=this.checkTier(t),{orgNameOf:r}=this.options;return!n.requiresConfirmation||!r?n:{...n,question:Gt(t,r(t.orgId),this.options.questionWords)}}checkTier(t){switch(t.orgTier){case"production":return this.checkProduction(t);case"staging":return this.checkStaging(t);case"development":case"scratch":return this.checkDevelopment(t)}}setProductionOverride(t,n){this.overrides.set(t,n)}isProductionOverridden(t){return this.overrides.get(t)===!0}get canAskForConfirmation(){return this.options.requestConfirmation!==void 0||pe()!==void 0}async confirmIfNeeded(t,n){if(!t.allowed||!t.requiresConfirmation)return t.allowed;let r=pe();return r?r.approved:this.options.requestConfirmation?t.question===void 0?this.options.requestConfirmation(t.impactSummary,n):this.options.requestConfirmation(t.impactSummary,n,t.question):!0}declinedWithoutAsking(t,n){if(!(!t.allowed||!t.requiresConfirmation||pe())&&this.options.requestConfirmation)return this.options.declinesWithoutAsking?.(n)}async confirmRun(t){return this.options.requestRunConfirmation?await this.options.requestRunConfirmation(t)?"confirmed":"declined":"unavailable"}orgPhrase(t,n){let r=this.options.orgNameOf?.(t.orgId);return r?n.org(t.orgTier,r,!0):n.org(t.orgTier,t.orgId,!1)}checkProduction(t){let n=[],r=Ye.has(t.operation),i=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${V(t.recordCount)} ${Ut(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let o=this.options.questionWords??nt;return t.operation==="deploy"?{allowed:!1,requiresConfirmation:!1,blockedReason:o.deployRefused(this.orgPhrase(t,o)),warnings:n,impactSummary:K(t)}:r&&!i?{allowed:!1,requiresConfirmation:!1,blockedReason:o.deleteRefused(t.operation==="hardDelete"?"hardDelete":"delete",this.orgPhrase(t,o)),warnings:n,impactSummary:K(t)}:(r&&i&&n.push("Production override is active \u2014 destructive operation permitted"),{allowed:!0,requiresConfirmation:!0,warnings:n,impactSummary:K(t)})}checkStaging(t){let n=[],r=Ye.has(t.operation),i=t.operation==="deploy",o=r||i||ge(t.recordCount)>he;return r&&n.push(`Destructive operation (${t.operation}) on staging org \u2014 confirmation required`),i&&n.push("Metadata deployment on staging org \u2014 confirmation required"),ge(t.recordCount)>he&&n.push(`Large volume operation: ${V(t.recordCount)} records on staging`),{allowed:!0,requiresConfirmation:o,warnings:n,impactSummary:K(t)}}checkDevelopment(t){let n=[];return ge(t.recordCount)>et&&n.push(`Large volume operation: ${V(t.recordCount)} records on ${t.orgTier} org`),{allowed:!0,requiresConfirmation:!1,warnings:n,impactSummary:K(t)}}};function V(e){return e==="unknown"?"an unknown number of":typeof e=="number"?String(e):`at most ${e.atMost}`}function ge(e){return e==="unknown"?0:typeof e=="number"?e:e.atMost}function Ut(e){return e.operation==="deploy"?"components":"records"}var Dr="the related records the run adds",nt={sentence:(e,t,n)=>{switch(e){case"insert":return`Insert ${t} into ${n}.`;case"update":return`Update ${t} in ${n}.`;case"upsert":return`Insert or update ${t} in ${n}.`;case"delete":return`Delete ${t} in ${n}.`;case"hardDelete":return`Permanently delete ${t} in ${n}.`;case"deploy":return`Deploy ${t} to ${n}.`}},counted:(e,t)=>t==="unknown"?`${e}s`:typeof t=="number"?`${t} ${e}${t===1?"":"s"}`:`at most ${t.atMost} ${e}s`,besides:(e,t)=>`${e}, plus ${t},`,org:(e,t,n)=>n?`the ${e} org "${t}"`:`the ${e} org ${t}`,deployRefused:e=>`SandForge deploys metadata only to a sandbox, a scratch org or a Developer Edition org, not to ${e}: bring the change there through your release process, as a change set or a deployment from source control.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},Wt=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function Gt(e,t,n=nt){let r=e.operation==="deploy"?"component":"record",i=Wt.has(e.objectName)?"":` (${e.objectName})`,o=`${n.counted(r,e.recordCount)}${i}`,s=e.alsoWrites?n.besides(o,e.alsoWrites):o,a=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,s,a)}function K(e){if(e.operation==="deploy")return`DEPLOY ${V(e.recordCount)} component(s) (${e.objectName}) to ${e.orgTier} org ${e.orgId} [module: ${e.module}]`;let t=e.alsoWrites?`, plus ${e.alsoWrites},`:"";return`${e.operation.toUpperCase()} ${V(e.recordCount)} ${e.objectName} record(s)${t} on ${e.orgTier} org ${e.orgId} [module: ${e.module}]`}function ne(e,t){return`${e} ${t}${e===1?"":"s"}`}var qt={cost:({records:e,objects:t,requests:n,seconds:r,megabytes:i,keepDays:o})=>`Checkpoint first: about ${ne(e,"record")} of ${ne(t,"object")}, ${ne(n,"API request")}, ${r} s, ${i} MB on this machine, unencrypted, and none of the org's storage, `+(o===0?"kept until you delete it.":`kept ${ne(o,"day")}.`),added:(e,t)=>`Added: ${e} \u2014 ${t}`,notHeld:(e,t)=>`Not in the checkpoint: ${e} \u2014 ${t}`,more:e=>`\u2026 and ${e} more`,unknown:"What an Apex trigger, or automation that could not be read, creates as the run writes is not known: a rewind leaves those records as they are."},be=10;function Ht(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function Tr(e,t=qt){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:Ht(n.bytes),keepDays:e.keepDays})],i=(o,s)=>{for(let{objectApiName:a,reason:l}of o.slice(0,be))r.push(s(a,l));o.length>be&&r.push(t.more(o.length-be))};return i(e.added,t.added),i(e.notHeld,t.notHeld),r.push(t.unknown),r}var Qt=300,zt=1024,Kt=160,Vt=500,ft=40,Jt=4,Yt=3,Xt=3,Zt=1,en=1e3,tn=1,rt=200,nn=60,rn=50,on=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
8
+ `),sn="IsDeleted = false",mt=4;function an(e){return e.access?.kind==="perObject"?e.access.requests:0}var dn=1,cn=200,un=3,ln=1,fn=1,mn=3,pt=2,pn=3,gn=2e3,bn=100,gt=["Id","SystemModstamp"],it=23,_=2.5,R=.35,hn=1,Rn=.9,w=.5,Ce=.25,x=.86,yn="ContentVersion",wn="ContentDocument",Re=200,ot=150,y={apiRequests:0,seconds:0};function u(e,t){return{apiRequests:e,seconds:e*t}}function J(e){return{apiRequests:e,seconds:g(e,Fe)*R}}function m(...e){return e.reduce((t,n)=>({apiRequests:t.apiRequests+n.apiRequests,seconds:t.seconds+n.seconds}),y)}function g(e,t){return e>0?Math.ceil(e/t):0}function k(e){return g(e,W)}function bt(e){return ue(e,gt).length}function On(e){return e.length>bn?W/4:W}function X(e,t){return g(e,On(t))*bt(t)}function st(e,t){if(e.length===0)return 0;let n=2*(e.length-1)+2+2*(t-1);for(let r of e){let i=JSON.stringify(r,null,2),o=1;for(let s=i.indexOf(`
9
+ `);s>=0;s=i.indexOf(`
10
+ `,s+1))o++;n+=Buffer.byteLength(i,"utf8")+o*2*t}return n}function Cn(e){let t=zt+(e.printsBytes??0),n=[];for(let r of e.objects)t+=r.records*Qt+Le(r.records,2),r.records>0&&(t+=Kt),t+=(r.inBin??0)*on,t+=(r.links??0)*(nn+rn),r.entry!==void 0&&n.push(r.entry);return t+st(n,2)+st(e.leftOut??[],3)}function Wr(e,t,n){let[,...r]=ue(t,gt),i=n==="scanAllLive"?sn:void 0;return r.map(o=>Ne(e,o,i))}function at(e,t){return t.reduce((n,r)=>n+g(e,Math.max(1,r)),0)}function Sn(e,t){if(e.records===0)return{pages:0,reads:0};let n=Math.floor(e.records/t),r=e.records-n*t,i=e.otherGroups??[];return{pages:n+(r>0?1:0),reads:n*at(t,i)+at(r,i)}}function Gr(e){let t=e.objects.length,n=g(e.described,G),r=e.describedAlone??0,i=J(g(e.counted??t,S)),o=(e.countedAlone??0)+g(e.recounted??0,S),s=i.apiRequests+o,a=J(g(t,S)),l=Math.min(e.pageRows,en),c=0,f=0,b=0;for(let E of e.objects){b+=E.records;let O=Sn(E,l);c+=O.pages,f+=O.reads}let j=Y(e.objects.map(E=>q(E.inBin??0))),h=kn(e.objects),D=e.objects.filter(E=>(E.stampedSince??0)>0),N=m(Y(D.flatMap(E=>[q(E.stampedSince??0),1])),J(g(D.length,S))),Q=c+f+(c>0?Zt:0),A=e.annexCalls??0,$={guard:Jt,scope:Yt+n+r,start:Xt,counts:s,bin:j.apiRequests,snapshot:Q+h.apiRequests+A,stability:tn+a.apiRequests+N.apiRequests};return{records:b,apiRequests:Object.values($).reduce((E,O)=>E+O,0),requestsByPhase:$,seconds:Math.ceil(n*_+(r+o+A)*R+i.seconds+a.seconds+j.seconds+N.seconds+h.seconds+c*hn+f*w),bytes:Cn(e)}}function kn(e){let t=e.filter(i=>i.links!==void 0);if(t.length===0)return y;let n=0,r=0;for(let i of t)i.links===null?n+=g(g(i.records,rt),S):r+=i.links??0;return m(Y(t.map(i=>q(i.links??0))),u(n,w),u(g(g(r,rt),S),w))}function q(e){return Math.max(1,g(e,gn))}function Y(e){let t=0,n=0;for(let r=0;r<e.length;r+=S){let i=Math.max(1,...e.slice(r,r+S));t+=1,n+=i-1}return m(u(t,R),u(n,Rn))}function An(e){let t=new Set([...e.held,...e.moved.map(n=>n.objectApiName)]);return m(J(g(e.objects,S)),Y(e.moved.flatMap(({live:n,deleted:r})=>[q(n),q(r)])),J(g(t.size,S)))}function ht(e){let t=e.reduce((n,r)=>n+k(r),0);return m(u(t*(un-1),w),u(t,x))}function En(e){return m(...e.filter(t=>t.records>0).map(({records:t,cascades:n,described:r})=>{let i=k(t);return m(u(r?0:1,_),ht([t]),u(i*g(n,S),R),u(i*ln,w))}))}function ye(e,t){let n=y;for(let r=e;r>0;r-=v){let i=Math.min(r,v);n=m(n,u(pt,R),u(X(i,t),w),u(te([{rows:i}]),x),u(k(i),w))}return n}function jn(e,t,n,r){return e===0||n===0?y:m(u(r?0:1,_),u((n+k(e))*g(t,S),R))}var Rt=B({childRelationships:Ee(B({childSObject:P().optional(),field:P().optional(),cascadeDelete:z().optional(),restrictedDelete:z().optional()}).loose()).nullish()}).loose();function qr(e,t){let n=Rt.parse(e).childRelationships??[],r=n.filter(l=>l.cascadeDelete===!0),i=t?.worked,o={dependents:n.filter(l=>(l.cascadeDelete===!0||l.restrictedDelete===!0)&&(i===void 0||l.childSObject!==void 0&&i.has(l.childSObject))).length,cascades:r.length,cascadeChildren:[...new Set(r.flatMap(l=>l.childSObject===void 0?[]:[l.childSObject]))]};if(t===void 0)return o;let s=n.filter(l=>l.cascadeDelete===!0&&l.childSObject!==void 0&&!t.inCheckpoint.has(l.childSObject.toLowerCase())),a=s.filter(l=>l.childSObject!==void 0&&t.worked?.has(l.childSObject)===!0);return{...o,outside:{all:s.length,worked:a.length}}}function Hr(e,t){return(Rt.parse(e).childRelationships??[]).flatMap(n=>(n.cascadeDelete===!0||n.restrictedDelete===!0)&&n.childSObject!==void 0&&n.field!==void 0&&(t===void 0||t.has(n.childSObject))?[{childSObject:n.childSObject,field:n.field}]:[])}function Se(e,t){return e?.get(t)??{dependents:it,cascades:it}}function Dn(e,t){if(e<xe||t===yn||t===wn)return u(te([{rows:e}]),x);let n=Math.ceil(e/Ie),r=Math.ceil(e/n),i=y;for(let o=e;o>0;o-=r){let s=Math.min(o,r);i=m(i,{apiRequests:Pe({stateReads:_e(s)}),seconds:ve(s)})}return i}function we(e,t=Number.POSITIVE_INFINITY){let n=e.filter(r=>r.records>0);return n.length===0?y:m(u(pn,R),...n.map(({records:r,dependents:i,pointing:o,objectApiName:s})=>{let a=k(r),l=0;for(let c=r;c>0;c-=t){let f=k(Math.min(c,t));l+=f>1?i+Math.min(o??i,i)*f:i}return m(u(1,R),u(a,w),u(l,Ce),yt(s,a,l),Dn(r,s))}))}function Tn(e,t,n){return m(...e.filter(({count:r})=>r>0).map(({objectApiName:r,count:i})=>{let{dependents:o}=Se(t,r),s=i>W?o:0;return m(u(n.has(r)?0:1,_),u(s+o*k(i),Ce))}))}function yt(e,t,n){return e===void 0||ee[e]===void 0||De.has(e)?y:m(u(1,R),u(t,w),u(n,Ce),u(t,x),u(t,w))}function I(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince}function re(e){return e.toBringBack.inBin+e.toBringBack.deletedWhileTaken+se(e)}function se(e){return e.toBringBack.carriers??0}function H(e){return e.toDelete.comesBackWithParent+se(e)}function ie(e){return e.cannotUndo.filter(t=>t.reason==="deletedWithCreatedParent"||t.reason==="deletedWithParentOutside").reduce((t,n)=>t+n.count,0)}function oe(e){return re(e)-se(e)+e.toBringBack.withParent}function wt(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}function Oe(e){return e.cannotUndo.filter(t=>t.reason==="goneForGood").reduce((t,n)=>t+n.count,0)}function L(e){return e.toRecreate??0}function Bn(e){return Oe(e)+L(e)}function Nn(e,t){let n=0;for(let r=e;r>0&&t>0;r-=v){let i=Math.min(r,v);n+=g(t*k(i),S)}return n}function ke(e,t,n){let r=Bn(e);return{objectApiName:e.objectApiName,live:e.toGiveBack.records+e.touched+I(e)+e.unexplained,deleted:oe(e)+H(e)+ie(e),valued:e.toGiveBack.records+e.touched+e.toBringBack.withParent,backTo:oe(e)+se(e)+ie(e)>0||t.undeletable===!1&&r>0,deletes:I(e),scans:r>0&&t.undeletable!==!1,whole:e.schemaDrift!==void 0,outside:n?.get(e.objectApiName)?.outside??{all:e.outside.length,worked:e.outside.length}}}function Pn(e,t,n,r,i=0){let o=ke(e,t,n),s=e.toBringBack,a=r?0:H(e);return{...o,live:e.toGiveBack.records+e.touched+e.unexplained+oe(e)+L(e)+a+i,deleted:Math.max(0,I(e)+H(e)-a-i+ie(e)),valued:e.toGiveBack.records+e.touched+s.inBin+s.withParent+L(e),backTo:ie(e)>0||t.undeletable===!1&&Oe(e)>0,scans:Oe(e)>0&&t.undeletable!==!1,deletes:a+i}}function Ot(e,t,n,r,i,o=0,s,a=0){let l=[],c=[],f=0,b=0,j=0,h=!1,D=0;for(let{objectApiName:A,records:$,fields:E}of e){let O=t.get(A);if(O===void 0){n.has(A)&&l.push({objectApiName:A,live:0,deleted:0});continue}l.push({objectApiName:A,live:O.live,deleted:O.deleted}),f+=X(O.valued,E),O.backTo&&!O.whole&&b++,O.scans&&c.push(Y([q($)])),O.deletes!==0&&(!O.whole&&!O.backTo&&j++,O.outside.all>0&&(h=!0),D+=Nn(O.deletes,O.outside.worked))}s!==void 0&&(h=!0);let N=s!==void 0?1:0,Q=i===void 0?g(e.length+N,G):g(i.first+N,G)+g(i.later,G);return m(u(dn,R),u(Q,_),An({objects:e.length,held:e.filter(A=>A.records>0).map(A=>A.objectApiName),moved:l}),u(f,w),u(g(b,G),_),u(j,R),u(h?1:0,_),u(D,R),u(o,R),u(a,R),u(s?.requests??0,w),...c,u(g(g(r,cn),S),R))}function Ct(e){return e.files!==void 0?{requests:e.filesRequests??0}:void 0}function St(e,t){let n=new Map(e.diff.objects.map(i=>[i.objectApiName,i])),r=new Map;for(let i of e.objects){let o=n.get(i.objectApiName);o&&r.set(i.objectApiName,t(o,i))}return r}function vn(e){let t=new Set(e.diff.objects.flatMap(n=>Object.keys(n.lastChangedBy)));return Ot(e.objects,St(e,(n,r)=>ke(n,r,e.relationships)),new Set(e.diff.unread.map(n=>n.objectApiName)),t.size,e.diff.described,e.diff.parentsOutsideRequests??0,Ct(e.diff),e.diff.fieldsRequests??0)}function dt(e,t,n=!1){let r=new Map((e.kept??[]).map(({objectApiName:a,count:l})=>[a,l])),i=!t&&(n||e.diff.objects.some(a=>H(a)>0))||r.size>0,o=e.diff.described,s=new Set(e.diff.objects.map(a=>a.objectApiName));return Ot(e.objects,St({...e,diff:e.readDiff??e.diff},(a,l)=>s.has(a.objectApiName)?Pn(a,l,e.relationships,t,r.get(a.objectApiName)):ke(a,l,e.relationships)),new Set(e.diff.unread.map(a=>a.objectApiName)),i?1:0,o===void 0?void 0:{first:o.first+o.later,later:0},e.diff.parentsOutsideRequests??0,Ct(e.diff),e.diff.fieldsRequests??0)}function _n(e){return m(...e.filter(t=>t>0).map(t=>m(u(1,R),u(k(t),x))))}var xn=new Set(["activateddate","activatedbyid"]);function In(e){return m(...e.filter(({objectApiName:t,records:n})=>n>0&&ee[t]!==void 0).map(({records:t})=>m(u(1,R),u(k(t),x))))}function Mn(e,t){return e*Vt+t*ft}function ct(e){return m(u(pt,R),u(bt(e),w),u(1,x),u(1,w))}function Fn(e,t,n,r){if(t===0)return y;let i=e==="Order"?n.find(c=>c.toLowerCase()==="status"):void 0,o=i===void 0?[]:[i],s=c=>m(ye(c,n),i?ye(c,o):y),a=m(ct(n),i?ct(o):y),l=u(X(t,n),w);return m(s(t),r.held?m(l,a):y,r.held&&r.twice?m(s(t),a):y,r.nextPass?m(l,a):y)}function ut(e,t,n,r){let i=r?.get(n.objectApiName)?.cascadeChildren;return i!==void 0?i.includes(t):e?.cascadeParents!==void 0&&e.cascadeParents.length===0?!1:e?.readOrder!==void 0&&n.readOrder!==void 0?e.readOrder<n.readOrder:!0}function Ln(e){let t=e.diff.objects,n=new Map(e.objects.map(d=>[d.objectApiName,d])),r=d=>Se(e.relationships,d),i=e.diff.undoCannot?e.diff.undoCannot.reduce((d,{objectApiName:p,count:C})=>d.set(p,(d.get(p)??0)+C),new Map):void 0,o=e.diff.withParentDeleted?new Map(e.diff.withParentDeleted.map(({objectApiName:d,count:p})=>[d,p])):void 0,s=new Map((e.kept??[]).map(({objectApiName:d,count:p})=>[d,p])),a=d=>Math.max(0,l(d)-(s.get(d.objectApiName)??0)),l=d=>{if(o!==void 0)return Math.max(0,I(d)-(o.get(d.objectApiName)??0));if(i===void 0||n.get(d.objectApiName)?.undeletable!==!1)return I(d);let p=(i.get(d.objectApiName)??0)-d.toDelete.comesBackWithParent;return Math.max(0,Math.min(I(d),p))},c=t.filter(d=>a(d)>0),f=t.filter(d=>H(d)>0),b=(d,p)=>p.some(C=>C.objectApiName!==d.objectApiName&&ut(n.get(C.objectApiName),C.objectApiName,d,e.relationships)),j=(d,p)=>p.some(C=>{let U=n.get(C.objectApiName);return U!==void 0&&C.objectApiName!==d.objectApiName&&ut(d,d.objectApiName,U,e.relationships)}),h=t.reduce((d,p)=>d+k(re(p)),0),D=e.duplicateSets??0,N=e.reusesPreview!==!0&&t.some(d=>I(d)>0&&(e.relationships?.get(d.objectApiName)?.outside?.all??d.outside.length)>0),Q=t.some(d=>re(d)>0&&r(d.objectApiName).cascades>0),A=t.map(d=>{let p=o?.get(d.objectApiName)??0;if(p===0)return y;let{dependents:C,pointing:U}=r(d.objectApiName),de=k(p),ce=yt(d.objectApiName,de,de>1?C+Math.min(U??C,C)*de:C);return ce.apiRequests>0&&a(d)===0?m(ce,u(1,_)):ce}),$=new Set(e.unpicked??[]),E=u(mn*t.filter((d,p)=>$.has(d.objectApiName)&&(a(d)>0||A[p].apiRequests>0)).length,R),O=m(E,...A,u(Q&&!N?1:0,_),En(t.map(d=>({records:re(d),cascades:r(d.objectApiName).cascades,described:e.reusesPreview!==!0}))),...t.map(d=>jn(d.toBringBack.withParent,r(d.objectApiName).cascades,h,e.reusesPreview!==!0)),...t.map(d=>{let p=n.get(d.objectApiName);return p===void 0?y:Fn(d.objectApiName,wt(d),p.fields,{held:b(p,c),twice:j(p,c),nextPass:b(p,f)})}),_n(t.map(L)),In(t.map(d=>({objectApiName:d.objectApiName,records:L(d)}))),u(D>0?2+g(D,W):0,w),we([...t.map(d=>({objectApiName:d.objectApiName,records:a(d),dependents:r(d.objectApiName).dependents,pointing:r(d.objectApiName).pointing})),{objectApiName:Me,records:D,dependents:1}],le)),ae=t.flatMap(d=>{let p=n.get(d.objectApiName),C=L(d);return C===0||p===void 0?[]:ee[d.objectApiName]===void 0?[]:p.fields.some(U=>xn.has(U.toLowerCase()))?[ye(C,p.fields)]:[]}),At=f.length>0||ae.length>0?m(we(f.map(d=>({objectApiName:d.objectApiName,records:H(d),dependents:r(d.objectApiName).dependents,pointing:r(d.objectApiName).pointing})),le),...ae,dt(e,!0)):y;return m(u(fn,R),O,Un(e.diff.files),dt(e,!1,ae.length>0),At)}function $n(e){return e===void 0?0:e.unlink+e.relink+e.updateLinks}function Un(e){return e===void 0?y:u(g(e.unlink,Re)+g(e.relink,Re)+g(e.updateLinks,Re),x)}function Qr(e){let t=e.diff.objects,n=t.reduce((f,b)=>f+I(b)+b.toDelete.comesBackWithParent,0),r=t.reduce((f,b)=>f+b.toGiveBack.records,0),i=t.reduce((f,b)=>f+oe(b),0),o=t.reduce((f,b)=>f+L(b),0),s=n+r+i+o,a=m(u(mt+an(e.diff),R),e.reusesPreview===!0?y:vn({...e,diff:e.readDiff??e.diff})),l=e.diff.files;if(s===0&&$n(l)===0)return{records:0,apiRequests:a.apiRequests,seconds:Math.ceil(a.seconds),bytes:0};let c=m(a,u(e.automationRequests,w),u(e.deliverabilityRequests??0,R),u(e.muteRequests??0,R),Ln(e));return{records:s,apiRequests:c.apiRequests,seconds:Math.ceil(c.seconds),bytes:Mn(t.reduce((f,b)=>f+wt(b),0),n+i+2*o)+Wn(l)}}function Wn(e){return e===void 0?0:e.unlink*ot+e.relink*ft+e.updateLinks*ot}var Gn=1;function lt(e,t){let n=y;for(let r=e;r>0;r-=v){let i=Math.min(r,v);n=m(n,u(Gn,R),u(X(i,t),w),u(te([{rows:i}]),x))}return n}function qn(e,t){let n=Math.min(e.givenBackHeld??0,e.givenBack),r=y;for(let i=e.givenBack;i>0;i-=v)r=m(r,u(X(Math.min(i,v),t),w));return m(lt(n,t),lt(e.givenBack-n,t),r)}var Hn=2;function Qn(e){let t=Math.min(e.givenBackHeld??0,e.givenBack);return u(k(e.givenBack)+k(t)+k(e.givenBack-t),w)}function zr(e){let t=new Map(e.objects.map(c=>[c.objectApiName,c.fields])),n=e.rewound.reduce((c,f)=>c+f.deleted+f.broughtBack+f.givenBack,0),r=u(mt,R);if(n===0)return{records:0,apiRequests:r.apiRequests,seconds:Math.ceil(r.seconds),bytes:0};let i=e.rewound.some(c=>c.deleted>0),o=e.rewound.some(c=>c.givenBack>0),s=new Set(e.rewound.filter(c=>c.broughtBack>0).map(c=>c.objectApiName)),a=i&&o?m(u(Hn,R),...e.rewound.map(Qn)):y,l=m(r,u(e.automationRequests,w),a,we(e.rewound.map(c=>({objectApiName:c.objectApiName,records:c.broughtBack,dependents:Se(e.relationships,c.objectApiName).dependents}))),s.size>0?Tn(e.along??[],e.relationships,s):y,ht(e.rewound.map(c=>c.deleted)),...e.rewound.map(c=>qn(c,t.get(c.objectApiName)??[])));return{records:n,apiRequests:l.apiRequests,seconds:Math.ceil(l.seconds),bytes:0}}var zn={take:{what:"This checkpoint",then:"Take it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or pick fewer objects.",done:"No record was read."},rewind:{what:"This rewind",then:"Rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or rewind fewer of its objects at a time, which sends only theirs (the objects ticked in the preview, or --object on a command line).",done:"No record was read or written."},undo:{what:"This undo",then:"Undo the rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 while the recycle bin still holds what it brings back.",done:"No record was read or written."}},Kn=B({FileStorageMB:B({Max:Z(),Remaining:Z()}).loose()}).loose(),Vn=B({DataStorageMB:B({Max:Z().int().nonnegative()}).loose()}).loose();async function Kr(e,t){let n,r;try{n=await e.request({method:"GET",url:"/limits"}),r=await $e({request:()=>Promise.resolve(n)})}catch(a){throw new Error(`${t} did not say how many API requests it has left today: ${T(a)}`)}let i;try{i=await We({request:()=>Promise.resolve(n)})}catch(a){i={unread:T(a)}}let o=Kn.safeParse(n),s=Vn.safeParse(n);return{...r,emails:i,...o.success?{fileStorage:{max:o.data.FileStorageMB.Max,remaining:o.data.FileStorageMB.Remaining}}:{},...s.success?{dataStorageMaxMB:s.data.DataStorageMB.Max}:{}}}var Jn={mute:e=>`to assign and take back the permission sets that mute ${e}'s automation`,deliverability:e=>`to read whether ${e} delivers its emails`};function Yn(e,t){if(e===void 0)return"";let n=Object.entries(Jn).flatMap(([r,i])=>{let o=e[r]??0;return o>0&&i?[{requests:o,words:i(t)}]:[]}).map(({requests:r,words:i},o)=>`${r}${o===0?" of them":""} ${i}`);return n.length>0?` (${n.join(", ")})`:""}function Vr(e,t,n,r){let i=Ue(t,n);if(i.verdict!=="exceeds")return;let o=zn[e];return{code:"API_BUDGET",message:`${o.what} takes about ${i.estimate} API requests${Yn(i.parts,r)}; ${r} has ${n.remaining} of its ${n.max} left today. ${o.then} ${o.done}`}}var Xn={rewind:{then:"Free file storage, then rewind again.",done:"Nothing was written."},undo:{then:"Free file storage, then undo the rewind again while the recycle bin still holds them.",done:"Nothing was written."}};function Zn(e){let t=e/1048576;return t<1?`${Math.max(1,Math.round(t*10))/10} MB`:`${Math.ceil(t)} MB`}function Jr(e,t,n,r){if(n===void 0||t.files===0||t.bytes<=n*1048576)return;let i=Xn[e];return{code:"FILE_STORAGE",message:`Bringing back ${t.files===1?"1 file":`${t.files} files`} takes ${Zn(t.bytes)} of file storage; ${r} has ${n} MB left. ${i.then} ${i.done}`}}import{randomUUID as er}from"node:crypto";var Ae="\0configStore:revision",tr="\0configStore";function nr(e){let t=e[Ae]?.value;if(t!==void 0)try{let n=JSON.parse(t);return typeof n.writer=="string"&&typeof n.write=="number"?{writer:n.writer,write:n.write}:void 0}catch{return}}var kt=class{backend;logWarning;writer=er();writes=0;written;constructor(t,n){this.backend=t,this.logWarning=n}initialize(){this.backend.getData()}get(t){let n=this.current()[t];if(n)try{return JSON.parse(n.value)}catch(r){let i=T(r);this.logWarning?.(`[ConfigStore] Failed to parse JSON for key "${t}": ${i}`);return}}set(t,n,r="general"){let i=JSON.stringify(n);this.update(o=>{let s=o[t];return s&&s.value===i&&s.category===r?!1:(o[t]={value:i,category:r},!0)})}delete(t){return this.update(n=>t in n?(delete n[t],!0):!1)}has(t){return t in this.current()}getByCategory(t){let n={};for(let[r,i]of Object.entries(this.current()))if(i.category===t)try{n[r]=JSON.parse(i.value)}catch(o){let s=T(o);this.logWarning?.(`[ConfigStore] Corrupted entry in category "${t}", key "${r}": ${s}`)}return n}getAllKeys(){return Object.keys(this.current()).filter(t=>t!==Ae)}getKeysByPrefix(t){return this.getAllKeys().filter(n=>n.startsWith(t))}clearCategory(t){let n=0;return this.update(r=>{for(let[i,o]of Object.entries(r))o.category===t&&(delete r[i],n++);return n>0}),n}clearAll(){this.write({})}current(){let t=this.backend.getData(),n=nr(t);return this.written&&n?.writer===this.writer&&n.write<this.writes?this.written:t}update(t){let n={...this.current()},r=t(n);return r&&this.write(n),r}write(t){this.writes+=1,t[Ae]={value:JSON.stringify({writer:this.writer,write:this.writes}),category:tr},this.backend.setData(t),this.written=t}};export{Tt as a,fe as b,lr as c,fr as d,gr as e,br as f,hr as g,Rr as h,yr as i,wr as j,Or as k,Cr as l,Sr as m,Er as n,pe as o,jr as p,Xe as q,Dr as r,Tr as s,en as t,gn as u,R as v,hn as w,x,Wr as y,Gr as z,qr as A,Hr as B,Ln as C,Qr as D,zr as E,Kr as F,Vr as G,Jr as H,kt as I};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b}from"./chunk-KYLHS74X.mjs";import"./chunk-FBYFCKPG.mjs";import"./chunk-CI2O7WBH.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-FG4Y4ZVL.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-CRPLDXJU.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
7
+ import{a,b}from"./chunk-BLMJ4WVI.mjs";import"./chunk-4NSXPONF.mjs";import"./chunk-65AMXOQU.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-DAUX63UB.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
@@ -0,0 +1,276 @@
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{s as Bt}from"./chunk-PBHDPTT6.mjs";import{a as Kt,b as he,c as Ht,e as Xt,f as We,g as Zt,h as Jt,i as Qt,j as Yt,k as me,l as ge,m as en}from"./chunk-TAN2CIRI.mjs";import{e as qt,g as Vt}from"./chunk-NCCHOV2N.mjs";import{f as Ut,h as Gt}from"./chunk-2LSGWTWX.mjs";import{a as Wt}from"./chunk-HUOR4M2L.mjs";import{a as tn}from"./chunk-TLX45X5U.mjs";import{Ab as xt,Bb as _t,Gb as Mt,Za as re,c as Ie,d as Pe,e as Et,f as Tt,h as zt,i as xe,j as Lt,k as jt,l as Ct,m as _e,ob as Me,pb as It,q as Dt,sb as Be,tb as pe,vb as Pt,wb as se}from"./chunk-E5FSPXYH.mjs";import{a as oe,d as Ft,j as De}from"./chunk-QHE2RUWX.mjs";import{c as ne,d as le}from"./chunk-6FARZYMJ.mjs";import{b as ce}from"./chunk-CJAWKLAL.mjs";import{a as ft,b as pt,c as ht,f as te,h as Ee,k as mt}from"./chunk-DDNCJVZ2.mjs";import{n as Ot}from"./chunk-C5AUNG6T.mjs";import{g as yt}from"./chunk-TYUYPFDJ.mjs";import{a as Se}from"./chunk-AL4C3GFT.mjs";import{b as ct,c as Oe}from"./chunk-WQCXOZEJ.mjs";import{Cc as ee,Jc as kt,Pb as $t,Yc as Rt,Zc as St,j as Le,n as je,o as Ce,sb as Ne,vb as fe,x as Y,yb as bt,zb as At}from"./chunk-OLCS7JCT.mjs";import{q as vt}from"./chunk-6HHSAPIM.mjs";import{h as ze}from"./chunk-UCUFLFNK.mjs";import{b as lt,f as gt,g as wt,h as Nt}from"./chunk-LCDPCUXS.mjs";import{E as Te}from"./chunk-SZOJ7BEJ.mjs";import{bd as at,je as it,ke as Fe,le as ue,me as dt,te as ut}from"./chunk-J347SPU6.mjs";import{existsSync as Ve,mkdirSync as Rn,readdirSync as Sn,readFileSync as be}from"node:fs";import{dirname as Fn,join as H}from"node:path";import{homedir as On}from"node:os";var En=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
8
+
9
+ Usage:
10
+ npx sandforge frozen <step> --config <file> [options]
11
+
12
+ Steps:
13
+ select pick one root per combination of the coverage matrix (needs --source)
14
+ extract read, pseudonymize, check and freeze those roots (needs --source)
15
+ load replay the frozen dataset into a sandbox or a Developer Edition
16
+ \u2014 WRITES (needs --target);
17
+ what the target runs as it inserts and updates is named first, and takes
18
+ --accept-automation or --mute-automation
19
+ verify check the last load against the dataset (needs --target)
20
+ remove delete the records a load created, the last first \u2014 DELETES (needs --target);
21
+ what the target runs as they go is named first, and takes --accept-automation
22
+ or --mute-automation; with --preview, say what it would delete, and delete
23
+ nothing
24
+ status what the store knows so far
25
+
26
+ Required:
27
+ --config <file> the project configuration, as the panel saves it (JSON)
28
+
29
+ Options:
30
+ --source <alias> sf CLI alias of the org the dataset is read from
31
+ --target <alias> sf CLI alias of the sandbox, or Developer Edition org, it is
32
+ loaded into
33
+ --author <name> who froze the dataset, for the manifest (default: sandforge)
34
+ --salt-file <file> the file holding the pseudonymization salt, when
35
+ SANDFORGE_FROZEN_SALT is not set
36
+ --store <file> where the run keeps its state (default: <sasDir>/cli-store.json)
37
+ --pilot load one root folder only
38
+ --reload replace the loads before: purge what earlier loads created,
39
+ then load again. Refused before anything is written when a
40
+ removal of those loads would leave records in the org \u2014
41
+ records changed since, kept for records that stay under them
42
+ (a contact made by hand since under one of their accounts,
43
+ which the org would delete along), of an object the user may
44
+ not delete, out of the user's sight or unread: take the load
45
+ back with remove first (--include-changed takes what changed
46
+ since, and what was added under them since). Refused as well
47
+ when one of them was recorded before loads kept what they
48
+ created, which no removal takes: refresh the sandbox, or find
49
+ what your user created that day with
50
+ ${Se("cleanup")}, its dry run
51
+ first, then delete it. Refused
52
+ the same way when the purge would have the org delete along a
53
+ record the reload finds again by its keys \u2014 a quote under the
54
+ opportunity an earlier load wrote: give that parent identity
55
+ keys too, or take the load back first. What the target's
56
+ automation likely made for a load holds nothing with --sweep,
57
+ which takes it first. What the target runs as the purge
58
+ deletes is read and named first, and nothing is written
59
+ while something fires unless --accept-automation or
60
+ --mute-automation answers it. The purge takes what those
61
+ loads created, not what the target's automation made for
62
+ them: --sweep takes that too. With --pilot, a reload purges
63
+ nothing, and is not asked
64
+ --gone-first <file> with load --reload --dry-run: the records taken back before
65
+ the reload runs, a JSON array of their ids \u2014 hanging from the
66
+ loads' records, they hold nothing. sandforge env gives it what
67
+ its apply takes back first; a reload that runs reads what is
68
+ still there
69
+ --max-total <n> with load: the most records it may insert \u2014 the count its dry
70
+ run gave. A load, or a reload, that would insert more is
71
+ refused before anything is written, the purge included; a dry
72
+ run says it would be, exit 1
73
+ --dry-run with load: say what the load would do \u2014 per object, what it
74
+ would insert, link, drop, rewrite and purge \u2014 and write nothing
75
+ --write-encrypted with load: write the fields the target encrypts as the dataset
76
+ holds them, though its manifest does not say its extraction
77
+ left out what it read masked \u2014 they may hold masks such as
78
+ ****1234 (left out otherwise, each named)
79
+ --mute-automation with load or remove: mute the target's automation for that
80
+ step through its own bypass \u2014 assign the user it writes as,
81
+ for the step alone, the permission sets holding the custom
82
+ permissions its flows, processes and workflow rules test to
83
+ stay quiet, those of what --sweep deletes included, and take
84
+ them back as it ends; what no bypass keeps quiet still runs,
85
+ and is named, and a load or a removal then needs
86
+ --accept-automation.
87
+ Refused on a production org and for a user who cannot assign
88
+ permission sets, exit 1; with --dry-run or --preview, says
89
+ what would be muted and assigns nothing
90
+ --accept-automation with load: write although the target runs flows, Apex
91
+ triggers, processes or workflow rules as the load inserts
92
+ its records and updates them \u2014 what --mute-automation
93
+ keeps quiet and a bypass the user holds aside \u2014 or could
94
+ not say what it runs; with remove, or load --reload:
95
+ delete although it runs them as the records go, those
96
+ --sweep deletes included \u2014 before or after a delete, or
97
+ as an activated order is set back to Draft for its
98
+ delete. Each is named before anything is written or
99
+ deleted; without the flag the load or the reload writes
100
+ nothing (AUTOMATION_NOT_ACCEPTED), the removal deletes
101
+ nothing, exit 1; --dry-run says so
102
+ --accept-emails with load: write although the target delivers every email
103
+ what still runs sends as the records go in, a reload's
104
+ purge and sweep included (Setup > Deliverability: All
105
+ email), or would not say whether it does: without it
106
+ such a load is refused, exit 1 (EMAILS_NOT_ACCEPTED),
107
+ nothing written. Read only when something that still
108
+ runs sends one, with one line of anonymous Apex that
109
+ sends nothing; on System email only or No access it is
110
+ not needed. The emails are counted too, on the records
111
+ of the dataset, at most, against what the target has
112
+ left today: past it, the load is refused whatever the
113
+ flag, exit 1 (FROZEN_EMAILS_EXCEEDED). --mute-automation
114
+ keeps quiet what tests the org's bypass; what an Apex
115
+ trigger sends is read nowhere. --dry-run says it all,
116
+ and what a load would be refused for
117
+ ${Et({run:"the load",simulation:"--dry-run",step:"with load: ",note:["Taken by this command once the load may write, before","the load's lease; deleted when the load is refused before","it writes or reports it wrote nothing, and kept when it","stops or fails part way: what it wrote then is not told","here."]})}
118
+ --include-changed remove also the records changed since the load, and what
119
+ was added to them since (kept otherwise); with load
120
+ --reload --sweep, the sweep of each load replaced takes
121
+ too what it finds changed since that load, which it
122
+ keeps and names otherwise, the load kept recorded for
123
+ a later sweep, and the reload no partial for them
124
+ --sweep with remove: before the load's records go, delete too what
125
+ the target's automation made for the load, that the
126
+ load's mapping does not hold: what the load's user
127
+ created under the load's records, what they point at,
128
+ or what hangs from those, three links at most, at most
129
+ a minute after the record it is tied to \u2014 in the
130
+ objects the load wrote and their children, tasks,
131
+ events, feed, email messages, notes, case comments, and
132
+ the objects the target's flows create; the window is
133
+ the load's writes, from a second before the first to a
134
+ minute after the last. What a record of the load points
135
+ at by a lookup the org refuses the delete for goes once
136
+ that record is gone. Listed and kept: what is tied to
137
+ the load but came later, up to 15 minutes, or as the
138
+ org's Automated Process user; and what the load's user
139
+ created in the window tied to nothing of it. Such
140
+ records then keep none of the load's records as records
141
+ that stay. A sweep refused, or that did not take all it was
142
+ asked to, exits 3, and ends partial a removal that took
143
+ every record of the load; one that left records of its own
144
+ keeps its own status. Once the load's records went already,
145
+ the sweep runs alone, the way to take what such a sweep
146
+ left (off otherwise: a removal that took the load's
147
+ records then reads what a sweep would take now, read
148
+ only, and names what stays and the option that takes
149
+ it, "notSwept" with --json). It sweeps too, each in its
150
+ own window, every other load recorded whose records
151
+ went \u2014 a load a reload replaced, kept for what its
152
+ sweep left \u2014, and lets it go once that sweep took all
153
+ it found. With load --reload: the sweep of each load
154
+ the reload replaces, as its removal sweeps it, around
155
+ the purge; what the target runs as it deletes is named
156
+ once it has read what it takes, before the first
157
+ delete, and answered as the purge's; with --dry-run, it
158
+ lists what it would take. One refused, or that did not
159
+ take all it was asked to, exits 3
160
+ --sweep-late with --sweep: take too what it lists as made late; with
161
+ --sweep-list, say what it would take
162
+ --sweep-untied with --sweep: take too what it lists as tied to nothing of
163
+ the load; with --sweep-list, say what it would take;
164
+ refused when another run wrote to the target
165
+ in the window \u2014 a load swept with it is none, a load
166
+ this command ran from another sas into the org is one
167
+ \u2014, or when that user created records in the window on
168
+ objects neither the load nor the automation reaches
169
+ (hand work, likely)
170
+ --sweep-list with remove: list what --sweep would delete, per object
171
+ with a few names and how many it ties to the load, and
172
+ for each other load it sweeps with it, and delete nothing;
173
+ exit 3 when it says a sweep is refused, as --sweep would
174
+ --preview with remove: say what the removal would do, per object \u2014 the
175
+ records it would delete, those it would keep as changed since
176
+ the load and who changed them, those gone already, those it
177
+ cannot see, and those it would leave because the user may not
178
+ delete them \u2014 what the target runs as they go, and what it
179
+ would be refused for, that automation without
180
+ --accept-automation included. It deletes nothing, writes
181
+ nothing to the sas and asks nothing; it exits 0 once it has
182
+ said it. It cannot know what hangs from the records, which a
183
+ removal reads at each object's turn. With --sweep, it lists
184
+ what the sweep would take, and reads what fires on it with
185
+ the load's own. Not with --sweep-list
186
+ --yes do not ask before a load writes or a removal deletes: a
187
+ removal asks last, once what it deletes and what the
188
+ target runs as they go are said. Without it, a step
189
+ with no terminal to answer the question \u2014 a CI step \u2014
190
+ stops there, exit 2, and writes nothing
191
+ --json emit what the panel would receive, every other line on
192
+ stderr; a step that ends before its request, refused or
193
+ with nothing to do, says "ended": true. Beside it, "step";
194
+ "dataset" \u2014 its folder, its digest (sha256 of the files a load
195
+ reads, the manifest less the verdict a verification writes
196
+ into it) and its version \u2014 for extract, load and verify;
197
+ "mapping", the file in the sas naming the records the loads
198
+ into the target created, for load, verify and remove; per
199
+ object, what the step counted ("objects"); how a load or a
200
+ removal ended ("status"); verify's verdict, and a load's, per
201
+ object ("verdict"); what a dry run or a
202
+ removal's preview would be refused for ("refusals"), with the
203
+ code of each ("refusalCodes"), as its line names it: a load
204
+ would be refused (CODE): ..., a removal would be refused
205
+ (CODE): ...; and what refused a load before it wrote \u2014 what
206
+ runs as it writes, its purge, its checkpoint, its emails or
207
+ its mute \u2014 or a removal
208
+ before its first delete \u2014 what fires as it deletes, its mute
209
+ or Production Guard \u2014 ("refused": {"code", "message"}), as
210
+ its line names it: refused (CODE): ...
211
+ --help this text
212
+
213
+ The salt that makes pseudonyms repeatable is read from SANDFORGE_FROZEN_SALT,
214
+ or else from --salt-file, and never made up here: an extraction without one is
215
+ refused. The editor keeps its own in VS Code's secret storage; copy it from there
216
+ with "SandForge: Copy Frozen Dataset Salt" to extract the same pseudonyms.
217
+
218
+ The graph a selection or an extraction discovers is kept in the sas
219
+ (discovery.json) and reused by the next one while the source's schema has not
220
+ changed and a day has not gone by: each says "graph reused from <step>" or
221
+ "rediscovered: <why>".
222
+
223
+ Ctrl-C stops a step after the call under way, a load recorded in the sas with
224
+ what it wrote, which remove takes back; a SIGTERM \u2014 a CI job cancelled or timed
225
+ out \u2014 or a SIGHUP stops it the same way. Ctrl-C again ends it at once. Stopped
226
+ at its question, a load or a removal ends there, nothing written or deleted;
227
+ stopped while it reads, before it is sent, a load goes no further, nothing
228
+ written; stopped once it is over, a load is recorded among the loads into the
229
+ target, its checkpoint settled, before the command ends.
230
+
231
+ Exit codes: 0 the step finished \u2014 a removal with nothing to take included, and a
232
+ removal's preview once said, its refusals included \u2014, and verify's verdict is
233
+ PASSED; 1 it failed or could not start, verify's verdict is FAILED, a dry run says
234
+ the load would be refused, a load was refused before it wrote for what the target
235
+ runs as it writes (AUTOMATION_NOT_ACCEPTED without --accept-automation), for its
236
+ emails (EMAILS_NOT_ACCEPTED without --accept-emails, FROZEN_EMAILS_EXCEEDED) or for
237
+ the data storage its records take past what the target has left
238
+ (FROZEN_STORAGE_EXCEEDED: --pilot, or a smaller dataset), or a removal
239
+ stopped before its first delete at what the target runs, without
240
+ --accept-automation; 2 a bad command line, or a question with
241
+ no terminal to answer it (give --yes); 3 verify's verdict is PARTIAL, a load
242
+ completed with errors, the verification it runs after it was FAILED or PARTIAL, or
243
+ the sweep of a reload did not take all it was asked to, or a removal left records
244
+ of the load or its sweep did not take all it was asked to; 4 verify's verdict is
245
+ UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
246
+ SIGHUP. A load is judged by its own report, which ends partial on a verification
247
+ FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
248
+ `,nn=["select","extract","load","verify","remove","status"],Tn={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...xt,"--preview","--yes","--json",...Pe.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...Pe.values]},on=1e6;function zn(e){let t;try{t=JSON.parse(be(e,"utf8"))}catch(n){process.stderr.write(`--gone-first: ${e} does not read: ${String(n)}
249
+ `),process.exit(2)}return(!Array.isArray(t)||!t.every(n=>typeof n=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(n)))&&(process.stderr.write(`--gone-first: ${e} holds no JSON array of record ids.
250
+ `),process.exit(2)),t}function Ln(e){let t=e.slice(2);(t.includes("--help")||t.includes("-h")||t.length===0)&&(process.stdout.write(En),process.exit(0));let n=m=>{let w=t.indexOf(m);return w>=0&&w+1<t.length?t[w+1]:void 0},o=t[0];nn.includes(o)||(process.stderr.write(`The first word is the step: ${nn.join(", ")} \u2014 not "${t[0]}".
251
+ `),process.exit(2)),lt(t,Tn);let s=n("--config");s||(process.stderr.write(`Missing --config. Run with --help.
252
+ `),process.exit(2));let a=n("--source"),f=n("--target");(o==="select"||o==="extract")&&!a&&(process.stderr.write(`${o} reads the source org: give --source.
253
+ `),process.exit(2)),(o==="load"||o==="verify"||o==="remove")&&!f&&(process.stderr.write(`${o} works on the target org: give --target.
254
+ `),process.exit(2)),t.includes("--sweep")&&t.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
255
+ `),process.exit(2)),t.includes("--sweep-list")&&o!=="remove"&&(process.stderr.write(`--sweep-list goes with remove${o==="load"?"; a reload lists what its sweep would take with --dry-run --sweep":""}. Run with --help.
256
+ `),process.exit(2)),t.includes("--sweep")&&o!=="remove"&&!(o==="load"&&t.includes("--reload")&&!t.includes("--pilot"))&&(process.stderr.write(`--sweep goes with remove or load --reload${o==="load"&&t.includes("--pilot")?", and a pilot purges nothing":""}. Run with --help.
257
+ `),process.exit(2)),t.includes("--include-changed")&&o!=="remove"&&!(o==="load"&&t.includes("--reload")&&t.includes("--sweep"))&&(process.stderr.write(`--include-changed goes with remove, or with load --reload --sweep, whose sweep then takes what changed since the loads it replaces. Run with --help.
258
+ `),process.exit(2)),t.includes("--gone-first")&&!(o==="load"&&t.includes("--reload")&&t.includes("--dry-run"))&&(process.stderr.write(`--gone-first goes with load --reload --dry-run. Run with --help.
259
+ `),process.exit(2));let r=n("--gone-first");t.includes("--gone-first")&&r===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
260
+ `),process.exit(2)),t.includes("--write-encrypted")&&o!=="load"&&(process.stderr.write(`--write-encrypted goes with load. Run with --help.
261
+ `),process.exit(2)),t.includes("--accept-emails")&&o!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
262
+ `),process.exit(2)),t.includes("--mute-automation")&&o!=="load"&&o!=="remove"&&(process.stderr.write(`--mute-automation goes with load or remove. Run with --help.
263
+ `),process.exit(2)),t.includes("--accept-automation")&&o!=="remove"&&o!=="load"&&(process.stderr.write(`--accept-automation goes with load or remove. Run with --help.
264
+ `),process.exit(2)),t.includes(Ie)&&o!=="load"&&(process.stderr.write(`${Ie} goes with load. Run with --help.
265
+ `),process.exit(2));let d=Tt(t);t.includes("--preview")&&o!=="remove"&&(process.stderr.write(`--preview goes with remove${o==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
266
+ `),process.exit(2)),t.includes("--preview")&&t.includes("--sweep-list")&&(process.stderr.write(`--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Run with --help.
267
+ `),process.exit(2));let i=_t(t);"refusal"in i&&(process.stderr.write(`${i.refusal} Run with --help.
268
+ `),process.exit(2));let u;if(t.includes("--max-total")){let m=n("--max-total");u=Number(m),o!=="load"&&(process.stderr.write(`--max-total goes with load. Run with --help.
269
+ `),process.exit(2)),(m===void 0||!/^\d+$/.test(m)||u<1||u>on)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${on}, not "${m??""}".
270
+ `),process.exit(2))}return{step:o,configPath:s,source:a,target:f,author:n("--author"),storePath:n("--store"),saltFile:n("--salt-file"),pilot:t.includes("--pilot"),reload:t.includes("--reload"),dryRun:t.includes("--dry-run"),writeEncrypted:t.includes("--write-encrypted"),muteAutomation:t.includes("--mute-automation"),acceptAutomation:t.includes("--accept-automation"),...d!==void 0?{checkpointFirst:d}:{},includeChanged:t.includes("--include-changed"),acceptEmails:t.includes("--accept-emails"),sweep:t.includes("--sweep"),sweepList:t.includes("--sweep-list"),...i,preview:t.includes("--preview"),...u!==void 0?{maxTotal:u}:{},...r!==void 0?{goneFirst:r}:{},yes:t.includes("--yes"),json:t.includes("--json")}}async function jn(e){let n=(await e.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!n)throw new Error("The org gave no Organization record.");if(n.IsSandbox)return{id:n.Id,orgType:"Sandbox"};try{let s=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof s=="string"&&s!==""?{id:n.Id,orgType:at({isSandbox:!1,edition:s}),edition:s}:{id:n.Id,orgType:"Production"}}catch{return{id:n.Id,orgType:"Production"}}}async function rn(e,t,n,o){let s=await ct(e),a=Oe(s),f;try{f=await jn(a)}catch(r){let d=r instanceof Error?r.message:String(r);throw new Error(`Could not read the Organization record of '${e}': ${d}`)}return t.set(f.id,{org:{id:f.id,alias:e,orgType:f.orgType,metadata:{apiVersion:"66.0",...f.edition?{edition:f.edition}:{}},username:s.username,instanceUrl:s.instanceUrl},credentials:{accessToken:s.accessToken,instanceUrl:s.instanceUrl}}),n?.set(f.id,a),o?.set(f.id,{session:s,typed:f}),f.id}var x={run:"load",done:"loaded",source:"the frozen dataset",recordedIn:"in this sas",remove:"`remove`",module:"frozen",again:"reload",againSubject:{purge:"reload",sweep:"reloadSweep"},maybeMasks:"the dataset's manifest does not say its extraction left out what it read masked, so they may hold masks such as ****1234; --write-encrypted writes them as the dataset holds them"};function Xe(e){return!e||e.length===0?[]:[`kept: the platform does not delete them \u2014 ${e.map(({objectApiName:n,count:o})=>`${n} (${o})`).join(", ")}`]}function sn(e,t,n=x){let o=(e??[]).filter(a=>a.reason==="may-hold-masks");if(o.length===0)return[];let s=o.map(({objectApiName:a,field:f,affectedRecords:r})=>`${a}.${f} (${r})`).join(", ");return[`${t} out, encrypted in the target: ${s} \u2014 ${n.maybeMasks}`]}function Cn(e,t){let n=e==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${e==="unique"?"unique in the target":"the record name"}`;return t===void 0?n:`${n} (first: "${t}")`}function Ze(e){return e.created.reduce((t,n)=>t+n.count,0)}function Nn(e){return{...e.includeChanged?{includeChanged:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}}}var Dn={removal:{heading:"removal",writer:"this removal",verb:"remove"},reload:{heading:"reload",writer:"this reload's purge",verb:"reload"},reloadSweep:{heading:"reload",writer:"this reload's sweep",verb:"reload"},replayAgain:{heading:"replay",writer:"this replay's purge",verb:"replay again"},replayAgainSweep:{heading:"replay",writer:"this replay's sweep",verb:"replay again"}};function Ue({read:e,steps:t,mute:n},o,s="removal",a){let f=n?Y(n.muted,o).map(u=>` ${u}`):[];if(!("objects"in e)){let u=Dn[s],m=s==="reload"||s==="replayAgain",w=`${u.writer}${m&&a?" and its sweep":""}`;return{lines:[`${u.heading} automation: what ${o} runs could not be read: ${e.unread}`,...f],refusal:`What ${o} runs as ${w} writes could not be read (${e.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${u.verb} all the same, or turn that automation off in ${o} first.`}}let r=n?.automation??e,d=a?it(t,a.delete??[]):t,i=St(r,o,{steps:t,...a?{sweep:a}:{},assign:kt(r,dt(r,d)),mayMute:n===void 0&&De("--mute-automation"),subject:s});return{lines:[...Rt(e,o,t,s,a),...f],...i!==void 0?{refusal:i}:{}}}function In(e,t,n=x){let o=Ze(e),s=e.earlier?`a ${n.run} before the last one, whose records the ${n.run}s after it left in place,`:`the last ${n.run}`,a=`a removal deletes the ${o} record(s) it created, children first:`;return e.removed&&o===0?a=`its records were removed on ${e.removed.removedAt}, and none is left to remove`:o===0&&(e.keptByThePlatform?.length??0)>0?a="it created no record a removal takes":e.removed&&(a=`the removal of ${e.removed.removedAt} left ${o} of the records it created, and a removal deletes those, children first:`),[`${s} wrote to ${t} at ${e.loadedAt}; ${a}`,...e.created.map(f=>` ${f.objectApiName}: ${f.count}`),`${e.linked} record(s) it linked to or reused stay`,...Xe(e.keptByThePlatform)]}function Pn(e,t){return e.recorded&&(Ze(e)>0||(t?.delete??[]).length>0)}function xn(e){return[e.deleted>0?`${e.deleted} deleted`:"",e.alreadyGone>0?`${e.alreadyGone} already gone`:"",e.keptChanged>0?`${e.keptChanged} kept, changed since the load`:"",e.keptDependents>0?`${e.keptDependents} kept for records that stay`+(e.heldBy.length>0?` (${e.heldBy.join(", ")})`:""):"",e.refused>0?`${e.refused} refused`:"",(e.notReached??0)>0?`${e.notReached} not reached`:""].filter(Boolean).join(", ")}function _n(e,t=x){let n=e.count>e.names.length?", \u2026":"";return`${e.count} file(s) attached to them stay in the org, as the ${t.run} did not create them: ${e.names.join(", ")}${n}`}function an(e){return`graph: ${e.objects} object(s) at a cap of ${e.maxNodes}`+(e.objects>e.maxNodes?" (raised for the parents their records cannot be written without)":"")+(e.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function dn(e){return"reusedFrom"in e?`graph reused from ${e.reusedFrom} (discovered ${e.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${e.rediscovered}`}function Mn(e){switch(e.phase){case"discovery":return` discovery: ${e.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${e.axis??"?"}\u2026`;case"combination":return` combination ${e.index??"?"}/${e.of??"?"}: ${e.combinationKey??"?"}`;case"candidate":return` candidate ${e.candidate??"?"}/${e.candidates??"?"} of ${e.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${e.roots??0} root(s) kept, together\u2026`}}function Bn(e){let t=e.reason==="timeout"?"its time ran out":"it was cancelled",n=e.during==="axes"?"while it listed the axis values":e.during==="measure"?"while it measured the roots it kept":`while it probed ${e.combinationKey??"?"}`+(e.candidate!==void 0?`, candidate ${e.candidate} of ${e.candidates??"?"}`:"");return[`STOPPED: ${t} ${n}; the combinations decided before are kept`,...e.notProbed.length>0?[` never probed: ${e.notProbed.join(", ")}`]:[]]}var Wn=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),wn="REMOVAL_DECLINED",un=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],Un=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",Ne,"FROZEN_STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ce.code,...un])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",ce.code,...un])]]);function Ke(e){let t=e.payload?.code,n=Un.get(String(e.type??""));if(!(typeof t!="string"||n?.has(t)!==!0))return{code:t,message:String(e.payload?.message??"")}}function He(e){let t=String(e.type??"");if(!t.endsWith(":error")||t==="frozen:remove:automation:error")return!1;let n=String(e.payload?.code);return t==="frozen:remove:error"&&n===wn?!1:!((t==="frozen:remove:error"||t==="frozen:remove:preview:error")&&Wn.has(n))}var ln={passed:0,partial:3,unstable:4,failed:1};function Gn(e,t,n){return async(o,s)=>{let a=Date.parse(s?.first??""),f=Math.max(a,Date.parse(s?.last??""));return!Number.isFinite(a)||!Number.isFinite(f)?[]:[...(await Mt({organizationId:o,alias:e,span:{from:a,to:f},own:{ids:[]},...t!==void 0?{journalDir:t}:{}})).map(({ids:d})=>({ids:d,from:a,to:f})),...Jt(Yt(t??oe(),o),{sasMark:n,own:[]})]}}function qn(e,t){return wt(t.map(n=>{let o=n.payload??{};if(e==="verify"&&n.type==="frozen:verify:result"){let s=String(o.verdict?.status??"");return Object.prototype.hasOwnProperty.call(ln,s)?ln[s]:1}if(e==="load"&&n.type==="frozen:load:response"){let s=o.report,a=o.replay?.summary.records.refusedBeforeWrite;return s?.status==="completed"&&(s.sweeps??[]).every(f=>f.result.status==="success")&&(a??0)===0?0:3}return e==="remove"&&n.type==="frozen:remove:response"?o.result?.status==="success"?0:3:0}))}function Vn(e,t){return` data storage: about ${ee(e.estimateMB)} MB`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${ee(e.automationMB)} MB of it for what the target's automation creates under them,`:"")+` of the ${ee(e.remainingMB)} MB ${t} has left of ${ee(e.maxMB)} MB`+$t(e.uncountedWrites?{uncountedWrites:e.uncountedWrites}:{},t)+(e.freedMB!==void 0?`, and the reload's purge frees about ${ee(e.freedMB)} MB first`:"")}function cn(e,t){return Dt(e.verdict==="unread"?{verdict:"unread",estimate:e.estimate,unread:e.unread??"not said"}:{verdict:e.verdict,estimate:e.estimate,remaining:e.remaining??0,max:e.max??0},t)}function Kn(e){return(e.filter(n=>n.type==="frozen:remove:response").at(-1)?.payload?.result?.objects??[]).some(n=>n.deleted+n.alreadyGone>0)}function we(e,t){if(Ft()!==void 0)return Be(e);let n=t.remove.replace(/`/g,"");return e==="--sweep"||e==="--sweep-list"?`${n} ${e}`:`${n} --sweep ${e}`}function Hn(e,t=x){if(!e||e.found.length===0)return[];let n=e.found.reduce((u,m)=>u+m.count,0),o=e.found.some(u=>u.overBound)?" or more":"",s=u=>e.found.reduce((m,w)=>m+(w.classes?u(w.classes):0),0),a=s(u=>u.made+u.madeOver),f=s(u=>u.late),r=s(u=>u.untied),d=e.found.filter(u=>u.overBound).map(u=>u.objectApiName),i=[...a>0?[`${we("--sweep",t)} takes the ${a} tied to the ${t.run}`]:[],...f>0?[`${we("--sweep-late",t)} takes the ${f} made late`]:[],...r>0?[e.untied?.refusal!==void 0?`the ${r} tied to nothing of the ${t.run} now stay: --sweep-untied is refused (${e.untied.refusal})`:`${we("--sweep-untied",t)} takes the ${r} tied to nothing of the ${t.run} now`]:[],...d.length>0?[`no sweep takes those of ${d.join(", ")}, past its bound`]:[]];return[`not swept: ${n}${o} record(s) the ${t.run}'s user created in its window stay, what the target's automation made for the ${t.run} likely: `+e.found.map(u=>`${u.objectApiName}: ${u.count}`).join(", "),...i.map(u=>` ${u}`),` ${we("--sweep-list",t)} names them first: a record made by hand as that user in the ${t.run}'s window reads as the automation's, so check the names before a sweep`]}var Ge={insert:{what:"record(s)",done:"written",of:"the inserts"},placeholder:{what:"placeholder(s)",done:"created",of:"the placeholders"},update:{what:"update(s)",done:"written",of:"the updates"},delete:{what:"purge delete(s)",done:"deleted",of:"the purge's deletes"}};function fn(e){let t=e.flatMap(({objectApiName:s,write:a,rows:f,written:r,stillLocked:d})=>{let i=Ge[a],u=ze(i.what,{refused:f,sentAgain:f,written:r,stillLocked:d,notSentAgain:0},i.done);return u?[` ${s}: ${u}`]:[]});if(t.length===0)return[];let n=Object.keys(Ge).filter(s=>e.some(a=>a.write===s&&a.rows>0)).map(s=>`of ${Ge[s].of}`);return[`sent again for a record lock, ${n.length>1?`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`:n[0]}:`,...t]}function Xn(e,t){let n=e.flatMap(({objectApiName:o,inserted:s,placeholders:a,failed:f,deleted:r,deactivated:d})=>{let i=[...s>0?[`${s} inserted`]:[],...a>0?[`${a} placeholder(s) created`]:[],...f>0?[`${f} refused by the target`]:[],...r>0?[`${r} deleted by the purge`]:[],...d>0?[`${d} deactivated by the purge`]:[]];return i.length>0?[` ${o}: ${i.join(", ")}`]:[]});return n.length>0?[`before the ${t} ended, it had written this:`,...n]:[]}function Zn(e,t={},n=x){let o=String(e.type??""),s=e.payload??{},a=o.replace(/^frozen:/,`${n.module}:`),f=n===x?"load":"run";if((o==="frozen:remove:error"||o==="frozen:remove:preview:error")&&!He(e))return[`nothing to remove: ${String(s.message??"")}`];if(o==="frozen:remove:error"&&!He(e))return[String(s.message??"")];if(o==="frozen:remove:automation:error")return[];if(o.endsWith(":error")){let r=o==="frozen:load:error"?s.sweeps??[]:[],d=o==="frozen:load:error"?s.emails:void 0,i=o==="frozen:load:error"?s.automation:void 0,u=o==="frozen:load:error"?s.mutedAutomation:void 0,m=Ke(e);return[...m?[]:[`! ${a}: ${String(s.message??"")}${s.code?` [${String(s.code)}]`:""}`],...i?ge(i,"the target"):[],...d?me(d,"the target"):[],...u?Y(u,"the target"):[],...r.length>0?[`before the ${n.run} ended, its sweep had already done this:`]:[],...r.flatMap(({loadedAt:w,result:A})=>[`sweep of the ${n.run} of ${w}:`,...se(A)]),...o==="frozen:load:error"?Xn(s.writtenPerObject??[],n.run):[],...o==="frozen:load:error"?fn(s.sentAgainForALock??[]):[],...m?[ne(m)]:[]]}switch(o){case"frozen:select:progress":return[Mn(s)];case"frozen:select:response":{let r=s.selection;return[`selected ${r.combinations.length} root(s): ${r.combinations.map(d=>d.combinationKey).join(", ")}`,...r.uncovered.map(d=>` uncovered ${d.combinationKey}: ${d.reason}`),...r.stopped?Bn(r.stopped):[],...r.discovery?[dn(r.discovery)]:[],...r.graph?[an(r.graph)]:[],`volumetry ${r.volumetry.total} / ${r.volumetry.budgetMax} record(s)`+(r.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(r.volumetry.measured).filter(([,d])=>d>0).map(([d,i])=>` ${d}: ${i}`)]}case"frozen:control:result":{let r=s.report;return[`non-reidentification control: ${r.passed?"PASSED":"FAILED"}`,...r.checks.map(d=>` ${d.passed?"ok ":"FAIL"} ${d.name}`+(d.violations.length>0?` (${d.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let r=s.manifest,d=s.discovery;return[`frozen ${String(s.recordCount)} record(s) as version ${r.version} in ${String(s.datasetDir)}`,...d?[dn(d)]:[],...r.coverage?[an(r.coverage)]:[],...r.coverage&&r.coverage.unboundedObjects.length>0?[`read without the time bound: ${r.coverage.unboundedObjects.join(", ")}`]:[],...(r.coverage?.leftToThePlatform??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(r.coverage?.exclusionCosts??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(r.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(r.coverage?.requiredLeftEmpty??[]).join(", ")}. Give each a rule that pseudonymizes it rather than clearing it and extract again, or declare its value in requiredFieldDefaults of the configuration, as "requiredFieldDefaults": {${JSON.stringify((r.coverage?.requiredLeftEmpty??[])[0])}: "\u2026"}`]:[],...(r.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(r.coverage?.keptWithoutARule??[]).join(", ")]:[],...(r.coverage?.encryptedNotKept??[]).length>0?["not kept, encrypted and read masked: the user the source is read as lacks View Encrypted Data, and the masks are not copied: "+(r.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(r.volumetry.measured).filter(([,i])=>i>0).map(([i,u])=>` ${i}: ${u}`)]}case"frozen:load:response":{let r=s.report,d=[`${n.run}: ${r.status} in ${r.durationMs}ms \u2014 ${r.alignment.excludedObjects.length} object(s) excluded, ${r.alignment.removals.length} field removal(s), ${r.alignment.recordTypeIssues.length} record type issue(s), ${r.placeholders.length} placeholder(s)`];for(let p of r.alignment.excludedObjects)d.push(` ${p.objectApiName}: not ${n.done} \u2014 ${p.reason}`);d.push(...sn(r.alignment.removals,"left",n));for(let p of r.perObject){let F=p.writtenByThePlatform??0;d.push(` ${p.objectApiName}: ${p.inserted} inserted, ${p.reused} reused`+(F>0?` (${F} written by the platform with ${Te(p.objectApiName)})`:"")+`, ${p.skippedDuplicates.length} duplicate(s), ${p.failed.length} failed of ${p.fromFiles}`);let M=p.failed[0];M&&d.push(` first refusal: ${M.errors?.[0]??M.error??"?"}`);let j=p.sentAgainForALock,K=j&&ze("record(s)",{refused:j.rows,sentAgain:j.rows,written:j.written,stillLocked:j.stillLocked,notSentAgain:0});K&&d.push(` ${K}`)}for(let p of[...r.leftToThePlatform??[],...r.untypedFeedItems??[],...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])d.push(` ${p.objectApiName}: ${p.note}`);let i=r.perObject.filter(p=>(p.writtenWithoutFields?.fields.length??0)>0);if(i.length>0){d.push(`written again without a field a validation rule or a restricted picklist refused (${i.length} object(s)):`);for(let{objectApiName:p,writtenWithoutFields:F}of i)for(let{field:M,refusedBy:j,reason:K,rows:ie,replacedWith:J}of F?.fields??[]){let I=j==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",Qe=J===void 0?"":` \u2014 written with "${J}", as its picklist rule declares`;d.push(` ${p}.${M} ${ie} record(s) \u2014 ${I}${Qe} \u2014 ${K}`)}}d.push(`pass 2: ${r.pass2.resolved} resolved, ${r.pass2.unresolved.length} unresolved`);for(let p of r.pass2.unresolved.slice(0,5))d.push(` ${p.objectApiName}.${p.field}: ${p.detail}`);let u=r.personContact,m=u?.sent??[];if(u&&u.restored+m.length+u.unresolved.length>0){d.push(`person contacts: ${u.restored} linked, ${m.length} sent as contacts of their own, ${u.unresolved.length} not linked`);for(let p of m.slice(0,5))d.push(` ${p.contactReferenceId} sent: ${p.detail}`);for(let p of u.unresolved.slice(0,5))d.push(` ${p.contactReferenceId}: ${p.detail}`)}if(r.statuses&&r.statuses.restored+r.statuses.refused.length>0){d.push(`statuses applied after insert: ${r.statuses.restored}, refused ${r.statuses.refused.length}`);for(let p of r.statuses.refused.slice(0,5))d.push(` ${p.objectApiName} \u2192 ${p.status}: ${p.detail}`)}let w=p=>Object.values(p).reduce((F,M)=>F+M,0),A=w(r.purge.deleted),b=w(r.purge.deactivated??{});if(A+b+r.purge.failures.length>0){d.push(`purge of earlier ${n.run}s: ${A} deleted, ${b} deactivated, ${r.purge.failures.length} failed`);for(let p of r.purge.failures.slice(0,5))d.push(` ${p.objectApiName}: ${p.errors[0]??"?"}`)}for(let[p,F]of Object.entries(r.purge.cameAlong??{}))d.push(` ${p}: took along ${F.count} record(s) the ${n.run}s did not write that came with their records, made as they wrote: ${F.objects.join(", ")}`);let B=Object.entries(r.purge.leftUnrecorded??{});if(B.length>0){d.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[p,F]of B)d.push(` ${p}: ${F}`)}let C=Object.entries(r.purge.keptByThePlatform??{});if(C.length>0){d.push("kept by the purge, the platform does not delete them:");for(let[p,F]of C)d.push(` ${p}: ${F}`)}d.push(...fn(r.sentAgainForALock??[]));for(let p of s.report.sweeps??[]){d.push(`sweep of the ${n.run} of ${p.loadedAt}:`,...se(p.result));let F=p.result.objects.reduce((M,j)=>M+j.keptChanged,0);F>0&&d.push(` ${F} record(s) kept, changed since that ${n.run}: `+(n===x?"load --reload --sweep --include-changed, or remove --sweep --include-changed, ":`${n.remove} --sweep --include-changed `)+"takes them")}let T=s.report.mutedAutomation;T&&d.push(...Y(T,"the target"));let _=s.report.automation;_&&d.push(...ge(_,"the target"));let l=s.report.emails;l&&d.push(...me(l,"the target"));let k=s.report.apiRequests;return k&&d.push(cn(k,"the target")),d.push(...yn(s.report.recordTypesGiven,!1)),d}case"frozen:load:preview:response":{let r=s.plan,d=l=>r.perObject.reduce((k,p)=>k+l(p),0),i=[`dry run${r.mode.pilot?" (pilot)":""}${r.mode.reload?` (${n.again})`:""}: ${d(l=>l.toInsert)} record(s) to insert, ${d(l=>l.reusedByKeys+l.reusedFromCatalog+(l.writtenByThePlatform??0))} to link, ${d(l=>l.notSent)} not sent`+(r.mode.reload?`, ${d(l=>l.toPurge)} to purge and ${d(l=>l.toDeactivate)} to deactivate of ${r.earlierLoads} earlier ${n.run}(s)`:"")+" \u2014 nothing written"];for(let l of r.perObject){let k=[`${l.toInsert} to insert`,l.reusedByKeys>0?`${l.reusedByKeys} found by identity keys`:"",l.reusedFromCatalog>0?`${l.reusedFromCatalog} found in the catalog`:"",(l.writtenByThePlatform??0)>0?`${l.writtenByThePlatform} to link (written by the platform with ${Te(l.objectApiName)})`:"",l.fieldsDropped>0?`${l.fieldsDropped} field(s) dropped`:"",l.picklistsRewritten>0?`${l.picklistsRewritten} picklist value(s) rewritten`:"",l.notSent>0?`${l.notSent} not sent`:"",l.toPurge>0?`${l.toPurge} to purge`:"",l.toDeactivate>0?`${l.toDeactivate} to deactivate`:""].filter(Boolean);i.push(` ${l.objectApiName}: ${k.join(", ")} of ${l.fromFiles}`)}for(let l of r.excludedObjects)i.push(` ${l.objectApiName}: not ${n.done} \u2014 ${l.reason}`);i.push(...sn(r.removals,"would leave",n));for(let l of[...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])i.push(` ${l.objectApiName}: ${l.note}`);for(let l of r.placeholders)i.push(`placeholder for ${l.objectApiName}.${l.field}: ${l.affectedRecords} record(s)`);for(let l of r.requiredDefaults)i.push(`default for ${l.objectApiName}.${l.field}: ${l.affectedRecords} record(s)`+(l.perRecord?`, ${Cn(l.perRecord,l.example)}`:""));r.personContacts>0&&i.push(`${r.personContacts} person account contact(s) go in with their account, not counted above`);let u=Object.entries(r.leftUnrecorded??{});if(u.length>0){i.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[l,k]of u)i.push(` ${l}: ${k}`)}let m=Object.entries(r.keptByThePlatform??{});if(m.length>0){i.push("left in place by the purge, the platform does not delete them:");for(let[l,k]of m)i.push(` ${l}: ${k}`)}let w=l=>` ${l.name}${l.field?` (${l.field})`:""}${l.message?` \u2014 ${l.message}`:""}`,A=r.perObject.filter(l=>(l.validationRules?.length??0)>0);for(let l of A){i.push(`${l.objectApiName}: ${l.validationRules?.length??0} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a record one of them refuses is counted to insert:`);for(let k of l.validationRules??[])i.push(w(k))}for(let l of r.perObject){let k=l.lookupFilters??[];k.length!==0&&i.push(`${l.objectApiName}: ${k.length} lookup filter(s) of the target, which a preview cannot check \u2014 a record whose lookup it refuses is refused, and what hangs from it: `+k.map(p=>`${p.field} (${p.referenceTo.join(" or ")}, ${p.records} record(s))`).join(", "))}for(let l of r.perObject){let k=l.validationRulesOnChange??[];k.length!==0&&i.push(`${l.objectApiName}: ${k.length} rule(s) left out \u2014 their formula holds only on a change of a record (ISCHANGED, PRIORVALUE, NOT(ISNEW())), which an insert never is: `+k.join(", "))}let b=new Map(r.placeholders.filter(l=>(l.validationRules?.length??0)>0).map(l=>[l.placeholderObjectApiName,l.validationRules??[]]));for(let[l,k]of b){i.push(`placeholder of ${l}: ${k.length} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a placeholder one of them refuses stops the load:`);for(let p of k)i.push(w(p))}r.validationRulesUnread&&i.push(`the target's validation rules could not be listed (${r.validationRulesUnread}): any of them may refuse a record counted to insert`);let B=s.plan.automation;B&&i.push(...ge(B,"the target"));let C=s.plan.emails;C&&i.push(...me(C,"the target"));let T=s.plan.apiRequests;T&&i.push(cn(T,"the target"));let _=s.plan.storage;return _&&i.push(Vn(_,"the target")),i}case"frozen:verify:result":{let r=s.verdict;return[`verification: ${r.status.toUpperCase()}`,...r.checks.map(d=>{let i=no(d,n);return` ${d.passed?"ok ":"FAIL"} ${i.name}: ${i.detail}`})]}case"frozen:remove:response":{let r=s.result,d=[...new Set(r.objects.flatMap(u=>u.unchecked))],i=r.sweep!==void 0&&r.objects.length===0;return[...r.sweep?se(r.sweep):[],...(r.otherLoadSweeps??[]).flatMap(({loadedAt:u,result:m})=>[`sweep of the ${n.run} of ${u}:`,...se(m)]),...i?[]:[`removal: ${r.status.toUpperCase()}`+(r.leftBy?` \u2014 of what the removal of ${r.leftBy} left`:"")],...r.objects.flatMap(u=>[` ${u.objectApiName}: ${xn(u)||"nothing"} of ${u.planned}${Me(u)}`,...It(u,f),...u.reasons.map(m=>` ${m}`),...u.filesLeft&&u.filesLeft.count>0?[` ${_n(u.filesLeft,n)}`]:[]]),...d.length>0?[`not checked, deleted with their parent: ${d.join(", ")}`]:[],...Xe(r.keptByThePlatform),...Pt(r.objects,{sweep:r.sweep!==void 0}),...r.mutedAutomation?Y(r.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let r=s.loads;if(r)return r.flatMap(({loadedAt:i,listing:u})=>[`sweep of the ${n.run} of ${i}:`,...pe(u,"the target org",t,!0)]);let d=s.otherLoads??[];return d.length>0?[{loadedAt:String(s.loadedAt),listing:s.listing},...d].flatMap(({loadedAt:i,listing:u})=>[`sweep of the ${n.run} of ${i}:`,...pe(u,"the target org",t,!0)]):pe(s.listing,"the target org",t,!0)}case"frozen:remove:preview:response":return Qn(s.preview,n);case"frozen:status:response":return[JSON.stringify(s.status,null,2)];default:return[]}}var Jn="not read by a preview: what hangs from the records, which a removal reads at each object's turn \u2014 a record kept for records that stay is counted with those to delete \u2014 nor what the target's automation does as they go";function Qn(e,t=x){let n=a=>e.userNames[a]??a,o=["preview: what a removal would do; nothing was deleted"+(e.leftBy?` \u2014 of what the removal of ${e.leftBy} left`:"")];for(let a of e.objects){let f=[a.toDelete>0?`${a.toDelete} to delete`:"",e.includeChanged&&a.changedSince>0?`${a.changedSince} of them changed since the ${t.run}`:"",a.alreadyGone>0?`${a.alreadyGone} gone already`:"",a.notVisible>0?`${a.notVisible} not visible`:"",a.keptChanged>0?`${a.keptChanged} kept, changed since the ${t.run}`:"",a.undeletable>0?`${a.undeletable} left, the user may not delete them`:"",a.unread>0?`${a.unread} left, not read`:""].filter(Boolean);o.push(` ${a.objectApiName}: ${f.join(", ")||"nothing"} of ${a.planned}${Me(a)}`);let r=Object.entries(a.changedBy).sort((d,i)=>i[1]-d[1]);r.length>0&&o.push(` last changed by: ${r.map(([d,i])=>`${n(d)} ${i}`).join(" \xB7 ")}`);for(let d of a.reasons)o.push(` ${d}`)}o.push(...Xe(e.keptByThePlatform));let s=e.refusalCodes;return e.refusals.forEach((a,f)=>{o.push(s?.length===e.refusals.length?le({code:s[f],message:a},"a removal"):`a removal would be refused: ${a}`)}),o.push(Jn),o}async function Yn(e){let t=H(e,"manifest.json");if(Ve(t))try{let n=await Kt(e),{version:o}=JSON.parse(be(t,"utf8"));return{dir:e,digest:n,...typeof o=="string"?{version:o}:{}}}catch{return}}function eo(e,t){let n=H(e,qt(t)),o=H(e,"referenceid-mapping.json");return!Ve(n)&&Ve(o)?o:n}function pn(e){return{status:e.status.toUpperCase(),objects:(e.objects??[]).map(({status:t,...n})=>({...n,verdict:t==="passed"?"PASSED":"FAILED"}))}}async function to(e,t,n){let o=i=>t.filter(u=>u.type===i).at(-1)?.payload,s=n.targetOrgId?eo(n.sasDir,n.targetOrgId):void 0,a={tool:"sandforge-frozen",step:e,posted:t},f=[],r=[],d=async i=>{if(i===void 0)return;let u=await Yn(i);u&&(a.dataset=u)};switch(e){case"extract":{let i=o("frozen:extract:response");if(!i)break;await d(typeof i.datasetDir=="string"?i.datasetDir:n.datasetDir);let u=i.manifest?.volumetry?.measured??{};a.objects=Object.entries(u).filter(([,m])=>m>0).map(([m,w])=>({objectApiName:m,records:w}));break}case"load":{await d(n.datasetDir);let i=o("frozen:load:response")?.report,u=o("frozen:load:preview:response")?.plan,m=i?i.recordTypesGiven:u?.recordTypesGiven;m&&(a.recordTypesGiven=m),i?(a.mapping=i.mappingPath,a.objects=i.perObject.map(b=>({objectApiName:b.objectApiName,fromFiles:b.fromFiles,inserted:b.inserted,reused:b.reused,duplicates:b.skippedDuplicates.length,failed:b.failed.length}))):u&&(s&&(a.mapping=s),a.objects=u.perObject.map(b=>({objectApiName:b.objectApiName,fromFiles:b.fromFiles,toInsert:b.toInsert,toLink:b.reusedByKeys+b.reusedFromCatalog+(b.writtenByThePlatform??0),notSent:b.notSent,toPurge:b.toPurge,toDeactivate:b.toDeactivate}))),i&&(a.status=i.status),!i&&o("frozen:load:error")?.code==="LOAD_CANCELLED"&&(a.status="cancelled",s&&(a.mapping=s));let w=i?void 0:o("frozen:load:error")?.writtenPerObject;w&&w.length>0&&(a.objects=w.map(b=>({...b})));let A=o("frozen:verify:result")?.verdict;A&&(a.verdict=pn(A));break}case"verify":{let i=o("frozen:verify:result")?.verdict;await d(i?.manifestPath?Fn(i.manifestPath):n.datasetDir),s&&(a.mapping=s),i&&(a.verdict=pn(i));break}case"remove":{s&&(a.mapping=s);let i=o("frozen:remove:response")?.result,u=o("frozen:remove:preview:response")?.preview;i?(a.status=i.status,i.mutedAutomation&&(a.mutedAutomation=i.mutedAutomation),a.objects=i.objects.map(m=>({objectApiName:m.objectApiName,planned:m.planned,deleted:m.deleted,alreadyGone:m.alreadyGone,keptChanged:m.keptChanged,keptDependents:m.keptDependents,refused:m.refused,notReached:m.notReached??0,notVisible:m.notVisible??0,...m.tookAlong?{tookAlong:m.tookAlong}:{},...m.cameAlong?{cameAlong:m.cameAlong}:{}})),a.includeChanged=i.includeChanged):u&&(a.preview=!0,a.includeChanged=u.includeChanged,a.objects=u.objects.map(m=>({objectApiName:m.objectApiName,planned:m.planned,toDelete:m.toDelete,alreadyGone:m.alreadyGone,changedSince:m.changedSince,keptChanged:m.keptChanged,undeletable:m.undeletable,notVisible:m.notVisible,unread:m.unread})),f.push(...u.refusals),u.refusalCodes?.length===u.refusals.length&&r.push(...u.refusalCodes));break}}return f.push(...n.refusals??[]),n.refusalCodes?.length===(n.refusals??[]).length&&r.push(...n.refusalCodes??[]),f.length>0&&(a.refusals=f),f.length>0&&r.length===f.length&&(a.refusalCodes=r),n.mute&&Object.assign(a,n.mute),n.checkpoint&&(a.checkpoint=n.checkpoint),a}function no(e,t){return t===x?e:{name:e.name==="load"?t.run:e.name,detail:e.detail.replace(/\bThe load\b/g,`The ${t.run}`).replace(/\bthe load\b/g,`the ${t.run}`).replace(/\bnot loaded\b/g,`not ${t.done}`).replace(/\bnot loadable\b/g,`not ${t.run}able`)}}async function oo(e=process.argv){await ro(Ln(e))}async function ro(e,t){let n=Date.now(),o=c=>{process[e.json?"stderr":"stdout"].write(`${c}
271
+ `)},s=t?.words??x,a=t?{}:JSON.parse(be(e.configPath??"","utf8")),f=t?t.folder.dir:typeof a.sasDir=="string"?a.sasDir:H(On(),".sandforge-sas");t||Rn(f,{recursive:!0});let r=Ot(t?t.auditStore:e.storePath??H(f,"cli-store.json")),d=new Map,i=new Map,u=new Map,m=e.source?await rn(e.source,d):void 0,w=e.target?await rn(e.target,d,i,u):void 0,A=[],b=!1,B=!1,C=new en({log:()=>{},broker:{postToWebview:c=>{if(c.type==="frozen:load:progress")return;if(t&&String(c.type).endsWith(":error")&&c.payload){let v=c.payload.code;c.payload.message=t.reword(typeof v=="string"?v:void 0,String(c.payload.message??""),c.payload)}A.push(c),He(c)&&(b=!0);let h=t?.refusalOf(c);if(h&&(E??=h,P.push(h)),B)return;let y=h?[ne(h)]:Zn(c,e,s),g=I!==void 0&&uo(c)?y.filter(v=>!v.startsWith("! ")):y;for(let v of t?t.lines(c,g):g)o(v)}},orgManager:{getOrg:c=>d.get(c)?.org},orgRegistry:{getCredentials:async c=>d.get(c)?.credentials},configStore:r,infraServices:{productionGuard:Wt(o,e.target??e.source??"the org"),piiDetector:new yt},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});t&&C.setReplayStores(t.stores);let T=w?i.get(w):void 0,_=w?u.get(w):void 0,l=e.checkpointFirst&&_?zt({module:t?"replay":"frozen",operationId:`sandforge-frozen-load-${n}`,request:e.checkpointFirst,session:_.session,org:{id:_.typed.id,orgType:_.typed.orgType,..._.typed.edition!==void 0?{edition:_.typed.edition}:{}},connect:Oe,journalDir:oe(),say:o}):void 0;T&&C.setTargetAutomation(re(T)),C.setMuteOffered(De("--mute-automation")),C.setSaltKeeper(Xt(process.env,e.saltFile)),e.target&&C.setOtherModuleRuns(Gn(e.target,void 0,We(f)));let k=new tn;C.setRegistry(k);let p,F,M=!1,j=!1,K=!1,ie=!1,J=!1,I,vn=mt(c=>{if(I=c,j){let g=ft();process.stderr.write(`${g?"":`
272
+ `}${lo(e.step,s)}
273
+ `),process.exit(te(c))}if(ie){Ee(`the ${s.run} is over, and the command ends once what it wrote is recorded`,c);return}let h=e.step==="load"&&!K,y=e.step==="remove"&&!J;if(Ee(h?`the ${e.dryRun?"dry run":s.run} stops after the call under way, before it writes anything`:y?`the ${e.preview?"preview":"removal"} stops after the call under way, before it deletes anything`:e.step==="remove"?"the removal stops after the call under way, and says what it deleted":`the ${e.step==="load"?s.run:e.step} stops after the call under way, and says what it wrote`,c),F){F.abort();return}for(let g of k.getRunning())k.abort(g.operationId);p&&k.cancelBeforeStart(p),(!p||j)&&process.exit(te(c))}),Ae=t?void 0:typeof a.datasetDir=="string"?a.datasetDir:H(f,"dataset"),P=[],G=c=>{let h=t?{code:c.code,message:t.reword(c.code,c.message)}:c;P.push(h),o(le(h,`a ${s.run}`))},U=c=>{if(!t)return{};let{organizationId:h,checkpointId:y,config:g}=t.request;return c==="load"?{replay:t.request}:c==="verify"?{replay:{organizationId:h,checkpointId:y,...g?{config:g}:{}}}:{replay:{organizationId:h,checkpointId:y}}},$e=[],E,Ye=!1,X,q,Q,ke=async(c,h=Number(process.exitCode??0))=>{if(!e.json)return;let y=[...P,...$e],g=await to(e.step,A,{...Ae!==void 0?{datasetDir:Ae}:{},sasDir:f,...w?{targetOrgId:w}:{},...y.length>0?{refusals:y.map(({message:$})=>$),refusalCodes:y.map(({code:$})=>$)}:{},...X?{mute:X}:{},...q?{checkpoint:q}:{}}),v=t?{...t.answer(g,{exit:h,...c?{ended:c}:{},...E?{refused:E}:{},...w?{targetOrgId:w}:{}}),...Q?{notSwept:Q}:{}}:{...g,...Q?{notSwept:Q}:{},...E?{refused:E}:{},...c?{ended:c}:{}};process.stdout.write(`${JSON.stringify(v,null,2)}
274
+ `)},N=async(c,h)=>{let y=`cli-${c}-${Date.now()}`;p=y;try{return await C.handle({id:y,type:c,payload:h})}finally{p=void 0}},et;try{et=await $n()}finally{vn()}if(et==="ended"&&!I){b&&(process.exitCode=1),await ke(!0);return}if(I){await ke(void 0,te(I));let c=e.preview?"preview":e.step==="load"&&e.dryRun?"dry run":e.step,h=e.step==="load"?K&&qe(A):e.step==="remove"?J:!0,y=A.some(g=>g.type==="frozen:load:response");process.stderr.write(`${M?bt:co(c,h,s,y)}
275
+ `),process.exitCode=te(I);return}if(gt(b||P.length>0?1:Ye?3:qn(e.step,A)),e.json){await ke();return}o(`done in ${Date.now()-n}ms`);async function tt(c){await N("frozen:remove:automation",{...c,...U("removal")});let h=z=>A.find(V=>V.type===z)?.payload,y=h("frozen:remove:automation:response"),g=Array.isArray(c.sweptObjects)?c.sweptObjects:[],v=y?.purge&&g.length>0?y.purge:void 0,$=y&&e.muteAutomation?T&&(e.preview||e.dryRun)?await je(Le(T),y.automation,{writes:ue(y.steps)}):Ce(y.automation,ue(y.steps)):void 0,D=$&&!("refused"in $)?$:void 0,{lines:R,refusal:O}=Ue({read:y?.automation??{unread:String(h("frozen:remove:automation:error")?.message)},steps:v??y?.steps??{},...D?{mute:{automation:D.automation,muted:D.planned}}:{}},e.target??"",c.reload===!0?s.againSubject.purge:"removal",v?{delete:g}:void 0);for(let z of R)o(z);let W=$&&"refused"in $?$.refused:O!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:O}:void 0;return{...y?{steps:y.steps}:{},...D?{planned:D}:{},...W?{refusal:W.message,code:W.code}:{}}}function nt(c){E={code:fe,message:c},P.push(E),o(ne(E)),b=!0}async function Re(){if(t){if(w===void 0)return;let h=Ut(await t.stores.replays.mappingStoreOf(t.folder,w).recordedLoads());return h?{...Gt(h),orgId:w}:void 0}return B=!0,await N("frozen:status",{}),B=!1,A.filter(h=>h.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(h=>h.orgId===w)}async function ot(c=[]){if(!e.reload||e.pilot)return;let h=await Re();if(!(!h||h.created.length===0&&c.length===0))return tt({targetOrgId:w,loadedAt:h.loadedAt,reload:!0,...c.length>0?{sweptObjects:c}:{}})}async function rt(){let c=await Re();if(!c)return[];o(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let h=A.length;await N("frozen:remove:sweep",{targetOrgId:w,loadedAt:c.loadedAt,reload:!0,...U("removal")});let y=A.slice(h);if(y.some(v=>v.type==="frozen:remove:sweep:error"))return;let g=y.filter(v=>v.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((g??[]).flatMap(({listing:v})=>Fe(v,e)))]}async function bn(c){o(`reading what a sweep of ${e.target} would take\u2026`);let h=A.length;await N("frozen:remove:sweep",{targetOrgId:w,loadedAt:c,...U("removal")});let y=A.slice(h);if(y.some($=>$.type==="frozen:remove:sweep:error"))return;let g=y.filter($=>$.type==="frozen:remove:sweep:response").at(-1)?.payload,v=[...g?.listing?[g.listing]:[],...(g?.otherLoads??[]).map(({listing:$})=>$)];return[...new Set(v.flatMap($=>Fe($,e)))]}async function st(c){o(`reading what ${t?`a replay of ${s.source}`:"a load"} into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await N("frozen:load:preview",{targetOrgId:w,...U("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:zn(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let h=A.find(S=>S.type==="frozen:load:preview:response")?.payload?.plan,y=A.find(S=>S.type==="frozen:load:preview:error"&&S.payload?.code==="LOAD_CONFIG")?.payload;if(h===void 0&&y!==void 0){P.push({code:"LOAD_CONFIG",message:String(y.message??"")});let S=Array.isArray(y.refusedBeside)?y.refusedBeside:[];for(let{code:L,message:Z}of S)G({code:L,message:Z})}let g=h?Ht(he(h),e.maxTotal):void 0;g&&G({code:"MAX_RECORDS",message:g});let v=h?.automation?.refused;v&&G(v);let $=h?.emails?.refused;$&&G($);let R=A.find(S=>S.type==="frozen:load:preview:response")?.payload?.replay?.storage?.refusal??h?.storage?.refusal;R&&G(R);let O=h?.apiRequests?.refused;O&&G(O);let W=(h&&e.sweep?await rt():[])??[],z=h?await ot(W):void 0;z?.refusal!==void 0&&G({code:z.code??"AUTOMATION_NOT_ACCEPTED",message:z.refusal});let V;if(e.muteAutomation&&h&&T){V=await re(T).read(w,[...new Set([...h.perObject.map(L=>L.objectApiName),...z?.steps?.delete??[]])]);let S=await je(Le(T),V,{writes:so(z?.steps)});if("refused"in S)P.some(({message:L})=>L===S.refused.message)||G(S.refused);else{for(let L of Y(S.planned,e.target??"the target"))o(L);X={mutedAutomation:S.planned,mutePlan:S.plan}}}for(let S of yn(h?.recordTypesGiven,!0,(X?.mutePlan.assign.length??0)>0))o(S);let de=h?mn(h):[];if(c&&l&&h&&T&&de.length>0){V??=await re(T).read(w,h.perObject.map(Z=>Z.objectApiName)).catch(()=>{});let{estimate:S,refused:L}=await gn(l,{written:de,running:hn(V,X?.mutePlan)});if(S){q=S;for(let Z of xe(S))o(Z)}L!==void 0&&G({code:fe,message:L})}return h}async function An(c){let h=A.length,y=b;B=!0;try{await N("frozen:remove:sweep",{targetOrgId:w,loadedAt:c,...U("removal")})}finally{B=!1}let g=A.splice(h);b=y;let v=g.find($=>$.type==="frozen:remove:sweep:response")?.payload?.listing;return v&&v.refusal===void 0&&v.found.length>0?v:void 0}async function $n(){if(t||await N("frozen:config:save",{config:a}),b)return"ended";switch(e.step){case"select":o(`selecting from ${e.source}\u2026`),await N("frozen:select",{sourceOrgId:m});break;case"extract":o(`extracting from ${e.source}\u2026`),await N("frozen:extract",{sourceOrgId:m,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){if(await st(!0),t&&!b)for(let R of t.dryRunEnd(P))o(R);break}let c;if(t){if(c=await st(!1),I)return"ended";if(X=void 0,c===void 0||b||P.length>0)return E??=P[0],b=!0,o("Nothing written."),"ended";if(he(c)===0)return o(`Nothing to create in ${e.target??"the target"}: nothing written.`),"ended"}let h=e.reload&&!e.pilot&&e.sweep?await rt():[];if(I)return"ended";if(h===void 0)return o("Nothing written."),"ended";let y=e.reload&&!e.pilot?await ot(h):void 0;if(I)return"ended";if(y?.refusal!==void 0)return E={code:y.code??"AUTOMATION_NOT_ACCEPTED",message:y.refusal},P.push(E),o(ne(E)),b=!0,"ended";if(e.sweep&&(o(`around the purge, a sweep deletes what the target's automation made for each ${s.run} it replaces, as the ${s.run}'s user, tied to its records \u2014 run with --dry-run to see what`),C.setRemovalAsker(async R=>{let{lines:O,refusal:W}=Ue(R,e.target??"",s.againSubject.sweep);for(let z of O)o(z);if(!(W===void 0||e.acceptAutomation))return E={code:"AUTOMATION_NOT_ACCEPTED",message:W},P.push(E),E})),!e.yes){j=!0;let R=await pt(t&&c?t.question(c):`Load the frozen dataset into ${e.target}${e.reload?`, purging first what earlier loads created${e.sweep?" and what the target's automation made for them":""}`:""}?`);if(j=!1,!R)return o("Nothing written."),"ended"}if(I)return"ended";let g;if(l&&T){let R=c?mn(c):ao(Ae??""),O=await re(T).read(w,R).catch(()=>{}),W={written:R,running:hn(O,e.muteAutomation&&O?Ce(O,Je).plan:void 0)},{estimate:z,refused:V}=await gn(l,W);if(z){q=z;for(let L of xe(z))o(L)}if(V!==void 0||z===void 0)return nt(`${V??""} Nothing was written.`.trim()),"ended";F=new AbortController;let de=F.signal,S=await At(()=>l.take(W,z,{signal:de})).finally(()=>{F=void 0});if("stop"in S)return S.stop.code!==fe?(M=!0,"ended"):(nt(jt(S.stop)),"ended");g=S.checkpoint,q=g;for(let L of Ct(g,e.target??"the target",e.muteAutomation))o(L);if(I){let L=S.checkpoint;q=await l.settle(L,!1).catch(()=>L);for(let Z of _e(q))o(Z);return"ended"}}o(t?`replaying ${s.source} into ${e.target}\u2026`:`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let v=new Date().toISOString(),$=e.maxTotal??(c?he(c):void 0);K=!0,await N("frozen:load",{targetOrgId:w,...U("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...$!==void 0?{maxRecords:$}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.sweep&&e.includeChanged?{includeChanged:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let D=A.filter(R=>R.type==="frozen:load:error").map(Ke).find(R=>R!==void 0);if(D&&!E&&(E=D,P.push(E)),ie=!0,w&&qe(A)){let R=Zt(await new Vt(f,{orgId:w}).recorded().catch(()=>{}),v);try{Qt(oe(),{organizationId:w,sas:We(f),startedAt:v,endedAt:new Date().toISOString(),...R?{lastWriteAt:R}:{}})}catch(O){o(`warning: this load could not be added to ${oe()}: another sas's sweep of ${e.target??""} will not see it (${O instanceof Error?O.message:String(O)})`)}}if(l&&g){let R=g;q=await l.settle(R,qe(A)).catch(O=>(o(`warning: the checkpoint '${R.name}' taken before the load could not be deleted (${O instanceof Error?O.message:String(O)}): delete it with ${Se("checkpoint")} delete --org ${e.target??""} --checkpoint `+R.checkpointId),R));for(let O of _e(q))o(O)}break}case"verify":o(t?`verifying the replay of ${s.source} into ${e.target}\u2026`:`verifying ${e.target}\u2026`),await N("frozen:verify",{targetOrgId:w,...U("verify")});break;case"remove":{let c=await Re();if(!c)return o(`No ${s.run} into ${e.target} is recorded ${s.recordedIn}: nothing to remove.`),"ended";if(e.preview){if(o(`reading what a removal from ${e.target} would do\u2026`),await N("frozen:remove:preview",{targetOrgId:w,loadedAt:c.loadedAt,...e.includeChanged?{includeChanged:!0}:{},...U("removal")}),A.some(g=>g.type==="frozen:remove:preview:response")){let g=e.sweep?await bn(c.loadedAt):[];if(g===void 0)break;let{planned:v,refusal:$,code:D}=await tt({targetOrgId:w,loadedAt:c.loadedAt,...g.length>0?{sweptObjects:g}:{}});if(v&&(X={mutedAutomation:v.planned,mutePlan:v.plan}),$!==void 0){let R={code:D??"AUTOMATION_NOT_ACCEPTED",message:$};$e.push(R),o(le(R,"a removal"))}}break}if(e.sweepList){o(`reading what a sweep of ${e.target} would take\u2026`),await N("frozen:remove:sweep",{targetOrgId:w,loadedAt:c.loadedAt,...U("removal")});let g=A.filter(v=>v.type==="frozen:remove:sweep:response").at(-1)?.payload;Ye=[g?.listing,...(g?.otherLoads??[]).map(({listing:v})=>v)].some(v=>v?.refusal!==void 0);break}for(let g of In(c,e.target??"",s))o(g);e.sweep&&o(`${Ze(c)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the ${s.run}, as the ${s.run}'s user, tied to its records \u2014 run ${Be("--sweep-list")} to see what`);let h=!1;if(C.setRemovalAsker(async g=>{let{lines:v,refusal:$}=Ue(g,e.target??"");for(let D of v)o(D);if($!==void 0&&!e.acceptAutomation)return{message:$,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&Pn(c,g.steps)){j=!0;let D=await ht(`Type ${e.target} to delete them:`);if(j=!1,D!==e.target)return h=!0,{message:"Nothing deleted.",code:wn}}J=!0,o(`removing from ${e.target}\u2026`)}),await N("frozen:remove",{targetOrgId:w,loadedAt:c.loadedAt,...Nn(e),...U("removal")}),h)return"ended";let y=A.filter(g=>g.type==="frozen:remove:error").map(Ke).find(g=>g!==void 0);if(y&&(E=y,$e.push(y)),!e.sweep&&!E&&Kn(A)){Q=await An(c.loadedAt);for(let g of Hn(Q,s))o(g)}break}case"status":await N("frozen:status",{});break}return"through"}}var Je=(e,t)=>t==="insert"||t==="update";function so(e){let t=e?ue(e):void 0;return(n,o)=>Je(n,o)||t?.(n,o)===!0}function yn(e,t,n=!1){return Bt((e??[]).map(o=>({recordTypeGiven:o})),t,n)}function hn(e,t){return{firing:e?ut(e,t,Je).firing:[]}}function mn(e){let t=[...e.perObject.filter(n=>n.toInsert>0||n.toPurge>0||n.toDeactivate>0).map(n=>n.objectApiName),...(e.placeholders??[]).map(n=>n.placeholderObjectApiName)];return[...new Set(t)]}function ao(e){try{let t=JSON.parse(be(H(e,"manifest.json"),"utf8")),n=Object.entries(t.volumetry?.measured??{}).filter(([,o])=>typeof o=="number"&&o>0).map(([o])=>o);if(n.length>0)return n}catch{}try{return Sn(H(e,"data")).filter(t=>t.endsWith(".json")).map(t=>t.slice(0,-5)).sort()}catch{return[]}}var io=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",ce.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",Ne,"FROZEN_STORAGE_EXCEEDED"]);function qe(e){let t=a=>e.filter(f=>f.type===a).at(-1)?.payload,n=t("frozen:load:response")?.report;if(n){let a=f=>Object.values(f??{}).reduce((r,d)=>r+d,0);return n.perObject.some(f=>f.inserted>0)||(n.placeholders??[]).length>0||a(n.purge?.deleted)>0||a(n.purge?.deactivated)>0}let o=t("frozen:load:error"),s=o?.code;return typeof s=="string"&&io.has(s)?!1:o?.written!==0}async function gn(e,t){try{let n=await e.scope(t);return{estimate:n,...n.refusal!==void 0?{refused:Lt(n.refusal)}:{}}}catch(n){return{refused:vt(n).replace(/ Nothing was written\.$/,"")}}}function uo(e){return e.type==="frozen:load:error"&&e.payload?.code==="LOAD_CANCELLED"}function lo(e,t=x){return e==="remove"?"interrupted at its question: the removal stopped before it deleted anything":`interrupted at its question: the ${e==="load"?t.run:e} stopped before it wrote anything`}function co(e,t=!0,n=x,o=!1){let s=n===x?"the sas":"the folder of its replays";return e==="load"&&o?t?`interrupted once the ${n.run} was through: what it wrote is recorded in ${s} and the audit trail, and ${n.remove} takes it back`:`interrupted once the ${n.run} was through: it created or purged no record, and ${n.remove} has nothing of this ${n.run} to take back`:e==="dry run"?"interrupted: the dry run stopped before it was through, and wrote nothing":e==="load"&&!t?`interrupted: the ${n.run} stopped before it created or purged a record: ${s} is as it was, and ${n.remove} has nothing of this ${n.run} to take back`:e==="load"?`interrupted: the ${n.run} stopped before it was through; what it wrote is recorded in ${s} and the audit trail, and ${n.remove} takes it back`:e==="remove"&&!t?`interrupted: the removal stopped before it deleted anything, and ${n.remove} again takes the records of the ${n.run}`:e==="remove"?`interrupted: the removal stopped before it was through; what it deleted is recorded, and ${n.remove} again takes what it left`:e==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${e} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(Nt(),oo().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
276
+ `),process.exit(1)}));export{zn as a,Ln as b,jn as c,x as d,Nn as e,Ue as f,In as g,Pn as h,dn as i,Mn as j,Ke as k,He as l,Gn as m,qn as n,Vn as o,cn as p,Kn as q,Hn as r,Zn as s,Jn as t,Qn as u,to as v,no as w,oo as x,ro as y,yn as z,mn as A,ao as B,qe as C,lo as D,co as E};