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
@@ -1,7 +0,0 @@
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{a as Ce}from"./chunk-GMY5427L.mjs";import{h as Re,i as be,j as Se,k as ke,n as Te,o as Fe}from"./chunk-TEIBWMJM.mjs";import{c as Oe}from"./chunk-BWWQXU2B.mjs";import{f as me,i as we}from"./chunk-EINEGS6E.mjs";import{d as he}from"./chunk-4N425UJC.mjs";import{b as fe,c as q,m as pe}from"./chunk-HFSBDM7B.mjs";import{d as K}from"./chunk-OHEOJISY.mjs";import{G as se,q as te,s as ne,t as re,u as oe}from"./chunk-Z354SAEF.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{a as z,l as ie,o as ae,q as de,t as ce,u as ue,v as le}from"./chunk-ICIYL45C.mjs";import{b as ye,e as ge}from"./chunk-JFVY66BS.mjs";import{Sc as X,id as B}from"./chunk-CRPLDXJU.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var We=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Ae(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Se(be(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ie(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function ze(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function ve(t,e){return`${t} ${e} record${t===1?"":"s"}`}function Ue(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(c=>b(c.id)===b(t)),y=i?(n.target??[]).filter(c=>c.sobjectType===i.sobjectType&&c.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:y.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function Ge(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??Te(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function Le(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${ve(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function Ee(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],y=r?.references??new Set,c={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},h=new Map,m=new Map,T=(d,l,g,k)=>{c.held.push({index:d,reason:g}),h.delete(d);let I=m.get(l);I?I.count++:m.set(l,{count:1,say:k})},w=e.operation==="insert"||e.operation==="upsert",W=w&&i.some(d=>!d.master),f=new Map;s&&w&&s.sources.forEach((d,l)=>{let g=d?.Id;typeof g=="string"&&H.test(g)&&f.set(b(g),l)});let v=new Set([...s&&w?s.later??[]:[]].map(d=>d.toLowerCase())),R=new Set(v.size===0?[]:(r?.fields??[]).flatMap(d=>d.isReference&&(d.referenceTo??[]).some(l=>v.has(l.toLowerCase()))&&!(d.nillable===!1&&d.defaultedOnCreate!==!0)?[d.name]:[]));n.forEach((d,l)=>{let g=ze(d,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){h.set(l,{payload:g,settled:new Set});return}let k=new Set;if(s)for(let p of Object.keys(g)){let C=g[p];if(p==="RecordTypeId"||!y.has(p)||typeof C!="string"||!H.test(C))continue;if(f.has(b(C))){delete g[p],c.deferred.push({index:l,field:p,parent:C});continue}let _=s.links.targetOf(C);if(_){g[p]=_,k.add(p);continue}let M=s.links.refusedObjectOf(C);if(M===void 0){R.has(p)&&(delete g[p],c.deferredAcross.push({index:l,field:p,parent:C}));continue}let G=Le(o,p,M);T(l,G.group,G.reason,G.say);return}let I=g.RecordTypeId,E,j=Oe(I);if(j)delete g.RecordTypeId;else if(typeof I=="string"&&H.test(I)){let p=Ue(I,i,s?.recordTypes);if("unmapped"in p){let C=p.unmapped,_=p.namesakes.length>0?` The target org's ${p.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";T(l,`unmapped:${C}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",M=>`RECORD_TYPE_UNMAPPED: ${ve(M,o)} held back, not sent: `+(C?`their record type ${C} has no active ${o} record type of that API name in the target org.${_} Create or activate record type ${C} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in p){let C=p.unavailable;T(l,`unavailable:${C.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${C.developerName} is closed to the running user in the target org.`,_=>`${pe({objectApiName:o,recordTypeId:C.recordTypeId,developerName:C.developerName,name:C.name,inactive:!C.active,recordCount:_})} Held back, not sent.`);return}g.RecordTypeId=p.sent,E=p.sent,p.info&&k.add("RecordTypeId")}let $=s?.sources[l]??d;if(re($)){let p=oe($,Ge(r,E,s?.recordTypes?.personTypes));for(let C of Object.keys(g))B(o,C,p)&&delete g[C]}else for(let p of Object.keys(g))B(o,p,"business")&&delete g[p];W&&!("RecordTypeId"in g)&&c.withoutRecordType.set(l,j?"masterInSource":"notRead"),h.set(l,{payload:g,settled:k})});let L=!0;for(;L;){L=!1;for(let{index:d,field:l,parent:g}of c.deferred){let k=f.get(b(g));if(!h.has(d)||k===void 0||h.has(k)||s?.links.targetOf(g)!==void 0)continue;let I=Le(o,l,o);T(d,I.group,I.reason,I.say),L=!0}}c.deferred=c.deferred.filter(({index:d})=>h.has(d)),c.deferredAcross=c.deferredAcross.filter(({index:d})=>h.has(d));for(let d of[...c.withoutRecordType.keys()])h.has(d)||c.withoutRecordType.delete(d);c.held.sort((d,l)=>d.index-l.index);let S=e.operation==="delete"?void 0:s?.currencies,O=r?.creatable.has(z)===!0,u=!O&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(d=>d.name===z)===!0,F=S&&(O||u)?ae(r?.fields??[]):void 0,P=[...r?.references??[]],A=new le;for(let[d,{payload:l,settled:g}]of[...h].sort(([k],[I])=>k-I)){for(let k of X(o,l))delete l[k];if(S&&F){let k=s?.sources[d]??n[d],I=k?.[z],E=O?de(l,{read:I,currencyFields:F,ratesOn:ie(o,k)},S):ue(l,{read:I,parent:k?ce(o,k,P,$=>s?.currencyChangesById?.get($)):void 0,currencyFields:F},S);A.add(o,E);let j=k?.Id;E&&typeof j=="string"&&s?.currencyChangesById?.set(j,E)}c.payloads.push(l),c.sentAt.push(d),c.settled.push(g)}return c.notes=[...m.values()].map(({count:d,say:l})=>l(d)),c.currencies=A.list(),c}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Be(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function yt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Be),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function gt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function ht(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ce(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function Pe(t,e,n,r){let s;try{s=await t(e)}catch(c){if(n==="delete")return{notAsked:!0};let h=Fe(c)?"notInTarget":"unread";return{refused:{why:h,message:Z(e,h,ee(c))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let y=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(y.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",y),key:y},target:s}:{target:s}}function Rt(t){return t.keepContactPoints===!0?void 0:new Re}function Ot(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function xe(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var x=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Ne=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:y}=await this.write(e,n,r);return Je(Qe(e.objectApiName,e.operation,s,o,i,y),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let u=await Pe(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in u){let F=n.map(()=>({success:!1,errors:[u.refused.message]}));return r&&$e(e,F,r),{outcomes:F,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in u&&u.target.creatable.size>0&&(s=u.target)}let o=Ee({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&xe(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=He(o.payloads,o.settled,r),y=new Map(o.held.map(({index:u,reason:F})=>[u,F])),c=u=>{let F=[],P=0;for(let A=0;A<n.length;A++){let d=y.get(A);if(d!==void 0){F.push({success:!1,errors:[d],heldBack:!0});continue}if(P>=u.length)break;F.push(u[P++])}return F},h,m=o.sentAt.filter(u=>u<(r?.standardFirst??0)).length,T=u=>this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField);try{h=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Ve(e.objectApiName,T,o.payloads.slice(0,m),o.payloads.slice(m)):await T(o.payloads)}catch(u){if(!(u instanceof x))throw u;let F=je(i,u.written),P=c(u.written);throw De(e,o.withoutRecordType,P,s,r),new x(e.objectApiName,P,[...o.notes,...u.notes],[...F?[F]:[],...u.lookupsLeftOut,...Q(U([...o.deferred,...o.deferredAcross],P))],u.writtenWithoutFields)}let w=await this.retryRefused(e,o.payloads,h,s?.references??null,o.settled);if(r)for(let u of w.ownersRefused)r.links.noteOwnerRefused(u);let W=c(w.outcomes);De(e,o.withoutRecordType,W,s,r);let f=je(i,w.outcomes),v=[...o.notes,...w.notes],R=[...f?[f]:[],...w.lookupsLeftOut],{writtenWithoutFields:L}=w,S=U(o.deferredAcross,W),O=0;if(w.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q([...U(o.deferred,W),...S])],L);if(r){$e(e,W,r),Ze(e,o.payloads,w.outcomes,r.links);let u=await this.setLookups(e,U(o.deferred,W),r.links,!1);if(R.push(...u.leftOut),O=u.unset,u.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q(S)],L)}return{outcomes:W,notes:v,currencies:o.currencies,lookupsLeftOut:R,...L?{writtenWithoutFields:L}:{},...S.length>0?{lookupsToSet:S}:{},...O>0?{lookupsUnset:O}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,y=new D;for(let{id:f,field:v,parent:R}of n){let L=r.targetOf(R),S=L!==void 0?a:s&&r.refusedObjectOf(R)===void 0?i:void 0;if(!S){y.add(f,v);continue}let O=S.get(f)??{Id:f};O[v]=L??R,S.set(f,O)}let c=new D,h=new D,m=new D,T=new D,w=!1;for(let f of[[...a.values()],[...i.values()]]){if(f.length===0)continue;if(w){for(let R of f)T.addRow(R);continue}let v;try{v=await this.executeOperation(o,"update",f,e.batchSize)}catch(R){if(!(R instanceof x)){let L=R instanceof Error?R.message:String(R);for(let S of f)m.addRow(S,L);continue}v=R.written,w=!0}f.forEach((R,L)=>{let S=v[L];S===void 0?T.addRow(R):S.success?c.addRow(R):S.errors.some(O=>J(O))?h.addRow(R):m.addRow(R,S.errors[0])})}let W=[y,h,m,T];return{...c.records>0?{set:{records:c.records,fields:c.fields()}}:{},leftOut:[y.leftOut("parentRefused"),h.leftOut("notInTarget"),m.leftOut("notSet"),T.leftOut("notReached")].flatMap(f=>f?[f]:[]),unset:new Set(W.flatMap(f=>[...f.recordIds])).size,cancelled:w}}async retryRefused(e,n,r,s,o){let a=Y(e)??void 0,i=[...r],y=[...n],c=n.map(()=>new Set),h=n.map(()=>[]),m=n.map(()=>[]),T=[],w,W=new Set;for(let S=0;S<2&&!w;S++){let O=[],u=[],F=[];if(i.forEach((A,d)=>{if(A.success)return;let l=y[d],g=o[d]??new Set;if(A.errors.some(E=>J(E))){let E=n[d]?.[N];if(typeof E=="string"&&!g.has(N)&&(A.errorDetails??[]).some(p=>J(p.statusCode)&&p.fields.includes(N))&&W.add(E),c[d].has("lookup")||!s||s.size===0)return;let j={},$=!1;for(let p of Object.keys(l)){if(s.has(p)&&!g.has(p)&&l[p]!==null&&l[p]!==void 0){$=!0;continue}j[p]=l[p]}if(!$)return;O.push(d),u.push(j),F.push(null);return}if(c[d].has("fields"))return;let k=me(A.errorDetails,l,a);if(!k||k.some(({field:E})=>g.has(E)))return;let I=new Set(k.map(({field:E})=>E));O.push(d),u.push(Object.fromEntries(Object.entries(l).filter(([E])=>!I.has(E)))),F.push(k)}),O.length===0)break;let P;try{P=await this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField)}catch(A){if(!(A instanceof x)){T.push(...Ye(O,y,u,F,A));break}P=A.written,w=A}P.forEach((A,d)=>{let l=O[d],g=F[d];c[l].add(g===null?"lookup":"fields"),g===null?h[l].push(...Object.keys(y[l]).filter(k=>!(k in u[d]))):m[l].push(...g),y[l]=u[d],i[l]=A})}let f=new Set,v=0,R,L=new Set(W);return i.forEach((S,O)=>{if(!(!S.success||c[O].size===0)){if(h[O].length>0){v++;for(let F of h[O])f.add(F);let u=n[O]?.[N];typeof u=="string"&&h[O].length===1&&h[O][0]===N&&L.add(u)}m[O].length>0&&(R=we(R,{rows:1,fields:m[O].map(u=>({...u,rows:1}))}))}}),{outcomes:i,notes:[...T,...w?.notes??[]],...R?{writtenWithoutFields:R}:{},cancelled:w!==void 0,ownersRefused:[...L],lookupsLeftOut:[...v>0?[{records:v,fields:[...f].sort(),reason:"notInTarget"}]:[],...w?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ke=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],qe=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ke.some(e=>t.includes(e))||qe.test(t)}var N="OwnerId";function He(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[N];typeof a!="string"||e[o]?.has(N)||n.links.isOwnerRefused(a)&&(delete s[N],r.add(o))}),r}function je(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[N],reason:"ownerRefusedEarlier"}}function Ye(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,y=0;return r.forEach((c,h)=>{if(c===null){y++;let m=n[h];for(let T of Object.keys(e[t[h]]))T in m||a.add(T)}else for(let{field:m}of c)i.add(m)}),[...y>0?[`${y} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-y} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var D=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function U(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function vt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new D;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Me(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Ve(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof x?new x(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function De(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[c,h]of e){let m=n[c];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(h),a.length<ke&&a.push(m.id))}let i=Ie(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),y=Ae(t.objectApiName,o,i);y&&s.createdWithoutRecordType.set(t.objectApiName,{given:y,types:i,ids:a})}function Ze(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function $e(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Me(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function Je(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var _e=1e3;function Qe(t,e,n,r=[],s=[],o){let a=0,i=0,y=0,c,h=[],m=0,T={created:0,updated:0},w={rows:0,written:0,stillLocked:0};for(let f of n)f.lockResends!==void 0&&(w.rows++,f.success?w.written++:he(f.errors,f.errorDetails)&&w.stillLocked++),f.success?(a++,f.created===!0?T.created++:f.created===!1&&T.updated++):Me(e,f)!==void 0?(y++,c??=f.errors[0]):(i++,!f.heldBack&&m++<_e&&h.push(...f.errors));let W=Math.max(0,m-_e);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:y,conflictCount:0,errors:[...h,...r],...y>0?{linkedToExisting:{records:y,...c?{refusal:c}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...w.rows>0?{sentAgainForALock:w}:{},...W>0?{refusalsDropped:W}:{},...e==="upsert"?{upsertSplit:T}:{}}}export{We as a,Ae as b,Ie as c,Ee as d,yt as e,gt as f,ht as g,Pe as h,Rt as i,Ot as j,xe as k,x as l,Ne as m,vt as n,Q as o,Me as p,Je as q,_e as r,Qe as s};
@@ -1,7 +0,0 @@
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{a as R,b as S,c as E,d as y}from"./chunk-RKTFFCNS.mjs";import{homedir as O}from"node:os";import{join as N,resolve as I}from"node:path";var P="SANDFORGE_JOURNAL_DIR";function k(e=process.env){let n=e[P];return n!==void 0&&n.trim()!==""?I(n):N(O(),".sandforge")}import{spawn as T}from"node:child_process";import{join as Y}from"node:path";import{StringDecoder as C}from"node:string_decoder";function G(){return process.execArgv.filter(e=>!/^--inspect/.test(e))}function j(e){return Y(__dirname,`${e}.mjs`)}var a="SANDFORGE_RELAYED_BY";function q(e={}){let n=(e.platform??process.platform)==="win32",A=e.scriptPath??j;return(v,w,o,i={})=>new Promise((B,L)=>{let p=i.relayedBy??e.relayedBy,b={...process.env,...p!==void 0?{[a]:p}:{},...n?{[y]:"ipc"}:{}},r=T(process.execPath,[...G(),A(v),...w],{stdio:n?["ignore","pipe","pipe","ipc"]:["ignore","pipe","pipe"],env:b,detached:!n,windowsHide:!0}),f=[],u=[],l=i.onStderr!==void 0?new C("utf8"):void 0;r.stdout?.on("data",t=>f.push(t)),r.stderr?.on("data",t=>{u.push(t),process.stderr.write(t);let d=l?.write(t);d&&i.onStderr?.(d)});let s=()=>{if(!n||!r.connected){r.kill("SIGINT");return}r.send(E,t=>{t&&r.kill("SIGINT")})};o.aborted?s():o.addEventListener("abort",s,{once:!0}),r.on("error",t=>{o.removeEventListener("abort",s),L(t)}),r.on("close",(t,d)=>{o.removeEventListener("abort",s);let m=l?.end();m&&i.onStderr?.(m);let g=R.find(h=>h===d);B({code:t??(g!==void 0?S(g):1),stdout:Buffer.concat(f).toString("utf8"),stderr:Buffer.concat(u).toString("utf8")})})})}function c(){let e=process.env[a]?.trim();return e===void 0||e===""?void 0:e}function _(){return c()?.startsWith("sandforge env")===!0}function ee(e,n){return _()?n:e}var F="sandforge mcp clone_org_plan",x="sandforge mcp clone_org",J=new Map([["sandforge env",["--sweep","--include-changed"]],["sandforge env, relayed by sandforge mcp",["--include-changed"]],["sandforge mcp",["--mute-automation","--leave-undeletable","--store","--include-changed","--preview"]],[F,["--max-total","--exclude-object","--exclude","--filter","--fit","--fit-within","--fit-seed","--fit-draw","--fit-parents","--fit-children","--fit-whole","--fit-floor","--anonymize","--accept-automation","--accept-emails","--mute-automation","--checkpoint-first"]],[x,[]]]);function ne(){return _()||c()===x}function H(e){let n=c();return n===void 0||J.get(n)?.includes(e)===!0}function te(e,n){return H(e)?e:n===void 0?`this script's own ${e}`:`this script's own ${n} with ${e}`}export{k as a,a as b,q as c,c as d,_ as e,ee as f,F as g,x as h,ne as i,H as j,te as k};
@@ -1,7 +0,0 @@
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{c as Be,d as Pe,e as je,f as We,p as xe,q as Le,t as _e,v as ze}from"./chunk-MB2DG66I.mjs";import{e as Me}from"./chunk-NCASRA7L.mjs";import{b as Te,f as Ne}from"./chunk-TE2W76II.mjs";import{m as Fe}from"./chunk-NZJXEULY.mjs";import{b as Ee}from"./chunk-KYLHS74X.mjs";import{i as we,j as ke,k as ye,l as be,m as Re,p as Ae,q as Oe}from"./chunk-ZLQHBI6V.mjs";import{A as Ue,B as Ie,C as $e,D as ve}from"./chunk-TG52WNGV.mjs";import{B as ge}from"./chunk-CSSOLHE3.mjs";import{a as le,b as fe}from"./chunk-YDXMTWAT.mjs";import{i as Ce,j as Se}from"./chunk-YGE4AUXG.mjs";import{b as ue,d as ce}from"./chunk-P6A22FMQ.mjs";import{c as me}from"./chunk-AIUAEBHR.mjs";import{j as pe,p as he,qc as De}from"./chunk-O3ZQSWDN.mjs";import{g as L,h as _,q as de}from"./chunk-FG4Y4ZVL.mjs";import{b as x}from"./chunk-CA5NAXSU.mjs";import{Od as se,Wd as W}from"./chunk-CRPLDXJU.mjs";var S=class extends Error{constructor(){super("The undo was stopped before it wrote anything to the org."),this.name="UndoStopped"}},z="No record was written.",Ke="accept that it runs to undo the rewind all the same";function Ge(e){return e.slice(0,15)}function Ye(e){return{query:n=>e.query(n),queryMore:n=>e.queryMore(n)}}function Qe(e,n,t){if(e.kind==="org")return;let s=e.userKey;if(n.users.some(i=>i.slice(0,15)!==s))return{code:"PERMISSIONS",message:`This rewind was made as another user than ${t}: what it deleted is that user's deletion in the recycle bin, which Salesforce brings back only for a user with View All Data and Modify All Data. Undo it as the user it was made as, or as a user with View All Data and Modify All Data. ${z}`};let r=n.objects.flatMap(i=>{let l=e.notHeld.get(i);return l===void 0?[]:[`${i}: ${l}`]});if(r.length!==0)return{code:"PERMISSIONS",message:`Undo takes back what the rewind did to objects ${t} no longer holds whole (${r.join("; ")}), and does not stop part way: an undo left part way could not be offered again. Undo it once the user has View All and Modify All on them again, or as a user with View All Data and Modify All Data. ${z}`}}function Xe(e,n){return{undone:!1,refusal:{code:e,message:n}}}function Ze(e,n){return{code:"RUN_WRITING",message:`${n.operation==="take"?`A checkpoint of ${e} is being taken`:n.operation==="rewind"?`A rewind is writing to ${e}`:n.operation==="undo"?`An undo is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${n.pid} on ${n.host}): undo the rewind once it has ended. No record was read or written.`}}function et(e,n,t,s){let r=W(n,t),i=[...new Set(r.map(b=>b.objectApiName))],l=(t.setToDraft??[]).length>0?", sets an order back to Draft":"",h=r.length>0?`${Me(r)} flow(s), trigger(s) or rule(s) of ${i.join(", ")} run as the undo brings records back, gives them their values back${l} or sends them back to the recycle bin`:"what runs as the undo writes could not all be read, so automation may run";return{code:"AUTOMATION",message:`${e}: ${h}. ${ye("undo",s)}Undo refused; ${Ke}. ${z}`}}async function tt(e,n){let t=0,s=0;for await(let r of n.bringBack.pages(L)){t+=r.length;for(let i of ce(r,ue)){let l=await e.queryDeleted(`SELECT Id, ContentSize FROM ${L} WHERE Id IN (${i}) AND IsDeleted = true`);for(let h of l.records)typeof h.ContentSize=="number"&&(s+=h.ContentSize)}}return{files:t,bytes:s}}function nt(e,n){return e.status==="cancelled"||e.status==="failure"?e.status:n.some(t=>t.reason==="changedDuringRewind")?"unstable":e.status}function ot(e,n){return e.map(t=>{if(t.reason==="notBack")return{objectApiName:t.objectApiName,reason:"notBack",count:t.count,ids:[...t.ids],...t.message!==void 0?{message:t.message}:{}};let s=Object.keys(t.by).filter(i=>!n.has(Ge(i)));if(s.length===0)return{objectApiName:t.objectApiName,reason:"automation",count:t.count,ids:[...t.ids]};let r=s.length===1&&s[0]!=="unknown"?s[0]:void 0;return{objectApiName:t.objectApiName,reason:"changedDuringRewind",...r!==void 0?{by:r}:{},count:t.count,ids:[...t.ids]}})}async function Ct(e,n){let{checkpoint:t,folder:s,orgName:r,rewindId:i}=n,l=e.signal,h=()=>l?.aborted===!0,b=(I,k)=>e.onProgress?.({percentage:I,step:k}),c=ze(e.org,e.undelete),T,U=await Ee(Ye(c.org),{act:"undo",orgName:r,registered:n.registered,username:n.username,organizationId:t.org.organizationId,customSettings:de(t)},{userId:async()=>T=await c.org.userId()});if(!U.allowed)return{undone:!1,refusal:U.refusal};let R=e.store.lock(t.org.organizationId,"undo",t.checkpointId);if("busy"in R)return{undone:!1,refusal:Ze(r,R.busy)};try{let I=await e.runWriting?.(U.org.id);if(I!==void 0)return Xe("RUN_WRITING",I);let k=await Ie(c.org,r);if(h())throw new S;b(5,"Reading what the rewind did");let g=await Pe(s,i,t.objects),G=je(g),N=g.goesWithParent.objects,qe=g.remade.keys.size>0?"Sending back to the recycle bin what the rewind brought back, and deleting again what it made again":"Sending back to the recycle bin what the rewind brought back",A=o=>o.filter(u=>u.count>0).map(u=>u.objectApiName),M=g.links,q=o=>o>0?[_]:[],B=g.remade.objects.filter(({objectApiName:o,count:u})=>u>0&&ge([o]).length>0),m={bringBack:A(g.bringBack.objects),giveBack:[...A(g.giveBack.objects),...q(M?.share.count??0)],...B.length>0?{setToDraft:A(B)}:{},delete:[...new Set([...A(N),...A(g.remove.objects),...q(M?.remove.count??0)])],...(M?.reinsert.count??0)>0?{recreate:[_]}:{}},H;try{H=await tt(c.org,g)}finally{await g.dispose()}let V=ve("undo",H,k.fileStorage?.remaining,r);if(V)return{undone:!1,refusal:V};let w=[...new Set([...m.bringBack??[],...m.giveBack??[],...m.setToDraft??[],...m.delete??[],...m.recreate??[]])],P;try{P=await Te({grants:U.grants,...T!==void 0?{userId:T}:{},username:n.username,checkpoint:t,reader:Se(c.org,l)})}catch(o){throw o instanceof Ce||h()?new S:o}if(P.kind==="perObject"){let o=await Be(s,i),u=Qe(P,{users:o.passes.map(f=>f.userId),objects:w},n.username);if(u)return{undone:!1,refusal:u}}let d;if(w.length>0&&e.readAutomation){try{d=await e.readAutomation(w)}catch(o){d=_e(w,x(o))}c.add(d.requests)}let $=d,y=w.length>0?await xe(e.mute,d,m):{},v="refusal"in y?y:void 0,J="refusal"in y?void 0:y.mute;y.automation&&(d=y.automation);let O=v?v.plan:J?.plan,K=n.acceptEmails===!0,p=w.length>0&&$?await Ae({act:"undo",orgName:r,automation:$,steps:m,...O?{plan:O}:{},accepted:K,mayMute:e.mute===void 0&&n.canMute===!0,read:()=>me(c.org)}):void 0,Y=we(G,N,B),Q=d?ke(Y,d):void 0,C=v?[v.refusal]:[];d&&!n.acceptAutomation&&(W(d,m).length>0||se(d.unread)||Q!==void 0)&&C.push(et(r,d,m,Q));let X=Ue({objects:t.objects,rewound:G,along:N,automationRequests:0}),Z=De(p?.ofRun),ee=$e("undo",{run:c.used()-(Z.deliverability??0)+X.apiRequests,...Z,...he(O)},k,r);w.length>0&&ee&&C.push(ee);let te=d?Re("undo",be(Y,d,k.emails),r):void 0;w.length>0&&te&&C.push(te),p?.refusal&&C.push(p.refusal);let[ne,...oe]=C;if(ne)return{undone:!1,refusal:ne,...oe.length>0?{alsoRefused:oe}:{}};if(h())throw new S;let He=await c.org.userId(),Ve=new Set(Ne(t.takenBy,He).map(Ge));b(20,"Bringing back what the rewind deleted and giving back what it wrote over");let j,E;try{E=await Le(J,`undo ${t.checkpointId} ${i}`,o=>{let u=o&&O&&$&&p?Oe({act:"undo",orgName:r,automation:$,steps:m,plan:O,held:o.outcome,planned:p.ofRun.senders,...p.ofRun.read?{reading:p.ofRun.read.reading}:{},accepted:K}):void 0;return u?Promise.resolve({relit:u}):We({folder:s,rewindId:i,lock:R.lock,objects:t.objects,org:c.org,undelete:c.undelete,splitting:le(fe(k.remaining,c.used()+X.apiRequests)),...l?{signal:l}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},onProgress:(f,ae,Je)=>b(20+Math.round(70*f/Math.max(ae,1)),`${qe}: ${Je} ${f} / ${ae}`)})},o=>{j=o})}catch(o){if(!pe(o))throw o;return{undone:!1,refusal:{code:"MUTE",message:`${o.message} No record was written.`}}}if("relit"in E)return{undone:!1,refusal:E.relit};let a=E,re=ot(a.residual,Ve),D=nt(a,re),F=[...a.notes];if(D!=="cancelled"&&D!=="failure"){let o=(e.now??(()=>new Date))().toISOString();try{await e.store.update(t.checkpointId,f=>f.lastRewind?.rewindId===i?{...f,lastRewind:{...f.lastRewind,undoneAt:o}}:f)}catch(f){F.push(`The checkpoint could not be told the rewind was undone (${x(f)}): its list may still offer to undo it.`)}let u=await Fe({folder:s,lock:R.lock,checkpoint:t,rewindId:i,status:D,undoneAt:o});u!==void 0&&F.push(u)}let ie=c.used();return{undone:!0,result:{checkpointId:t.checkpointId,rewindId:i,status:D,deleted:a.deleted,...a.remade?{remade:a.remade}:{},...a.carriedAlone?{carriedAlone:a.carriedAlone}:{},...a.wentAlong?{wentAlong:a.wentAlong}:{},...a.cameBackAlong?{cameBackAlong:a.cameBackAlong}:{},restored:a.restored,undeleted:a.undeleted,...a.files?{files:a.files}:{},residual:re,passes:1,apiRequests:{used:ie,leftToday:Math.max(0,k.remaining-ie)},finishedAt:a.finishedAt,...j?{mutedAutomation:j}:{}},notes:F,...p?.gate.audit!==void 0?{deliverability:p.gate.audit}:{}}}finally{R.lock.release()}}export{S as a,Ke as b,Ct as c};
@@ -1,14 +0,0 @@
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
- var m=()=>({input:process.stdin,output:process.stderr});function p(t,r,n){let{input:e,output:i}=r;return e.isTTY!==!0&&(i.write(`${t}
8
- no terminal to answer: give --yes to go ahead without the question.
9
- `),process.exit(2)),n?.aborted===!0?Promise.resolve(void 0):(i.write(`${t} `),new Promise(c=>{let o=s=>{e.off("data",a),e.off("end",u),n?.removeEventListener("abort",f),e.pause(),c(s)},a=s=>o(String(s).trim()),u=()=>o(void 0),f=()=>{i.write(`
10
- `),o(void 0)};e.on("data",a),e.on("end",u),n?.addEventListener("abort",f,{once:!0}),e.resume()}))}async function T(t,r=m(),n){let e=await p(`${t} [y/N]`,r,n);return e!==void 0&&/^y(es)?$/i.test(e)}async function E(t,r=m(),n){return await p(t,r,n)??""}var w=new Set(["\r",`
11
- `]),g=new Set(["\x7F","\b"]),l="",S="";function b(t,r,n=m()){let{input:e,output:i}=n;return e.isTTY!==!0&&(i.write(`${t}
12
- no terminal to type it on: ${r}.
13
- `),process.exit(2)),i.write(`${t} `),e.setRawMode?.(!0),new Promise(c=>{let o="",a=s=>{e.off("data",u),e.off("end",f),e.setRawMode?.(!1),e.pause(),i.write(`
14
- `),c(s)},u=s=>{for(let d of String(s)){if(w.has(d))return a(o);if(d===l||d===S&&o==="")return a(void 0);g.has(d)?o=o.slice(0,-1):d>=" "&&(o+=d)}},f=()=>a(void 0);e.on("data",u),e.on("end",f),e.resume()})}export{T as a,E as b,b as c};
@@ -1,156 +0,0 @@
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{a as _e}from"./chunk-TW3N6W5Z.mjs";import{a as Le,b as Ee,c as Te,d as De}from"./chunk-5GBO4KD5.mjs";import{a as ye,j as $e}from"./chunk-2METQHGG.mjs";import{c as J}from"./chunk-6FARZYMJ.mjs";import{a as Me}from"./chunk-MQLTEXB7.mjs";import{f as pe,j as Q,k as T,m as ge,n as _,o as D,p as we}from"./chunk-AAOMUI7S.mjs";import{a as Se,c as je,d as xe,e as Re,f as Ce,g as Oe,h as Ie,i as Pe,j as Ne}from"./chunk-W6SLQZKQ.mjs";import{Rc as fe,za as le}from"./chunk-RIIJJRGF.mjs";import{h as be,i as ke}from"./chunk-EYFP3NA6.mjs";import{a as M}from"./chunk-4BQPAVMP.mjs";import{b as G,e as H}from"./chunk-RKTFFCNS.mjs";import{n as ve}from"./chunk-SAHGDSZQ.mjs";import{m as me}from"./chunk-TG52WNGV.mjs";import{h as he}from"./chunk-RM5G4IP6.mjs";import{a as U}from"./chunk-AL4C3GFT.mjs";import{b as oe}from"./chunk-XZRON54U.mjs";import{b as ne,c as re,e as ae,f as ie,h as Ae}from"./chunk-LCDPCUXS.mjs";import{q as ue}from"./chunk-Z354SAEF.mjs";import{e as de,g as ce}from"./chunk-TZE3Y7IQ.mjs";import{Wc as te,gd as se,y as W}from"./chunk-CRPLDXJU.mjs";import{readFileSync as Xe}from"node:fs";import{basename as Ke,join as Ve}from"node:path";var Ze=`sandforge dataops \u2014 mask an org's records, and put them back, without the editor.
8
-
9
- Usage:
10
- npx sandforge dataops anonymize \\
11
- --org <alias> [--object <ApiName>] (--template <id> | --rules <file>) [options]
12
- npx sandforge dataops anonymize \\
13
- --org <alias> --restore <snapshot or set> [--slice <k[,k]>] [--rewrite-all]
14
- [--include-changed] [--store <dir>] [--yes]
15
- npx sandforge dataops anonymize \\
16
- --org <alias> (--template <id> | --rules <file>) --abandon [--store <dir>] [--yes]
17
- A run and a restore take [--accept-automation] [--accept-emails] [--mute-automation].
18
-
19
- Required:
20
- anonymize the command
21
- --org <alias> sf CLI alias of the org
22
- --template <id> a template that ships (tpl-gdpr-standard, tpl-ccpa-california,
23
- tpl-hipaa-health, tpl-sandbox-scrub) or one saved in the store
24
- --rules <file> or a JSON file of rules, saved in the store as a template:
25
- {"name": "...", "rules": [{"fieldPattern": "Contact.Email",
26
- "ruleType": "hash"}]} \u2014 a rule as the panel's editor saves it
27
-
28
- Options:
29
- --object <ApiName> the object to mask, one per run; without it, every object
30
- the template masks, as the panel's Apply masks them \u2014
31
- Account's person accounts among them, in an org that has
32
- person accounts, when the template masks contacts
33
- --where <clause> with --object: mask only the records this SOQL condition
34
- selects, written without WHERE
35
- --dry-run say what a run would mask \u2014 the fields, the records, the
36
- first records masked as a run masks them \u2014 and write
37
- nothing
38
- --slices mask in slices of --max-records records each, consecutive
39
- by Id, each backed up just before it is masked and masked
40
- from that backup: an object past what one snapshot holds
41
- is masked with a way back. With --dry-run, their plan: the
42
- slices, the requests against what the org has left today,
43
- the disk and the time. A slice that cannot be backed up
44
- whole stops the run there, and the slices before it stay
45
- masked with their backups
46
- --max-requests <n> with --slices: the most requests the run sends. It stops
47
- between two slices before the next would send more, exit
48
- 3, and --resume masks the rest
49
- --resume mask only what the last run of the same template, object
50
- and filter left, from where it stopped; of a run in
51
- slices, the rest of its set, with the key it was masked
52
- with
53
- --abandon give up the set of slices of the template left open on the
54
- org: nothing more is masked, and no resume carries it on.
55
- Its slices stay masked, each with its snapshot, which
56
- --restore puts back until the retention removes them; the
57
- records no slice reached keep their values. It writes
58
- nothing to the org
59
- --restore <id> put back the values a snapshot holds, by Id: the id a run
60
- printed, a snapshot's or a set of slices'. Of a set, every
61
- slice not put back yet, in their order: stopped part way,
62
- the same line puts back the rest. It reads the org's
63
- values first and writes only the rows where one of them
64
- differs from the snapshot, and says how many it found
65
- unchanged
66
- --slice <k[,k]> with --restore of a set of slices: only these slices, by
67
- their number, put back again if they were already
68
- --rewrite-all with --restore: write every row of the snapshot back,
69
- the ones the org already holds as the snapshot does
70
- included; of a set, every slice, those put back already
71
- too
72
- --include-changed with --restore of the snapshot a Sync run kept of what
73
- it wrote over: put back the records changed or deleted
74
- since the run too, which a restore of it otherwise
75
- leaves as they are and counts, as removing the run does
76
- --max-age-days <n> the retention, as sandforge.backup.maxAgeDays sets it:
77
- snapshots taken more than <n> days ago are removed as
78
- the command starts, each named on stderr \u2014 the one a
79
- Sync run kept of what it wrote over too, which removing
80
- that run then no longer puts back; 0 keeps them all
81
- (default: 30)
82
- --store <dir> where snapshots, saved templates and checkpoints live, a
83
- folder of your own, and the key of each run in slices
84
- until its set ends, in keys/, read by its owner alone;
85
- the one sandforge backup reads and lists (default:
86
- ~/.sandforge/backups, under the folder
87
- SANDFORGE_JOURNAL_DIR names when it is set)
88
- --max-records <n> most records of the object a snapshot holds, as
89
- sandforge.backup.maxRecordsPerObject sets it; a run with
90
- more writes nothing, and a dry run says so \u2014 past it,
91
- --slices masks in slices of this size (default: 50000;
92
- 100 to 1000000, any other refused, exit 2)
93
- ${Te("written over","--dry-run")} --yes do not ask before writing. Without it, a command with no
94
- terminal to answer the question \u2014 a CI step \u2014 stops
95
- there, exit 2, and writes nothing. It answers no to a
96
- restore into a sandbox refreshed since its snapshot,
97
- which only a yes typed in a terminal writes
98
- --json emit what the panel would receive, every other line on
99
- stderr; a preview's original values are left out
100
- --help this text
101
-
102
- A run takes a snapshot of the records it masks, their masked fields as they are,
103
- before its first write, and writes nothing unless the snapshot holds every one of
104
- them. A production org is refused.
105
-
106
- With --slices, each slice is backed up just before it is masked, and masked from
107
- that backup, so a record created since is never masked without one: a run says
108
- at its end the records created during it in a range a slice masked, which
109
- --resume masks with a slice of their own. The key the run hashes and draws its
110
- people with is kept in the store's keys/ until its set is done or given up, so a
111
- resume, in another process too, masks the same values the same way. While the
112
- set is open, a new run of the template is refused: --resume masks the rest, and
113
- --abandon gives the set up. The run writes over REST, 200 records a call, and
114
- sends no Bulk API batch.
115
-
116
- Before it writes, a run and a --restore say what the org runs as the records are
117
- written over \u2014 its record-triggered flows, Apex triggers, processes and workflow
118
- rules on update, and on undelete for what a restore brings back from the recycle
119
- bin \u2014, the emails that sends against what the org has left today, and whether
120
- the org delivers them; a dry run says it too, and what a real run would be
121
- refused for (with --json, the dataops:automation:response it carries).
122
-
123
- Ctrl-C stops a run as the panel's Cancel does: before its next page, what it
124
- masked recorded in the audit trail of the store, and --resume masks only what it
125
- left \u2014 of a run in slices, from where the slice it was in stopped. It stops a
126
- --restore before its next batch, what it put back recorded the same way, and the
127
- same --restore puts back the rest. Ctrl-C again ends the process at once. A
128
- SIGTERM \u2014 a CI job cancelled or timed out \u2014 or a SIGHUP stops it the same way.
129
-
130
- Exit codes: 0 the run masked every record it counted, or the restore put back
131
- every value; 1 it could not start, was refused or failed \u2014 what the org runs as
132
- it writes, without --accept-automation (AUTOMATION_NOT_ACCEPTED), emails it
133
- delivers, without --accept-emails (EMAILS_NOT_ACCEPTED), more emails than it
134
- has left today (EMAILS_EXCEEDED), or a mute refused among the reasons \u2014, or a
135
- --dry-run saw that a run would be refused; 2 a bad command line,
136
- or a question with no terminal to answer it (give --yes); 3 the run left
137
- records unmasked, their personal data still in the org (--resume masks what
138
- it left) \u2014 of a run in slices, slices it did not reach, stopped by
139
- --max-requests or the org's day, or records created during it in a range a
140
- slice masked \u2014, or the restore left values as they are (rows the org refused, a
141
- snapshot that holds part of the records, or records of a Sync run's snapshot
142
- changed since the run, held back without --include-changed); 130 Ctrl-C
143
- stopped the run, 143 a SIGTERM, 129 a SIGHUP.
144
- `,qe=1e9,Ye=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,et={words:1,switches:["--dry-run","--resume","--slices","--abandon","--rewrite-all","--include-changed","--yes","--json",...Le],values:["--org","--object","--template","--rules","--where","--restore","--slice","--store","--max-records","--max-requests","--max-age-days"]};function g(s){process.stderr.write(`${s}
145
- `),process.exit(2)}function tt(s){let e;try{e=JSON.parse(Xe(s,"utf8"))}catch(r){g(`Cannot read the rules in ${s}: ${r instanceof Error?r.message:String(r)}`)}let n=Array.isArray(e)?{rules:e}:e,a=typeof n=="object"&&n!==null&&!("name"in n)?{...n,name:`Rules from ${Ke(s)}`}:n,o=le.safeParse(a);if(!o.success){let r=o.error.issues.map(d=>`${d.path.join(".")||"(file)"}: ${d.message}`).join("; ");g(`The rules in ${s} are not rules the panel saves: ${r}`)}return o.data}function st(s){let e=s.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(Ze),process.exit(0)),e[0]!=="anonymize"&&g(`The command is anonymize: ${U("dataops")} anonymize --org \u2026 Run with --help.`),ne(e,et);let n=l=>{let b=e.indexOf(l),I=b>=0?e[b+1]:void 0;return b>=0&&(I===void 0||I.startsWith("--"))&&g(`${l} needs a value.`),I},a=l=>e.filter(b=>b===l).length,o=n("--org");o||g("Missing --org. Run with --help."),re.test(o)||g(`Not an sf alias: "${o}"`);let r=n("--restore"),d=e.includes("--dry-run"),C=e.includes("--resume"),w=e.includes("--slices"),x=e.includes("--abandon"),k=n("--max-records");k!==void 0&&!/^[1-9]\d*$/.test(k)&&g(`Not a number of records: "${k}"`),k!==void 0&&(Number(k)<_||Number(k)>D)&&g(`--max-records takes ${_} to ${D} records, not ${k}: a snapshot holds at least ${_} records of one object and at most ${D}; past that, --slices masks the object in slices of --max-records records, each backed up just before it is masked, or narrow the run with --where.`);let c=n("--max-requests");c!==void 0&&(!/^[1-9]\d{0,9}$/.test(c)||Number(c)>qe)&&g(`Not a number of requests, 1 to ${qe}: "${c}"`),c!==void 0&&!w&&r===void 0&&!x&&g("--max-requests bounds a run in slices: give it with --slices.");let p=Re(e,"--slice");p.length>0&&r===void 0&&g("--slice goes with --restore: it names the slices of a set to put back. A run in slices is --slices.");let h=e.includes("--rewrite-all");h&&r===void 0&&g("--rewrite-all goes with --restore.");let f=e.includes("--include-changed");f&&r===void 0&&g("--include-changed goes with --restore.");let R=xe(n("--max-age-days")),A={org:o,rewriteAll:h,includeChanged:f,...R!==void 0?{maxAgeDays:R}:{},storeDir:n("--store")??Se(),...k!==void 0?{maxRecords:Number(k)}:{},slices:w,...c!==void 0?{maxRequests:Number(c)}:{},yes:e.includes("--yes"),json:e.includes("--json"),accord:Ee(e)};if(r!==void 0){let l=["--object","--template","--rules","--where","--dry-run","--resume","--slices","--max-requests","--abandon"].filter(b=>e.includes(b));return l.length>0&&g(`--restore puts a snapshot back as it is: drop ${l.join(", ")}.`),{...A,mode:"restore",restoreId:r,...p.length>0?{restoreSlices:Ce(p)}:{}}}if(x){let l=["--dry-run","--resume","--max-requests"].filter(b=>e.includes(b));l.length>0&&g(`--abandon gives a set of slices up and masks nothing: drop ${l.join(", ")}.`)}a("--object")>1&&g("Give one --object at most: a run masks one object, or every object its template masks.");let $=n("--object");$!==void 0&&!Ye.test($)&&g(`Not an SObject API name: "${$}"`);let v=n("--template"),m=n("--rules");v===void 0==(m===void 0)&&g("Give one of --template or --rules: the rules a run masks with."),d&&C&&g("Give one of --dry-run or --resume.");let y=n("--where")?.trim();return y!==void 0&&(y===""||!de(y))&&g(`Not a filter --where can take: "${y}". ${ce}`),y!==void 0&&$===void 0&&g("--where filters the records of one object: give it with --object."),{...A,mode:x?"abandon":d?"dry-run":C?"resume":"run",...$!==void 0?{object:$}:{},...v!==void 0?{templateId:v}:{},...m!==void 0?{rules:tt(m)}:{},...y!==void 0?{where:y}:{}}}function Be(s,e){let n=`${e.toLowerCase()}.`;return s.rules.filter(a=>a.fieldPattern.toLowerCase().startsWith(n)||a.fieldPattern==="*")}function nt(s,e){return Be(s,e).length>0?!0:e.toLowerCase()===ue.toLowerCase()&&pe(s.rules).length>0}function rt(s,e){let n=a=>JSON.stringify(a.map(o=>[o.fieldPattern.toLowerCase(),o.ruleType,o.config??null]).sort((o,r)=>String(o[0]).localeCompare(String(r[0]))));return n(s)===n(e)}function ot(s){if(s==null||s==="")return"(empty)";let e=typeof s=="string"?s:JSON.stringify(s);return JSON.stringify(e.length>40?`${e.slice(0,39)}\u2026`:e)}function ze(s,e){let n=[];typeof s.message=="string"&&n.push(s.message);for(let d of s.objects??[])n.push(` ${d.objectApiName.padEnd(28)} counted ${d.total} masked ${d.processed} refused ${d.failed} still original ${d.notMasked}`);let a=s.errors??[];a[0]&&n.push(` e.g. ${a[0].objectApiName}: ${a[0].message}`);let o=s.snapshot;o&&n.push(`snapshot ${o.operationId}: ${o.totalRecords} record(s) as they were before the run. To put their values back:`,` ${e(o.operationId)}`);let r=s.slices;return r&&n.push(...at(r,e)),n}function at(s,e){let n=s.objects.flatMap(r=>r.slices).sort((r,d)=>r.index-d.index),a=n.filter(r=>r.state==="masked").length,o=[`set ${s.setId} (${s.state}): ${a} of ${n.length} slice(s) masked, up to ${s.size} records a slice, ${s.requestsSpent} request(s) sent by this run`,...n.map(r=>` slice ${r.index} ${r.objectApiName.padEnd(20)} ${r.state.padEnd(8)} ${r.rows} record(s) masked ${r.masked} refused ${r.refused} deleted since ${r.deletedSince}${r.late?" created during the run":""}${r.sizeUsed!==void 0?` read ${r.sizeUsed} at a time`:""} snapshot ${r.snapshotId}`)];return s.lateRecords>0&&o.push(` ${s.lateRecords} record(s) created during the run in a range a slice masked, or past its last: no snapshot holds them, and they keep their values`),n.some(r=>r.state!=="pending")&&o.push("To put back the values its slices hold, every slice in one line:",` ${e(s.setId)}`),o}function it(s,e){return`${s}.${e}: the org has no such field, or field-level security hides it from this user \u2014 a run is refused and masks nothing (give the user read and edit access to it, or take it out of the template)`}function Fe(s,e){return e===void 0?`${s}: this user may not edit its records \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to the object)`:`${s}.${e}: this user may read it and not edit it \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to it, or take it out of the template)`}function dt(s,e={},n=!1){let a=s.fieldsNotFound??[],o=s.objects??[],r=e.objects??[];return a.length>0||o.some(d=>d.notCovered===!0||d.error!==void 0||d.writeDenied!==void 0)||r.some(d=>d.count===null&&!(n&&d.slicePlan!==void 0))}function ct(s,e){let n=[],a=s.objects??[];for(let{objectApiName:d,count:C,slicePlan:w}of a)w!==void 0&&(!e&&C!==null&&C>w.size&&n.push(`${d} holds ${C} record(s), more than the ${w.size} a snapshot holds of one object: --slices masks it in ${w.slices} slices, each backed up just before it is masked (the same line with --slices shows their plan), or narrow the run with --where`),e&&w.slices>W&&n.push(`${d} would take ${w.slices} slices of ${w.size} records, more than the ${W} a set holds: give --max-records up to ${D}, or narrow the run with --where`));let o=s.plan;e&&o?.diskFree!==void 0&&Q(o.diskBytes)>o.diskFree&&n.push(`the slices' snapshots take about ${T(Q(o.diskBytes))}, and the store has ${T(o.diskFree)} free: give --store a folder on another disk, delete the backups no longer needed, or keep backups fewer days (--max-age-days)`);let r=s.sliceSet;return r?.state==="open"&&n.push(`set ${r.setId} of this template is still open on the org (${r.done} of ${r.total} slice(s) masked, last moved ${r.savedAt}), and a new run would mask its rows again: the same line with --resume masks the rest, and --abandon gives it up`),n}function ut(s,e){let n=s.apiBudget;if(n.verdict==="unread")return`the org's requests left today were not read (${n.unread??"no answer"}): the run stops between two slices if the org's day runs short, and --resume masks the rest`;let a=`of ${n.remaining??"?"} the org has left today`;if(n.verdict==="fits")return`${a}: fits`;if(n.verdict==="near")return`${a}: near it \u2014 the run stops between two slices before the org's integrations run short, and --resume masks the rest`;let o=s.requests/Math.max(1,e),r=Math.max(0,Math.floor((n.remaining??0)/Math.max(1,o)));return`${a}: more than that \u2014 about ${Math.min(r,e)} of the ${e} slices go today, the run stops between two of them, and --resume masks the rest`}function lt(s,e,n){let{snapshots:a,updates:o,reads:r}=s.parts;return[" a run in slices:",` requests: about ${s.requests} (snapshots ${a}, updates ${o}, reads ${r}) ${ut(s,e)}`," Bulk API batches: none (the run writes over REST, 200 records a call)",` disk: about ${T(s.diskBytes)} in ${n}`+(s.diskFree!==void 0?` (${T(s.diskFree)} free)`:""),` time: about ${se(s.seconds)}`]}function ht(s,e,n,a){let o=["dry run \u2014 nothing is written"],r=e.objects??[],d=n.objects??[],C=n.fieldsNotFound??[];for(let c of r){let p=c.count===null?"an unknown number of":String(c.count);o.push(` ${c.objectApiName}: ${p} record(s) to mask`);let h=a!==void 0?c.slicePlan:void 0;c.count===null&&o.push(h!==void 0?" not counted by the org: its own figure of the records plans the slices, approximate; the run reads the object a slice at a time by Id, whatever it holds":" not counted by the org: a run stops at its count and masks nothing"),h!==void 0&&o.push(` slices: ${h.approximate?"about ":""}${h.slices} of up to ${h.size} records, each backed up just before it is masked`);let f=d.find(m=>m.objectApiName===c.objectApiName);if(f?.error){o.push(` not read: ${f.error}`);continue}let R=new Map([...Be(s,c.objectApiName).map(m=>[m.fieldPattern.split(".").pop()?.toLowerCase()??"",m.ruleType]),...Object.entries(f?.methods??{}).map(([m,y])=>[m.toLowerCase(),y])]),A=f?.fields??[];o.push(` fields: ${A.map(m=>`${m} (${R.get(m.toLowerCase())??"?"})`).join(", ")||"(none)"}`);for(let m of C.filter(y=>y.objectApiName===c.objectApiName))o.push(` ${it(m.objectApiName,m.fieldApiName)}`);f?.notCovered&&o.push(" no field of it can be masked: a run is refused and masks nothing");let $=f?.writeDenied?.deniedFields;$?.length===0&&o.push(` ${Fe(c.objectApiName)}`);for(let m of $??[])o.push(` ${Fe(c.objectApiName,m)}`);let v=f?.rows??[];if(v.length>0){o.push(" the first records, masked as a run masks them (a run draws its own key, so its made-up names and digests differ from these):");for(let m of v)o.push(` ${m.id}: ${A.map(y=>`${y} ${ot(m.after[y])}`).join(", ")}`)}}let w=r.reduce((c,p)=>c+(p.count??0),0),x=e.plan;if(a!==void 0&&x!==void 0){let c=r.reduce((p,h)=>p+(h.slicePlan?.slices??0),0);o.push(...lt(x,c,a.store)),o.push(" a run backs each slice up just before it masks it, and masks it from that backup: a slice that cannot be backed up whole stops the run there, and the slices before it stay masked with their backups")}else w>0&&o.push(` a run takes a snapshot of these ${w} record(s) first, and writes nothing without it`);let k=e.checkpoint;return k&&o.push(` a run of this template, object and filter stopped short on ${k.savedAt}: --resume masks only what it left`),o}function pt(s){return`interrupted: the restore stopped before it was through; what it restored is in the audit trail, and the same line puts back the rest: ${s}`}function mt(s){return s!==void 0?`interrupted: the masking stopped before it was through; what it masked is in the audit trail, each slice it masked has its snapshot (--restore ${s} puts their values back), and the same line with --resume masks the rest, from where its slice stopped`:"interrupted: the masking stopped before it was through; what it masked is in the audit trail, the snapshot puts their values back (--restore), and the same line with --resume masks only what it left"}function ft(s){return s.map(e=>{if(e.type!=="dataops:anonymize:preview:response")return e;let n=e.payload?.objects??[];return{...e,payload:{...e.payload,objects:n.map(a=>({...a,rows:(a.rows??[]).map(({id:o,after:r})=>({id:o,after:r}))}))}}})}async function gt(s=process.argv){let e=st(s),n=t=>{process[e.json?"stderr":"stdout"].write(`${t}
146
- `)},a=t=>{process.stderr.write(`${t}
147
- `),process.exitCode=1},o=je(e.storeDir);if(o!==void 0){a(o);return}let r=await oe(e.org),d=await new Me().validateConnection(r.accessToken,r.instanceUrl),C={alias:e.org,orgType:te({isSandbox:d.isSandbox,edition:d.orgType}),metadata:{apiVersion:"66.0",edition:d.orgType}};n(`sandforge dataops ${e.org} (${d.isSandbox?"sandbox":d.orgType||"production"}) store: ${e.storeDir}`);let w=ve(Ve(e.storeDir,"snapshots.json")),x=[],k=new Map,c=new _e,p=new we({log:t=>{/^\[(WARN|INFO)\]/.test(t)&&n(` ${t}`)},broker:{postToWebview:t=>{if(x.push(t),t.type!=="operation:progress")return;let i=String(t.payload?.operationId??""),u=Number(t.payload?.percentage??0);(u-(k.get(i)??-10)>=10||u===100)&&(k.set(i,u),n(` ${u}% ${String(t.payload?.currentStep??"")}`))}},orgManager:{getOrg:()=>C},orgRegistry:{getCredentials:async()=>({accessToken:r.accessToken,instanceUrl:r.instanceUrl})},configStore:w,services:{getSandforgeSetting:Oe(e)},infraServices:{backgroundRegistry:c,productionGuard:new me({requestConfirmation:(t,i)=>(n(`refused: ${e.org} is taken for a ${i} org, and this command writes to none (${t})`),Promise.resolve(!1))}),confirmRestoreIntoReplacedOrg:({alias:t,backedUpFrom:i,now:u})=>e.yes?Promise.resolve(!1):M(`${t} answered as org ${i} when this snapshot was taken and answers as org ${u} now. Write its saved values into the org it is now?`)},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});p.setExpiryListener(t=>process.stderr.write(`${Ie(t)}
148
- `)),p.setRunKeyStore(ge(e.storeDir)),p.setBackupRecordStore(new ke(be(e.storeDir))),await p.swept(),p.setSyncRuns(he(ye())),p.setMuteOffered($e("--mute-automation")),p.setOnCommandLine(!0);let h=async(t,i)=>{let u=`cli-${t.replaceAll(":","-")}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return await p.handle({id:u,type:t,timestamp:Date.now(),payload:i}),x.find(j=>j.correlationId===u&&(j.type===`${t}:response`||j.type==="dataops:error"))??{type:"dataops:error",payload:{message:`${t} was not answered.`}}},f=t=>t.type==="dataops:error",R=t=>String(t.payload?.message??t.type),A=t=>`${U("dataops")} anonymize --org ${e.org} --restore ${t} --store ${e.storeDir}`,$=async(t,i)=>{let u=await h("dataops:automation",{orgId:e.org,act:t,objects:i,...e.accord});if(f(u)){a(R(u));return}let S=u.payload;for(let j of S.lines)n(j);return S},v=t=>{e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-dataops",command:t,org:e.org,...e.slices?{slices:!0}:{},posted:ft(x)},null,2)}
149
- `)};if(e.mode==="restore"){let t=e.restoreId,i=Pe(w,t,{...e.restoreSlices?{slices:e.restoreSlices}:{},rewriteAll:e.rewriteAll});if(!i){a(`No snapshot or set of slices "${t}" in ${e.storeDir}.`);return}let u=i.objects.map(N=>N.objectApiName).join(", "),S=await $("restore",i.objects);if(!S){v("restore");return}if(S.refusals.length>0){v("restore");for(let N of S.refusals)a(J(N));return}if(!e.yes&&!await M(`Put back into ${e.org} the values ${i.words} holds? ${i.totalRecords} record(s) of ${u} will have those fields written over.`)){n("Nothing written.");return}n(`restoring ${t} into ${e.org}${e.rewriteAll?", every row written back":""}\u2026`);let j,He=H(N=>{j=N,process.stderr.write(`
150
- interrupted: the restore stops before its next batch, and says what it restored (Ctrl-C again ends it at once)
151
- `);for(let Je of c.getRunning())c.abort(Je.operationId)}),P;try{P=await h("dataops:rollback",{orgId:e.org,operationId:t,...e.rewriteAll?{rewriteAll:!0}:{},...e.includeChanged?{includeChanged:!0}:{},...e.restoreSlices?{slices:e.restoreSlices}:{},...e.accord})}finally{He()}if(v("restore"),f(P)){a(R(P)),e.yes&&P.payload?.code==="ORG_REPLACED_SINCE_BACKUP"&&a("--yes does not answer this question: it is answered yes only when typed in a terminal. Run the same line without --yes in a terminal to answer it; nothing answers it from a CI step.");return}n(String(P.payload?.message??""));for(let N of Ne(P.payload??{}))n(N);if(j){process.stderr.write(`${pt(A(t))}
152
- `),process.exitCode=G(j);return}ie(ae(P.payload??{}));return}let y=(await h("dataops:anonymization-templates",{})).payload?.templates??[],l;if(e.rules){let t=e.rules,i=y.find(u=>u.saved===!0&&u.name.trim().toLowerCase()===t.name.toLowerCase());if(i&&rt(i.rules,t.rules))l=i;else{i&&await h("dataops:anonymization-template:delete",{templateId:i.id});let u=await h("dataops:anonymization-template:save",{name:t.name,rules:t.rules});if(f(u)){a(R(u));return}l=u.payload?.template,n(`rules saved in the store as template "${l.name}" (${l.id})`)}}else if(l=y.find(t=>t.id===e.templateId),!l){a(`No template "${e.templateId??""}". Templates: `+y.map(t=>`${t.id}${t.saved?` (saved: ${t.name})`:""}`).join(", "));return}let b=e.object;if(b!==void 0&&!nt(l,b)){a(`Template "${l.name}" has no rule for ${b}: a run would mask nothing.`);return}let I={orgId:e.org,templateId:l.id,...b!==void 0?{objects:[b]}:{},...e.where!==void 0?{where:e.where}:{}};if(n(`template: ${l.name} (${l.id}) `+(b!==void 0?`object: ${b}`:"objects: every object the template masks")+(e.where!==void 0?` where: ${e.where}`:"")+(e.slices?" in slices":"")),e.mode==="abandon"){let t=new fe(w).openFor(e.org,l.id);if(t&&!e.yes){let u=t.objects.flatMap(j=>j.slices).filter(j=>j.state==="masked").length,S=t.objects.reduce((j,ee)=>j+ee.slices.length,0);if(!await M(`Give up set ${t.setId} of ${l.name} on ${e.org}, ${u} of ${S} slice(s) masked, last moved ${t.lastActivityAt}? Nothing more is masked and no resume carries it on; its slices stay masked, each with its snapshot, which --restore ${t.setId} puts back until the retention removes them.`)){n("Nothing given up.");return}}let i=await h("dataops:anonymize",{...I,abandon:!0});v("abandon");for(let u of ze(i.payload??{},A))n(u);f(i)&&(process.exitCode=1);return}let O=await h("dataops:anonymize:coverage",{...I,...e.slices?{slices:!0}:{}});if(f(O)){a(R(O));return}let L=O.payload?.objects??[],Ue=L.reduce((t,i)=>t+(i.count??0),0),We=e.slices?L.filter(t=>t.count===null&&t.slicePlan!==void 0):[],q=O.payload?.sliceSet,K=L.map(t=>({objectApiName:t.objectApiName,records:t.count??(e.slices&&t.slicePlan!==void 0?t.slicePlan.slices*t.slicePlan.size:0)}));if(e.mode==="dry-run"){let t=await h("dataops:anonymize:preview",I);if(f(t)){v("dry-run"),a(R(t));return}for(let S of ht(l,O.payload??{},t.payload??{},e.slices?{store:e.storeDir}:void 0))n(S);let i=await $("masking",K);if(v("dry-run"),!i)return;for(let S of De(i))n(S);let u=ct(O.payload??{},e.slices);for(let S of u)n(` a run would be refused: ${S}`);(u.length>0||i.refusals.length>0||dt(t.payload??{},O.payload??{},e.slices))&&(process.exitCode=1);return}let V=O.payload?.checkpoint;if(e.mode==="resume"&&!V){a(q!==void 0?`There is nothing to resume for this object and filter: set ${q.setId} of this template is open on ${e.org}, its run given another object or filter. Its own line with --resume masks the rest, and --abandon gives it up.`:`There is nothing to resume: no run of this template, object and filter stopped short in ${e.storeDir}.`);return}let Z=e.mode==="resume"&&q!==void 0;if(e.mode==="run"&&Ue===0&&We.length===0){let t=L.filter(i=>i.count===null).map(i=>i.objectApiName);if(t.length>0){a(`${t.join(", ")}: the org did not count the records a run would mask, so nothing was masked (its reason is in the warning above).`);return}n(b!==void 0?"Nothing to mask: no record of the object is under the filter.":"Nothing to mask: no object the template masks holds a record."),v("run");return}let z=await $("masking",K);if(!z){v(e.mode);return}if(z.refusals.length>0){v(e.mode);for(let t of z.refusals)a(J(t));return}if(!e.yes){let t=b??L.map(i=>i.objectApiName).join(", ");if(!await M(wt(e,l.name,t,O,Z))){n("Nothing written.");return}}n(e.mode==="resume"?"resuming\u2026":"masking\u2026");let F,Ge=H(t=>{F=t,process.stderr.write(`
153
- interrupted: the masking stops before its next page, and says what it masked (Ctrl-C again ends it at once)
154
- `);for(let i of c.getRunning())c.abort(i.operationId)}),Y=e.slices||Z,E;try{E=await h("dataops:anonymize",{...I,...e.mode==="resume"?{resumeFrom:V.id}:{snapshot:!0},...Y?{slices:!0}:{},...Y&&e.maxRequests!==void 0?{maxRequests:e.maxRequests}:{},...e.accord})}finally{Ge()}v(e.mode);for(let t of ze(E.payload??{},A))n(t);let B=E.payload?.slices;if(F){process.stderr.write(`${mt(B?.setId)}
155
- `),process.exitCode=G(F);return}if(f(E)){process.exitCode=1;return}(Number(E.payload?.recordsNotMasked??0)>0||B?.state==="open")&&(B===void 0&&n("A resume masks only what this run left: the same line with --resume, in place of the snapshot it does not take again."),process.exitCode=3)}function wt(s,e,n,a,o){let r=a.payload?.objects??[],d=a.payload?.sliceSet,C=a.payload?.checkpoint;if(s.mode==="resume")return o&&d!==void 0?`Resume the masking of ${n} in ${s.org} in slices, set ${d.setId}: ${d.done} of ${d.total} slice(s) masked, last moved ${d.savedAt}? Each slice left is backed up just before it is masked, with the key the set was masked with.`:`Resume the masking of ${n} in ${s.org} that stopped on ${C?.savedAt??"?"}? What it left is written over; the snapshot the first run took holds their values.`;let w=r.reduce((A,$)=>A+($.count??0),0),x=r.some(A=>A.count===null),k=x?`the records of ${n}`:`${w} record(s) of ${n}`;if(!s.slices)return`Mask ${k} in ${s.org} with ${e}? A snapshot of their values is taken first.`;let c=r.reduce((A,$)=>A+($.slicePlan?.slices??0),0),p=a.payload?.plan,h=p?.apiBudget,f=p!==void 0?p.requests/Math.max(1,c):0,R=h?.remaining!==void 0&&f>0?Math.min(c,Math.floor(h.remaining/f)):void 0;return`Mask ${k} in ${s.org} with ${e}, in ${x?"about ":""}${c} slice(s)? Each slice is backed up just before it is masked; if one cannot be backed up whole, the run stops there and the slices before it stay masked with their backups.`+(h?.verdict==="exceeds"&&R!==void 0?` The org has ${h.remaining} requests left today, enough for about ${R} of them: the run stops between two slices, and the same line with --resume masks the rest.`:"")}/sandforge-dataops\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(Ae(),gt().then(()=>process.exit()).catch(s=>{process.stderr.write(`${s instanceof Error?s.message:String(s)}
156
- `),process.exit(1)}));export{st as a,nt as b,ze as c,at as d,it as e,Fe as f,dt as g,ct as h,lt as i,ht as j,pt as k,mt as l,gt as m,wt as n};
@@ -1,7 +0,0 @@
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{$a as k,$b as ka,Ab as L,Ac as La,Bb as M,Bc as Ma,Cb as N,Cc as Na,Db as O,Dc as Oa,Eb as P,Ec as Pa,Fb as Q,Fc as Qa,Gb as R,Gc as Ra,Hb as S,Hc as Sa,Ib as T,Ic as Ta,Jb as U,Jc as Ua,Kb as V,Kc as Va,Lb as W,Lc as Wa,Mb as X,Mc as Xa,Nb as Y,Nc as Ya,Ob as Z,Oc as Za,Pb as _,Pc as _a,Qb as $,Qc as $a,Ra as a,Rb as aa,Rc as ab,Sa as b,Sb as ba,Sc as bb,Ta as c,Tb as ca,Tc as cb,Ua as d,Ub as da,Uc as db,Va as e,Vb as ea,Wa as f,Wb as fa,Xa as g,Xb as ga,Ya as h,Yb as ha,Za as i,Zb as ia,_a as j,_b as ja,ab as l,ac as la,bb as m,bc as ma,cb as n,cc as na,db as o,dc as oa,eb as p,ec as pa,fb as q,fc as qa,gb as r,gc as ra,hb as s,hc as sa,ib as t,ic as ta,jb as u,jc as ua,kb as v,kc as va,lb as w,lc as wa,mb as x,mc as xa,nb as y,nc as ya,ob as z,oc as za,pb as A,pc as Aa,qb as B,qc as Ba,rb as C,rc as Ca,sb as D,sc as Da,tb as E,tc as Ea,ub as F,uc as Fa,vb as G,vc as Ga,wb as H,wc as Ha,xb as I,xc as Ia,yb as J,yc as Ja,zb as K,zc as Ka}from"./chunk-O3ZQSWDN.mjs";import"./chunk-DNE7JI3A.mjs";import"./chunk-CI2O7WBH.mjs";import"./chunk-5T3LFDJ5.mjs";import"./chunk-AX3YF7SC.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-JBOGAUGH.mjs";import"./chunk-4N425UJC.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-FG4Y4ZVL.mjs";import"./chunk-Z354SAEF.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-THYQOG24.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-CRPLDXJU.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{y as API_BUDGET_EXCEEDED,u as API_BUDGET_NEAR_SHARE,r as API_REQUESTS_NOT_TOLD,L as BULK_BATCHES_NOT_TOLD,B as CHECKPOINT_REFUSED,E as CHECKPOINT_STOPPED_WORDS,a as DEFAULT_CONFIRM_ABOVE_RECORDS,b as DEFAULT_MAX_TOTAL,$ as DELIVERABILITY_READ_MOST,ka as DEVELOPER_EDITION_SINGLE_EMAILS,ya as EMAILS_NOT_ACCEPTED,Ta as ForgeRunGateError,l as LastSimulations,Ra as OWNER_MAP_INACTIVE,Sa as OWNER_MAP_UNKNOWN,c as READ_CEILING_PER_OBJECT,ca as SAMPLE_CANNOT_FIT,fa as SAMPLE_PLAN_GONE,ea as SAMPLE_PLAN_MISMATCH,ba as SAMPLE_STORAGE_UNREAD,da as SAMPLE_TOO_LARGE,e as STORAGE_NEAR_SHARE,f as STORAGE_ROUNDING_MARGIN_MB,I as WHOLE_ORG_SOURCE_READS_PER_OBJECT,H as WHOLE_ORG_TARGET_READS_PER_OBJECT,la as alertsCountAsSingle,x as apiBudgetCheckOf,z as apiBudgetRefusal,W as automationBytesOf,Aa as automationReadRequests,$a as automationRefusal,Qa as automationUnreadOf,M as bulkBatchesRefusal,_a as bypassAssistantSentences,Pa as bypassesToAssign,C as checkpointPartOf,D as checkpointScopeStop,A as confirmationApiOf,n as confirmationSimulatedOf,Ha as confirmationStorageOf,pa as countedEmailChecksOf,i as countedStorageBytes,qa as countedTargetEmails,Ga as deliverabilityAfterLeaseStop,Da as deliverabilityGate,Ca as deliverabilityLineOf,Ba as deliverabilityPartOf,xa as emailCheckLines,oa as emailChecksOf,wa as emailRefusal,na as emailsCountedPerRecord,va as emailsOfLimit,sa as emailsUncountedOf,m as farPastTheSimulation,O as fileStorageRefusal,Va as filesRefusalStop,Ka as firedOnInsertOf,La as firedOnUpdateOf,J as forgeRequestPartsOf,k as forgeVolumeCaseKey,S as forgeWriteBudgetOf,G as forgeWritesOf,Ia as formatMB,Ja as formatMBPast,ra as insertsOf,Ua as isForgeRunGateError,Ya as leftOutLines,q as limitsOfOrg,d as objectsAboveReadCeiling,Ma as objectsUpdatedAfterInsert,ta as overEmailOf,Z as personalFieldsAsIsOf,o as pricesForLinesOf,t as readApiBudget,P as readBoundRefusal,Q as readBoundStopOf,s as readDataStorage,ja as readEmailLimits,bb as removalAutomationLines,ab as removalAutomationRefusal,Za as removalRiskLines,cb as removalStepsAutomationLines,db as removalStepsAutomationRefusal,p as rolesMayBeOf,h as rowStorageBytes,Oa as runBypassesOf,v as runRequestsEstimate,w as runRequestsTotal,ia as sampleGateErrorOf,ha as sampleGateStopOf,ga as sampleStorageUnreadStopOf,Ea as sendersOfNothingWritten,Fa as sendersOfNothingWrittenLine,za as sendersUnreadOf,ma as singleCountAsWorkflow,N as sourceApiBudgetRefusal,T as storageCheckOf,U as storageCountedOf,V as storageCountedWords,Wa as storageRefusal,g as storageRoomMB,X as storageTakesWords,F as takeCheckpointFirst,ua as unreadEmailOf,Na as updateStepsOf,K as wholeOrgCostOf,aa as wholeOrgDryRunOf,R as wholeOrgFilesOf,_ as wholeOrgLeftOutOf,Y as wholeOrgWritePlanOf,Xa as writePlanLines,j as writePlanOf};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{b as Ne}from"./chunk-WB2RIVO3.mjs";import{a as re}from"./chunk-BOGNK4LV.mjs";import{j as Oe}from"./chunk-TG52WNGV.mjs";import{a as Re,b as Q}from"./chunk-T63U4OZJ.mjs";import{e as Pe,f as we,g as Ie}from"./chunk-5EESNYE3.mjs";import{Cb as xe,Ib as Le,Lc as Ge,_a as Se,fc as Fe,ic as Me,kb as ke,mb as ae,nc as Be,ob as Ce,pb as De,qc as ve,rb as Te,sb as je,ub as _e,wc as Ue}from"./chunk-O3ZQSWDN.mjs";import{a as B}from"./chunk-4TLYUZD5.mjs";import{i as be}from"./chunk-INIT2UKJ.mjs";import{b as ye}from"./chunk-4N425UJC.mjs";import{a as he}from"./chunk-EADHKH3A.mjs";import{b as ne,d as ie}from"./chunk-FG4Y4ZVL.mjs";import{q,r as X}from"./chunk-Z354SAEF.mjs";import{a as v,h as j}from"./chunk-TZE3Y7IQ.mjs";import{b as G}from"./chunk-CA5NAXSU.mjs";import{a as Y,j as Ee}from"./chunk-ICIYL45C.mjs";import{Ac as fe,Ec as te,Fc as ge,Gc as K,Hc as Ae,Lc as V,Mc as oe,zc as me}from"./chunk-CRPLDXJU.mjs";import{b as Z,f as ee,k as de,l as pe}from"./chunk-WZQEK4WT.mjs";var He=we,Ke=Pe,$=200;function Ve(n,e){let t=new Set(e?.fields.map(r=>r.name)??[]),i=new Set(n.split(", "));for(let r of[Y,oe])t.has(r)&&i.add(r);return[...i].join(", ")}var Xe=10,Ye=new Set([q]),M="IsPersonAccount",qe="IsStandard",$e=class{maxConcurrent;constructor(e=10){this.maxConcurrent=e}async listObjects(e,t,i){let[r,c]=await Promise.all([e.describeGlobal(),t.describeGlobal()]),s=new Set(r.sobjects.filter(o=>o.createable).map(o=>o.name)),a=ie(c.sobjects.filter(o=>!s.has(o.name)),await this.toolingObjects(t)),l=new Map(c.sobjects.map(o=>[o.name,o.createable!==!1]));return r.sobjects.filter(o=>o.queryable&&(o.createable||l.get(o.name)===!0)).filter(o=>i||o.custom).filter(o=>!ne(o.name,a)).map(o=>({apiName:o.name,label:o.label,custom:o.custom,...l.has(o.name)?l.get(o.name)===!1?{notCreateableInTarget:!0}:{}:{missingInTarget:!0}}))}async countObjects(e,t){return this.countRecords(e,t)}async scan(e,t,i,r,c={}){let s=ce(c.maxDepth,He),a=ce(c.maxObjects,Ke),l=ce(c.maxRecordsPerObject,5e4),o=c.onProgress??(()=>{});if(i.length===0)throw new Error("Choose the objects to copy: a scan starts from them, and with none chosen it would describe and count every object of the org.");let g=await e.describeGlobal(),h=[...i],m=await t.describeGlobal(),N=ie(m.sobjects,await this.toolingObjects(t)),I=A=>ne(A,N);h=h.filter(A=>!I(A)),o(`describing ${h.length} selected object(s)\u2026`);let R=await this.describeAll(e,h),P=new Set(R.keys()),C=new Map(g.sobjects.map(A=>[A.name,A.custom])),D=new Map;for(let A of g.sobjects)A.keyPrefix&&D.set(A.keyPrefix,A.name);let f=await this.walkRecords(e,R,P,{isStandard:A=>C.get(A)===!1||!C.has(A)&&!A.includes("__"),includeStandardObjects:r,leftOut:I,keyPrefixes:D,maxDepth:s,maxObjects:a,maxRecords:l,say:o}),S=new Set(m.sobjects.map(A=>A.name)),_=[...R.keys()].filter(A=>!S.has(A)),x=await this.currenciesOf(e,t,R),W=await this.personAccountsOf(e,R,P,f.parentIds,{cutShort:f.cutShort,cutAt:f.cutAt});return{objectDescribes:R,autoDiscoveredObjects:f.added,missingInTarget:_,recordCounts:f.recordCounts,totalObjectsScanned:R.size,parentIds:f.parentIds,personAccounts:W,scope:{maxDepth:s,maxObjects:a,selected:[...P],parents:f.added.map(A=>({objectApiName:A,records:f.parentIds.get(A)?.length??0})),leftEmpty:f.leftEmpty,standardNeeded:f.standardNeeded,...f.followedByDefault.length>0?{followedByDefault:f.followedByDefault}:{},...x?{currencies:x}:{},...f.cutShort.length>0?{cutShort:f.cutShort}:{}}}}async readFitRows(e,t,i=()=>{}){let r=new Set(t.objectDescribes.keys()),c=new Map;for(let s of t.scope.selected){let a=t.objectDescribes.get(s);if(!a)continue;i(`reading the lookups of ${s} to fit it\u2026`);let l=new Set(a.fields.map(m=>m.name)),o=We(s,a).filter(m=>m.targets.some(N=>r.has(N))),g=["Id",...new Set(o.map(m=>m.field)),...(s===q||s===X)&&l.has(M)?[M]:[],...s===ge&&l.has(qe)?[qe]:[]],h=await be(`SELECT ${g.map(j).join(", ")} FROM ${j(s)} ORDER BY Id`,async m=>(await this.readAll(e,m)).records);c.set(s,h.filter(m=>typeof m.Id=="string"))}return c}async walkFrom(e,t,i,r=()=>{}){let c=new Map(t.objectDescribes),s=new Set(c.keys()),a=new Map;for(let[o,g]of c)g.keyPrefix&&a.set(g.keyPrefix,o);let l=await this.walkRecords(e,c,new Set(t.scope.selected),{isStandard:()=>!1,includeStandardObjects:!0,leftOut:o=>!s.has(o),keyPrefixes:a,maxDepth:t.scope.maxDepth,maxObjects:s.size,say:r},i);return{added:l.added,parentIds:l.parentIds,personAccounts:l.personAccounts,leftEmpty:l.leftEmpty,namingSelected:l.namingSelected}}async personAccountsOf(e,t,i,r,c){let s=new Map;for(let a of[q,X]){if(!t.get(a)?.fields.some(g=>g.name===M))continue;let o=`SELECT COUNT() FROM ${j(a)} WHERE ${M} = true`;try{let g=c.cutShort.find(m=>m.objectApiName===a)?.copied;if(i.has(a)&&g!==void 0){let m=c.cutAt.get(a)??await this.lastIdOfTheFirst(e,a,g);s.set(a,m!==void 0?(await e.query(`${o} AND Id <= '${v(m)}'`)).totalSize:Math.min((await e.query(o)).totalSize,g));continue}if(i.has(a)){s.set(a,(await e.query(o)).totalSize);continue}let h=0;for(let m of this.chunk([...r.get(a)??[]],$)){let N=m.map(I=>`'${v(I)}'`).join(", ");h+=(await e.query(`${o} AND Id IN (${N})`)).totalSize}s.set(a,h)}catch(g){B.warn("Autopilot could not count the person accounts it copies",{objectApiName:a,error:G(g)})}}return s}async lastIdOfTheFirst(e,t,i){let{records:r}=await this.readAll(e,`SELECT Id FROM ${j(t)} ORDER BY Id`),c=r.length>=i?r[i-1]?.Id:void 0;return typeof c=="string"?c:void 0}async currenciesOf(e,t,i){let r=[...i.values()].filter(l=>l.fields.some(o=>o.name===Y)).map(l=>l.name).sort();if(r.length===0)return;let c=await Ee(async l=>(await e.query(l)).records,async l=>(await t.query(l)).records),s=c?.target.corporate;if(!c||s===void 0)return;let a=[...c.source.active].filter(l=>!c.target.active.has(l));return a.length>0?{notInTarget:a.sort(),writtenIn:s,objects:r}:void 0}async walkRecords(e,t,i,r,c){let s=new Set(i),a=new Set,l=r.maxRecords??5e4,o=r.maxObjects,g=r.maxObjects*Ie,h=new Map,m=[],N=[],I=[],R=new Map,P=[],C=new Map,D=new Map,f=new Map,S=[],_=u=>{let b=t.get(u);return b?We(u,b).map(E=>({...E,targets:E.targets.filter(d=>!r.leftOut(d)&&!a.has(d))})).filter(E=>E.targets.length>0):[]},x=u=>["Id",...new Set(_(u).map(b=>b.field)),...c&&(u===q||u===X)&&t.get(u)?.fields.some(b=>b.name===M)?[M]:[]].map(j).join(", "),W=(u,b,E)=>{let d=`${u.objectApiName}.${u.field}>${b}`;h.has(d)||h.set(d,{objectApiName:u.objectApiName,fieldApiName:u.field,target:b,reason:E,...u.required?{required:!0}:{}})},A=new Map,z=(u,b,E)=>{let d=_(u);for(let w of b)for(let p of d){let y=w[p.field];if(typeof y!="string"||y==="")continue;let O=Qe(y,p.targets,r.keyPrefixes,c!==void 0&&p.polymorphic);if(!O)continue;if(i.has(O)){c&&E>0&&S.push({objectApiName:u,field:p.field,required:p.required,target:O,id:y});continue}let k={objectApiName:u,field:p.field,required:p.required};if(E>=r.maxDepth&&!p.required){s.has(O)||W(k,O,"depth");continue}if(D.get(O)?.has(y))continue;let L=A.get(O)??{ids:new Set,required:!1,via:[]};L.ids.add(y),L.required||=p.required,L.via.some(T=>T.objectApiName===u&&T.field===p.field)||L.via.push(k),A.set(O,L)}},J=[];for(let u of i){if(c){z(u,c.get(u)??[],0);continue}let b=_(u).filter(E=>E.targets.some(d=>!i.has(d)));if(b.length===0){J.push(u);continue}r.say(`reading the lookups of ${u}\u2026`);try{let E=["Id",...new Set(b.map(p=>p.field))].map(j).join(", "),{records:d,truncated:w}=await this.readAll(e,`SELECT ${E} FROM ${j(u)} ORDER BY Id`,l);if(C.set(u,d.length),w){let p=(await this.countRecords(e,[u])).get(u);I.push({objectApiName:u,copied:d.length,...p!==void 0?{total:p}:{}});let y=d[d.length-1]?.Id;typeof y=="string"&&R.set(u,y)}z(u,d,0)}catch(E){B.warn("Autopilot could not read the lookups of a selected object",{objectApiName:u,error:G(E)}),J.push(u)}}for(let[u,b]of await this.countRecords(e,J))b>l?(C.set(u,l),I.push({objectApiName:u,copied:l,total:b})):C.set(u,b);let ze=r.maxDepth+Xe;for(let u=1;A.size>0&&u<=ze;u++){let b=A;A=new Map;let E=[];for(let[d,w]of b){if(s.has(d))continue;let p=r.isStandard(d)&&!r.includeStandardObjects,y=p&&!w.required&&Ye.has(d),O;if(p&&!w.required&&!y?O="standard":s.size>=o&&(w.required&&o<g?o++:O="objects"),O){for(let k of w.via)W(k,d,O);b.delete(d);continue}if(s.add(d),E.push(d),y)N.push({objectApiName:d,referencedBy:w.via.map(k=>`${k.objectApiName}.${k.field}`)});else if(p){let k=w.via[0];m.push({objectApiName:d,neededBy:`${k.objectApiName}.${k.field}`})}}if(E.length>0){let d=E.filter(p=>!t.has(p));d.length>0&&r.say(`describing ${d.length} parent object(s) at depth ${u}\u2026`);let w=await this.describeAll(e,d);for(let p of E){let y=t.get(p)??w.get(p);y?(t.set(p,y),P.push(p)):(s.delete(p),a.add(p),b.delete(p))}}for(let[d,w]of b){let p=[...w.ids].filter(T=>!D.get(d)?.has(T));if(p.length===0)continue;r.say(`reading ${p.length} ${d} record(s) by id\u2026`);let y=D.get(d)??new Set;D.set(d,y);let O=d===te,k=O?Ve(x(d),t.get(d)):x(d),L=[];for(let T of this.chunk(p,$)){let U=T.map(F=>`'${v(F)}'`).join(", "),H=(await e.query(`SELECT ${k} FROM ${j(d)} WHERE Id IN (${U})`)).records.filter(F=>typeof F.Id=="string");for(let F of H)y.add(F.Id);L.push(...H);let ue=H.filter(F=>F[M]===!0).length;c&&ue>0&&f.set(d,(f.get(d)??0)+ue),z(d,H,u)}if(O){let T=await this.standardPricesOf(e,k,L,y);if(T.length>0){r.say(`reading ${T.length} standard price(s) the prices need\u2026`);for(let U of T)y.add(U.Id);z(d,T.map(U=>({...U,[K]:void 0})),u)}}}}let le=new Map;for(let u of P){let b=[...D.get(u)??[]];le.set(u,b),C.set(u,b.length)}return{added:P,leftEmpty:[...h.values()].filter(u=>!s.has(u.target)),standardNeeded:m,followedByDefault:N.filter(u=>s.has(u.objectApiName)),cutShort:I,cutAt:R,recordCounts:C,parentIds:le,personAccounts:f,namingSelected:S}}async standardPricesOf(e,t,i,r){let c=s=>[s[V],s[Y],s[oe]].map(a=>String(a??"")).join("|");try{let[s]=(await e.query(Ae)).records,a=s?.Id;if(typeof a!="string")return[];let l=i.filter(m=>m[K]!==a),o=[...new Set(l.flatMap(m=>{let N=m[V];return typeof N=="string"&&N!==""?[N]:[]}))];if(o.length===0)return[];let g=new Set(l.map(c)),h=[];for(let m of this.chunk(o,$)){let N=m.map(R=>`'${v(R)}'`).join(", "),I=await e.query(`SELECT ${t} FROM ${te} WHERE ${K} = '${v(a)}' AND ${V} IN (${N})`);for(let R of I.records){let P=R.Id;typeof P!="string"||r.has(P)||!g.has(c(R))||h.push(R)}}return h}catch(s){return B.warn("Autopilot could not read the standard prices its prices need",{error:G(s)}),[]}}async readAll(e,t,i=5e4){let{queryMore:r}=e;if(!r){let s=await e.query(t);return{records:s.records,truncated:s.done===!1}}let c=await he({query:s=>e.query(s),queryMore:s=>r.call(e,s)},t,i);return c.truncated&&B.warn("Autopilot read the lookups of a selected object to its bound only",{records:c.records.length}),{records:c.records,truncated:c.truncated}}async toolingObjects(e){if(!e.tooling)return[];try{return(await e.tooling.describeGlobal()).sobjects.map(i=>i.name)}catch(t){return B.warn("Autopilot could not ask the Tooling API which objects are metadata",{error:G(t)}),[]}}async describeAll(e,t){let i=new Map,r=this.chunk(t,this.maxConcurrent);for(let c of r){let s=await Promise.allSettled(c.map(a=>e.describe(a)));for(let a of s)a.status==="fulfilled"&&i.set(a.value.name,a.value)}return i}async countRecords(e,t){let i=new Map,r=this.chunk(t,this.maxConcurrent);for(let c of r){let s=await Promise.allSettled(c.map(async a=>{let l=await e.query(`SELECT COUNT() FROM ${j(a)}`);return{name:a,count:l.totalSize}}));for(let a of s)a.status==="fulfilled"&&i.set(a.value.name,a.value.count)}return i}chunk(e,t){let i=[];for(let r=0;r<e.length;r+=t)i.push(e.slice(r,r+t));return i}};function ce(n,e){return n!==void 0&&Number.isInteger(n)&&n>0?n:e}function We(n,e){return e.fields.filter(t=>t.referenceTo.length>0&&fe(t)).map(t=>({field:t.name,targets:[...t.referenceTo],required:me(n,t.name,t.nillable),polymorphic:t.referenceTo.length>1}))}function Qe(n,e,t,i=!1){if(e.length===1&&!i)return e[0];let r=t.get(n.slice(0,3));return r!==void 0&&e.includes(r)?r:void 0}var Je={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},Ze={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},et={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},tt=.9;function Ot(n,e){let t=[];for(let[i,r]of e){let c=r.fields.filter(o=>o.createable&&Ne({name:o.name,label:o.label,type:o.type})),s=new Map(c.map(o=>[o.name,o])),a=new Map,l=n.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of l.piiFields){let g=s.get(o.fieldApiName);if(!g)continue;let h=Je[o.classification];a.set(g.name,{objectApiName:i,fieldApiName:g.name,fieldLabel:g.label,fieldType:g.type,piiCategory:h,detectionMethod:et[o.detectionMethod],confidence:o.confidence,suggestedMethod:Ze[h]})}for(let o of c)a.has(o.name)||Q(o.name,o.type)===void 0||a.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:tt,suggestedMethod:"fake"});t.push(...a.values())}return t}function Pt(n,e){let t=r=>`${r.objectApiName}.${r.fieldApiName}`,i=new Set(n.map(t));return[...n,...e.filter(r=>!i.has(t(r)))]}var ot=["Contact","Lead"];function wt(n,e,t){if(n==="none")return[];let i=new Set(e),r=[];for(let c of ot){if(!i.has(c))continue;let s=t.filter(l=>l.objectApiName===c).map(l=>l.fieldApiName),a=[];s.some(Re)||a.push("name"),s.some(l=>Q(l,"string")==="email")||a.push("email"),s.some(l=>Q(l,"string")==="phone")||a.push("phone"),a.length>0&&r.push({objectApiName:c,missing:a})}return r}function St(n){return n.fatalError!==void 0?"failure":n.totalFailure>0||n.failedObjects.length>0?n.totalSuccess+(n.totalLinked??0)>0?"partial":"failure":[...Object.values(n.lookups??{}),...Object.values(n.statuses??{})].some(t=>t.refusals.length>0)||n.stopped===!0?"partial":"success"}var nt=pe({name:Z().min(1),referenceTo:de(Z()).min(1),createable:ee().optional(),updateable:ee().optional()}).loose();function Dt(n){if(!Array.isArray(n))return[];let e=[];for(let t of n){let i=nt.safeParse(t);i.success&&e.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return e}var Mt={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:Be},Bt={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function vt(n,e,t=new Map){return Se(n.waves.flatMap(i=>i.objects).map(i=>{let r=t.get(i);return{objectApiName:i,rows:[],counted:{rows:e.get(i)??0,...r!==void 0?{personAccounts:r}:{}}}}))}function Ut(n){return[...new Set(n.waves.flatMap(e=>e.objects.map(String)))]}async function Gt(n){return Fe(n)}function it(n){return n.filter(e=>e.verdict==="exceeds").map(Me)}function rt(n){return n.filter(e=>e.verdict==="unread").map(e=>({limit:e.limit,emails:e.emails,unread:e.unread??""}))}function qt(n){return n.objects.filter(({rows:e})=>e>0).length}async function at(n,e,t,i,r={}){let c="unread"in e?await t().catch(o=>({unread:o instanceof Error?o.message:String(o)})):e.dailyApiRequests,{readBack:s=0,deliverability:a=0,mute:l=0}=r;return ae({run:ke(n.objects.map(({rows:o})=>({rows:o}))),...Te(i),...l>0?{mute:l}:{},...s>0?{readBack:s}:{},...a>0?{deliverability:a}:{}},c)}function st(n){return n.objects.reduce((e,{rows:t})=>e+Math.ceil(Math.max(0,t)/$),0)}async function ct(n,e){let t=await e().catch(i=>({unread:i instanceof Error?i.message:String(i)}));return ae(st(n),t)}async function $t(n){let{plan:e}=n,t=Le(e,n.storage);if(e.totalRows===0)return{go:!0,check:t,asked:!1};let i=n.checkpointFirst?.estimate,r=je(i);if(r)return{go:!1,...r,check:t};let c=Ge(t,n.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:t};let s=await at(e,n.storage,n.readApiBudget,i,{...n.readBack!==void 0?{readBack:n.readBack}:{},...n.mute!==void 0?{mute:n.mute}:{},...ve(n.runEmails?.ofRun)}),a=Ce(s,n.org,ye);if(a)return{go:!1,code:"API_BUDGET_EXCEEDED",message:a,check:t};if(n.source){let f=await ct(e,n.source.readApiBudget),S=xe(f,n.source.org);if(S!==void 0&&f.verdict==="exceeds")return{go:!1,code:"API_BUDGET_EXCEEDED",message:S,check:t,source:{estimate:f.estimate,remaining:f.remaining,max:f.max}}}let l=n.confirmAboveRecords,o=l>0&&e.totalRows>l?l:void 0,g=it(n.emails??[]),h=rt(n.emails??[]),m=n.emailsUncounted,N=n.runEmails?.gate,I=N?.verdict==="asks",R=async f=>{let S=re(N,f&&I),_=n.checkpointFirst;if(_===void 0)return{go:!0,check:t,asked:f,...S};let x=await _e(()=>_.take(_.estimate));return"stop"in x?{go:!1,...x.stop,check:t,...S}:{go:!0,check:t,asked:f,checkpoint:x.checkpoint,...S}};if(o===void 0&&t.verdict==="fits"&&g.length===0&&h.length===0&&m===void 0&&i===void 0&&!I)return R(!1);let P=Oe(n.orgTier),C=await n.confirm({stage:"write",module:"autopilot",org:n.org,orgTier:n.orgTier,objects:e.objects.map(({objectApiName:f,rows:S})=>({objectApiName:f,rows:S})),total:e.totalRows,...o!==void 0?{aboveRecords:o}:{},...P!==void 0&&e.totalRows>P?{largeVolume:P}:{},storage:Ue(t),counted:!0,...g.length>0?{emails:g}:{},...h.length>0?{emailsUnread:h}:{},...m!==void 0?{emailsUncounted:m}:{},...De(s),...i!==void 0?{checkpoint:i}:{},...N?.confirmation});if(C==="confirmed")return R(!0);let D=re(N,!1);return C==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:t,...D}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written: run it again from the Autopilot page, where the question is asked.",check:t,...D}}export{He as a,Ke as b,$ as c,M as d,qe as e,$e as f,We as g,Ot as h,Pt as i,wt as j,St as k,Dt as l,Mt as m,Bt as n,vt as o,Ut as p,Gt as q,qt as r,at as s,ct as t,$t as u};
@@ -1,8 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{b as $e}from"./chunk-QAXKUEJT.mjs";import{a as We}from"./chunk-M6P5ZZLE.mjs";import{c as ke,d as Ge}from"./chunk-C2MHMI7U.mjs";import{d as _e,z as Le}from"./chunk-SF52ZSIV.mjs";import{a as Me}from"./chunk-VV3B6IC3.mjs";import{a as k}from"./chunk-4TLYUZD5.mjs";import{m as qe}from"./chunk-AX3YF7SC.mjs";import{a as re,b as De}from"./chunk-Q7TLC3I2.mjs";import{b as xe}from"./chunk-EADHKH3A.mjs";import{a as H,c as Ae,g as oe,j as Pe,n as Ne}from"./chunk-FG4Y4ZVL.mjs";import{a as Te,h as q}from"./chunk-TZE3Y7IQ.mjs";import{a as je,b as x}from"./chunk-CA5NAXSU.mjs";import{Ac as ee,Bc as te,ca as Ie,ja as Fe,wa as ve,za as ue,zc as Z}from"./chunk-CRPLDXJU.mjs";import{b as Ce,e as Ee,i as Re,k as Se,l as de}from"./chunk-WZQEK4WT.mjs";import{appendFile as tt}from"node:fs/promises";var fe=new Set(["Task","Event"]),rt=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,ot="an emptying";function nt(t){let e=q(t.objectApiName),o=fe.has(t.objectApiName),r=[...t.filter!==void 0&&t.filter.trim()!==""?[`(${t.filter})`]:[],...o?["IsDeleted = false"]:[]];return{soql:`SELECT Id FROM ${e}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`,scanAll:o}}async function zt(t,e,o,r={}){let n=()=>r.signal?.aborted===!0,c=[];await Le(e);for(let a of o){let{soql:d,scanAll:u}=nt(a),m={objectApiName:a.objectApiName,count:0};if(c.push(m),n())return{stopped:!0,read:c};let R=ke(e,a.objectApiName),i=!0,h=0,b=await t.query(d,{scanAll:u});for(;;){let S=b.records.map(y=>{let C=y.Id;if(typeof C!="string"||!rt.test(C))throw new Error(`The org answered a ${a.objectApiName} row with no record id: its ids are not read.`);return C});if((S.length>0||i)&&(await tt(R,S.map(y=>`${y}
8
- `).join(""),{encoding:"utf8",mode:_e,flag:i?"w":"a"}),i=!1),m.count+=S.length,r.onPage?.(a.objectApiName,m.count),h=S.length===0?h+1:0,b.done||!b.nextRecordsUrl)break;if(h>=xe)throw new Error(`The org kept answering empty pages of ${a.objectApiName} without saying it was done: ${m.count} id(s) read, the rest not.`);if(n())return{stopped:!0,read:c};b=await t.queryMore(b.nextRecordsUrl)}}return{stopped:!1,spool:await Ge(e,c,ot)}}function ne(t,e,o){return e.nillable!==!1||e.referenceTo.length!==1?!1:e.isMasterDetail||(o??[]).some(r=>r.isCascadeDelete&&r.childSObject===t&&r.field===e.name)}var V=.001,ge=.01,st=50,it=5,at=2,ct=4;function lt(t){return t.level===0||t.recordCount>0||t.status==="error"||t.recordCountUnknown===!0}function Be(t){return t.inputMode==="record"&&typeof t.recordId=="string"&&t.recordId!==""}function pe(t){if(!Fe(t)||t.inputMode!=="soql")return;let e=Ie(t.soqlQuery??"");return e?{where:e.where,limit:e.limit}:void 0}function dt(t,e,o){let r=[];o===0&&Be(t)&&r.push(`Id = '${Te(t.recordId??"")}'`);let n=o===0?pe(t):void 0;n?.where&&r.push(`(${n.where})`);let c=t.objectSoqlFilters?.[e];return c&&r.push(`(${c})`),`SELECT COUNT() FROM ${q(e)}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`}var me=typeof setImmediate=="function"?()=>new Promise(t=>setImmediate(t)):()=>new Promise(t=>setTimeout(t,0)),A=class extends Error{constructor(){super("Discovery cancelled"),this.name="DiscoveryCancelled"}};function M(t,e){return e?e.aborted?Promise.reject(new A):new Promise((o,r)=>{let n=()=>r(new A);e.addEventListener("abort",n,{once:!0}),t().then(c=>{e.removeEventListener("abort",n),o(c)},c=>{e.removeEventListener("abort",n),r(c)})}):t()}function ut(t){return t.fieldCount>0||t.piiFields.length>0}function ft(t,e){if(t.type!=="master-detail")return t;let o=(e.get(t.targetObject)?.fields??[]).filter(n=>n.referenceTo.includes(t.sourceObject)),r=e.get(t.sourceObject)?.childRelationships;return o.some(n=>ne(t.targetObject,n,r))?t:{...t,type:"lookup"}}function Y(){return{nodes:[],edges:[],totalRecords:0,estimatedSizeMB:0,estimatedDurationSeconds:0,truncated:!1}}var Ue=class{deps;constructor(e){this.deps=e}async discover(e,o){if(e.inputMode==="org"||e.depth==="all")return ze(this.deps,e,o);let r=o?.signal;if(r?.aborted)return Y();o?.onProgress?.({phase:"resolving-root",discoveredCount:0,queueRemaining:1});let n=Date.now(),c;try{c=await this.resolveRootObject(e,r)}catch(g){if(g instanceof A)return Y();throw g}let a=Date.now();a-n>2e3&&k.warn(`[forge-discover] resolveRootObject took ${a-n}ms (cold path, consider verifying describeGlobal cache state)`);let d=this.resolveMaxDepth(e),u=o?.maxNodes??st,m=u,R=u*at,i=new Set,h=[],b=u*ct,S=0,y=0,C=new Set,I=[],$=new Map,N=new Map,L=()=>S+y+w.length<m&&I.length+y+w.length<b,W=(g,j)=>{i.has(g)||h.push([g,j]),i.add(g)},D=g=>{i.delete(g)&&(h=h.filter(([j])=>j!==g))},U=new Map,B=(g,j,P,F)=>{if(H(g.sourceObject)||H(g.targetObject)||g.sourceObject===g.targetObject)return;let s=`${g.sourceObject}|${g.targetObject}`,l=U.get(s)??new Map;(P!==void 0||!l.has(j))&&l.set(j,{settable:P,insertOnly:F}),U.set(s,l);let p=$.get(s);if(!p){$.set(s,g);return}let f=g.type==="master-detail"&&p.type==="lookup"?g:p,v=p.required===!0||g.required===!0;$.set(s,v?{...f,required:v}:f)},w=[[c,0]];for(C.add(c);w.length>0&&!r?.aborted;){await me();let g=m-S;if(g<=0)break;let j=Math.min(6,g,w.length),P=w.splice(0,j),F=await Promise.all(P.map(async([s,l])=>{let p,f=!1,v=dt(e,s,l);try{let[E,Q]=await Promise.all([M(()=>this.deps.describeObject(e.sourceOrgId,s,r),r),M(()=>this.deps.queryCount(e.sourceOrgId,v,r),r).catch(_=>{if(_ instanceof A)throw _;return p=x(_),f=se(_),-1})]);return{objectName:s,depth:l,describe:E,recordCount:Q,countError:p,countRefused:f}}catch(E){return E instanceof A||r?.aborted?{objectName:s,depth:l,describe:null,recordCount:-1,cancelled:!0}:{objectName:s,depth:l,describe:null,recordCount:-1,describeError:x(E)}}}));y=F.length;for(let s of F){if(y--,s.cancelled)continue;let{objectName:l,depth:p,describe:f,recordCount:v,countError:E,countRefused:Q,describeError:_}=s;if(!f){I.push({objectApiName:l,recordCount:0,fieldCount:0,status:"error",progress:0,included:!1,piiFields:[],anonymizeFields:[],level:p,successCount:0,failureCount:0,errors:[`Describe unavailable: ${_??"unknown error"}`],createableFieldCount:0,estimatedSizeMB:0,estimatedApiCalls:0,batchStrategy:"auto"}),S++,o?.onProgress?.({phase:"object",objectApiName:l,discoveredCount:I.length,queueRemaining:w.length});continue}N.set(l,f);let ie=v<0,ae=ie&&Q!==!0,ce=ie&&!ae,le=p===0?pe(e)?.limit:void 0,J=ie?0:typeof le=="number"&&Number.isFinite(le)?Math.min(v,le):v,Je=p===0&&(Be(e)||pe(e)!==void 0),be=this.deps.detectPII(f.fields),Ke=f.fields.filter(O=>O.type!=="id").length,Oe={objectApiName:l,...f.label?{label:f.label}:{},recordCount:J,...ae?{recordCountUnknown:!0}:{},fieldCount:f.fields.length,status:ce?"error":"idle",progress:0,included:ce?!1:ae||Je||!e.skipEmpty||J>0,piiFields:be,anonymizeFields:e.anonymizePII?be:[],level:p,successCount:0,failureCount:0,errors:ce?[`Record count unavailable: ${E??"unknown error"}`]:[],createableFieldCount:Ke,estimatedSizeMB:J*V,estimatedApiCalls:Math.ceil(J/200),batchStrategy:"auto"};I.push(Oe);let ye=lt(Oe);if(ye&&S++,p<d&&ye){for(let O of f.fields){if(O.referenceTo.length===0)continue;let we=ee(O),K=we&&Z(l,O.name,O.nillable),Ze=te(O);for(let T of O.referenceTo){B({sourceObject:T,targetObject:l,relationshipName:O.relationshipName??O.name,type:O.isMasterDetail?"master-detail":"lookup",required:K},O.name,we,Ze);let et=i.has(T);(!C.has(T)||K&&et)&&!H(T)&&(L()?(C.add(T),D(T),K?w.unshift([T,p+1]):w.push([T,p+1])):K&&m<R?(C.add(T),D(T),m++,w.unshift([T,p+1])):(C.add(T),W(T,p+1)))}}for(let O of f.childRelationships)B({sourceObject:l,targetObject:O.childSObject,relationshipName:O.relationshipName,type:O.isCascadeDelete?"master-detail":"lookup"},O.field,void 0,void 0),!C.has(O.childSObject)&&!H(O.childSObject)&&(C.add(O.childSObject),L()?w.push([O.childSObject,p+1]):W(O.childSObject,p+1))}o?.onProgress?.({phase:"object",objectApiName:l,discoveredCount:I.length,queueRemaining:w.length})}for(;h.length>0&&L();){let[s,l]=h.shift();i.delete(s),w.push([s,l])}}let z=I.reduce((g,j)=>g+j.recordCount,0),G=[...$].map(([g,j])=>{let P=[...U.get(g)?.values()??[]],F=ft(j,N);return P.length>0&&P.every(s=>s.settable===!1)&&(F={...F,settable:!1}),P.some(s=>s.insertOnly===!0)&&(F={...F,insertOnly:!0}),F});return{nodes:I,edges:G,totalRecords:z,estimatedSizeMB:z*V,estimatedDurationSeconds:z*ge,truncated:h.length>0}}personalFields(e){return this.deps.detectPII(e)}async readPersonalFields(e,o,r){let n=e.nodes.filter(a=>!ut(a)&&a.status!=="error"),c=new Map;for(let a=0;a<n.length&&!r?.aborted;a+=6)await Promise.all(n.slice(a,a+6).map(async({objectApiName:d})=>{try{let u=await this.deps.describeObject(o.sourceOrgId,d,r),m=this.deps.detectPII(u.fields);m.length>0&&c.set(d,m)}catch(u){k.warn(`[forge] personal fields of ${d} not read: ${x(u)}`)}}));return c.size===0?e:{...e,nodes:e.nodes.map(a=>{let d=c.get(a.objectApiName);return d?{...a,piiFields:d,anonymizeFields:o.anonymizePII?[...d]:[]}:a})}}async resolveRootObject(e,o){if(e.inputMode==="record"&&e.recordId){let r=e.recordId.substring(0,3),c=(await M(()=>this.deps.describeGlobal(e.sourceOrgId,o),o)).find(a=>a.keyPrefix===r);if(!c)throw new Error(`No object found for record ID prefix "${r}". The ID may not belong to any accessible object in this org.`);return c.name}if(e.inputMode==="soql"&&e.soqlQuery)return pt(e.soqlQuery);throw new Error(`Cannot resolve root object for inputMode "${e.inputMode}". Provide a valid recordId (for "record" mode) or soqlQuery (for "soql" mode).`)}resolveMaxDepth(e){switch(e.depth){case"direct":return 1;case"full":return it;case"custom":return Math.max(1,Math.min(10,e.customDepth??3));case"all":throw new Error("A clone of the whole org is discovered without a walk (WholeOrgDiscovery)")}}};function pt(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/--[^\n]*/g,"");for(let r=0;r<32;r++){let n=e.replace(/\([^()]*\)/g,"");if(n===e)break;e=n}let o=/\bFROM\s+(\w+)/i.exec(e);if(!o)throw new Error('Could not parse object name from SOQL query. Ensure the query uses standard "SELECT ... FROM ObjectName" syntax.');return q(o[1])}var gt={clone:"write",empty:"delete"},mt=["settings","definition"],ht=new Set(["contentworkspace"]);function bt(t){if(t.name.includes("__"))return!1;let e=t.name.toLowerCase();return ht.has(e)||mt.some(o=>e.endsWith(o))?!0:t.createable===!1&&e!==oe.toLowerCase()}function Ot(t,e){return t.objectApiName<e.objectApiName?-1:t.objectApiName>e.objectApiName?1:0}function yt(t,e,o,r={}){let n=Ne(t,{mode:"everything",access:gt[o],...r.excluded!==void 0?{excluded:r.excluded}:{},...r.customSettings!==void 0?{customSettings:r.customSettings}:{}},e),c=new Map(t.map(u=>[u.name.toLowerCase(),u])),a=[],d=[];for(let u of n.candidates){let m=c.get(u.toLowerCase());m!==void 0&&bt(m)?d.push({objectApiName:u,reason:"configuration"}):a.push(u)}return d.length===0?n:{...n,candidates:a,leftOut:[...n.leftOut,...d].sort(Ot)}}var wt=new Set([oe,Pe].map(t=>t.toLowerCase())),Qe="withTheirRecords",Ct="noLayout";function Et(t){switch(t){case"configuration":return{reason:"setup"};case"chatter":case"history":case"sharing":case"changeEvent":case"unsupportedKind":case"customSetting":case"files":case"setup":case"platformCreated":case"metadata":case"notWritable":case"excludedByUser":return{reason:t};case"heldWithFiles":return{reason:"files",detail:Qe};case"notFound":case"notCustomSetting":return{reason:"missingInTarget"}}}function Rt(t){switch(t){case"platform":return{reason:"platformCreated"};case"setup":return{reason:"setup"};case"feature":case"parent":return{reason:"notWritable",detail:t};case"user":return{reason:"notWritable"}}}function St(t){if(t.createable!==!0||t.queryable!==!0)return;let e=t.updateable===!0,o=t.deletable===!0;if(!(e&&o))return!e&&!o?{reason:"createOnly"}:{reason:"createOnly",detail:e?Ft:It}}var It="noEdit",Ft="noDelete";function vt(t,e){return t.objectApiName<e.objectApiName?-1:t.objectApiName>e.objectApiName?1:0}function He(t,e,o,r={}){let n=yt(e,o,"clone",r),c=new Map(t.map(i=>[i.name.toLowerCase(),i])),a=new Map(e.map(i=>[i.name.toLowerCase(),i])),d=[],u=[],m=new Set,R=(i,h,b)=>{m.add(i.toLowerCase()),u.push({objectApiName:i,reason:h,...b!==void 0?{detail:b}:{}})};for(let i of t)a.has(i.name.toLowerCase())||R(i.name,"missingInTarget");for(let i of n.leftOut){let h=i.objectApiName.toLowerCase(),b=c.get(h);if(!b||m.has(h))continue;let S=a.get(h),y=Et(i.reason),C=h!==oe.toLowerCase();y.reason==="notWritable"&&C&&S?.createable!==!0&&r.createFacts&&(y=Rt(We(b.name,r.createFacts))),y.reason==="notWritable"&&C&&S&&(y=St(S)??y);let I=i.reason==="setup"&&S?.layoutable===!1&&!Ae(i.objectApiName);R(b.name,y.reason,I?Ct:y.detail??i.detail)}for(let i of n.candidates){let h=i.toLowerCase(),b=c.get(h);b&&(b.queryable!==!0?R(b.name,"notQueryable"):wt.has(h)?R(b.name,"files",Qe):d.push(b.name))}return d.sort(),u.sort(vt),{candidates:d,leftOut:u}}var he=1950,Xe=2e4,jt=1e6,Dt=18,Tt=200,At=new Set(["QUERY_TIMEOUT","OPERATION_TOO_LARGE","REQUEST_LIMIT_EXCEEDED","REQUEST_RUNNING_TOO_LONG","SERVER_UNAVAILABLE","UNKNOWN_EXCEPTION"]);function se(t){if(t instanceof Me||De(t))return!1;let e=je(x(t));return e===void 0?!1:!At.has(e)&&!e.startsWith("ERROR_HTTP_")}function Pt(t,e){let o=fe.has(t),r=[...e?[`(${e})`]:[],...o?["IsDeleted = false"]:[]];return{soql:`SELECT COUNT() FROM ${q(t)}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`,all:o}}async function Ve(t,e){let o=0,r=!1,n=()=>r,c=async()=>{for(;!r&&o<t.length;){let a=o++;try{await e(t[a],a,n)}catch(d){throw r=!0,d}}};await Promise.all(Array.from({length:Math.min(6,t.length)},c))}async function Nt(t,e){try{return await t()}catch(o){if(o instanceof A||re(o)||se(o))throw o;return k.warn(`[forge-discover] whole org: describe of ${e} unanswered, asked again: ${x(o)}`),t()}}function Ye(t){if(!(t<=ue))throw new Error(`The source org lists ${t} objects a clone of the whole org leaves out, more than the ${ue} one graph says. Nothing was written. Clone the org in parts instead: a run from a record or from a query for each part.`)}var xt=de({name:Ce().min(1),count:Ee().int().nonnegative()});function Mt(t){let e=de({sObjects:Se(Re())}).safeParse(t);if(!e.success)return;let o=new Map;for(let r of e.data.sObjects){let n=xt.safeParse(r);n.success&&o.set(n.data.name,n.data.count)}return o}function _t(t){let e=new Map;for(let[o,r]of t)for(let n of r.fields){if(n.referenceTo.length===0)continue;let c=ee(n),a=c&&Z(o,n.name,n.nillable),d=te(n);for(let u of n.referenceTo){if(u===o||!t.has(u))continue;let m=`${u}|${o}`,R={sourceObject:u,targetObject:o,relationshipName:n.relationshipName??n.name,type:ne(o,n,t.get(u)?.childRelationships)?"master-detail":"lookup",required:a},i=e.get(m);if(!i){e.set(m,{edge:R,noneSettable:!c,insertOnly:d});continue}let h=R.type==="master-detail"&&i.edge.type==="lookup"?R:i.edge;i.edge={...h,required:i.edge.required===!0||a},i.noneSettable=i.noneSettable&&!c,i.insertOnly=i.insertOnly||d}}return[...e.values()].map(({edge:o,noneSettable:r,insertOnly:n})=>({...o,...r?{settable:!1}:{},...n?{insertOnly:!0}:{}}))}function Lt(t,e){let o=e.filter(qe),r=$e(t,o).reverse(),n=new Map;r.forEach((d,u)=>{for(let m of d)n.set(m,u)});let c=new Map;for(let d of o){let u=c.get(d.targetObject)??[];u.push(d.sourceObject),c.set(d.targetObject,u)}let a=r.map(()=>0);return r.forEach((d,u)=>{for(let m of d)for(let R of c.get(m)??[]){let i=n.get(R);i!==void 0&&i!==u&&(a[u]=Math.max(a[u],a[i]+1))}}),new Map(t.map(d=>[d,Math.min(Dt,1+a[n.get(d)??0])]))}async function ze(t,e,o){let r=ve(e);if(r!==void 0)throw new Error(r);let n=o?.signal;if(n?.aborted)return Y();try{return await kt(t,e,o)}catch(c){if(c instanceof A||n?.aborted)return Y();throw c}}async function kt(t,e,o){let r=o?.signal,n=s=>o?.onProgress?.(s),c=Date.now(),a=s=>l=>{if(l instanceof A)throw l;return k.warn(`[forge-discover] whole org: ${x(l)}`),s},{toolingObjects:d,recordCounts:u,createFacts:m}=t;n({phase:"listing",discoveredCount:0,queueRemaining:0});let[R,i,h,b,S]=await Promise.all([M(()=>t.describeGlobal(e.sourceOrgId,r),r),M(()=>t.describeGlobal(e.targetOrgId,r),r),d?M(()=>d(e.targetOrgId,r),r).catch(a([])):Promise.resolve([]),m?M(()=>m(e.targetOrgId),r).catch(a(void 0)):Promise.resolve(void 0),u?M(()=>u(e.sourceOrgId,r),r).catch(a(void 0)):Promise.resolve(void 0)]),y=Mt(S),C=e.excludedObjects??[],{candidates:I,leftOut:$}=He(R,i,h,{...b?{createFacts:b}:{},...C.length>0?{excluded:C}:{}}),N=[...$];Ye(N.length);let L=I.map(()=>{}),W=0;n({phase:"counting",discoveredCount:0,queueRemaining:I.length,total:I.length}),await Ve(I,async(s,l,p)=>{let f=y?.get(s),v=e.objectSoqlFilters?.[s];if(f!==void 0&&f>jt&&!v)L[l]={objectApiName:s,rows:f,approximate:!0};else try{let{soql:E,all:Q}=Pt(s,v),_=await M(()=>t.queryCount(e.sourceOrgId,E,r,Q?{all:!0}:void 0),r);if(p())return;_>0?L[l]={objectApiName:s,rows:_}:N.push({objectApiName:s,reason:"empty"})}catch(E){if(E instanceof A||re(E))throw E;if(p())return;se(E)?N.push({objectApiName:s,reason:"unreadable",detail:x(E)}):(k.warn(`[forge-discover] whole org: ${s} not counted, kept: ${x(E)}`),L[l]=f!==void 0&&f>0&&!v?{objectApiName:s,rows:f,approximate:!0}:{objectApiName:s,rows:0,unknown:!0})}W++,n({phase:"counting",objectApiName:s,discoveredCount:W,queueRemaining:I.length-W,total:I.length})});let D=L.filter(s=>s!==void 0);if(D.length>he)throw new Error(`The source org holds records in ${D.length} objects a clone of the whole org would take, more than the ${he} one run writes. Nothing was written. Leave ${D.length-he} of them out or more, or clone the org in parts instead: a run from a record or from a query for each part.`);let U=D.map(()=>{}),B=0;n({phase:"describing",discoveredCount:0,queueRemaining:D.length,total:D.length}),await Ve(D,async({objectApiName:s},l,p)=>{try{let f=await Nt(()=>M(()=>t.describeObject(e.sourceOrgId,s,r),r),s);if(p())return;U[l]=f}catch(f){if(f instanceof A||re(f))throw f;if(p())return;N.push({objectApiName:s,reason:"notDescribed",detail:x(f)})}B++,n({phase:"describing",objectApiName:s,discoveredCount:B,queueRemaining:D.length-B,total:D.length})}),await me();let w=new Map,z=new Map;D.forEach((s,l)=>{let p=U[l];p&&(w.set(s.objectApiName,p),z.set(s.objectApiName,s))});let G=_t(w);if(G.length>Xe)throw new Error(`The ${w.size} objects of the source org a clone of the whole org would take relate ${G.length} pairs of objects, more than the ${Xe} one run writes in order. Nothing was written. Clone the org in parts instead: a run from a record or from a query for each part.`);let g=[...w.keys()],j=Lt(g,G),P=g.map(s=>{let l=w.get(s),p=z.get(s),f=p.rows,v=t.detectPII(l.fields);return{objectApiName:s,...l.label?{label:l.label}:{},recordCount:f,...p.approximate?{recordCountApproximate:!0}:{},...p.unknown?{recordCountUnknown:!0}:{},fieldCount:l.fields.length,status:"idle",progress:0,included:!0,piiFields:v,anonymizeFields:e.anonymizePII?[...v]:[],level:j.get(s)??1,successCount:0,failureCount:0,errors:[],createableFieldCount:l.fields.filter(E=>E.type!=="id").length,estimatedSizeMB:f*V,estimatedApiCalls:Math.ceil(f/Tt),batchStrategy:"auto"}});Ye(N.length);let F=P.reduce((s,l)=>s+l.recordCount,0);return N.sort((s,l)=>s.objectApiName<l.objectApiName?-1:s.objectApiName>l.objectApiName?1:0),k.info(`[forge-discover] whole org: ${P.length} object(s), ${G.length} relation(s), ${N.length} left out, ${F} record(s), in ${Date.now()-c}ms`),{nodes:P,edges:G,totalRecords:F,estimatedSizeMB:F*V,estimatedDurationSeconds:F*ge,truncated:!1,leftOut:N}}export{fe as a,ot as b,zt as c,ne as d,st as e,it as f,at as g,lt as h,ut as i,Ue as j,yt as k,he as l,Xe as m,se as n,Ve as o,Mt as p,ze as q};
@@ -1,7 +0,0 @@
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{ye as c}from"./chunk-CRPLDXJU.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var y=[{type:"seed",label:"Seed Data",description:"Seed an org with a template saved on the Seed page or shipped with SandForge, never a production org; its records are taken back from Seed\u2019s History",category:"data",icon:"database",configSchema:{orgId:{type:"string"},templateId:{type:"string"}}},{type:"sync",label:"Sync Data",description:"Run a Sync configuration saved on the Sync page; a target Production Guard asks about, a production org or a sandbox marked Staging, needs an Approval step before it",category:"data",icon:"sync",configSchema:{configId:{type:"string"}}},{type:"backup",label:"Backup",description:"Take a DataOps snapshot of the listed objects into local storage",category:"data",icon:"archive",configSchema:{orgId:{type:"string"},objects:{type:"array"}}},{type:"restore",label:"Restore",description:"Restore data from a previous backup snapshot",category:"data",icon:"history",configSchema:{backupId:{type:"string"}}},{type:"anonymize",label:"Anonymize",description:"Mask an org with a DataOps template, after a snapshot of the values it writes over, never a production org",category:"data",icon:"shield",configSchema:{orgId:{type:"string"},templateId:{type:"string"},object:{type:"string",optional:!0},where:{type:"string",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1}}},{type:"delete",label:"Delete",description:"Delete records matching specified criteria",category:"data",icon:"trash",configSchema:{objectName:{type:"string"},where:{type:"string"}}},{type:"checkpoint",label:"Checkpoint",description:"Take a checkpoint of a sandbox, a scratch org or a Developer Edition org, kept on this machine",category:"data",icon:"bookmark",configSchema:{orgId:{type:"string"},mode:{type:"string",default:"everything"},objects:{type:"array",optional:!0},excluded:{type:"array",optional:!0},name:{type:"string",optional:!0},keepDays:{type:"number",default:c},maxTotal:{type:"number",optional:!0},ignoredFields:{type:"array",optional:!0}}},{type:"rewind",label:"Rewind",description:"Put an org back to a checkpoint kept on this machine, once confirmed by typing the org\u2019s alias, at most maxRecords records",category:"data",icon:"history",configSchema:{orgId:{type:"string"},checkpointId:{type:"string"},objects:{type:"array",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},acceptNoUndo:{type:"boolean",default:!1},acceptRecreate:{type:"boolean",default:!1},acceptOutside:{type:"boolean",default:!1},acceptUnseen:{type:"boolean",default:!1},maxRecords:{type:"number",required:!0},refuseWhenActive:{type:"boolean",default:!0}}},{type:"compare",label:"Compare Orgs",description:"Compare the metadata of two orgs, as the Compare page does",category:"quality",icon:"git-compare",configSchema:{sourceOrgId:{type:"string"},targetOrgId:{type:"string"},types:{type:"array"}}},{type:"precheck",label:"Pre-check",description:"Read an org\u2019s API usage, storage, error logs or failed jobs as the Monitor does; the run stops on a critical reading",category:"quality",icon:"check-circle",configSchema:{orgId:{type:"string"},checks:{type:"array"}}},{type:"condition",label:"Condition",description:"Branch pipeline execution based on conditions",category:"control",icon:"git-branch",configSchema:{field:{type:"string"},operator:{type:"string"},value:{type:"string"}}},{type:"delay",label:"Delay",description:"Wait for a specified duration before continuing",category:"control",icon:"clock",configSchema:{durationMs:{type:"number"}}},{type:"approval",label:"Approval",description:"Pauses the run until someone approves it in VS Code; a rejection, or no answer in time, stops it",category:"control",icon:"user-check",configSchema:{message:{type:"string"},timeoutMinutes:{type:"number"}}},{type:"notification",label:"Notification",description:"Shows its message as a VS Code notification",category:"notification",icon:"bell",configSchema:{message:{type:"string"}}}],p=class{registry;constructor(){this.registry=new Map(y.map(e=>[e.type,e]))}getStepTypes(){return[...this.registry.values()]}getStepType(e){return this.registry.get(e)}getDefaultConfig(e){let r=this.registry.get(e);if(!r)return{};let o={};for(let[t,a]of Object.entries(r.configSchema)){let n=a;if(!(n.optional===!0||n.required===!0)){if("default"in n){o[t]=n.default;continue}switch(n.type){case"string":o[t]="";break;case"number":o[t]=0;break;case"array":o[t]=[];break;case"boolean":o[t]=!1;break;default:o[t]=null}}}return o}validateStepConfig(e,r){let o=this.registry.get(e);if(!o)return[`Unknown step type: ${e}`];let t=[];for(let[a,n]of Object.entries(o.configSchema)){let l=n,i=r[a],s=l.type;i!=null&&(s==="array"&&!Array.isArray(i)?t.push(`Field "${a}" must be an array`):s==="string"&&typeof i!="string"?t.push(`Field "${a}" must be a string`):s==="number"&&typeof i!="number"?t.push(`Field "${a}" must be a number`):s==="boolean"&&typeof i!="boolean"&&t.push(`Field "${a}" must be a boolean`))}return t}getStepCategories(){let e=new Set;for(let r of this.registry.values())e.add(r.category);return[...e]}};export{p as StepLibrary};