sandforge 1.84.1 → 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 (277) hide show
  1. package/README.md +1 -1
  2. package/lib/{chunk-S42RBRH2.mjs → chunk-22L43JMK.mjs} +1 -1
  3. package/lib/{chunk-Y2DRK37K.mjs → chunk-2LSGWTWX.mjs} +1 -1
  4. package/lib/{chunk-24RFOFYT.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-3TZSBHEY.mjs → chunk-35IJ4WEU.mjs} +1 -1
  8. package/lib/chunk-3EHPAFKV.mjs +7 -0
  9. package/lib/{chunk-6YL7BNYD.mjs → chunk-3HAVVEXF.mjs} +1 -1
  10. package/lib/{chunk-6JWWSDM6.mjs → chunk-3I6FXFCN.mjs} +1 -1
  11. package/lib/{chunk-WUUKFE2U.mjs → chunk-3KJCSYXY.mjs} +1 -1
  12. package/lib/{chunk-2HVOZUM4.mjs → chunk-3L6DVNCR.mjs} +1 -1
  13. package/lib/chunk-3LRFPGYZ.mjs +7 -0
  14. package/lib/{chunk-GWZRR3MM.mjs → chunk-3MVWGL5A.mjs} +1 -1
  15. package/lib/{chunk-KGU4SVIT.mjs → chunk-4CSBZZAL.mjs} +1 -1
  16. package/lib/{chunk-JE6SCT6R.mjs → chunk-4NSXPONF.mjs} +1 -1
  17. package/lib/{chunk-UIOMAX56.mjs → chunk-4VLP6RHC.mjs} +1 -1
  18. package/lib/{chunk-YA6ATMTB.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-6QE6R6RL.mjs → chunk-5EHHQ5UX.mjs} +1 -1
  22. package/lib/{chunk-FITPY3L4.mjs → chunk-5JMQXHJ2.mjs} +1 -1
  23. package/lib/{chunk-W6PN6TJG.mjs → chunk-65AMXOQU.mjs} +1 -1
  24. package/lib/{chunk-3Q353S2R.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-6ROL3KBM.mjs +7 -0
  28. package/lib/{chunk-2JDAOWUW.mjs → chunk-72AWCN7U.mjs} +1 -1
  29. package/lib/{chunk-JLSIWO4Z.mjs → chunk-7KHA5UIQ.mjs} +1 -1
  30. package/lib/chunk-7O6EFNQS.mjs +10 -0
  31. package/lib/{chunk-WWTCWWZI.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-D4GF4FAB.mjs → chunk-ATBQIE2V.mjs} +1 -1
  35. package/lib/{chunk-NED4MBIM.mjs → chunk-ATQML7ZK.mjs} +1 -1
  36. package/lib/chunk-AVY742BJ.mjs +7 -0
  37. package/lib/{chunk-YWEQQL3C.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-O677VOGO.mjs → chunk-BLMJ4WVI.mjs} +1 -1
  41. package/lib/{chunk-RE7RYF3B.mjs → chunk-BNHJCJJM.mjs} +1 -1
  42. package/lib/{chunk-5M5FQ7RP.mjs → chunk-BNPQEQXC.mjs} +1 -1
  43. package/lib/chunk-C5AUNG6T.mjs +37 -0
  44. package/lib/{chunk-ETDCBLGU.mjs → chunk-C5EQ7GFC.mjs} +1 -1
  45. package/lib/{chunk-MJZU3U5O.mjs → chunk-C7CKDZMC.mjs} +61 -61
  46. package/lib/{chunk-HCGXK7G7.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-VCUXCK36.mjs → chunk-CLUNF4FK.mjs} +1 -1
  50. package/lib/chunk-CSMGP53U.mjs +7 -0
  51. package/lib/{chunk-7YNM6KFZ.mjs → chunk-CT324C7I.mjs} +1 -1
  52. package/lib/{chunk-7UVKIWKV.mjs → chunk-CZXDJXQP.mjs} +1 -1
  53. package/lib/{chunk-43TOMFV4.mjs → chunk-D2X6U3MS.mjs} +1 -1
  54. package/lib/{chunk-M6K34KGF.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-FP7CYB2F.mjs → chunk-DLSU66MY.mjs} +1 -1
  58. package/lib/{chunk-JKJ74BX5.mjs → chunk-DO6PSHQZ.mjs} +1 -1
  59. package/lib/{chunk-MDMPJEV3.mjs → chunk-DUBECLZV.mjs} +1 -1
  60. package/lib/{chunk-KZTZDC7H.mjs → chunk-DYHF6DNT.mjs} +1 -1
  61. package/lib/chunk-E5FSPXYH.mjs +930 -0
  62. package/lib/{chunk-Q7GIJBCD.mjs → chunk-EGL3I3IX.mjs} +1 -1
  63. package/lib/chunk-EIYMQPMG.mjs +7 -0
  64. package/lib/{chunk-RHNTHGNU.mjs → chunk-EUIALBMX.mjs} +1 -1
  65. package/lib/{chunk-NCZKWSC7.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
  66. package/lib/{chunk-PAXNWTYK.mjs → chunk-FM4QCTO7.mjs} +1 -1
  67. package/lib/{chunk-HV7VPEXP.mjs → chunk-FRSIEASH.mjs} +1 -1
  68. package/lib/{chunk-QAFPQ3YB.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-NSQWI7ZY.mjs → chunk-GFB2DNCB.mjs} +1 -1
  73. package/lib/chunk-GFGMGFSH.mjs +7 -0
  74. package/lib/{chunk-RGUQOSBU.mjs → chunk-GIFQXB2Q.mjs} +1 -1
  75. package/lib/{chunk-JAEDM4SI.mjs → chunk-GP5J3DGS.mjs} +1 -1
  76. package/lib/chunk-GQZEX7LH.mjs +231 -0
  77. package/lib/{chunk-JSAJS3MY.mjs → chunk-GYDTM62J.mjs} +1 -1
  78. package/lib/{chunk-OPMO6I45.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-EAC5QCE3.mjs → chunk-HDDJ3CVN.mjs} +1 -1
  82. package/lib/{chunk-5SMWFNE7.mjs → chunk-HDWB4ZOG.mjs} +1 -1
  83. package/lib/chunk-HGVPBJR6.mjs +7 -0
  84. package/lib/{chunk-BBRWFKS5.mjs → chunk-HLROVOR6.mjs} +1 -1
  85. package/lib/{chunk-LKTNQEBS.mjs → chunk-HUOR4M2L.mjs} +1 -1
  86. package/lib/chunk-HZCS6EED.mjs +8 -0
  87. package/lib/{chunk-36JOHEJL.mjs → chunk-HZUI56KZ.mjs} +1 -1
  88. package/lib/chunk-IAB5H7WN.mjs +7 -0
  89. package/lib/{chunk-X4BXESMQ.mjs → chunk-IQ5UKRHU.mjs} +1 -1
  90. package/lib/{chunk-54WZUS7J.mjs → chunk-IRQ4WANV.mjs} +1 -1
  91. package/lib/{chunk-5IZTFMJM.mjs → chunk-IT3DGX37.mjs} +1 -1
  92. package/lib/chunk-J347SPU6.mjs +49 -0
  93. package/lib/{chunk-QO53K5W2.mjs → chunk-JANBNTR5.mjs} +1 -1
  94. package/lib/chunk-JFXQZPRY.mjs +9 -0
  95. package/lib/{chunk-KAZS5Z6W.mjs → chunk-JRLYWVF4.mjs} +1 -1
  96. package/lib/{chunk-GKY2JMHY.mjs → chunk-JSNMUTY6.mjs} +1 -1
  97. package/lib/chunk-JTNJKSAA.mjs +7 -0
  98. package/lib/{chunk-7WATA4SB.mjs → chunk-JV2LAKWQ.mjs} +1 -1
  99. package/lib/{chunk-WAPSSYMT.mjs → chunk-JV7K2ZHK.mjs} +1 -1
  100. package/lib/{chunk-ZBAWJUG2.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-OLCVHL7I.mjs → chunk-KQVLZVOP.mjs} +1 -1
  104. package/lib/chunk-KWUS7UAV.mjs +19 -0
  105. package/lib/{chunk-JGZPD4IM.mjs → chunk-L6G73FXM.mjs} +1 -1
  106. package/lib/{chunk-BAWCOKRW.mjs → chunk-LG466Q5H.mjs} +1 -1
  107. package/lib/{chunk-GMIGWR6U.mjs → chunk-LHNAR6FC.mjs} +1 -1
  108. package/lib/chunk-LT4GHEI2.mjs +7 -0
  109. package/lib/{chunk-EC72TIEG.mjs → chunk-MR262Y3B.mjs} +1 -1
  110. package/lib/{chunk-LA4KIATH.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-PR3XCSPO.mjs → chunk-O3GIN5TU.mjs} +1 -1
  114. package/lib/chunk-O6FHK6NQ.mjs +13 -0
  115. package/lib/{chunk-M4BLK6HJ.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-N4WPCWJO.mjs → chunk-OO2WY3UB.mjs} +1 -1
  120. package/lib/{chunk-MSIEU5MR.mjs → chunk-OT2NHL2V.mjs} +1 -1
  121. package/lib/{chunk-6WX5ZU7Q.mjs → chunk-P2M5ZXWU.mjs} +1 -1
  122. package/lib/{chunk-GNRSF65U.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-PBY2O6OF.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-J3DND3BC.mjs → chunk-QGVL5EW3.mjs} +1 -1
  130. package/lib/chunk-QHE2RUWX.mjs +7 -0
  131. package/lib/{chunk-QKEKG2LD.mjs → chunk-RCW5BZNW.mjs} +1 -1
  132. package/lib/{chunk-4JE4BYXK.mjs → chunk-RJ6HHG7J.mjs} +1 -1
  133. package/lib/{chunk-ZQWIVYVM.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-WY5V5PR3.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-6PD6K7LP.mjs → chunk-SUIPDW5O.mjs} +1 -1
  141. package/lib/{chunk-TNT27RBG.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
  142. package/lib/{chunk-4EOHEDFP.mjs → chunk-T542Z54E.mjs} +1 -1
  143. package/lib/chunk-TAN2CIRI.mjs +21 -0
  144. package/lib/{chunk-A3MYSOOC.mjs → chunk-TCNBINOG.mjs} +1 -1
  145. package/lib/chunk-TFDF3DBN.mjs +7 -0
  146. package/lib/chunk-TICZXC53.mjs +9 -0
  147. package/lib/chunk-TLX45X5U.mjs +7 -0
  148. package/lib/{chunk-QTG6LUZT.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-UCUFLFNK.mjs +7 -0
  154. package/lib/chunk-UK3QLBHW.mjs +7 -0
  155. package/lib/{chunk-IZGCEOYO.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-OFTT7J2M.mjs → chunk-VFKG2G37.mjs} +1 -1
  160. package/lib/chunk-VJNEW5MQ.mjs +7 -0
  161. package/lib/{chunk-L53JWJ3S.mjs → chunk-VKREON6Q.mjs} +1 -1
  162. package/lib/{chunk-NOBQTEQD.mjs → chunk-VNNDYPBL.mjs} +1 -1
  163. package/lib/{chunk-ZJW6YOMV.mjs → chunk-VRBETPHY.mjs} +1 -1
  164. package/lib/{chunk-EPFCERGL.mjs → chunk-VT6P3X6R.mjs} +1 -1
  165. package/lib/{chunk-ZV7ZFQQC.mjs → chunk-VUTQY76O.mjs} +1 -1
  166. package/lib/chunk-WF5S4FW5.mjs +7 -0
  167. package/lib/{chunk-Z4LKKOFY.mjs → chunk-WJGK6VGU.mjs} +1 -1
  168. package/lib/{chunk-5CRLRHOJ.mjs → chunk-WJHMB3SL.mjs} +1 -1
  169. package/lib/{chunk-OUZQPYT3.mjs → chunk-WQCXOZEJ.mjs} +1 -1
  170. package/lib/{chunk-L2E5WBGD.mjs → chunk-WVVFR4E3.mjs} +1 -1
  171. package/lib/{chunk-PWRJRL5U.mjs → chunk-XBYXT74L.mjs} +1 -1
  172. package/lib/chunk-XJE3LJHP.mjs +7 -0
  173. package/lib/{chunk-CPQIZGG5.mjs → chunk-XV4CVZYD.mjs} +1 -1
  174. package/lib/chunk-Y37ED7AS.mjs +7 -0
  175. package/lib/{chunk-YTLUYSMF.mjs → chunk-YGBNZYT4.mjs} +1 -1
  176. package/lib/{chunk-4CVUUVGJ.mjs → chunk-YGTOX7IL.mjs} +1 -1
  177. package/lib/{chunk-OMNMLKDT.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-B63POIPQ.mjs → chunk-YZKZC62O.mjs} +1 -1
  182. package/lib/{chunk-DPMRIMUC.mjs → chunk-YZQN7BRB.mjs} +1 -1
  183. package/lib/{chunk-7SQSWVAU.mjs → chunk-Z5IUK2QO.mjs} +1 -1
  184. package/lib/{chunk-M2ABR4JM.mjs → chunk-ZEGSMW5A.mjs} +1 -1
  185. package/lib/{chunk-PR42EZSR.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 +32 -14
  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-23SEDORH.mjs +0 -11
  209. package/lib/chunk-26POJDIT.mjs +0 -7
  210. package/lib/chunk-2AZQHBEF.mjs +0 -7
  211. package/lib/chunk-2METQHGG.mjs +0 -7
  212. package/lib/chunk-2WFIVO4F.mjs +0 -13
  213. package/lib/chunk-2YHZBUZE.mjs +0 -7
  214. package/lib/chunk-326AJTIU.mjs +0 -272
  215. package/lib/chunk-3PVRGTVK.mjs +0 -7
  216. package/lib/chunk-5XTUSN72.mjs +0 -8
  217. package/lib/chunk-6I6TWNV5.mjs +0 -7
  218. package/lib/chunk-6O222PW6.mjs +0 -7
  219. package/lib/chunk-6ZLKIT3H.mjs +0 -7
  220. package/lib/chunk-7QYHEHMA.mjs +0 -9
  221. package/lib/chunk-B3FBHVNN.mjs +0 -21
  222. package/lib/chunk-BEA27DLS.mjs +0 -7
  223. package/lib/chunk-BRY3PLIZ.mjs +0 -7
  224. package/lib/chunk-CBH3TOWK.mjs +0 -341
  225. package/lib/chunk-CVHNXJH3.mjs +0 -7
  226. package/lib/chunk-DGDRQRCW.mjs +0 -7
  227. package/lib/chunk-DUN2EPRC.mjs +0 -7
  228. package/lib/chunk-E3A3LOCY.mjs +0 -7
  229. package/lib/chunk-F2424IKX.mjs +0 -7
  230. package/lib/chunk-F3AQW6IU.mjs +0 -7
  231. package/lib/chunk-FNJ4SGWO.mjs +0 -7
  232. package/lib/chunk-GOOVPVWX.mjs +0 -7
  233. package/lib/chunk-H2BHESDA.mjs +0 -9
  234. package/lib/chunk-H4CGM6YO.mjs +0 -7
  235. package/lib/chunk-HIDW7FNV.mjs +0 -9
  236. package/lib/chunk-HSBXRQTI.mjs +0 -7
  237. package/lib/chunk-HUZPBE47.mjs +0 -7
  238. package/lib/chunk-I6E6T6YY.mjs +0 -7
  239. package/lib/chunk-IUM4NFKI.mjs +0 -10
  240. package/lib/chunk-IVFVNNGB.mjs +0 -37
  241. package/lib/chunk-JCFBFF4Y.mjs +0 -7
  242. package/lib/chunk-JTJK2D36.mjs +0 -7
  243. package/lib/chunk-KB4ZHM4Q.mjs +0 -10
  244. package/lib/chunk-KJWFYBMU.mjs +0 -15
  245. package/lib/chunk-LC3NDW4N.mjs +0 -7
  246. package/lib/chunk-OM5NORJG.mjs +0 -7
  247. package/lib/chunk-OVNMB6Q2.mjs +0 -7
  248. package/lib/chunk-PEDQPM2P.mjs +0 -926
  249. package/lib/chunk-PH7SP4YK.mjs +0 -21
  250. package/lib/chunk-PMN4PAC3.mjs +0 -19
  251. package/lib/chunk-PMWAFDUB.mjs +0 -48
  252. package/lib/chunk-PPLVFX6N.mjs +0 -7
  253. package/lib/chunk-PZBZ7MNC.mjs +0 -7
  254. package/lib/chunk-QROPNEGY.mjs +0 -14
  255. package/lib/chunk-RGBGUCJA.mjs +0 -156
  256. package/lib/chunk-RKTFFCNS.mjs +0 -7
  257. package/lib/chunk-ROV3QXEF.mjs +0 -475
  258. package/lib/chunk-RT47RKLY.mjs +0 -7
  259. package/lib/chunk-SI267LYR.mjs +0 -8
  260. package/lib/chunk-SRPWW4A2.mjs +0 -10
  261. package/lib/chunk-T3G6VZNS.mjs +0 -7
  262. package/lib/chunk-T63U4OZJ.mjs +0 -7
  263. package/lib/chunk-TEIBWMJM.mjs +0 -7
  264. package/lib/chunk-TW3N6W5Z.mjs +0 -7
  265. package/lib/chunk-UBIKR5VO.mjs +0 -7
  266. package/lib/chunk-UI3JQVRU.mjs +0 -8
  267. package/lib/chunk-UX3BVH2Y.mjs +0 -7
  268. package/lib/chunk-VINGECAJ.mjs +0 -10
  269. package/lib/chunk-VOXJHJIE.mjs +0 -7
  270. package/lib/chunk-WB2RIVO3.mjs +0 -7
  271. package/lib/chunk-WXDLQT2O.mjs +0 -10
  272. package/lib/chunk-XBQGZGWR.mjs +0 -7
  273. package/lib/chunk-XGGOUNPP.mjs +0 -7
  274. package/lib/chunk-XKWW3GKF.mjs +0 -7
  275. package/lib/chunk-YHR4WQPR.mjs +0 -7
  276. package/lib/chunk-ZQQXSCVI.mjs +0 -7
  277. package/lib/chunk-ZRUDYB7O.mjs +0 -7
package/README.md CHANGED
@@ -39,7 +39,7 @@ The tools, the `confirm` rule a write needs, and what each answer carries: [Sand
39
39
  | `cleanup` | Bulk delete records you created on a sandbox in a time window |
40
40
  | `clone` | clone a record, or whole tables, from one org to a sandbox, or remove a run |
41
41
  | `compare` | compare two orgs the way the Compare page does, and deploy what differs |
42
- | `dataops` | mask an org's records, and put them back |
42
+ | `dataops` | mask an org's records and put them back, verify a masking, list templates |
43
43
  | `empty` | empty objects of a sandbox, or the whole of it |
44
44
  | `env` | apply a sandforge.yaml to an org, and take it back |
45
45
  | `frozen` | build and replay a Frozen Dataset |
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as S,b as k}from"./chunk-UNDIBZWG.mjs";import{qc as m,rc as z,sc as E,tc as h}from"./chunk-PMWAFDUB.mjs";import{b as c,f as g,i as f,k as l,l as d}from"./chunk-WZQEK4WT.mjs";var D=/\bid\.?\s*:\s*([A-Za-z0-9]{18}|[A-Za-z0-9]{15})(?![A-Za-z0-9])/i;function x(e,s){let t;if(/^[A-Za-z0-9]{15}$/.test(e))t=S(e);else if(k(e))t=e;else return;if(!(s&&!t.startsWith(s)))return t}function v(e){return D.exec(e)?.[1]}var R=d({statusCode:c().optional(),errorCode:c().optional(),message:c().optional(),fields:l(f()).optional(),duplicateResult:f().optional()}).loose(),p="UNKNOWN_ERROR";function y(e){if(typeof e=="string")return{statusCode:p,message:e,fields:[]};let s=R.safeParse(e);return s.success?{statusCode:s.data.statusCode??s.data.errorCode??p,message:s.data.message??"",fields:(s.data.fields??[]).filter(t=>typeof t=="string")}:{statusCode:p,message:"Unknown error",fields:[]}}var _=/^([A-Z][A-Z0-9_]*):([\s\S]*):([A-Za-z0-9_]+(?: [A-Za-z0-9_]+)*)? ?--$/;function M(e){let s=e.trim();if(!s.endsWith("--")||s.slice(0,-2).includes("--"))return;let t=_.exec(s);if(t)return{statusCode:t[1],message:t[2],fields:t[3]===void 0?[]:t[3].split(" ")}}var b=d({matchResults:l(d({entityType:c().optional(),matchRecords:l(d({record:d({Id:c().optional(),attributes:d({type:c().optional()}).loose().optional()}).loose().optional()}).loose()).optional()}).loose()).optional()}).loose(),I=d({id:c().nullish(),success:g(),created:g().optional(),errors:l(f()).optional()}).loose();function P(e){return e.statusCode===p?e.message:`${e.statusCode}: ${e.message}`}function A(e){if(typeof e=="string")return e;let s=R.safeParse(e);if(!s.success)return"Unknown error";let t=s.data.statusCode??s.data.errorCode,n=s.data.message??"",r=t?`${t}: ${n}`:n,i=(s.data.fields??[]).filter(a=>typeof a=="string");if(i.length===0)return r;let o=`[${i.join(", ")}]`;return r.includes(o)?r:r?`${r} ${o}`:o}var C=5;function T(e){let s=(e??[]).map(r=>A(r)).filter(r=>r!==""&&r!=="Unknown error");if(s.length===0)return"Unknown insert error";let t=s.slice(0,C).join("; "),n=s.length-C;return n>0?`${t} (and ${n} more)`:t}function O(e,s){let t=R.safeParse(e);if(!t.success)return[];if((t.data.statusCode??t.data.errorCode)!==m)return[];let n=b.safeParse(t.data.duplicateResult);if(!n.success)return[];let r=[];for(let i of n.data.matchResults??[])for(let{record:o}of i.matchRecords??[]){let a=[i.entityType,o?.attributes?.type].filter(u=>typeof u=="string");a.length===0||a.some(u=>u!==s)||o?.Id&&r.push(o.Id)}return r}function w(e,s){let t=I.safeParse(e);if(!t.success){let i="Salesforce returned a save result of an unexpected shape";return{id:"",success:!1,errors:[i],errorDetails:[y(i)]}}let n=t.data.errors??[],r=n.flatMap(i=>O(i,s));return{id:t.data.id??"",success:t.data.success,...t.data.created!==void 0?{created:t.data.created}:{},errors:n.map(A),errorDetails:n.map(y),...r.length>0?{duplicateMatchIds:r}:{}}}function Z(e,s){return(Array.isArray(e)?e:[e]).map(t=>w(t,s))}function L(e,s){if(e.success||e.errors.length===0)return{kind:"none"};let t=o=>h(o)||z(o);if(!e.errors.every(t))return{kind:"none"};let n=new Set,r=!1;for(let o of e.errors){if(!o.includes(E))continue;let a=v(o),u=a?x(a,s):void 0;u?n.add(u):r=!0}let i=e.duplicateMatchIds??[];e.errors.some(o=>o.includes(m))&&i.length===0&&(r=!0);for(let o of i){let a=x(o,s);a?n.add(a):r=!0}return r||n.size!==1?{kind:"unidentified"}:{kind:"linked",id:[...n][0]}}export{x as a,p as b,y as c,M as d,P as e,A as f,T as g,O as h,w as i,Z as j,L as k};
7
+ import{a as S,b as k}from"./chunk-UNDIBZWG.mjs";import{Ac as h,xc as m,yc as z,zc as E}from"./chunk-J347SPU6.mjs";import{b as c,f as g,i as f,k as l,l as d}from"./chunk-WZQEK4WT.mjs";var D=/\bid\.?\s*:\s*([A-Za-z0-9]{18}|[A-Za-z0-9]{15})(?![A-Za-z0-9])/i;function x(e,s){let t;if(/^[A-Za-z0-9]{15}$/.test(e))t=S(e);else if(k(e))t=e;else return;if(!(s&&!t.startsWith(s)))return t}function v(e){return D.exec(e)?.[1]}var R=d({statusCode:c().optional(),errorCode:c().optional(),message:c().optional(),fields:l(f()).optional(),duplicateResult:f().optional()}).loose(),p="UNKNOWN_ERROR";function y(e){if(typeof e=="string")return{statusCode:p,message:e,fields:[]};let s=R.safeParse(e);return s.success?{statusCode:s.data.statusCode??s.data.errorCode??p,message:s.data.message??"",fields:(s.data.fields??[]).filter(t=>typeof t=="string")}:{statusCode:p,message:"Unknown error",fields:[]}}var _=/^([A-Z][A-Z0-9_]*):([\s\S]*):([A-Za-z0-9_]+(?: [A-Za-z0-9_]+)*)? ?--$/;function M(e){let s=e.trim();if(!s.endsWith("--")||s.slice(0,-2).includes("--"))return;let t=_.exec(s);if(t)return{statusCode:t[1],message:t[2],fields:t[3]===void 0?[]:t[3].split(" ")}}var b=d({matchResults:l(d({entityType:c().optional(),matchRecords:l(d({record:d({Id:c().optional(),attributes:d({type:c().optional()}).loose().optional()}).loose().optional()}).loose()).optional()}).loose()).optional()}).loose(),I=d({id:c().nullish(),success:g(),created:g().optional(),errors:l(f()).optional()}).loose();function P(e){return e.statusCode===p?e.message:`${e.statusCode}: ${e.message}`}function A(e){if(typeof e=="string")return e;let s=R.safeParse(e);if(!s.success)return"Unknown error";let t=s.data.statusCode??s.data.errorCode,n=s.data.message??"",r=t?`${t}: ${n}`:n,i=(s.data.fields??[]).filter(a=>typeof a=="string");if(i.length===0)return r;let o=`[${i.join(", ")}]`;return r.includes(o)?r:r?`${r} ${o}`:o}var C=5;function T(e){let s=(e??[]).map(r=>A(r)).filter(r=>r!==""&&r!=="Unknown error");if(s.length===0)return"Unknown insert error";let t=s.slice(0,C).join("; "),n=s.length-C;return n>0?`${t} (and ${n} more)`:t}function O(e,s){let t=R.safeParse(e);if(!t.success)return[];if((t.data.statusCode??t.data.errorCode)!==m)return[];let n=b.safeParse(t.data.duplicateResult);if(!n.success)return[];let r=[];for(let i of n.data.matchResults??[])for(let{record:o}of i.matchRecords??[]){let a=[i.entityType,o?.attributes?.type].filter(u=>typeof u=="string");a.length===0||a.some(u=>u!==s)||o?.Id&&r.push(o.Id)}return r}function w(e,s){let t=I.safeParse(e);if(!t.success){let i="Salesforce returned a save result of an unexpected shape";return{id:"",success:!1,errors:[i],errorDetails:[y(i)]}}let n=t.data.errors??[],r=n.flatMap(i=>O(i,s));return{id:t.data.id??"",success:t.data.success,...t.data.created!==void 0?{created:t.data.created}:{},errors:n.map(A),errorDetails:n.map(y),...r.length>0?{duplicateMatchIds:r}:{}}}function Z(e,s){return(Array.isArray(e)?e:[e]).map(t=>w(t,s))}function L(e,s){if(e.success||e.errors.length===0)return{kind:"none"};let t=o=>h(o)||z(o);if(!e.errors.every(t))return{kind:"none"};let n=new Set,r=!1;for(let o of e.errors){if(!o.includes(E))continue;let a=v(o),u=a?x(a,s):void 0;u?n.add(u):r=!0}let i=e.duplicateMatchIds??[];e.errors.some(o=>o.includes(m))&&i.length===0&&(r=!0);for(let o of i){let a=x(o,s);a?n.add(a):r=!0}return r||n.size!==1?{kind:"unidentified"}:{kind:"linked",id:[...n][0]}}export{x as a,p as b,y as c,M as d,P as e,A as f,T as g,O as h,w as i,Z as j,L as k};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{wd as u}from"./chunk-PMWAFDUB.mjs";var f={BusinessHours:["Name"]},j=["DUPLICATE_VALUE","DUPLICATES_DETECTED","duplicate value found"];var y=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,k=/^[A-Za-z][A-Za-z0-9_]*$/;function l(e){return e.slice(0,15)}function g(e,r){let t=e.mapping.get(r);return typeof t=="string"&&y.test(t)?t:void 0}function m(e){let r=new Set((e.created??[]).flatMap(i=>i.referenceIds)),t=new Set;for(let i of e.mapping.keys()){if(r.has(i))continue;let n=g(e,i);n&&t.add(l(n))}return t}function P(e){let r=new Set((e.created??[]).flatMap(n=>n.referenceIds)),t=[...Object.entries(e.personContacts??{}),...Object.entries(e.withTheirRecord??{})];for(let n=!0;n;){n=!1;for(let[o,s]of t)r.has(o)||!r.has(s)||(r.add(o),n=!0)}let i=new Set;for(let[n]of t){let o=r.has(n)?g(e,n):void 0;o&&i.add(l(o))}return i}function b(e){let r=m(e),t=new Map;for(let{objectApiName:o,referenceIds:s}of e.created??[])k.test(o)&&t.set(o,[...t.get(o)??[],...s]);let i=new Set,n=[];for(let[o,s]of[...t].reverse()){let a=[];for(let A of[...s].reverse()){let c=g(e,A);if(!c)continue;let d=l(c);r.has(d)||i.has(d)||(i.add(d),a.push(c))}a.length>0&&n.push({objectApiName:o,ids:a})}return n}function p(e){return u(e.removal)?[]:b(e).filter(r=>!R(r.objectApiName))}function R(e){return Object.prototype.hasOwnProperty.call(f,e)}function h(e){return b(e).filter(r=>R(r.objectApiName)).map(({objectApiName:r,ids:t})=>({objectApiName:r,count:t.length}))}function O(e){return e.find(r=>p(r).length>0)??e[0]}function I(e,r){return e.filter(t=>t.endedAt!==r.endedAt&&t.created!==void 0&&p(t).length===0)}function v(e){let r=e.created!==void 0,t=P(e),i=[...m(e)].filter(o=>!t.has(o)),n=h(e);return{orgId:e.orgId,loadedAt:e.endedAt,created:p(e).map(({objectApiName:o,ids:s})=>({objectApiName:o,count:s.length})),linked:r?i.length:0,recorded:r,...e.removal?{removed:e.removal}:{},...e.earlier?{earlier:!0}:{},...n.length>0?{keptByThePlatform:n}:{}}}export{f as a,j as b,b as c,p as d,h as e,O as f,I as g,v as h};
7
+ import{Gd as u}from"./chunk-J347SPU6.mjs";var f={BusinessHours:["Name"]},j=["DUPLICATE_VALUE","DUPLICATES_DETECTED","duplicate value found"];var y=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,k=/^[A-Za-z][A-Za-z0-9_]*$/;function l(e){return e.slice(0,15)}function g(e,r){let t=e.mapping.get(r);return typeof t=="string"&&y.test(t)?t:void 0}function m(e){let r=new Set((e.created??[]).flatMap(i=>i.referenceIds)),t=new Set;for(let i of e.mapping.keys()){if(r.has(i))continue;let n=g(e,i);n&&t.add(l(n))}return t}function P(e){let r=new Set((e.created??[]).flatMap(n=>n.referenceIds)),t=[...Object.entries(e.personContacts??{}),...Object.entries(e.withTheirRecord??{})];for(let n=!0;n;){n=!1;for(let[o,s]of t)r.has(o)||!r.has(s)||(r.add(o),n=!0)}let i=new Set;for(let[n]of t){let o=r.has(n)?g(e,n):void 0;o&&i.add(l(o))}return i}function b(e){let r=m(e),t=new Map;for(let{objectApiName:o,referenceIds:s}of e.created??[])k.test(o)&&t.set(o,[...t.get(o)??[],...s]);let i=new Set,n=[];for(let[o,s]of[...t].reverse()){let a=[];for(let A of[...s].reverse()){let c=g(e,A);if(!c)continue;let d=l(c);r.has(d)||i.has(d)||(i.add(d),a.push(c))}a.length>0&&n.push({objectApiName:o,ids:a})}return n}function p(e){return u(e.removal)?[]:b(e).filter(r=>!R(r.objectApiName))}function R(e){return Object.prototype.hasOwnProperty.call(f,e)}function h(e){return b(e).filter(r=>R(r.objectApiName)).map(({objectApiName:r,ids:t})=>({objectApiName:r,count:t.length}))}function O(e){return e.find(r=>p(r).length>0)??e[0]}function I(e,r){return e.filter(t=>t.endedAt!==r.endedAt&&t.created!==void 0&&p(t).length===0)}function v(e){let r=e.created!==void 0,t=P(e),i=[...m(e)].filter(o=>!t.has(o)),n=h(e);return{orgId:e.orgId,loadedAt:e.endedAt,created:p(e).map(({objectApiName:o,ids:s})=>({objectApiName:o,count:s.length})),linked:r?i.length:0,recorded:r,...e.removal?{removed:e.removal}:{},...e.earlier?{earlier:!0}:{},...n.length>0?{keptByThePlatform:n}:{}}}export{f as a,j as b,b as c,p as d,h as e,O as f,I as g,v as h};
@@ -4,5 +4,5 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{e as C,f as I}from"./chunk-UIOMAX56.mjs";import{e as T,r as S,z as O}from"./chunk-FP7CYB2F.mjs";import{H as A,d as P,r as b}from"./chunk-KGU4SVIT.mjs";import{b as w}from"./chunk-CA5NAXSU.mjs";import{a as u}from"./chunk-S42RBRH2.mjs";import{_a as h}from"./chunk-PMWAFDUB.mjs";import{b as i,f as R,l as m}from"./chunk-WZQEK4WT.mjs";import{randomBytes as q}from"node:crypto";import{open as U,readFile as F,rename as $,rm as M}from"node:fs/promises";import{promisify as N}from"node:util";import{gunzip as L,gzip as _}from"node:zlib";var D=N(_),Q=N(L),G=200,E="005",j="User",z="Group",H=new Set(["Pricebook2","PricebookEntry"]);function Re(e,n){let t=new Set(n);return e.fields.filter(o=>t.has(o.name)&&!C.includes(o.name)&&o.type==="reference"&&o.createable===!0&&(o.referenceTo??[]).some(r=>r===j||r===z)).map(o=>o.name)}async function Ae(e,n,t){let o=new Set;for(let{objectApiName:r,userLookups:s}of t){if(s.length===0)continue;let c=await S.read(e,n,r);for await(let l of c.records())for(let y of s){let a=l[y];if(typeof a!="string")continue;let p=u(a,E);p!==void 0&&o.add(p)}}return[...o].sort()}function ke(e){for(let n of e)if((n.name==="Account"||n.name==="Contact")&&n.fields.some(t=>t.name===I))return!0;return!1}function be(e){for(let n of e)if(H.has(n))return!0;return!1}function J(e){return e.map(n=>{if(u(n,E)!==n)throw new Error(`Not a user id: ${n}`);return`'${n}'`}).join(", ")}function W(e,n){let t=[];for(let o=0;o<e.length;o+=n)t.push(e.slice(o,o+n));return t}function B(e,n){return[...v(e),...W(n,G).map(t=>({part:"users",objectApiName:j,soql:`SELECT Id, Username, Name, IsActive, UserType FROM User WHERE Id IN (${J(t)})`,scanAll:!1}))]}function v(e){let n=[{part:"recordTypes",objectApiName:"RecordType",soql:`SELECT Id, SobjectType, DeveloperName, NamespacePrefix, Name, IsActive${e.personAccounts?", IsPersonType":""} FROM RecordType`,scanAll:!1},{part:"queues",of:"groups",objectApiName:z,soql:"SELECT Id, DeveloperName, Name FROM Group WHERE Type = 'Queue'",scanAll:!1},{part:"queues",of:"objects",objectApiName:"QueueSobject",soql:"SELECT QueueId, SobjectType FROM QueueSobject",scanAll:!1}];return e.catalog&&n.push({part:"standardPricebook",objectApiName:"Pricebook2",soql:"SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1",scanAll:!1}),n}function xe(e){return Math.ceil((v(e).length+1)/T)}var K=m({Id:i(),SobjectType:i(),DeveloperName:i(),NamespacePrefix:i().nullish(),Name:i(),IsActive:R(),IsPersonType:R().nullish()}).loose(),X=m({Id:i(),DeveloperName:i(),Name:i().nullish()}).loose(),V=m({QueueId:i(),SobjectType:i()}).loose(),Y=m({Id:i(),Username:i(),Name:i().nullish(),IsActive:R(),UserType:i()}).loose(),f="the org answered with rows this SandForge does not read";function Z(e,n){let t=[];for(let o of e){let r=K.safeParse(o);if(!r.success)return{unread:f};let s=r.data;t.push({id:u(s.Id)??s.Id,sobjectType:s.SobjectType,developerName:s.DeveloperName,...s.NamespacePrefix?{namespacePrefix:s.NamespacePrefix}:{},name:s.Name,isActive:s.IsActive,...n&&typeof s.IsPersonType=="boolean"?{isPersonType:s.IsPersonType}:{}})}return{rows:t.sort((o,r)=>x(`${o.sobjectType}.${o.developerName}`,`${r.sobjectType}.${r.developerName}`))}}function ee(e,n){let t=new Map;for(let r of n){let s=V.safeParse(r);if(!s.success)return{unread:f};let c=s.data.QueueId.slice(0,15);t.set(c,[...t.get(c)??[],s.data.SobjectType])}let o=[];for(let r of e){let s=X.safeParse(r);if(!s.success)return{unread:f};let c=s.data;o.push({id:u(c.Id)??c.Id,developerName:c.DeveloperName,name:c.Name??"",sobjectTypes:[...t.get(c.Id.slice(0,15))??[]].sort()})}return{rows:o.sort((r,s)=>x(r.developerName,s.developerName))}}function ne(e){let n=[];for(let t of e){let o=Y.safeParse(t);if(!o.success)return{unread:f};let r=o.data;n.push({id:u(r.Id)??r.Id,username:r.Username,name:r.Name??"",isActive:r.IsActive,userType:r.UserType})}return{rows:n.sort((t,o)=>x(t.id,o.id))}}async function we(e){let n=B(e,e.users),t=n.map(()=>[]),o=await O(e.reader,n,(a,p)=>{t[a].push(...p)},e.signal),r=new Map;o.forEach((a,p)=>{let{part:d}=n[p];!a.read&&!r.has(d)&&r.set(d,a.reason)});let s=(a,p)=>n.flatMap((d,g)=>d.part===a&&(p===void 0||d.of===p)?t[g]:[]),c={version:1,organizationId:u(e.organizationId)??e.organizationId,recordTypes:[],users:[],queues:[],unread:[]},l=(a,p,d)=>{let g=r.get(a);if(g!==void 0){c.unread.push({part:a,reason:oe(g)});return}let k=p();"unread"in k?c.unread.push({part:a,reason:k.unread}):d(k.rows)};l("recordTypes",()=>Z(s("recordTypes"),e.personAccounts),a=>{c.recordTypes=a}),l("queues",()=>ee(s("queues","groups"),s("queues","objects")),a=>{c.queues=a}),e.catalog&&l("standardPricebook",()=>{let[a]=s("standardPricebook"),p=typeof a?.Id=="string"?u(a.Id,"01s"):void 0;return a!==void 0&&p===void 0?{unread:f}:{rows:p}},a=>{a!==void 0&&(c.standardPricebookId=a)}),l("users",()=>ne(s("users")),a=>{c.users=a});let y=h.safeParse(c);return y.success?y.data:re(c,y.error.issues)}function re(e,n){let t=new Set;for(let r of n){let[s]=r.path;(s==="recordTypes"||s==="users"||s==="queues")&&t.add(s),s==="standardPricebookId"&&t.add("standardPricebook")}let o={...e,unread:[...e.unread]};for(let r of t)r==="recordTypes"&&(o.recordTypes=[]),r==="users"&&(o.users=[]),r==="queues"&&(o.queues=[]),r==="standardPricebook"&&delete o.standardPricebookId,o.unread.push({part:r,reason:f});return h.parse(o)}function x(e,n){return e<n?-1:e>n?1:0}function oe(e){let n=e.trim()===""?"the org gave no reason":e.trim();return n.length<=500?n:`${n.slice(0,499)}\u2026`}function te(e){let n=[...new Set(e.unread.map(t=>t.part))];return{recordTypes:e.recordTypes.length,users:e.users.length,queues:e.queues.length,standardPricebook:e.standardPricebookId!==void 0,...n.length>0?{unread:n}:{}}}async function Te(e,n){let t=h.safeParse(n);if(!t.success)throw new A("invalid",`Not a replay annex: ${t.error.message}`);let o=b(e),r=`${o}.${process.pid}-${q(4).toString("hex")}.tmp`,s=await U(r,"wx",P);try{try{await s.writeFile(await D(`${JSON.stringify(t.data)}
7
+ import{e as C,f as I}from"./chunk-4VLP6RHC.mjs";import{e as T,r as S,z as O}from"./chunk-DLSU66MY.mjs";import{H as A,d as P,r as b}from"./chunk-4CSBZZAL.mjs";import{b as w}from"./chunk-CA5NAXSU.mjs";import{a as u}from"./chunk-22L43JMK.mjs";import{bb as h}from"./chunk-J347SPU6.mjs";import{b as i,f as R,l as m}from"./chunk-WZQEK4WT.mjs";import{randomBytes as q}from"node:crypto";import{open as U,readFile as F,rename as $,rm as M}from"node:fs/promises";import{promisify as N}from"node:util";import{gunzip as L,gzip as _}from"node:zlib";var D=N(_),Q=N(L),G=200,E="005",j="User",z="Group",H=new Set(["Pricebook2","PricebookEntry"]);function Re(e,n){let t=new Set(n);return e.fields.filter(o=>t.has(o.name)&&!C.includes(o.name)&&o.type==="reference"&&o.createable===!0&&(o.referenceTo??[]).some(r=>r===j||r===z)).map(o=>o.name)}async function Ae(e,n,t){let o=new Set;for(let{objectApiName:r,userLookups:s}of t){if(s.length===0)continue;let c=await S.read(e,n,r);for await(let l of c.records())for(let y of s){let a=l[y];if(typeof a!="string")continue;let p=u(a,E);p!==void 0&&o.add(p)}}return[...o].sort()}function ke(e){for(let n of e)if((n.name==="Account"||n.name==="Contact")&&n.fields.some(t=>t.name===I))return!0;return!1}function be(e){for(let n of e)if(H.has(n))return!0;return!1}function J(e){return e.map(n=>{if(u(n,E)!==n)throw new Error(`Not a user id: ${n}`);return`'${n}'`}).join(", ")}function W(e,n){let t=[];for(let o=0;o<e.length;o+=n)t.push(e.slice(o,o+n));return t}function B(e,n){return[...v(e),...W(n,G).map(t=>({part:"users",objectApiName:j,soql:`SELECT Id, Username, Name, IsActive, UserType FROM User WHERE Id IN (${J(t)})`,scanAll:!1}))]}function v(e){let n=[{part:"recordTypes",objectApiName:"RecordType",soql:`SELECT Id, SobjectType, DeveloperName, NamespacePrefix, Name, IsActive${e.personAccounts?", IsPersonType":""} FROM RecordType`,scanAll:!1},{part:"queues",of:"groups",objectApiName:z,soql:"SELECT Id, DeveloperName, Name FROM Group WHERE Type = 'Queue'",scanAll:!1},{part:"queues",of:"objects",objectApiName:"QueueSobject",soql:"SELECT QueueId, SobjectType FROM QueueSobject",scanAll:!1}];return e.catalog&&n.push({part:"standardPricebook",objectApiName:"Pricebook2",soql:"SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1",scanAll:!1}),n}function xe(e){return Math.ceil((v(e).length+1)/T)}var K=m({Id:i(),SobjectType:i(),DeveloperName:i(),NamespacePrefix:i().nullish(),Name:i(),IsActive:R(),IsPersonType:R().nullish()}).loose(),X=m({Id:i(),DeveloperName:i(),Name:i().nullish()}).loose(),V=m({QueueId:i(),SobjectType:i()}).loose(),Y=m({Id:i(),Username:i(),Name:i().nullish(),IsActive:R(),UserType:i()}).loose(),f="the org answered with rows this SandForge does not read";function Z(e,n){let t=[];for(let o of e){let r=K.safeParse(o);if(!r.success)return{unread:f};let s=r.data;t.push({id:u(s.Id)??s.Id,sobjectType:s.SobjectType,developerName:s.DeveloperName,...s.NamespacePrefix?{namespacePrefix:s.NamespacePrefix}:{},name:s.Name,isActive:s.IsActive,...n&&typeof s.IsPersonType=="boolean"?{isPersonType:s.IsPersonType}:{}})}return{rows:t.sort((o,r)=>x(`${o.sobjectType}.${o.developerName}`,`${r.sobjectType}.${r.developerName}`))}}function ee(e,n){let t=new Map;for(let r of n){let s=V.safeParse(r);if(!s.success)return{unread:f};let c=s.data.QueueId.slice(0,15);t.set(c,[...t.get(c)??[],s.data.SobjectType])}let o=[];for(let r of e){let s=X.safeParse(r);if(!s.success)return{unread:f};let c=s.data;o.push({id:u(c.Id)??c.Id,developerName:c.DeveloperName,name:c.Name??"",sobjectTypes:[...t.get(c.Id.slice(0,15))??[]].sort()})}return{rows:o.sort((r,s)=>x(r.developerName,s.developerName))}}function ne(e){let n=[];for(let t of e){let o=Y.safeParse(t);if(!o.success)return{unread:f};let r=o.data;n.push({id:u(r.Id)??r.Id,username:r.Username,name:r.Name??"",isActive:r.IsActive,userType:r.UserType})}return{rows:n.sort((t,o)=>x(t.id,o.id))}}async function we(e){let n=B(e,e.users),t=n.map(()=>[]),o=await O(e.reader,n,(a,p)=>{t[a].push(...p)},e.signal),r=new Map;o.forEach((a,p)=>{let{part:d}=n[p];!a.read&&!r.has(d)&&r.set(d,a.reason)});let s=(a,p)=>n.flatMap((d,g)=>d.part===a&&(p===void 0||d.of===p)?t[g]:[]),c={version:1,organizationId:u(e.organizationId)??e.organizationId,recordTypes:[],users:[],queues:[],unread:[]},l=(a,p,d)=>{let g=r.get(a);if(g!==void 0){c.unread.push({part:a,reason:oe(g)});return}let k=p();"unread"in k?c.unread.push({part:a,reason:k.unread}):d(k.rows)};l("recordTypes",()=>Z(s("recordTypes"),e.personAccounts),a=>{c.recordTypes=a}),l("queues",()=>ee(s("queues","groups"),s("queues","objects")),a=>{c.queues=a}),e.catalog&&l("standardPricebook",()=>{let[a]=s("standardPricebook"),p=typeof a?.Id=="string"?u(a.Id,"01s"):void 0;return a!==void 0&&p===void 0?{unread:f}:{rows:p}},a=>{a!==void 0&&(c.standardPricebookId=a)}),l("users",()=>ne(s("users")),a=>{c.users=a});let y=h.safeParse(c);return y.success?y.data:re(c,y.error.issues)}function re(e,n){let t=new Set;for(let r of n){let[s]=r.path;(s==="recordTypes"||s==="users"||s==="queues")&&t.add(s),s==="standardPricebookId"&&t.add("standardPricebook")}let o={...e,unread:[...e.unread]};for(let r of t)r==="recordTypes"&&(o.recordTypes=[]),r==="users"&&(o.users=[]),r==="queues"&&(o.queues=[]),r==="standardPricebook"&&delete o.standardPricebookId,o.unread.push({part:r,reason:f});return h.parse(o)}function x(e,n){return e<n?-1:e>n?1:0}function oe(e){let n=e.trim()===""?"the org gave no reason":e.trim();return n.length<=500?n:`${n.slice(0,499)}\u2026`}function te(e){let n=[...new Set(e.unread.map(t=>t.part))];return{recordTypes:e.recordTypes.length,users:e.users.length,queues:e.queues.length,standardPricebook:e.standardPricebookId!==void 0,...n.length>0?{unread:n}:{}}}async function Te(e,n){let t=h.safeParse(n);if(!t.success)throw new A("invalid",`Not a replay annex: ${t.error.message}`);let o=b(e),r=`${o}.${process.pid}-${q(4).toString("hex")}.tmp`,s=await U(r,"wx",P);try{try{await s.writeFile(await D(`${JSON.stringify(t.data)}
8
8
  `)),await s.sync()}finally{await s.close()}await $(r,o)}catch(c){throw await M(r,{force:!0}),c}return te(t.data)}async function Pe(e){let n;try{n=await F(b(e))}catch(r){if(r.code==="ENOENT")return;throw r}let t;try{t=JSON.parse((await Q(n)).toString("utf8"))}catch(r){throw new A("damaged",`The checkpoint\u2019s replay annex cannot be read: ${w(r)}`)}let o=h.safeParse(t);if(!o.success)throw new A("damaged","The checkpoint\u2019s replay annex does not parse");return o.data}export{Re as a,Ae as b,ke as c,be as d,xe as e,we as f,te as g,Te as h,Pe as i};
@@ -0,0 +1,10 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{p as h}from"./chunk-KWUS7UAV.mjs";import{a as c,b as a,e as u}from"./chunk-K5PUMHZU.mjs";import{b as o,e as m,k as g,l as p,u as f}from"./chunk-WZQEK4WT.mjs";import{appendFile as y,mkdir as w,readFile as D,writeFile as R}from"node:fs/promises";import{dirname as S,join as O}from"node:path";var v="seed-runs-dropped.ndjson",F=50,E={readFile:e=>D(e,"utf8"),appendFile:async(e,t)=>{await w(S(e),{recursive:!0,mode:c}),await u(e,a),await y(e,t,{encoding:"utf8",mode:a})},writeFile:async(e,t)=>{await w(S(e),{recursive:!0,mode:c}),await u(e,a),await R(e,t,{encoding:"utf8",mode:a})}},P=p({runId:o().min(1),targetOrgId:o().min(1),origin:f(["csv","clone"]).optional(),startedAt:o().min(1),droppedAt:o().min(1),left:g(p({objectApiName:o().min(1),count:m().int().nonnegative()}))});function I(e,t){return{runId:e.runId,targetOrgId:e.targetOrgId,...e.origin?{origin:e.origin}:{},startedAt:e.startedAt,droppedAt:t,left:h(e).map(({objectApiName:n,ids:i})=>({objectApiName:n,count:i.length}))}}var l=class{constructor(t,n=E,i=F){this.file=t;this.files=n;this.kept=i}file;files;kept;writes=Promise.resolve();note(t,n=new Date().toISOString()){let i=I(t,n);return this.writes=this.writes.then(()=>this.append(i)).catch(()=>{}),this.writes}async find(t){return await this.writes,(await this.read()).reverse().find(n=>n.runId===t)}async read(){let t;try{t=await this.files.readFile(this.file)}catch{return[]}let n=[];for(let i of t.split(`
8
+ `)){if(i.trim()==="")continue;let r;try{r=JSON.parse(i)}catch{continue}let s=P.safeParse(r);s.success&&n.push(s.data)}return n}async append(t){let n=await this.read();if(n.length<this.kept){await this.files.appendFile(this.file,`${JSON.stringify(t)}
9
+ `);return}let i=[...n.slice(n.length-this.kept+1),t];await this.files.writeFile(this.file,i.map(r=>`${JSON.stringify(r)}
10
+ `).join(""))}};function $(e){return new l(O(e,v))}function b(e,t){let n=e.left.reduce((r,{count:s})=>r+s,0),i=e.left.map(({objectApiName:r})=>r).join(", ");return`Nothing this run created is kept: it was dropped on ${e.droppedAt} to keep the runs kept on this machine within their bound, ${n} of its records still in its org${i?` (${i})`:""}. ${t} lists, deleting nothing, every record you created there since the day the run started, its records among them; the same line without --dry-run deletes what it counted.`}function k(e,t,n){let i=new Date(e.startedAt).toISOString().slice(0,10),r=e.left.map(({objectApiName:d})=>d),s=Math.max(1,...e.left.map(({count:d})=>d));return[t,`--target ${n}`,`--since ${i}`,...r.length>0?[`--objects ${r.join(",")}`,`--max ${s}`]:[],"--dry-run"].join(" ")}export{$ as a,b,k as c};
@@ -0,0 +1,7 @@
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{f as F,g}from"./chunk-FQGHL7GR.mjs";import{e as l}from"./chunk-22L43JMK.mjs";var p="FIELD_CUSTOM_VALIDATION_EXCEPTION",T="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST",x="FIELD_FILTER_VALIDATION_EXCEPTION",w="INACTIVE_OWNER_OR_USER",R=/\[(005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?)\]/,A="005",_=["CreatedById","LastModifiedById"];function $(e,n){if(e.statusCode!==w)return;let r=c(n,"OwnerId"),t=r===void 0?void 0:n[r],i=R.exec(e.message)?.[1];if(!(typeof t!="string"||i===void 0))return t.slice(0,15)===i.slice(0,15)?i.slice(0,15):void 0}function I(e,n,r){let t=c(n,"OwnerId");if(t===void 0||t.toLowerCase()===r?.toLowerCase())return;let i=n[t];if(!(typeof i!="string"||!i.startsWith(A)||e.fields.some(f=>f.toLowerCase()!=="ownerid")||!(R.test(e.message)?$(e,n)!==void 0:_.every(f=>c(n,f)===void 0))))return{field:t,refusedBy:"inactive-owner",reason:l(e)}}var b=new Map([[p,"validation-rule"],[T,"restricted-picklist"],[x,"lookup-filter"]]);function P(e){return e!=null&&e!==""}function c(e,n){let r=n.toLowerCase();return Object.keys(e).find(t=>t.toLowerCase()===r&&P(e[t]))}function X(e,n,r,t,i){if(!e||e.length===0)return;let o=new Map;for(let s of e){let f=b.get(s.statusCode);if(!f){let d=i?.inactiveOwner===!0&&s.statusCode===w?I(s,n,r):void 0;if(!d)return;o.has(d.field)||o.set(d.field,d);continue}let u=s.fields.map(d=>c(n,d)).filter(d=>d!==void 0&&d.toLowerCase()!==r?.toLowerCase());if(u.length===0||f==="lookup-filter"&&!u.every(d=>t?.(d)===!0))return;for(let d of u)o.has(d)||o.set(d,{field:d,refusedBy:f,reason:l(s)})}return[...o.values()]}function H(e){return(e??[]).some(n=>n.statusCode===p&&n.fields.length===0)}function Y(e,n){let r=new Set(n.map(t=>t.field));return Object.fromEntries(Object.entries(e).filter(([t])=>!r.has(t)))}function G(e,n){let r=e??{rows:0,fields:[]};r.rows+=n.rows;for(let t of n.fields){let i=r.fields.find(o=>o.field===t.field&&o.reason===t.reason);i?i.rows+=t.rows:r.fields.push({...t})}return r}var v={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function S(e){return(e?.fields??[]).map(({field:n,refusedBy:r="validation-rule",reason:t,rows:i,replacedWith:o})=>{let s=o===void 0?`written without ${n}`:`written with ${n} set to "${o}"`;return`, ${i} ${s}: ${v[r]}, ${t}`}).join("")}function q(e){let n=`${e.rows} record(s) written again without the fields the target refused them on${S(e)}`;return n.endsWith(".")?n:`${n}.`}var D=80,y=".test",ee=/\.(?:invalid|test)$/i,O=/\.(?:invalid|example)$/i,N=/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g,W=/\+?(?<!\d)\d(?:[\s.()/-]{0,2}\d){6,}/g,L=/^[\d\s.()/+-]+$/,h=3;function U(e,n){if(/\.test$/i.test(e))return;let r=e.slice(e.lastIndexOf("@")+1);if(!e.includes("@")||!g(r))return;let t=O.test(e)?e.replace(O,y):`${e}${y}`;return t.length<=n?t:void 0}function k(e){if(!L.test(e))return;let n=e.trim(),r=n.replace(/\D/g,""),t=n.startsWith("+")?r:r.startsWith("00")?r.slice(2):void 0;for(let{phoneRange:i}of Object.values(F)){let{countryCode:o,trunkPrefix:s,nationalNumber:f}=i,u=r;if(t!==void 0){if(!t.startsWith(o))continue;u=t.slice(o.length)}let d=s!==""&&u.startsWith(s)?u.slice(s.length):u;if(f.test(d))return{countryCode:o,trunkPrefix:s,national:d};if(f.test(u))return{countryCode:o,trunkPrefix:s,national:u}}}function K(e){let n=e.length%2===1?[e[0]]:[],r=e.slice(n.length).match(/\d{2}/g)??[];return[...n,...r].join(" ")}function E(e){let n=k(e);if(!n)return[];let{countryCode:r,trunkPrefix:t,national:i}=n,o=t==="0",s=o?"(0)":`(${i.slice(0,3)})`,f=o?i:i.slice(3),u=[o?`+${r} (0)${K(i)}`:`+${r} ${s} ${f}`,`+${r}${s}${f}`,`+${r}${i}`];return[...new Set(u)].filter(d=>d!==e.trim()).slice(0,h)}function M(e,n,r){let t=o=>r===void 0||o.length<=r;if(e==="email"){let o=r??D,s=!1,f=!0,u=n.replace(N,d=>{let a=U(d,o);return a===void 0?(!/\.test$/i.test(d)&&C(d)&&(f=!1),d):(s=!0,a)});return s&&f&&u.length<=o?[u]:[]}if(L.test(n))return E(n).filter(t);let i=[];for(let o=0;o<h;o++){let s=!1,f=n.replace(W,u=>{let d=E(u)[o];return d===void 0?u:(s=!0,d)});if(!s)break;t(f)&&!i.includes(f)&&i.push(f)}return i}function C(e){return g(e.slice(e.lastIndexOf("@")+1))}function j(e){if(!(typeof e!="string"||e.trim()===""))return/^[^\s@]+@[^\s@]+$/.test(e.trim())?C(e.trim())?{kind:"email"}:void 0:k(e)?{kind:"phone"}:void 0}function ne(e,n,r,t){let i={},o=[];for(let s of e){let f=s.refusedBy==="validation-rule"?r(s.field):void 0,u=n[s.field],d=t.get(s.field),a=d?.first??(typeof u=="string"?u:void 0),m=f&&a!==void 0?M(f.kind,a,f.maxLength)[d?.tried??0]:void 0;if(m===void 0||a===void 0){o.push(s);continue}i[s.field]=m,t.set(s.field,{first:a,tried:(d?.tried??0)+1})}return{forms:i,leftOut:o}}function te(e,n,r){let t=new Set(n.map(({field:o})=>o)),i=[];for(let o of e.keys()){let s=r(o);!s||t.has(o)||i.push({field:o,kind:s.kind,how:"otherForm"})}for(let o of t){let s=r(o);s&&i.push({field:o,kind:s.kind,how:"withoutField"})}return i}function B(e){return e==="email"?"under .test":"in another layout of the same fictional number"}function re(e){let n=e?.refusedForms??[];return n.length===0?[]:["refused under the first form by a validation rule of the target, written under another that reaches no one, or without the field once every form was refused:",...n.map(({objectApiName:r,field:t,kind:i,otherForm:o,withoutField:s})=>` ${r}.${t} ${o} ${B(i)}, ${s} without it`)]}function V(e,n){if(!e)return[];let r=new Map(n.map(i=>[i.name.toLowerCase(),i])),t=[];for(let i of e){let o=r.get(i.toLowerCase());o&&!t.some(s=>s.field===o.name)&&t.push({field:o.name,kind:o.kind})}return t}function oe(e){let n=new Map;for(let r of e)for(let[t,i]of Object.entries(r)){if(n.has(t))continue;let o=j(i);o&&n.set(t,{name:t,kind:o.kind})}return[...n.values()]}function ie(e,n){return e.flatMap(r=>{let t=V(r.reads,n);return t.length>0?[`validation rule ${r.name} ${z(t)}`]:[]})}function z(e){if(e.length===0)return"";let n=new Set(e.map(i=>i.kind)),r=n.has(void 0),t=[...n.has("email")||r?["an address once under .test"]:[],...n.has("phone")||r?[`a phone number in up to ${h} other layouts of the same fictional number`]:[]].join(", ");return`reads ${e.map(i=>i.field).join(", ")}, which the run writes unreachable: refused, a row goes again with another unreachable form \u2014 ${t} \u2014 then without the field`}export{T as a,x as b,w as c,$ as d,c as e,X as f,H as g,Y as h,G as i,S as j,q as k,ee as l,h as m,j as n,ne as o,te as p,re as q,V as r,oe as s,ie as t,z as u};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{y as he}from"./chunk-326AJTIU.mjs";import{i as ce,j as x,k as de,l as pe}from"./chunk-LA4KIATH.mjs";import{l as le,n as z}from"./chunk-GMIGWR6U.mjs";import{e as F,i as ae,k as D,l as se}from"./chunk-IZGCEOYO.mjs";import{d as j,f as oe,yb as re,zb as ie}from"./chunk-PEDQPM2P.mjs";import{$a as J}from"./chunk-XGGOUNPP.mjs";import{c as ne}from"./chunk-QROPNEGY.mjs";import{L as te,e as X,k as Q,z as ee}from"./chunk-KGU4SVIT.mjs";import{a as v,c as A}from"./chunk-AL4C3GFT.mjs";import{wc as C}from"./chunk-KB4ZHM4Q.mjs";import{Ra as Z,cb as V}from"./chunk-PMWAFDUB.mjs";import{existsSync as $e,readFileSync as ve}from"node:fs";import{hostname as be}from"node:os";import{join as ge,resolve as T}from"node:path";var Ae=["--custom-settings","--mask","--keep-contact-points","--no-real-data"],Ee=["--objects","--exclude-object","--owners","--owner-map","--link","--replay-config"],Ie=["--again","--accept-emails","--max-records",...j.switches,...j.values],Oe=["--preview","--sweep","--sweep-list",...re,"--include-changed"],Ne=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,E=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,me=e=>Z.safeParse(e).success,Se={ownerMap:"--owner-map",objects:"--objects",excluded:"--exclude-object",link:"--link"};function Rt(e,t){let n=c=>e.includes(c),o=c=>{let p=[];for(let w=1;w<e.length;w++){if(e[w]!==c)continue;let $=e[w+1];if($===void 0||$.startsWith("--"))return t(`${c} wants a value.`);p.push($),w++}return p},r=c=>{let p=o(c);return p.length>1&&t(`${c} is given ${p.length} times: give it once.`),p[0]},s=c=>{let p=r(c);if(p!==void 0)return/^\d{1,15}$/.test(p)||t(`${c} takes a whole number, not "${p}".`),Number(p)},d=["--dry-run","--verify","--remove"].filter(n);d.length>1&&t(`Give one of --dry-run, --verify and --remove, not ${d.join(" and ")}. Nothing was run.`);let i=n("--dry-run")?"dryRun":n("--verify")?"verify":n("--remove")?"remove":"replay",a=c=>c.filter(n);if(i==="verify"||i==="remove"){let c=a([...Ae,...Ee]);c.length>0&&t(`${c.join(", ")} ${c.length===1?"is a choice":"are choices"} of a replay and its dry run: --verify reads the choices its last replay was made with, and --remove takes back what it wrote. Nothing was run.`);let p=a(Ie);p.length>0&&t(`${p.join(", ")} goes with a replay or its dry run, not with --${i}. Nothing was run.`)}if(i!=="remove"){let c=a(Oe);c.length>0&&t(`${c.join(", ")} goes with --remove. Nothing was run.`)}n("--sweep")&&n("--sweep-list")&&t("--sweep deletes and --sweep-list only lists: give one of them. Nothing was run."),n("--preview")&&n("--sweep-list")&&t("--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Nothing was run.");let u=ie(e);if("refusal"in u&&t(`${u.refusal} Nothing was run.`),i==="verify"){let c=a(["--mute-automation","--accept-automation"]);c.length>0&&t(`${c.join(", ")} goes with a replay or its removal: a verification only reads. Nothing was run.`)}let m=r("--checkpoint"),f=r("--file");if(m===void 0&&f===void 0)return t("replay needs --checkpoint <id|name> (list names them) or --file <.sfcheckpoint>. Run with --help.");m!==void 0&&f!==void 0&&t("Give --checkpoint or --file, not both. Nothing was run.");let h=r("--from");if(h!==void 0&&m===void 0&&t("--from goes with --checkpoint <name>: it names the org the checkpoint was taken of."),m!==void 0&&!me(m)&&h===void 0&&t(`--checkpoint '${m}' is not a checkpoint's id: a name names one of an org's checkpoints, so give --from <alias|username|00D\u2026>, the org it was taken of, or its id ("${v("checkpoint")} list" names them). Nothing was run.`),f===void 0){let c=a(["--key-env","--keep-days"]);c.length>0&&t(`${c.join(" and ")} goes with --file. Nothing was run.`)}let k=r("--target")??t("replay needs --target <alias>, the org the checkpoint's records go into. Run with --help."),R=o("--objects").flatMap(c=>c.split(",").map(p=>p.trim()).filter(p=>p!=="")),g=o("--exclude-object");for(let[c,p]of[["--objects",R],["--exclude-object",g]]){let w=p.find($=>!Ne.test($));w!==void 0&&t(`${c} takes objects' API names, not "${w}".`)}let I=c=>c.filter((p,w)=>c.findIndex($=>$.toLowerCase()===p.toLowerCase())===w),O=r("--owners")??"same";O!=="same"&&O!=="me"&&t(`--owners takes same or me, not "${O}".`);let we=o("--link").map(c=>{let p=/^([A-Za-z][A-Za-z0-9_]*)=([A-Za-z0-9_,]+)$/.exec(c);return p?{objectApiName:p[1],fields:p[2].split(",").filter(w=>w!=="")}:t(`--link takes Object=Field or Object=Field,Field \u2014 the fields a record of the other org is found by \u2014, not "${c}".`)}),N=r("--owner-map"),Y=N!==void 0?ye("--owner-map",N,t):void 0,Re={owners:O,...Y!==void 0?{ownerMap:Y}:{},customSettings:n("--custom-settings"),mask:n("--mask"),contactPoints:n("--keep-contact-points")?"kept":"neutralized",objects:I(R),excluded:I(g),link:we,...n("--no-real-data")?{noRealData:!0}:{}},_=V.safeParse(Re);if(!_.success){let c=_.error.issues[0],p=String(c?.path[0]??"");return t(`${Se[p]??p}: ${c?.message??"not read"}. Nothing was run.`)}let K=_.data,S=r("--replay-config"),H=S!==void 0?Ce(S,K,t):void 0,P=s("--max-records");P===0&&t('--max-records takes a whole number of 1 or more, not "0". Nothing was run.');let G=Fe(r("--key-env"),t),q=oe(e);return{action:i,...m!==void 0?{checkpoint:m}:{},...h!==void 0?{from:h}:{},...f!==void 0?{file:T(f)}:{},...G!==void 0?{keyEnv:G}:{},keepDays:s("--keep-days")??X,target:k,choices:K,...N!==void 0?{ownerMapFile:T(N)}:{},...H!==void 0?{config:H}:{},...S!==void 0?{configFile:T(S)}:{},again:n("--again"),muteAutomation:n("--mute-automation"),acceptAutomation:n("--accept-automation"),acceptEmails:n("--accept-emails"),...q!==void 0?{checkpointFirst:q}:{},...P!==void 0?{maxRecords:P}:{},preview:n("--preview"),sweep:n("--sweep"),sweepList:n("--sweep-list"),...u,includeChanged:n("--include-changed"),yes:n("--yes")}}function $t(e,t){let n=e.flatMap((r,s)=>r==="--target"?[e[s+1]]:[]);n.length>1&&t(`--target is given ${n.length} times: give it once.`);let o=n[0];return o!==void 0?{target:o}:{}}function ye(e,t,n){try{return JSON.parse(ve(t,"utf8"))}catch(o){return n(`${e}: ${t} does not read as JSON (${o instanceof Error?o.message:String(o)}). Nothing was run.`)}}function Ce(e,t,n){let o=ye("--replay-config",e,n),r=J.safeParse({targetOrgId:"command-line",replay:{organizationId:"00D000000000000AAA",checkpointId:"ck-20000101-000000-0000",choices:t,config:o}});if(!r.success){let s=r.error.issues[0],d=(s?.path??[]).slice(2).join(".");return n(`--replay-config: ${d!==""?`${d}: `:""}${s?.message??"not read"}. It takes the load\u2019s part of a Frozen project\u2019s configuration: requiredFieldDefaults, requiredLookupPlaceholders, picklistRules, defaultPicklistRule, identityKeys, undeletableObjects, duplicateErrorPatterns, mockDetection, protectedOrgIds. Nothing was run.`)}return o}function Fe(e,t){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||F(e)!==void 0?t("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}var ze="cli-store.json";function W(e,t){return t?ge(e,".replays"):ce()}var y=class extends Error{constructor(n,o=1){super(n.message);this.refusal=n;this.code=o;this.name="ReplayStop"}refusal;code};function ke(e){try{return new x({root:e})}catch(t){throw new y({code:"STORE_REFUSED",message:`The replays cannot be kept in ${e}: ${t instanceof Error?t.message:String(t)} Name a store outside any repository with --store <folder>. Nothing was read or written.`})}}function B(e,t){let n=D(e);if(!$e(n))return;let o=te({root:n,...t!==void 0?{locksDir:t}:{}});return"store"in o?o.store:void 0}function vt(e,t){return`${v("checkpoint")} replay --file ${A(e)} --target ${t}`}function L(e,t,n){return`${v("checkpoint")} replay --checkpoint ${e} --target ${t}`+(n!==void 0?` --store ${A(n)}`:"")}var l=e=>e.toLocaleString("en-US");function b(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function M(e,t=8){return e.length<=t?e.join(", "):`${e.slice(0,t).join(", ")} and ${l(e.length-t)} more`}function Le(e){return{run:"replay",done:"replayed",source:e,recordedIn:"for this checkpoint on this machine",remove:"--remove",module:"replay",again:"again",againSubject:{purge:"replayAgain",sweep:"replayAgainSweep"},maybeMasks:"the checkpoint does not say whether its take read them unmasked, so they may hold the masks a user without View Encrypted Data reads, such as ****1234"}}var _e={fileContentNotKept:()=>"a checkpoint keeps no file's content",notInTarget:(e,t)=>`${t} has no such object: deploy it there, or leave it out (--exclude-object ${e})`,notCreateable:(e,t)=>`${t} lets no one create its records`,excluded:()=>"left out as asked"},Pe={objectNotReplayed:e=>`the checkpoint holds the records it names and does not replay them: add ${e.split(".")[0]}'s target with --objects`,objectNotHeld:(e,t)=>`the checkpoint does not hold what it names, and ${t} has no record of that Id`,userNotInTarget:(e,t)=>`${t} has no active standard user for it`},fe={requiredLookupMissing:"a required lookup names a record neither replayed nor in the other org",parentRefused:"a parent of theirs is refused, and no orphan is written",personAccountsUnsupported:"the other org has not turned person accounts on",inactiveCurrency:"their currency is not active in the other org",recordTypeUnavailable:"their record type is one the user who replays may not create"};function je(e){return`${Object.hasOwn(fe,e.reason)?fe[e.reason]:e.reason}${e.path?`: ${e.path}`:""}`}var De={byName:"found by its name",byId:"found by its Id",default:"the other org's default for the user who replays"};function xe(e){let{summary:t}=e,n=e.target.name,o=[],{records:r}=t;r.linkedById>0&&o.push(`${l(r.linkedById)} record(s) ${n} holds under the same Id \u2014 a sandbox copied from the same production \u2014: linked, not changed`),r.linkedByKey>0&&o.push(`${l(r.linkedByKey)} record(s) found in ${n} by the fields --link names: linked, not created`);let s=t.owners,d=[s.reasons.notInTarget>0?`their user is not in ${n}: ${l(s.reasons.notInTarget)}`:"",s.reasons.inactive>0?`their user is inactive in ${n}: ${l(s.reasons.inactive)}`:"",s.reasons.queueMissing>0?`their queue is not in ${n}: ${l(s.reasons.queueMissing)}`:""].filter(Boolean);o.push(`owners: ${l(s.kept)} kept, ${l(s.toRunningUser)} to the user who replays`+(d.length>0?` \u2014 ${d.join("; ")}`:""));for(let i of t.recordTypes)o.push(`record type ${i.object}.${i.recordType}: ${De[i.outcome]} \u2014 ${l(i.records)} record(s)`);for(let i of t.refused)o.push(`refused before anything is written: ${i.object} ${l(i.records)} \u2014 `+je(i));for(let i of t.notReplayed)o.push(`not replayed: ${i.object} ${l(i.records)} \u2014 `+_e[i.reason](i.object,n));e.filesLeft.length>0&&o.push(`${l(e.filesLeft.length)} file(s) left where they were, a checkpoint keeping no file's content:`,...e.filesLeft.map(i=>` ${i.objectApiName}${i.name!==void 0?` '${i.name}'`:""}`));for(let i of t.lookupsEmptied)o.push(`${i.field}: emptied on ${l(i.records)} record(s) \u2014 `+Pe[i.reason](i.field,n));for(let i of t.fieldsNotInTarget)o.push(`${i.object}: ${M(i.fields)} left out \u2014 ${n} does not have them`);t.customSettings&&o.push(`custom settings: ${l(t.customSettings.inserted)} row(s) set up, ${l(t.customSettings.alreadyThere)} already in ${n}, kept as they are`);for(let i of t.currencies.refused)o.push(`${i.code}: ${l(i.records)} record(s) refused \u2014 the currency is not active in ${n}: activate it there, or leave those records out`);if(t.currencies.singleCurrencyTarget&&o.push(`${n} has one currency: amounts are kept as they are, in its currency`),t.standardPricebook==="deduced"?o.push("standard price book: told from the price book entries, the checkpoint naming none"):t.standardPricebook==="ambiguous"&&o.push("standard price book: the price book entries do not tell which it was, and those that need it are refused"),t.masked.fields.length>0&&o.push(`masked: ${M(t.masked.fields)}`),(t.masked.unmaskedFreeText??[]).length>0&&o.push(`not masked, free text the masking does not read: ${M(t.masked.unmaskedFreeText??[])}`),o.push(t.contactPoints==="neutralized"?"emails and phone numbers made unreachable (.invalid, numbers that ring nobody); --keep-contact-points keeps them":"emails and phone numbers kept as they are: they reach the people they name"),(t.archivedActivities??0)>0&&o.push(`${l(t.archivedActivities??0)} archived task(s) and event(s) replayed, which ${n} holds live`),t.degraded.length>0&&o.push((e.checkpoint.annex?`its take could not read ${t.degraded.join(", ")}`:"taken before SandForge 1.81, it keeps no record types, users, queues nor standard price book")+`: the records they name get what ${n} gives them, each said above`),o.push("created and modified dates and users are the replay's own: the platform sets them"),e.storage){let{storage:i}=e;o.push(`data storage: about ${C(i.estimateMB)} MB of the ${C(i.remainingMB)} MB ${n} has left of ${C(i.maxMB)} MB`)}return o}var Te=new Set(["REPLAY_SAME_ORG","REPLAY_REAL_DATA","REPLAY_COPY_UNKNOWN","REPLAY_TOO_MANY","REPLAY_NOTHING","REPLAY_CHECKPOINT_UNUSABLE","REPLAY_NO_PILOT","CHECKPOINT_NOT_FOUND","OWNER_MAP_INACTIVE","OWNER_MAP_UNKNOWN","GUARD_REFUSED","NO_LOAD","TARGET_REFRESHED","LOAD_REMOVED","LOAD_STOPPED"]);function Me(e){let t=String(e.type??""),n=e.payload?.code;if(!(!t.endsWith(":error")||typeof n!="string")&&Te.has(n))return{code:n,message:String(e.payload?.message??"")}}function Ue(e,t,n,o={}){switch(e){case"TARGET_REFRESHED":if(/dataset/i.test(t))return`${n} was refreshed after the last replay: the records it created went with the refresh. Replay the checkpoint again, then verify.`;break;case"LOAD_REMOVED":{let r=/removal of (\S+) took part/.exec(t);if(r)return`The removal of ${r[1]} took part of the records the last replay created and left ${l(Number(o.left??0))} in ${n}: a verification would read the ones it took as missing. Remove what is left (--remove), or replay again (--again), which purges or finds it again; then verify.`;let s=/removed on (\S+?)\.(?:\s|$)/.exec(t);return`The records the last replay created were removed${s?` on ${s[1]}`:""}. Replay the checkpoint again, then verify.`}case"LOAD_STOPPED":return"The last replay stopped part way \u2014 it was cancelled, or failed once it had written \u2014 and wrote no counting contract: a verification would judge it by the one before. Replay it again (--again), which purges or finds again what the stopped replay wrote, or take it back (--remove); then verify.";case"NO_LOAD":if(/dataset|\bsas\b/i.test(t))return`No replay of this checkpoint into ${n} is recorded on this machine: nothing names the records to verify. Replay it there, then verify.`;break;case"MAX_RECORDS":{let r=/insert (\d+) record\(s\), more than the (\d+)/.exec(t);if(r)return`This replay would create ${l(Number(r[1]))} record(s), more than the ${l(Number(r[2]))} it may: nothing was written. The checkpoint's records or ${n} changed since that count was taken: run its dry run again, and replay with the count it gives (--max-records).`;break}case"REPLACE_LEAVES_RECORDS":{let r=/would leave (\d+) of their records in the org — (.*?): loaded again/.exec(t);if(r)return`Taking back what the replays before created in ${n} would leave ${r[1]} of their records there \u2014 ${r[2]}: replayed again, the checkpoint's records would stand beside them. Nothing was written. Take the replay back first (--remove; --include-changed takes too what was changed since, and what was added under it since), then replay it again.`;break}case"GUARD_REFUSED":if(o.guard==="non-sandbox")return`A replay goes into a sandbox, a scratch org or a Developer Edition org, never into a production org nor a sandbox marked Staging, which hold real data: ${n} is ${o.tier==="staging"?"a sandbox marked Staging":"a production org"}. Nothing was read or written.`;break}return/dataset/i.test(t)?t.replace(/frozen-dataset load/gi,"replay").replace(/the frozen dataset/gi,"the checkpoint").replace(/the dataset/gi,"the checkpoint").replace(/datasets?/gi,"checkpoint"):t}async function bt(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=B(t.storeRoot,t.locksDir);o!==void 0&&await Ye(o,t.say);let r=e.file!==void 0?await qe(e,t):await Ke(e,t,n),s=n.folderOf(r.organizationId,r.checkpointId);await ee(n.root);let d={checkpoints:()=>[t.store,...[B(t.storeRoot,t.locksDir)].filter(f=>f!==void 0)],replays:n},i=t.storeNamed?t.storeRoot:void 0,a=L(r.checkpointId,e.target,i),u=r.name!==void 0?`checkpoint '${r.name}'`:`checkpoint ${r.checkpointId}`,m={request:{organizationId:r.organizationId,checkpointId:r.checkpointId,choices:e.choices,...e.config!==void 0?{config:e.config}:{}},stores:d,folder:s,auditStore:ge(n.root,ze),words:Le(u),refusalOf:Me,reword:(f,h,k)=>Ue(f,h,e.target,k),lines:(f,h)=>Qe(f,h,{asked:e,chosen:r,again:a}),question:f=>`Replay ${u} into ${e.target}, creating ${l(Be(f))} record(s) there${e.again?" once what its replays before created there is purged":""}?`,dryRunEnd:f=>f.length>0?[]:[`To replay it: ${a}${et(e)}`],answer:(f,h)=>nt(f,h,{asked:e,chosen:r,again:a})};await he(We(e,t.json),m)}function Be(e){return e.perObject.reduce((t,n)=>t+n.toInsert,0)}function We(e,t){return{step:e.action==="verify"?"verify":e.action==="remove"?"remove":"load",target:e.target,pilot:!1,reload:e.again,dryRun:e.action==="dryRun",writeEncrypted:!1,muteAutomation:e.muteAutomation,acceptAutomation:e.acceptAutomation,...e.checkpointFirst!==void 0?{checkpointFirst:e.checkpointFirst}:{},includeChanged:e.includeChanged,acceptEmails:e.acceptEmails,sweep:e.sweep,sweepList:e.sweepList,...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},preview:e.preview,...e.maxRecords!==void 0?{maxTotal:e.maxRecords}:{},yes:e.yes,json:t}}async function Ye(e,t){let n=await e.sweep().catch(()=>{});for(let o of n?.checkpoints??[])t(`deleted the checkpoint '${o.name}' (${o.checkpointId}) of a file received, kept until ${b(o.expiresAt)}: its replays stay, and still take back with --remove`)}async function Ke(e,t,n){let o=e.checkpoint??"",r=B(t.storeRoot,t.locksDir),s=new Set,d=[...await t.listAll(),...await r?.list()??[]].filter(h=>{let k=`${h.organizationId.slice(0,15)}/${h.checkpointId}`;return s.has(k)?!1:(s.add(k),!0)}),i=h=>({organizationId:h.organizationId,checkpointId:h.checkpointId,...h.checkpoint?{name:h.checkpoint.name}:{},of:Ge(h)}),a=e.from;if(me(o)){let h=d.filter(g=>g.checkpointId===o&&(a===void 0||!E.test(a)||ue(g.organizationId,a)));if(h.length===1)return i(h[0]);let k=(await n.list({checkpointId:o})).filter(g=>a===void 0||!E.test(a)||ue(g.sourceOrganizationId,a)),R=[...new Set(k.map(g=>g.sourceOrganizationId))];if(h.length===0&&R.length===1){let g=k[0];return{organizationId:g.sourceOrganizationId,checkpointId:o,...g.checkpointName!==void 0?{name:g.checkpointName}:{}}}if(h.length+R.length>1){let g=[...new Set([...h.map(I=>I.organizationId),...R])];throw new y({code:"AMBIGUOUS",message:`Checkpoints of ${g.length} orgs have the id ${o}: name the org it was taken of with --from (${g.join(", ")}). Nothing was run.`},2)}throw new y({code:"NOT_FOUND",message:`No checkpoint ${o} is kept on this machine, nor a replay of it. `+He(t.storeNamed)})}let u=a??"",m=t.checkpointsOf(d,u,E.test(u)?u:void 0),f=t.resolve(d,m,o,u);if("entry"in f)return i(f.entry);throw"ambiguous"in f?new y({code:"AMBIGUOUS",message:f.ambiguous},2):new y({code:"NOT_FOUND",message:f.none})}function ue(e,t){return e.slice(0,15)===t.slice(0,15)}function He(e){return`"${v("checkpoint")} list" names the checkpoints kept, and "${v("checkpoint")} replays" the replays.${e?"":" One kept in another folder is read with --store <folder>."} A file a teammate sent replays with --file <.sfcheckpoint>.`}function Ge(e){let t=e.checkpoint?.org;if(t===void 0)return;let n=t.alias??t.username;return e.why==="refreshed"?`${n} before its refresh${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}`:e.why==="scratchExpired"?`${n}, a scratch org expired since`:n}async function qe(e,t){let n=e.file??"",o=await ae(n);if("refusal"in o)throw new y(o.refusal);let{header:r}=o.read;t.say(`the file holds checkpoint ${r.checkpointId} of org ${r.organizationId}, taken ${b(r.takenAt)}: ${l(r.records)} record(s) of ${l(r.objects)} object(s), exported by SandForge ${r.sandforgeVersion}`);let s={organizationId:r.organizationId,checkpointId:r.checkpointId,file:{path:n,header:r}};if(e.action==="remove")return s;if(e.action!=="verify"){let u=Ze(r,e);if(u!==void 0)throw new y(u)}let d=e.keyEnv!==void 0?Ve(e.keyEnv):await Je(),i=await se({storeRoot:t.storeRoot,...t.locksDir!==void 0?{locksDir:t.locksDir}:{},file:n,key:d,keepDays:e.keepDays,takenOn:{host:be(),pid:process.pid}});if(!i.imported)throw new y(i.refusal);let{checkpoint:a}=i;return t.say(i.outcome==="imported"?`kept checkpoint '${a.name}' of the file on this machine, apart from those it rewinds, to replay it: ${D(t.storeRoot)}, `+(a.expiresAt===null?"until it is deleted":`until ${b(a.expiresAt)} (--keep-days)`):`checkpoint '${a.name}' of the file is kept on this machine already, the same`),{...s,name:a.name,of:a.org.alias??a.org.username}}function Ze(e,t){if(t.choices.mask)return;let n=le({tier:e.orgTier,...e.dataStorageMaxMB!==void 0?{dataStorageMaxMB:e.dataStorageMaxMB}:{},...e.staging?{staging:!0}:{}}),o=`The file holds checkpoint ${e.checkpointId}`;if(n.kind==="real")return{code:"REPLAY_REAL_DATA",message:`${o} of ${n.why==="staging"?"a sandbox marked Staging":`a Partial Copy or Full sandbox, by its data storage (${l(n.dataStorageMaxMB??0)} MB)`}, which may hold real data: it goes into another org masked only. To replay it into ${t.target}, ${z.mask}. Its key was not read, and nothing was kept, read or written.`};if(n.kind==="unknown"&&t.choices.noRealData!==!0)return{code:"REPLAY_COPY_UNKNOWN",message:`${o} of a sandbox, and does not say which: made before SandForge 1.81, it keeps no data storage, and a Partial Copy or a Full sandbox holds production\u2019s records. To replay it into ${t.target}, ${z.mask}, or ${z.noRealData}. Its key was not read, and nothing was kept, read or written.`}}function Ve(e){let t=process.env[e];if(t===void 0||t.trim()==="")throw new y({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let n=F(t);if(n===void 0)throw new y({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return n}async function Je(){let e=await ne("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new y({code:"DECLINED",message:"No key was typed. Nothing was run."});let t=F(e);if(t===void 0)throw new y({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was run."});return t}function Xe(e){let t=e.payload?.replay;return typeof t=="object"&&t!==null?t:void 0}function Qe(e,t,n){let o=Xe(e);if(o===void 0)return t;let{again:r}=n,s=o.target.name,d=o.filesLeft.length>0?` ${l(o.filesLeft.length)} file(s) are not replayed: a checkpoint keeps no file's content.`:"";if(e.type==="frozen:load:preview:response"){let i=n.chosen.of??o.checkpoint.alias??o.checkpoint.organizationId;return[`A replay of checkpoint '${o.checkpoint.name}' (of ${i}, taken ${b(o.checkpoint.takenAt)}) into ${s} would create copies of ${l(o.summary.records.toCreate)} of its records there, parents first, with new Ids; nothing ${s} holds is changed or deleted.${d}`,...t,...xe(o)]}return e.type==="frozen:load:response"?[...t,`To take it back: ${r} --remove`]:t}function et(e){let{choices:t}=e,n=e.checkpointFirst;return[t.objects.length>0?` --objects ${t.objects.join(",")}`:"",...t.excluded.map(o=>` --exclude-object ${o}`),t.owners!=="same"?` --owners ${t.owners}`:"",e.ownerMapFile!==void 0?` --owner-map ${A(e.ownerMapFile)}`:"",...t.link.map(o=>` --link ${o.objectApiName}=${o.fields.join(",")}`),t.customSettings?" --custom-settings":"",t.mask?" --mask":"",t.contactPoints==="kept"?" --keep-contact-points":"",t.noRealData?" --no-real-data":"",e.configFile!==void 0?` --replay-config ${A(e.configFile)}`:"",e.again?" --again":"",e.muteAutomation?" --mute-automation":"",e.acceptAutomation?" --accept-automation":"",e.acceptEmails?" --accept-emails":"",n!==void 0?" --checkpoint-first":"",n?.keepDays!==void 0?` --checkpoint-keep-days ${n.keepDays}`:"",...(n?.excluded??[]).map(o=>` --checkpoint-exclude-object ${o}`),e.maxRecords!==void 0?` --max-records ${e.maxRecords}`:""].join("")}function U(e,t){return e.filter(n=>n.type===t).at(-1)?.payload}var tt=new Set(["tool","step","posted","dataset","checkpoint"]);function nt(e,t,n){let{asked:o,chosen:r,again:s}=n,d=U(e.posted,"frozen:load:preview:response"),i=U(e.posted,"frozen:load:response"),a=i?.replay??d?.replay,u=d?.plan,m=i?.report,f=U(e.posted,"frozen:remove:response")?.result,h=Object.fromEntries(Object.entries(e).filter(([g])=>!tt.has(g))),k=e.checkpoint,R=a?.target.organizationId??t.targetOrgId;return{command:"replay",action:o.action,dryRun:o.action==="dryRun",checkpoint:a?{id:a.checkpoint.checkpointId,name:a.checkpoint.name,organizationId:a.checkpoint.organizationId,takenAt:a.checkpoint.takenAt,tier:a.checkpoint.tier,annex:a.checkpoint.annex}:{id:r.checkpointId,...r.name!==void 0?{name:r.name}:{},organizationId:r.organizationId},target:{alias:o.target,...R!==void 0?{organizationId:Q(R)}:{}},...o.action==="replay"||o.action==="dryRun"?{choices:a?.choices??o.choices}:{},...r.file?{file:r.file.path}:{},...u?{plan:u}:{},...a?{replay:{...a.summary,filesLeft:a.filesLeft,...a.storage?{storage:a.storage}:{},requests:a.requests}}:{},...m?{result:m}:{},...f!==void 0?{removal:f}:{},...h,...k?{checkpointFirst:k}:{},removeWith:`${s} --remove`,...t.refused?{refused:t.refused}:{},...t.ended?{ended:t.ended}:{},exit:t.exit}}function ot(e,t){return{checkpointId:e.checkpointId,...e.checkpointName!==void 0?{checkpointName:e.checkpointName}:{},sourceOrganizationId:e.sourceOrganizationId,...e.takenAt!==void 0?{takenAt:e.takenAt}:{},target:e.target,...e.choices!==void 0?{choices:e.choices}:{},...e.replayedAt!==void 0?{replayedAt:e.replayedAt}:{},inPlace:e.inPlace,inPlaceByObject:e.inPlaceByObject,...e.removed?{removed:!0}:{},removeWith:`${L(e.checkpointId,e.target.name??"<alias>",t)} --remove`}}function rt(e,t,n,o){return e.length===0?[`No replay${n!==void 0?` into ${n}`:""} is kept in ${t}.`]:e.flatMap(r=>{let s=r.target.name??r.target.organizationId,d=r.inPlaceByObject.map(i=>`${i.objectApiName} ${l(i.records)}`).join(", ");return[`${r.checkpointId} ${r.checkpointName!==void 0?`'${r.checkpointName}' `:""}of ${r.sourceOrganizationId}${r.takenAt!==void 0?`, taken ${b(r.takenAt)}`:""} into ${s} (${r.target.organizationId})`+(r.replayedAt!==void 0?` replayed ${b(r.replayedAt)}`:""),r.inPlace>0?` ${l(r.inPlace)} record(s) in place: ${d}`:r.removed?" removed: none of its records is left there":" none of its records is left there",...r.inPlace>0?[` to take it back: ${L(r.checkpointId,r.target.name??"<alias>",o)} --remove`]:[]]})}async function At(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=await n.list(e!==void 0&&E.test(e)?{targetOrganizationId:e}:{}),r=e!==void 0&&!E.test(e)?o.filter(d=>d.target.name===e):o,s=t.storeNamed?t.storeRoot:void 0;for(let d of rt(r,n.root,e,s))t.say(d);t.answerJson(r.map(d=>ot(d,s)))}async function Et(e,t){let n;try{n=new x({root:W(t.storeRoot,t.storeNamed)})}catch{return{lines:[],entries:[]}}let o=t.storeNamed?t.storeRoot:void 0,r=[],s=[];for(let d of e){let i=await n.replaysOf(d.organizationId,d.checkpointId).catch(()=>[]),a=pe(i);if(a!==void 0){r.push(` ${a}`);for(let u of de(i))r.push(` to take it back: ${L(u.checkpointId,u.target.name??"<alias>",o)} --remove`),s.push(u)}}return{lines:r,entries:s}}export{Rt as a,$t as b,W as c,y as d,vt as e,L as f,je as g,bt as h,ot as i,At as j,Et as k};
7
+ import{y as he}from"./chunk-A2TXLAC3.mjs";import{i as ce,j as x,k as de,l as pe}from"./chunk-NCCHOV2N.mjs";import{l as le,n as z}from"./chunk-LHNAR6FC.mjs";import{e as F,i as ae,k as D,l as se}from"./chunk-UM2B4GR7.mjs";import{Ab as re,Bb as ie,d as j,f as oe}from"./chunk-E5FSPXYH.mjs";import{cb as X}from"./chunk-CJAWKLAL.mjs";import{d as J}from"./chunk-DDNCJVZ2.mjs";import{L as ne,e as Q,k as ee,z as te}from"./chunk-4CSBZZAL.mjs";import{a as v,c as A}from"./chunk-AL4C3GFT.mjs";import{Cc as C}from"./chunk-OLCS7JCT.mjs";import{Ua as Z,fb as V}from"./chunk-J347SPU6.mjs";import{existsSync as $e,readFileSync as ve}from"node:fs";import{hostname as be}from"node:os";import{join as ge,resolve as T}from"node:path";var Ae=["--custom-settings","--mask","--keep-contact-points","--no-real-data"],Ee=["--objects","--exclude-object","--owners","--owner-map","--link","--replay-config"],Ie=["--again","--accept-emails","--max-records",...j.switches,...j.values],Oe=["--preview","--sweep","--sweep-list",...re,"--include-changed"],Ne=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,E=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,me=e=>Z.safeParse(e).success,Se={ownerMap:"--owner-map",objects:"--objects",excluded:"--exclude-object",link:"--link"};function Rt(e,t){let n=c=>e.includes(c),o=c=>{let p=[];for(let w=1;w<e.length;w++){if(e[w]!==c)continue;let $=e[w+1];if($===void 0||$.startsWith("--"))return t(`${c} wants a value.`);p.push($),w++}return p},r=c=>{let p=o(c);return p.length>1&&t(`${c} is given ${p.length} times: give it once.`),p[0]},s=c=>{let p=r(c);if(p!==void 0)return/^\d{1,15}$/.test(p)||t(`${c} takes a whole number, not "${p}".`),Number(p)},d=["--dry-run","--verify","--remove"].filter(n);d.length>1&&t(`Give one of --dry-run, --verify and --remove, not ${d.join(" and ")}. Nothing was run.`);let i=n("--dry-run")?"dryRun":n("--verify")?"verify":n("--remove")?"remove":"replay",a=c=>c.filter(n);if(i==="verify"||i==="remove"){let c=a([...Ae,...Ee]);c.length>0&&t(`${c.join(", ")} ${c.length===1?"is a choice":"are choices"} of a replay and its dry run: --verify reads the choices its last replay was made with, and --remove takes back what it wrote. Nothing was run.`);let p=a(Ie);p.length>0&&t(`${p.join(", ")} goes with a replay or its dry run, not with --${i}. Nothing was run.`)}if(i!=="remove"){let c=a(Oe);c.length>0&&t(`${c.join(", ")} goes with --remove. Nothing was run.`)}n("--sweep")&&n("--sweep-list")&&t("--sweep deletes and --sweep-list only lists: give one of them. Nothing was run."),n("--preview")&&n("--sweep-list")&&t("--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Nothing was run.");let u=ie(e);if("refusal"in u&&t(`${u.refusal} Nothing was run.`),i==="verify"){let c=a(["--mute-automation","--accept-automation"]);c.length>0&&t(`${c.join(", ")} goes with a replay or its removal: a verification only reads. Nothing was run.`)}let m=r("--checkpoint"),f=r("--file");if(m===void 0&&f===void 0)return t("replay needs --checkpoint <id|name> (list names them) or --file <.sfcheckpoint>. Run with --help.");m!==void 0&&f!==void 0&&t("Give --checkpoint or --file, not both. Nothing was run.");let h=r("--from");if(h!==void 0&&m===void 0&&t("--from goes with --checkpoint <name>: it names the org the checkpoint was taken of."),m!==void 0&&!me(m)&&h===void 0&&t(`--checkpoint '${m}' is not a checkpoint's id: a name names one of an org's checkpoints, so give --from <alias|username|00D\u2026>, the org it was taken of, or its id ("${v("checkpoint")} list" names them). Nothing was run.`),f===void 0){let c=a(["--key-env","--keep-days"]);c.length>0&&t(`${c.join(" and ")} goes with --file. Nothing was run.`)}let k=r("--target")??t("replay needs --target <alias>, the org the checkpoint's records go into. Run with --help."),R=o("--objects").flatMap(c=>c.split(",").map(p=>p.trim()).filter(p=>p!=="")),g=o("--exclude-object");for(let[c,p]of[["--objects",R],["--exclude-object",g]]){let w=p.find($=>!Ne.test($));w!==void 0&&t(`${c} takes objects' API names, not "${w}".`)}let I=c=>c.filter((p,w)=>c.findIndex($=>$.toLowerCase()===p.toLowerCase())===w),O=r("--owners")??"same";O!=="same"&&O!=="me"&&t(`--owners takes same or me, not "${O}".`);let we=o("--link").map(c=>{let p=/^([A-Za-z][A-Za-z0-9_]*)=([A-Za-z0-9_,]+)$/.exec(c);return p?{objectApiName:p[1],fields:p[2].split(",").filter(w=>w!=="")}:t(`--link takes Object=Field or Object=Field,Field \u2014 the fields a record of the other org is found by \u2014, not "${c}".`)}),N=r("--owner-map"),Y=N!==void 0?ye("--owner-map",N,t):void 0,Re={owners:O,...Y!==void 0?{ownerMap:Y}:{},customSettings:n("--custom-settings"),mask:n("--mask"),contactPoints:n("--keep-contact-points")?"kept":"neutralized",objects:I(R),excluded:I(g),link:we,...n("--no-real-data")?{noRealData:!0}:{}},_=V.safeParse(Re);if(!_.success){let c=_.error.issues[0],p=String(c?.path[0]??"");return t(`${Se[p]??p}: ${c?.message??"not read"}. Nothing was run.`)}let K=_.data,S=r("--replay-config"),H=S!==void 0?Ce(S,K,t):void 0,P=s("--max-records");P===0&&t('--max-records takes a whole number of 1 or more, not "0". Nothing was run.');let G=Fe(r("--key-env"),t),q=oe(e);return{action:i,...m!==void 0?{checkpoint:m}:{},...h!==void 0?{from:h}:{},...f!==void 0?{file:T(f)}:{},...G!==void 0?{keyEnv:G}:{},keepDays:s("--keep-days")??Q,target:k,choices:K,...N!==void 0?{ownerMapFile:T(N)}:{},...H!==void 0?{config:H}:{},...S!==void 0?{configFile:T(S)}:{},again:n("--again"),muteAutomation:n("--mute-automation"),acceptAutomation:n("--accept-automation"),acceptEmails:n("--accept-emails"),...q!==void 0?{checkpointFirst:q}:{},...P!==void 0?{maxRecords:P}:{},preview:n("--preview"),sweep:n("--sweep"),sweepList:n("--sweep-list"),...u,includeChanged:n("--include-changed"),yes:n("--yes")}}function $t(e,t){let n=e.flatMap((r,s)=>r==="--target"?[e[s+1]]:[]);n.length>1&&t(`--target is given ${n.length} times: give it once.`);let o=n[0];return o!==void 0?{target:o}:{}}function ye(e,t,n){try{return JSON.parse(ve(t,"utf8"))}catch(o){return n(`${e}: ${t} does not read as JSON (${o instanceof Error?o.message:String(o)}). Nothing was run.`)}}function Ce(e,t,n){let o=ye("--replay-config",e,n),r=X.safeParse({targetOrgId:"command-line",replay:{organizationId:"00D000000000000AAA",checkpointId:"ck-20000101-000000-0000",choices:t,config:o}});if(!r.success){let s=r.error.issues[0],d=(s?.path??[]).slice(2).join(".");return n(`--replay-config: ${d!==""?`${d}: `:""}${s?.message??"not read"}. It takes the load\u2019s part of a Frozen project\u2019s configuration: requiredFieldDefaults, requiredLookupPlaceholders, picklistRules, defaultPicklistRule, identityKeys, undeletableObjects, duplicateErrorPatterns, mockDetection, protectedOrgIds. Nothing was run.`)}return o}function Fe(e,t){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||F(e)!==void 0?t("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}var ze="cli-store.json";function W(e,t){return t?ge(e,".replays"):ce()}var y=class extends Error{constructor(n,o=1){super(n.message);this.refusal=n;this.code=o;this.name="ReplayStop"}refusal;code};function ke(e){try{return new x({root:e})}catch(t){throw new y({code:"STORE_REFUSED",message:`The replays cannot be kept in ${e}: ${t instanceof Error?t.message:String(t)} Name a store outside any repository with --store <folder>. Nothing was read or written.`})}}function B(e,t){let n=D(e);if(!$e(n))return;let o=ne({root:n,...t!==void 0?{locksDir:t}:{}});return"store"in o?o.store:void 0}function vt(e,t){return`${v("checkpoint")} replay --file ${A(e)} --target ${t}`}function L(e,t,n){return`${v("checkpoint")} replay --checkpoint ${e} --target ${t}`+(n!==void 0?` --store ${A(n)}`:"")}var l=e=>e.toLocaleString("en-US");function b(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function M(e,t=8){return e.length<=t?e.join(", "):`${e.slice(0,t).join(", ")} and ${l(e.length-t)} more`}function Le(e){return{run:"replay",done:"replayed",source:e,recordedIn:"for this checkpoint on this machine",remove:"--remove",module:"replay",again:"again",againSubject:{purge:"replayAgain",sweep:"replayAgainSweep"},maybeMasks:"the checkpoint does not say whether its take read them unmasked, so they may hold the masks a user without View Encrypted Data reads, such as ****1234"}}var _e={fileContentNotKept:()=>"a checkpoint keeps no file's content",notInTarget:(e,t)=>`${t} has no such object: deploy it there, or leave it out (--exclude-object ${e})`,notCreateable:(e,t)=>`${t} lets no one create its records`,excluded:()=>"left out as asked"},Pe={objectNotReplayed:e=>`the checkpoint holds the records it names and does not replay them: add ${e.split(".")[0]}'s target with --objects`,objectNotHeld:(e,t)=>`the checkpoint does not hold what it names, and ${t} has no record of that Id`,userNotInTarget:(e,t)=>`${t} has no active standard user for it`},fe={requiredLookupMissing:"a required lookup names a record neither replayed nor in the other org",parentRefused:"a parent of theirs is refused, and no orphan is written",personAccountsUnsupported:"the other org has not turned person accounts on",inactiveCurrency:"their currency is not active in the other org",recordTypeUnavailable:"their record type is one the user who replays may not create"};function je(e){return`${Object.hasOwn(fe,e.reason)?fe[e.reason]:e.reason}${e.path?`: ${e.path}`:""}`}var De={byName:"found by its name",byId:"found by its Id",default:"the other org's default for the user who replays"};function xe(e){let{summary:t}=e,n=e.target.name,o=[],{records:r}=t;r.linkedById>0&&o.push(`${l(r.linkedById)} record(s) ${n} holds under the same Id \u2014 a sandbox copied from the same production \u2014: linked, not changed`),r.linkedByKey>0&&o.push(`${l(r.linkedByKey)} record(s) found in ${n} by the fields --link names: linked, not created`);let s=t.owners,d=[s.reasons.notInTarget>0?`their user is not in ${n}: ${l(s.reasons.notInTarget)}`:"",s.reasons.inactive>0?`their user is inactive in ${n}: ${l(s.reasons.inactive)}`:"",s.reasons.queueMissing>0?`their queue is not in ${n}: ${l(s.reasons.queueMissing)}`:""].filter(Boolean);o.push(`owners: ${l(s.kept)} kept, ${l(s.toRunningUser)} to the user who replays`+(d.length>0?` \u2014 ${d.join("; ")}`:""));for(let i of t.recordTypes)o.push(`record type ${i.object}.${i.recordType}: ${De[i.outcome]} \u2014 ${l(i.records)} record(s)`);for(let i of t.refused)o.push(`refused before anything is written: ${i.object} ${l(i.records)} \u2014 `+je(i));for(let i of t.notReplayed)o.push(`not replayed: ${i.object} ${l(i.records)} \u2014 `+_e[i.reason](i.object,n));e.filesLeft.length>0&&o.push(`${l(e.filesLeft.length)} file(s) left where they were, a checkpoint keeping no file's content:`,...e.filesLeft.map(i=>` ${i.objectApiName}${i.name!==void 0?` '${i.name}'`:""}`));for(let i of t.lookupsEmptied)o.push(`${i.field}: emptied on ${l(i.records)} record(s) \u2014 `+Pe[i.reason](i.field,n));for(let i of t.fieldsNotInTarget)o.push(`${i.object}: ${M(i.fields)} left out \u2014 ${n} does not have them`);t.customSettings&&o.push(`custom settings: ${l(t.customSettings.inserted)} row(s) set up, ${l(t.customSettings.alreadyThere)} already in ${n}, kept as they are`);for(let i of t.currencies.refused)o.push(`${i.code}: ${l(i.records)} record(s) refused \u2014 the currency is not active in ${n}: activate it there, or leave those records out`);if(t.currencies.singleCurrencyTarget&&o.push(`${n} has one currency: amounts are kept as they are, in its currency`),t.standardPricebook==="deduced"?o.push("standard price book: told from the price book entries, the checkpoint naming none"):t.standardPricebook==="ambiguous"&&o.push("standard price book: the price book entries do not tell which it was, and those that need it are refused"),t.masked.fields.length>0&&o.push(`masked: ${M(t.masked.fields)}`),(t.masked.unmaskedFreeText??[]).length>0&&o.push(`not masked, free text the masking does not read: ${M(t.masked.unmaskedFreeText??[])}`),o.push(t.contactPoints==="neutralized"?"emails and phone numbers made unreachable (.invalid, numbers that ring nobody); --keep-contact-points keeps them":"emails and phone numbers kept as they are: they reach the people they name"),(t.archivedActivities??0)>0&&o.push(`${l(t.archivedActivities??0)} archived task(s) and event(s) replayed, which ${n} holds live`),t.degraded.length>0&&o.push((e.checkpoint.annex?`its take could not read ${t.degraded.join(", ")}`:"taken before SandForge 1.81, it keeps no record types, users, queues nor standard price book")+`: the records they name get what ${n} gives them, each said above`),o.push("created and modified dates and users are the replay's own: the platform sets them"),e.storage){let{storage:i}=e;o.push(`data storage: about ${C(i.estimateMB)} MB of the ${C(i.remainingMB)} MB ${n} has left of ${C(i.maxMB)} MB`)}return o}var Te=new Set(["REPLAY_SAME_ORG","REPLAY_REAL_DATA","REPLAY_COPY_UNKNOWN","REPLAY_TOO_MANY","REPLAY_NOTHING","REPLAY_CHECKPOINT_UNUSABLE","REPLAY_NO_PILOT","CHECKPOINT_NOT_FOUND","OWNER_MAP_INACTIVE","OWNER_MAP_UNKNOWN","GUARD_REFUSED","NO_LOAD","TARGET_REFRESHED","LOAD_REMOVED","LOAD_STOPPED"]);function Me(e){let t=String(e.type??""),n=e.payload?.code;if(!(!t.endsWith(":error")||typeof n!="string")&&Te.has(n))return{code:n,message:String(e.payload?.message??"")}}function Ue(e,t,n,o={}){switch(e){case"TARGET_REFRESHED":if(/dataset/i.test(t))return`${n} was refreshed after the last replay: the records it created went with the refresh. Replay the checkpoint again, then verify.`;break;case"LOAD_REMOVED":{let r=/removal of (\S+) took part/.exec(t);if(r)return`The removal of ${r[1]} took part of the records the last replay created and left ${l(Number(o.left??0))} in ${n}: a verification would read the ones it took as missing. Remove what is left (--remove), or replay again (--again), which purges or finds it again; then verify.`;let s=/removed on (\S+?)\.(?:\s|$)/.exec(t);return`The records the last replay created were removed${s?` on ${s[1]}`:""}. Replay the checkpoint again, then verify.`}case"LOAD_STOPPED":return"The last replay stopped part way \u2014 it was cancelled, or failed once it had written \u2014 and wrote no counting contract: a verification would judge it by the one before. Replay it again (--again), which purges or finds again what the stopped replay wrote, or take it back (--remove); then verify.";case"NO_LOAD":if(/dataset|\bsas\b/i.test(t))return`No replay of this checkpoint into ${n} is recorded on this machine: nothing names the records to verify. Replay it there, then verify.`;break;case"MAX_RECORDS":{let r=/insert (\d+) record\(s\), more than the (\d+)/.exec(t);if(r)return`This replay would create ${l(Number(r[1]))} record(s), more than the ${l(Number(r[2]))} it may: nothing was written. The checkpoint's records or ${n} changed since that count was taken: run its dry run again, and replay with the count it gives (--max-records).`;break}case"REPLACE_LEAVES_RECORDS":{let r=/would leave (\d+) of their records in the org — (.*?): loaded again/.exec(t);if(r)return`Taking back what the replays before created in ${n} would leave ${r[1]} of their records there \u2014 ${r[2]}: replayed again, the checkpoint's records would stand beside them. Nothing was written. Take the replay back first (--remove; --include-changed takes too what was changed since, and what was added under it since), then replay it again.`;break}case"GUARD_REFUSED":if(o.guard==="non-sandbox")return`A replay goes into a sandbox, a scratch org or a Developer Edition org, never into a production org nor a sandbox marked Staging, which hold real data: ${n} is ${o.tier==="staging"?"a sandbox marked Staging":"a production org"}. Nothing was read or written.`;break}return/dataset/i.test(t)?t.replace(/frozen-dataset load/gi,"replay").replace(/the frozen dataset/gi,"the checkpoint").replace(/the dataset/gi,"the checkpoint").replace(/datasets?/gi,"checkpoint"):t}async function bt(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=B(t.storeRoot,t.locksDir);o!==void 0&&await Ye(o,t.say);let r=e.file!==void 0?await qe(e,t):await Ke(e,t,n),s=n.folderOf(r.organizationId,r.checkpointId);await te(n.root);let d={checkpoints:()=>[t.store,...[B(t.storeRoot,t.locksDir)].filter(f=>f!==void 0)],replays:n},i=t.storeNamed?t.storeRoot:void 0,a=L(r.checkpointId,e.target,i),u=r.name!==void 0?`checkpoint '${r.name}'`:`checkpoint ${r.checkpointId}`,m={request:{organizationId:r.organizationId,checkpointId:r.checkpointId,choices:e.choices,...e.config!==void 0?{config:e.config}:{}},stores:d,folder:s,auditStore:ge(n.root,ze),words:Le(u),refusalOf:Me,reword:(f,h,k)=>Ue(f,h,e.target,k),lines:(f,h)=>Qe(f,h,{asked:e,chosen:r,again:a}),question:f=>`Replay ${u} into ${e.target}, creating ${l(Be(f))} record(s) there${e.again?" once what its replays before created there is purged":""}?`,dryRunEnd:f=>f.length>0?[]:[`To replay it: ${a}${et(e)}`],answer:(f,h)=>nt(f,h,{asked:e,chosen:r,again:a})};await he(We(e,t.json),m)}function Be(e){return e.perObject.reduce((t,n)=>t+n.toInsert,0)}function We(e,t){return{step:e.action==="verify"?"verify":e.action==="remove"?"remove":"load",target:e.target,pilot:!1,reload:e.again,dryRun:e.action==="dryRun",writeEncrypted:!1,muteAutomation:e.muteAutomation,acceptAutomation:e.acceptAutomation,...e.checkpointFirst!==void 0?{checkpointFirst:e.checkpointFirst}:{},includeChanged:e.includeChanged,acceptEmails:e.acceptEmails,sweep:e.sweep,sweepList:e.sweepList,...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},preview:e.preview,...e.maxRecords!==void 0?{maxTotal:e.maxRecords}:{},yes:e.yes,json:t}}async function Ye(e,t){let n=await e.sweep().catch(()=>{});for(let o of n?.checkpoints??[])t(`deleted the checkpoint '${o.name}' (${o.checkpointId}) of a file received, kept until ${b(o.expiresAt)}: its replays stay, and still take back with --remove`)}async function Ke(e,t,n){let o=e.checkpoint??"",r=B(t.storeRoot,t.locksDir),s=new Set,d=[...await t.listAll(),...await r?.list()??[]].filter(h=>{let k=`${h.organizationId.slice(0,15)}/${h.checkpointId}`;return s.has(k)?!1:(s.add(k),!0)}),i=h=>({organizationId:h.organizationId,checkpointId:h.checkpointId,...h.checkpoint?{name:h.checkpoint.name}:{},of:Ge(h)}),a=e.from;if(me(o)){let h=d.filter(g=>g.checkpointId===o&&(a===void 0||!E.test(a)||ue(g.organizationId,a)));if(h.length===1)return i(h[0]);let k=(await n.list({checkpointId:o})).filter(g=>a===void 0||!E.test(a)||ue(g.sourceOrganizationId,a)),R=[...new Set(k.map(g=>g.sourceOrganizationId))];if(h.length===0&&R.length===1){let g=k[0];return{organizationId:g.sourceOrganizationId,checkpointId:o,...g.checkpointName!==void 0?{name:g.checkpointName}:{}}}if(h.length+R.length>1){let g=[...new Set([...h.map(I=>I.organizationId),...R])];throw new y({code:"AMBIGUOUS",message:`Checkpoints of ${g.length} orgs have the id ${o}: name the org it was taken of with --from (${g.join(", ")}). Nothing was run.`},2)}throw new y({code:"NOT_FOUND",message:`No checkpoint ${o} is kept on this machine, nor a replay of it. `+He(t.storeNamed)})}let u=a??"",m=t.checkpointsOf(d,u,E.test(u)?u:void 0),f=t.resolve(d,m,o,u);if("entry"in f)return i(f.entry);throw"ambiguous"in f?new y({code:"AMBIGUOUS",message:f.ambiguous},2):new y({code:"NOT_FOUND",message:f.none})}function ue(e,t){return e.slice(0,15)===t.slice(0,15)}function He(e){return`"${v("checkpoint")} list" names the checkpoints kept, and "${v("checkpoint")} replays" the replays.${e?"":" One kept in another folder is read with --store <folder>."} A file a teammate sent replays with --file <.sfcheckpoint>.`}function Ge(e){let t=e.checkpoint?.org;if(t===void 0)return;let n=t.alias??t.username;return e.why==="refreshed"?`${n} before its refresh${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}`:e.why==="scratchExpired"?`${n}, a scratch org expired since`:n}async function qe(e,t){let n=e.file??"",o=await ae(n);if("refusal"in o)throw new y(o.refusal);let{header:r}=o.read;t.say(`the file holds checkpoint ${r.checkpointId} of org ${r.organizationId}, taken ${b(r.takenAt)}: ${l(r.records)} record(s) of ${l(r.objects)} object(s), exported by SandForge ${r.sandforgeVersion}`);let s={organizationId:r.organizationId,checkpointId:r.checkpointId,file:{path:n,header:r}};if(e.action==="remove")return s;if(e.action!=="verify"){let u=Ze(r,e);if(u!==void 0)throw new y(u)}let d=e.keyEnv!==void 0?Ve(e.keyEnv):await Je(),i=await se({storeRoot:t.storeRoot,...t.locksDir!==void 0?{locksDir:t.locksDir}:{},file:n,key:d,keepDays:e.keepDays,takenOn:{host:be(),pid:process.pid}});if(!i.imported)throw new y(i.refusal);let{checkpoint:a}=i;return t.say(i.outcome==="imported"?`kept checkpoint '${a.name}' of the file on this machine, apart from those it rewinds, to replay it: ${D(t.storeRoot)}, `+(a.expiresAt===null?"until it is deleted":`until ${b(a.expiresAt)} (--keep-days)`):`checkpoint '${a.name}' of the file is kept on this machine already, the same`),{...s,name:a.name,of:a.org.alias??a.org.username}}function Ze(e,t){if(t.choices.mask)return;let n=le({tier:e.orgTier,...e.dataStorageMaxMB!==void 0?{dataStorageMaxMB:e.dataStorageMaxMB}:{},...e.staging?{staging:!0}:{}}),o=`The file holds checkpoint ${e.checkpointId}`;if(n.kind==="real")return{code:"REPLAY_REAL_DATA",message:`${o} of ${n.why==="staging"?"a sandbox marked Staging":`a Partial Copy or Full sandbox, by its data storage (${l(n.dataStorageMaxMB??0)} MB)`}, which may hold real data: it goes into another org masked only. To replay it into ${t.target}, ${z.mask}. Its key was not read, and nothing was kept, read or written.`};if(n.kind==="unknown"&&t.choices.noRealData!==!0)return{code:"REPLAY_COPY_UNKNOWN",message:`${o} of a sandbox, and does not say which: made before SandForge 1.81, it keeps no data storage, and a Partial Copy or a Full sandbox holds production\u2019s records. To replay it into ${t.target}, ${z.mask}, or ${z.noRealData}. Its key was not read, and nothing was kept, read or written.`}}function Ve(e){let t=process.env[e];if(t===void 0||t.trim()==="")throw new y({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let n=F(t);if(n===void 0)throw new y({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return n}async function Je(){let e=await J("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new y({code:"DECLINED",message:"No key was typed. Nothing was run."});let t=F(e);if(t===void 0)throw new y({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was run."});return t}function Xe(e){let t=e.payload?.replay;return typeof t=="object"&&t!==null?t:void 0}function Qe(e,t,n){let o=Xe(e);if(o===void 0)return t;let{again:r}=n,s=o.target.name,d=o.filesLeft.length>0?` ${l(o.filesLeft.length)} file(s) are not replayed: a checkpoint keeps no file's content.`:"";if(e.type==="frozen:load:preview:response"){let i=n.chosen.of??o.checkpoint.alias??o.checkpoint.organizationId;return[`A replay of checkpoint '${o.checkpoint.name}' (of ${i}, taken ${b(o.checkpoint.takenAt)}) into ${s} would create copies of ${l(o.summary.records.toCreate)} of its records there, parents first, with new Ids; nothing ${s} holds is changed or deleted.${d}`,...t,...xe(o)]}return e.type==="frozen:load:response"?[...t,`To take it back: ${r} --remove`]:t}function et(e){let{choices:t}=e,n=e.checkpointFirst;return[t.objects.length>0?` --objects ${t.objects.join(",")}`:"",...t.excluded.map(o=>` --exclude-object ${o}`),t.owners!=="same"?` --owners ${t.owners}`:"",e.ownerMapFile!==void 0?` --owner-map ${A(e.ownerMapFile)}`:"",...t.link.map(o=>` --link ${o.objectApiName}=${o.fields.join(",")}`),t.customSettings?" --custom-settings":"",t.mask?" --mask":"",t.contactPoints==="kept"?" --keep-contact-points":"",t.noRealData?" --no-real-data":"",e.configFile!==void 0?` --replay-config ${A(e.configFile)}`:"",e.again?" --again":"",e.muteAutomation?" --mute-automation":"",e.acceptAutomation?" --accept-automation":"",e.acceptEmails?" --accept-emails":"",n!==void 0?" --checkpoint-first":"",n?.keepDays!==void 0?` --checkpoint-keep-days ${n.keepDays}`:"",...(n?.excluded??[]).map(o=>` --checkpoint-exclude-object ${o}`),e.maxRecords!==void 0?` --max-records ${e.maxRecords}`:""].join("")}function U(e,t){return e.filter(n=>n.type===t).at(-1)?.payload}var tt=new Set(["tool","step","posted","dataset","checkpoint"]);function nt(e,t,n){let{asked:o,chosen:r,again:s}=n,d=U(e.posted,"frozen:load:preview:response"),i=U(e.posted,"frozen:load:response"),a=i?.replay??d?.replay,u=d?.plan,m=i?.report,f=U(e.posted,"frozen:remove:response")?.result,h=Object.fromEntries(Object.entries(e).filter(([g])=>!tt.has(g))),k=e.checkpoint,R=a?.target.organizationId??t.targetOrgId;return{command:"replay",action:o.action,dryRun:o.action==="dryRun",checkpoint:a?{id:a.checkpoint.checkpointId,name:a.checkpoint.name,organizationId:a.checkpoint.organizationId,takenAt:a.checkpoint.takenAt,tier:a.checkpoint.tier,annex:a.checkpoint.annex}:{id:r.checkpointId,...r.name!==void 0?{name:r.name}:{},organizationId:r.organizationId},target:{alias:o.target,...R!==void 0?{organizationId:ee(R)}:{}},...o.action==="replay"||o.action==="dryRun"?{choices:a?.choices??o.choices}:{},...r.file?{file:r.file.path}:{},...u?{plan:u}:{},...a?{replay:{...a.summary,filesLeft:a.filesLeft,...a.storage?{storage:a.storage}:{},requests:a.requests}}:{},...m?{result:m}:{},...f!==void 0?{removal:f}:{},...h,...k?{checkpointFirst:k}:{},removeWith:`${s} --remove`,...t.refused?{refused:t.refused}:{},...t.ended?{ended:t.ended}:{},exit:t.exit}}function ot(e,t){return{checkpointId:e.checkpointId,...e.checkpointName!==void 0?{checkpointName:e.checkpointName}:{},sourceOrganizationId:e.sourceOrganizationId,...e.takenAt!==void 0?{takenAt:e.takenAt}:{},target:e.target,...e.choices!==void 0?{choices:e.choices}:{},...e.replayedAt!==void 0?{replayedAt:e.replayedAt}:{},inPlace:e.inPlace,inPlaceByObject:e.inPlaceByObject,...e.removed?{removed:!0}:{},removeWith:`${L(e.checkpointId,e.target.name??"<alias>",t)} --remove`}}function rt(e,t,n,o){return e.length===0?[`No replay${n!==void 0?` into ${n}`:""} is kept in ${t}.`]:e.flatMap(r=>{let s=r.target.name??r.target.organizationId,d=r.inPlaceByObject.map(i=>`${i.objectApiName} ${l(i.records)}`).join(", ");return[`${r.checkpointId} ${r.checkpointName!==void 0?`'${r.checkpointName}' `:""}of ${r.sourceOrganizationId}${r.takenAt!==void 0?`, taken ${b(r.takenAt)}`:""} into ${s} (${r.target.organizationId})`+(r.replayedAt!==void 0?` replayed ${b(r.replayedAt)}`:""),r.inPlace>0?` ${l(r.inPlace)} record(s) in place: ${d}`:r.removed?" removed: none of its records is left there":" none of its records is left there",...r.inPlace>0?[` to take it back: ${L(r.checkpointId,r.target.name??"<alias>",o)} --remove`]:[]]})}async function At(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=await n.list(e!==void 0&&E.test(e)?{targetOrganizationId:e}:{}),r=e!==void 0&&!E.test(e)?o.filter(d=>d.target.name===e):o,s=t.storeNamed?t.storeRoot:void 0;for(let d of rt(r,n.root,e,s))t.say(d);t.answerJson(r.map(d=>ot(d,s)))}async function Et(e,t){let n;try{n=new x({root:W(t.storeRoot,t.storeNamed)})}catch{return{lines:[],entries:[]}}let o=t.storeNamed?t.storeRoot:void 0,r=[],s=[];for(let d of e){let i=await n.replaysOf(d.organizationId,d.checkpointId).catch(()=>[]),a=pe(i);if(a!==void 0){r.push(` ${a}`);for(let u of de(i))r.push(` to take it back: ${L(u.checkpointId,u.target.name??"<alias>",o)} --remove`),s.push(u)}}return{lines:r,entries:s}}export{Rt as a,$t as b,W as c,y as d,vt as e,L as f,je as g,bt as h,ot as i,At as j,Et as k};
@@ -0,0 +1,7 @@
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,b,c,d}from"./chunk-L6G73FXM.mjs";import"./chunk-WVVFR4E3.mjs";import"./chunk-H33DVU3D.mjs";import"./chunk-4CSBZZAL.mjs";import"./chunk-ZVU7MD2S.mjs";import"./chunk-OLCS7JCT.mjs";import"./chunk-TQ6HEJ73.mjs";import"./chunk-65AMXOQU.mjs";import"./chunk-6HHSAPIM.mjs";import"./chunk-K5PUMHZU.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-EUIALBMX.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ATBQIE2V.mjs";import"./chunk-UCUFLFNK.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-DAUX63UB.mjs";import"./chunk-SZOJ7BEJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as auditRequestsOf,a as auditsAskedOf,c as findingsOf,d as readAudits};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{b as N,e as k}from"./chunk-BBRWFKS5.mjs";import{l as y}from"./chunk-FQGHL7GR.mjs";var S=class{deps;constructor(t){this.deps=t}async mapFields(t,n,r,i=0,a){let{recordCount:s,fieldRules:f,rows:d}=t;if(s<=0||f.length===0&&!d)return[];let u=f.filter(o=>o.ruleType==="ai_generate"),g=f.filter(o=>o.ruleType==="faker"),R=N(),O=f.filter(o=>o.ruleType!=="ai_generate"&&o.ruleType!=="faker").map(o=>G(o,R)),p=u.length>0?await this.deps.aiGenerator.generate(u,s):[],b=g.length>0?this.deps.fakerFallback.generate(g,s,i):[],m=I(u,p,s),V=m?this.deps.fakerFallback.generate(u.map(q),s,i):[];m&&r?.({fields:C(u,p,s),reason:p.length===0?"no-answer":"short-answer"});let D=[...u,...g],x=this.deps.random??Math.random,_=E(t),F=d?P(f,R,a):void 0,w=[];for(let o=0;o<s;o++){let l={};for(let c of O)l[c.fieldApiName]=L(c,i+o,n,x);p[o]&&Object.assign(l,p[o]);for(let c of m?u:[])(l[c.fieldApiName]===void 0||l[c.fieldApiName]===null)&&(l[c.fieldApiName]=V[o]?.[c.fieldApiName]??null);b[o]&&Object.assign(l,b[o]);for(let c of D)l[c.fieldApiName]=M(l[c.fieldApiName],c.config.maxLength);_&&typeof l[h]=="string"&&(l[T]=this.deps.fakerFallback.dateOf(j.test(l[h])?"pastDate":"futureDate"));let A=d?.[i+o];A&&F&&Object.assign(l,F(A)),w.push(l)}return w}};function P(e,t,n){let r=new Set(e.filter(a=>a.fieldType?.toLowerCase()==="phone").map(a=>a.fieldApiName)),i=new Map(e.flatMap(a=>a.config.maxLength!==void 0?[[a.fieldApiName,a.config.maxLength]]:[]));return a=>{let s=k(a.values,r,t);for(let[f,d]of Object.entries(s))s[f]=M(d,n?.get(f)??i.get(f));return s}}var h="StageName",T="CloseDate",j=/closed/i;function E(e){return e.objectApiName!=="Opportunity"?!1:e.fieldRules.find(n=>n.fieldApiName===T)?.ruleType==="faker"&&e.fieldRules.some(n=>n.fieldApiName===h)}function G(e,t){let n=e.config.picklistValues;if(e.ruleType!=="picklist_random"||!n)return e;let r=new Set(e.fieldType?.toLowerCase()==="phone"?[e.fieldApiName]:[]),i=n.map(a=>{let s=k({[e.fieldApiName]:a},r,t)[e.fieldApiName];return typeof s=="string"?s:a});return{...e,config:{...e.config,picklistValues:i}}}function M(e,t){if(typeof e!="string"||t===void 0||t<=0||e.length<=t)return e;let n=e.slice(0,t);if(/\s/.test(e.charAt(t)))return n.trimEnd();let r=n.search(/\s\S*$/);return r>0?n.slice(0,r).trimEnd():n}function C(e,t,n){return e.filter(r=>Array.from({length:n},(i,a)=>t[a]?.[r.fieldApiName]).some(i=>i==null)).map(r=>r.fieldApiName)}function I(e,t,n){return e.length===0?!1:t.length<n?!0:t.some(r=>e.some(i=>r[i.fieldApiName]===void 0||r[i.fieldApiName]===null))}function q(e){return{fieldApiName:e.fieldApiName,ruleType:"faker",config:{fakerMethod:"sentence"}}}function L(e,t,n,r=Math.random){switch(e.ruleType){case"static":return e.config.staticValue??null;case"random":return $(e,r);case"sequence":return U(e,t);case"picklist_random":return v(e,r);case"reference":return z(e,n,r);case"formula":return e.config.formula??null;case"regex":return Y(e,t);case"from_csv":return null;default:return null}}function $(e,t){let n=e.config.minValue??0,r=e.config.maxValue??1e3;return Math.floor(n+t()*(r-n+1))}function U(e,t){let n=e.config.sequenceStart??1,r=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${n+t*r}`}function Y(e,t){let n=e.config.regexPattern;return n?y(n,t):null}function v(e,t){let n=e.config.picklistValues;if(!n||n.length===0)return null;let r=Math.floor(t()*n.length);return n[r]}function z(e,t,n){let r=e.config.referenceObject;if(!r)return null;let i=t.get(r);if(!i||i.length===0)return null;let a=Math.floor(n()*i.length);return i[a]}export{S as a,L as b};
7
+ import{b as N,e as k}from"./chunk-HLROVOR6.mjs";import{l as y}from"./chunk-FQGHL7GR.mjs";var S=class{deps;constructor(t){this.deps=t}async mapFields(t,n,r,i=0,a){let{recordCount:s,fieldRules:f,rows:d}=t;if(s<=0||f.length===0&&!d)return[];let u=f.filter(o=>o.ruleType==="ai_generate"),g=f.filter(o=>o.ruleType==="faker"),R=N(),O=f.filter(o=>o.ruleType!=="ai_generate"&&o.ruleType!=="faker").map(o=>G(o,R)),p=u.length>0?await this.deps.aiGenerator.generate(u,s):[],b=g.length>0?this.deps.fakerFallback.generate(g,s,i):[],m=I(u,p,s),V=m?this.deps.fakerFallback.generate(u.map(q),s,i):[];m&&r?.({fields:C(u,p,s),reason:p.length===0?"no-answer":"short-answer"});let D=[...u,...g],x=this.deps.random??Math.random,_=E(t),F=d?P(f,R,a):void 0,w=[];for(let o=0;o<s;o++){let l={};for(let c of O)l[c.fieldApiName]=L(c,i+o,n,x);p[o]&&Object.assign(l,p[o]);for(let c of m?u:[])(l[c.fieldApiName]===void 0||l[c.fieldApiName]===null)&&(l[c.fieldApiName]=V[o]?.[c.fieldApiName]??null);b[o]&&Object.assign(l,b[o]);for(let c of D)l[c.fieldApiName]=M(l[c.fieldApiName],c.config.maxLength);_&&typeof l[h]=="string"&&(l[T]=this.deps.fakerFallback.dateOf(j.test(l[h])?"pastDate":"futureDate"));let A=d?.[i+o];A&&F&&Object.assign(l,F(A)),w.push(l)}return w}};function P(e,t,n){let r=new Set(e.filter(a=>a.fieldType?.toLowerCase()==="phone").map(a=>a.fieldApiName)),i=new Map(e.flatMap(a=>a.config.maxLength!==void 0?[[a.fieldApiName,a.config.maxLength]]:[]));return a=>{let s=k(a.values,r,t);for(let[f,d]of Object.entries(s))s[f]=M(d,n?.get(f)??i.get(f));return s}}var h="StageName",T="CloseDate",j=/closed/i;function E(e){return e.objectApiName!=="Opportunity"?!1:e.fieldRules.find(n=>n.fieldApiName===T)?.ruleType==="faker"&&e.fieldRules.some(n=>n.fieldApiName===h)}function G(e,t){let n=e.config.picklistValues;if(e.ruleType!=="picklist_random"||!n)return e;let r=new Set(e.fieldType?.toLowerCase()==="phone"?[e.fieldApiName]:[]),i=n.map(a=>{let s=k({[e.fieldApiName]:a},r,t)[e.fieldApiName];return typeof s=="string"?s:a});return{...e,config:{...e.config,picklistValues:i}}}function M(e,t){if(typeof e!="string"||t===void 0||t<=0||e.length<=t)return e;let n=e.slice(0,t);if(/\s/.test(e.charAt(t)))return n.trimEnd();let r=n.search(/\s\S*$/);return r>0?n.slice(0,r).trimEnd():n}function C(e,t,n){return e.filter(r=>Array.from({length:n},(i,a)=>t[a]?.[r.fieldApiName]).some(i=>i==null)).map(r=>r.fieldApiName)}function I(e,t,n){return e.length===0?!1:t.length<n?!0:t.some(r=>e.some(i=>r[i.fieldApiName]===void 0||r[i.fieldApiName]===null))}function q(e){return{fieldApiName:e.fieldApiName,ruleType:"faker",config:{fakerMethod:"sentence"}}}function L(e,t,n,r=Math.random){switch(e.ruleType){case"static":return e.config.staticValue??null;case"random":return $(e,r);case"sequence":return U(e,t);case"picklist_random":return v(e,r);case"reference":return z(e,n,r);case"formula":return e.config.formula??null;case"regex":return Y(e,t);case"from_csv":return null;default:return null}}function $(e,t){let n=e.config.minValue??0,r=e.config.maxValue??1e3;return Math.floor(n+t()*(r-n+1))}function U(e,t){let n=e.config.sequenceStart??1,r=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${n+t*r}`}function Y(e,t){let n=e.config.regexPattern;return n?y(n,t):null}function v(e,t){let n=e.config.picklistValues;if(!n||n.length===0)return null;let r=Math.floor(t()*n.length);return n[r]}function z(e,t,n){let r=e.config.referenceObject;if(!r)return null;let i=t.get(r);if(!i||i.length===0)return null;let a=Math.floor(n()*i.length);return i[a]}export{S as a,L as b};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{r as L}from"./chunk-ICIYL45C.mjs";import{Ec as C,Gc as R,Lc as S,Mc as m,Pc as b}from"./chunk-PMWAFDUB.mjs";var A="PricebookEntryId",F=Object.fromEntries([["OpportunityLineItem","Opportunity"],["QuoteLineItem","Quote"],["OrderItem","Order"],["ContractLineItem","ServiceContract"]].map(([e,o])=>[e,{record:o,field:L[e]}]));function K(e,o,c){if(!e.has(C))return[];let t=new Map;for(let{sourceObject:n,targetObject:a}of c)t.set(n,[...t.get(n)??[],a]);let i=n=>{let a=new Set,l=[C];for(;l.length>0;){let u=l.pop();if(u===n)return!0;a.has(u)||(a.add(u),l.push(...t.get(u)??[]))}return!1};return[...new Set(o.flatMap(n=>F[n]?.record??[]))].filter(n=>e.has(n)&&!i(n)).map(n=>({sourceObject:n,targetObject:C,relationshipName:`${n}Before${C}`,type:"lookup",required:!0}))}function k(e,o){return[e[R],e[S],o?e[m]:""].map(c=>String(c??"")).join("|")}function h(e,o){return`${e}|${o}`}function Y(e){return h([e.book,e.product,e.model].join("|"),e.currency)}function v(e){let o=e[b];return typeof o=="string"&&o!==""?o:void 0}function x(e){let o=e.wanted??new Map,c=e.prices.flatMap(i=>{let d=i.Id,n=v(i);if(typeof d!="string"||n===void 0)return[];let a=e.writtenIn(n),l=new Set(o.get(d)??[]);l.size===0&&!e.active.has(n)&&a!==void 0&&l.add(a);let u=i[R]===e.standardBookId;return[{row:i,id:d,read:n,alone:a,own:l,standard:u}]}),t=new Map;for(let{row:i,read:d,alone:n,own:a,standard:l}of c){if(l)continue;let u=a.size>0?a:n!==void 0?[n]:[],w=h(k({...i,[R]:e.standardBookId},e.sellingModels),d),p=t.get(w)??new Set;for(let y of u)p.add(y);t.set(w,p)}return c.map(({row:i,id:d,read:n,alone:a,own:l,standard:u})=>{let w=k(i,e.sellingModels),p=new Set(o.get(d)??[]);if(u)for(let y of t.get(h(w,n))??[])p.add(y);if(p.size===0)for(let y of l)p.add(y);return{row:i,id:d,key:w,read:n,alone:a,targets:[...p]}})}function _(e,o){let c=new Map;for(let t of e){if(t.alone!==t.read||!o.has(t.read))continue;let i=h(t.key,t.read);c.has(i)||c.set(i,t)}return c}function W(e){let o=x(e),c=_(o,e.active),t=new Map;for(let{row:i,key:d,targets:n}of o)for(let a of n){let l=h(d,a);c.has(l)||t.has(l)||t.set(l,{book:String(i[R]??""),product:String(i[S]??""),model:e.sellingModels?String(i[m]??""):"",currency:a})}return[...t.values()]}function G(e,o){let c=x(e),t=_(c,e.active),i=new Map(c.map(r=>[r.id,r.key])),d=new Map;for(let r of o){let s=r.Id,f=v(r);if(typeof s!="string"||f===void 0||e.writtenIn(f)!==f)continue;let g=k(r,e.sellingModels),P=h(g,f);if(t.has(P))continue;let M=d.get(P);M!==void 0&&!(r.IsActive===!0&&M.IsActive!==!0)||(d.set(P,r),i.set(s,g))}let n=new Map,a=new Set,l=new Set,u=new Map,w=new Set,p=[],y=(r,s,f)=>{s!==r.read&&p.push({from:r.read,to:s,how:f,forLines:s!==r.alone})},E=[];for(let r of c)for(let s of r.targets){let f=h(r.key,s),g=t.get(f);if(g){n.set(f,g.id),a.add(g.id),g!==r&&y(r,s,"replaced");continue}let P=d.get(f);if(P){n.set(f,String(P.Id)),l.add(P),y(r,s,"replaced");continue}E.push({price:r,to:s})}for(let{price:r,to:s}of E){let f=h(r.key,s);n.has(f)?y(r,s,"replaced"):!a.has(r.id)&&!w.has(r.id)?(w.add(r.id),n.set(f,r.id),s!==r.alone&&u.set(r.id,s),y(r,s,"converted")):y(r,s,"none")}let O=new Map,I=[],B=new Map(c.map(r=>[r.row,r]));for(let r of e.prices){let s=B.get(r);if(!s||s.targets.length===0||a.has(s.id)||w.has(s.id)){I.push(r);continue}let f=s.targets.map(g=>n.get(h(s.key,g))).find(g=>g!==void 0&&g!==s.id);if(f===void 0){I.push(r);continue}O.set(s.id,f)}I.push(...o.filter(r=>l.has(r)));for(let r of c){if(r.targets.length>0||r.alone===void 0)continue;let s=h(r.key,r.alone);n.has(s)||n.set(s,r.id)}return{rows:I,standsFor:O,convertedInto:u,written:n,keys:i,said:p}}function N(e){let o=new Map;for(let{from:c,to:t,how:i,forLines:d}of e){let n=[c,t,i,d?"lines":""].join("|"),a=o.get(n)??{from:c,to:t,how:i,forLines:d,prices:0};a.prices++,o.set(n,a)}return[...o.values()]}function $(e){let o=new Map;for(let{from:c,to:t,prices:i}of e){let d=`${c} \u2192 ${t}`;o.set(d,(o.get(d)??0)+i)}return[...o].map(([c,t])=>`${t} ${c}`).join(", ")}function H(e){return T(N(e))}function T(e){let o=(t,i)=>e.filter(d=>d.forLines===t&&d.how===i);return[[o(!1,"replaced"),"price(s) in a currency the target does not hold active replaced by the source's own price in the currency written, for the same product and price book"],[o(!1,"converted"),"no price in the currency written in the source for the same product and price book, written in it at the amount converted at the source's rates"],[o(!0,"replaced"),"price(s) replaced by the source's own price in the currency of the record their lines belong to, for the same product and price book"],[o(!0,"converted"),"no price in the currency of the record their lines belong to in the source for the same product and price book, written in it at its amount converted"],[e.filter(t=>t.how==="none"),"no price in the currency of the record their lines belong to in the source for the same product and price book, and the price goes in another currency for other lines: the target refuses the lines of a record in it"]].filter(([t])=>t.length>0).map(([t,i])=>`${$(t)}: ${i}`)}export{A as a,F as b,K as c,k as d,h as e,Y as f,W as g,G as h,N as i,H as j,T as k};
7
+ import{r as L}from"./chunk-ICIYL45C.mjs";import{Lc as C,Nc as R,Sc as S,Tc as m,Wc as b}from"./chunk-J347SPU6.mjs";var A="PricebookEntryId",F=Object.fromEntries([["OpportunityLineItem","Opportunity"],["QuoteLineItem","Quote"],["OrderItem","Order"],["ContractLineItem","ServiceContract"]].map(([e,o])=>[e,{record:o,field:L[e]}]));function K(e,o,c){if(!e.has(C))return[];let t=new Map;for(let{sourceObject:n,targetObject:a}of c)t.set(n,[...t.get(n)??[],a]);let i=n=>{let a=new Set,l=[C];for(;l.length>0;){let u=l.pop();if(u===n)return!0;a.has(u)||(a.add(u),l.push(...t.get(u)??[]))}return!1};return[...new Set(o.flatMap(n=>F[n]?.record??[]))].filter(n=>e.has(n)&&!i(n)).map(n=>({sourceObject:n,targetObject:C,relationshipName:`${n}Before${C}`,type:"lookup",required:!0}))}function k(e,o){return[e[R],e[S],o?e[m]:""].map(c=>String(c??"")).join("|")}function h(e,o){return`${e}|${o}`}function Y(e){return h([e.book,e.product,e.model].join("|"),e.currency)}function v(e){let o=e[b];return typeof o=="string"&&o!==""?o:void 0}function x(e){let o=e.wanted??new Map,c=e.prices.flatMap(i=>{let d=i.Id,n=v(i);if(typeof d!="string"||n===void 0)return[];let a=e.writtenIn(n),l=new Set(o.get(d)??[]);l.size===0&&!e.active.has(n)&&a!==void 0&&l.add(a);let u=i[R]===e.standardBookId;return[{row:i,id:d,read:n,alone:a,own:l,standard:u}]}),t=new Map;for(let{row:i,read:d,alone:n,own:a,standard:l}of c){if(l)continue;let u=a.size>0?a:n!==void 0?[n]:[],w=h(k({...i,[R]:e.standardBookId},e.sellingModels),d),p=t.get(w)??new Set;for(let y of u)p.add(y);t.set(w,p)}return c.map(({row:i,id:d,read:n,alone:a,own:l,standard:u})=>{let w=k(i,e.sellingModels),p=new Set(o.get(d)??[]);if(u)for(let y of t.get(h(w,n))??[])p.add(y);if(p.size===0)for(let y of l)p.add(y);return{row:i,id:d,key:w,read:n,alone:a,targets:[...p]}})}function _(e,o){let c=new Map;for(let t of e){if(t.alone!==t.read||!o.has(t.read))continue;let i=h(t.key,t.read);c.has(i)||c.set(i,t)}return c}function W(e){let o=x(e),c=_(o,e.active),t=new Map;for(let{row:i,key:d,targets:n}of o)for(let a of n){let l=h(d,a);c.has(l)||t.has(l)||t.set(l,{book:String(i[R]??""),product:String(i[S]??""),model:e.sellingModels?String(i[m]??""):"",currency:a})}return[...t.values()]}function G(e,o){let c=x(e),t=_(c,e.active),i=new Map(c.map(r=>[r.id,r.key])),d=new Map;for(let r of o){let s=r.Id,f=v(r);if(typeof s!="string"||f===void 0||e.writtenIn(f)!==f)continue;let g=k(r,e.sellingModels),P=h(g,f);if(t.has(P))continue;let M=d.get(P);M!==void 0&&!(r.IsActive===!0&&M.IsActive!==!0)||(d.set(P,r),i.set(s,g))}let n=new Map,a=new Set,l=new Set,u=new Map,w=new Set,p=[],y=(r,s,f)=>{s!==r.read&&p.push({from:r.read,to:s,how:f,forLines:s!==r.alone})},E=[];for(let r of c)for(let s of r.targets){let f=h(r.key,s),g=t.get(f);if(g){n.set(f,g.id),a.add(g.id),g!==r&&y(r,s,"replaced");continue}let P=d.get(f);if(P){n.set(f,String(P.Id)),l.add(P),y(r,s,"replaced");continue}E.push({price:r,to:s})}for(let{price:r,to:s}of E){let f=h(r.key,s);n.has(f)?y(r,s,"replaced"):!a.has(r.id)&&!w.has(r.id)?(w.add(r.id),n.set(f,r.id),s!==r.alone&&u.set(r.id,s),y(r,s,"converted")):y(r,s,"none")}let O=new Map,I=[],B=new Map(c.map(r=>[r.row,r]));for(let r of e.prices){let s=B.get(r);if(!s||s.targets.length===0||a.has(s.id)||w.has(s.id)){I.push(r);continue}let f=s.targets.map(g=>n.get(h(s.key,g))).find(g=>g!==void 0&&g!==s.id);if(f===void 0){I.push(r);continue}O.set(s.id,f)}I.push(...o.filter(r=>l.has(r)));for(let r of c){if(r.targets.length>0||r.alone===void 0)continue;let s=h(r.key,r.alone);n.has(s)||n.set(s,r.id)}return{rows:I,standsFor:O,convertedInto:u,written:n,keys:i,said:p}}function N(e){let o=new Map;for(let{from:c,to:t,how:i,forLines:d}of e){let n=[c,t,i,d?"lines":""].join("|"),a=o.get(n)??{from:c,to:t,how:i,forLines:d,prices:0};a.prices++,o.set(n,a)}return[...o.values()]}function $(e){let o=new Map;for(let{from:c,to:t,prices:i}of e){let d=`${c} \u2192 ${t}`;o.set(d,(o.get(d)??0)+i)}return[...o].map(([c,t])=>`${t} ${c}`).join(", ")}function H(e){return T(N(e))}function T(e){let o=(t,i)=>e.filter(d=>d.forLines===t&&d.how===i);return[[o(!1,"replaced"),"price(s) in a currency the target does not hold active replaced by the source's own price in the currency written, for the same product and price book"],[o(!1,"converted"),"no price in the currency written in the source for the same product and price book, written in it at the amount converted at the source's rates"],[o(!0,"replaced"),"price(s) replaced by the source's own price in the currency of the record their lines belong to, for the same product and price book"],[o(!0,"converted"),"no price in the currency of the record their lines belong to in the source for the same product and price book, written in it at its amount converted"],[e.filter(t=>t.how==="none"),"no price in the currency of the record their lines belong to in the source for the same product and price book, and the price goes in another currency for other lines: the target refuses the lines of a record in it"]].filter(([t])=>t.length>0).map(([t,i])=>`${$(t)}: ${i}`)}export{A as a,F as b,K as c,k as d,h as e,Y as f,W as g,G as h,N as i,H as j,T as k};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as c}from"./chunk-EAC5QCE3.mjs";var p=class{apply(n,r,t=[]){return m(n,r,t)}applyAddOns(n,r){let t={...n};for(let o of r)(!(o.fieldApiName in t)||o.overwriteExisting)&&(t[o.fieldApiName]=o.value);return t}},g=new Set(["direct","rename","transform","add_on"]),i=e=>e.toLowerCase();function S(e){return new Set(e.filter(n=>n.type!=="exclude").map(n=>i(n.targetField)))}function w(e,n=[]){let r=new Set(n.map(i));for(let t of e)(g.has(t.type)||t.type==="exclude")&&r.add(i(t.sourceField)),r.add(i(t.targetField));return r}var y=new c;function m(e,n,r=[]){if(n.length===0&&r.length===0)return{...e};let t=new Set(r.map(i)),o=Object.fromEntries(Object.entries(e).filter(([s])=>!t.has(i(s)))),d=w(n,r),l=Object.fromEntries(Object.entries(o).filter(([s])=>!d.has(i(s))));for(let s of n){let u=R(o,s);u!==void 0&&(l[s.targetField]=u)}return l}function a(e,n){if(n in e)return e[n];let r=i(n),t=Object.keys(e).find(o=>i(o)===r);return t===void 0?void 0:e[t]}var f=Symbol("exclude");function R(e,n){let r=F[n.type],t=r(e,n);if(!(t===f||t===void 0))return n.transformRules&&n.transformRules.length>0?y.transform(t,n.transformRules):t}var F={direct:(e,n)=>a(e,n.sourceField),rename:(e,n)=>a(e,n.sourceField),transform:(e,n)=>a(e,n.sourceField),constant:(e,n)=>n.targetField?n.sourceField:void 0,formula:(e,n)=>k(e,n.sourceField),exclude:()=>f,add_on:(e,n)=>a(e,n.sourceField)};function k(e,n){return/\{(\w+)\}/g.test(n)?n.replace(/\{(\w+)\}/g,(t,o)=>{let d=e[o];return d!=null?String(d):""}):e[n]}export{p as a,g as b,S as c,w as d,m as e};
7
+ import{a as c}from"./chunk-HDDJ3CVN.mjs";var p=class{apply(n,r,t=[]){return m(n,r,t)}applyAddOns(n,r){let t={...n};for(let o of r)(!(o.fieldApiName in t)||o.overwriteExisting)&&(t[o.fieldApiName]=o.value);return t}},g=new Set(["direct","rename","transform","add_on"]),i=e=>e.toLowerCase();function S(e){return new Set(e.filter(n=>n.type!=="exclude").map(n=>i(n.targetField)))}function w(e,n=[]){let r=new Set(n.map(i));for(let t of e)(g.has(t.type)||t.type==="exclude")&&r.add(i(t.sourceField)),r.add(i(t.targetField));return r}var y=new c;function m(e,n,r=[]){if(n.length===0&&r.length===0)return{...e};let t=new Set(r.map(i)),o=Object.fromEntries(Object.entries(e).filter(([s])=>!t.has(i(s)))),d=w(n,r),l=Object.fromEntries(Object.entries(o).filter(([s])=>!d.has(i(s))));for(let s of n){let u=R(o,s);u!==void 0&&(l[s.targetField]=u)}return l}function a(e,n){if(n in e)return e[n];let r=i(n),t=Object.keys(e).find(o=>i(o)===r);return t===void 0?void 0:e[t]}var f=Symbol("exclude");function R(e,n){let r=F[n.type],t=r(e,n);if(!(t===f||t===void 0))return n.transformRules&&n.transformRules.length>0?y.transform(t,n.transformRules):t}var F={direct:(e,n)=>a(e,n.sourceField),rename:(e,n)=>a(e,n.sourceField),transform:(e,n)=>a(e,n.sourceField),constant:(e,n)=>n.targetField?n.sourceField:void 0,formula:(e,n)=>k(e,n.sourceField),exclude:()=>f,add_on:(e,n)=>a(e,n.sourceField)};function k(e,n){return/\{(\w+)\}/g.test(n)?n.replace(/\{(\w+)\}/g,(t,o)=>{let d=e[o];return d!=null?String(d):""}):e[n]}export{p as a,g as b,S as c,w as d,m as e};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{ke as s,le as d}from"./chunk-PMWAFDUB.mjs";function c(l,e){return l.type==="condition"&&e.status==="completed"&&e.output?.conditionMet===!1}var f=class{evaluate(e,n){return d(e,n)}check(e){return s(e)}evaluateGroup(e,n){return e.length===0?!0:e.some(t=>t.logicalGroup==="or")?e.some(t=>this.evaluate(t,n)):e.every(t=>this.evaluate(t,n))}getNextStep(e,n){if(n.status==="completed")return c(e,n)?e.onFailure:e.onSuccess;if(n.status==="failed")return e.onFailure}endsRun(e,n){return c(e,n)&&!e.onFailure}findBranch(e,n,o){let t=new Map(e.map(r=>[r.id,r])),u=[],a=new Set,i=n,p=t.get(i);if(!p)return u;for(i=o?p.onSuccess:p.onFailure;i&&!a.has(i);){a.add(i);let r=t.get(i);if(!r)break;u.push(r),i=o?r.onSuccess:r.onFailure}return u}};export{f as a};
7
+ import{Ae as d,ze as s}from"./chunk-J347SPU6.mjs";function c(l,e){return l.type==="condition"&&e.status==="completed"&&e.output?.conditionMet===!1}var f=class{evaluate(e,n){return d(e,n)}check(e){return s(e)}evaluateGroup(e,n){return e.length===0?!0:e.some(t=>t.logicalGroup==="or")?e.some(t=>this.evaluate(t,n)):e.every(t=>this.evaluate(t,n))}getNextStep(e,n){if(n.status==="completed")return c(e,n)?e.onFailure:e.onSuccess;if(n.status==="failed")return e.onFailure}endsRun(e,n){return c(e,n)&&!e.onFailure}findBranch(e,n,o){let t=new Map(e.map(r=>[r.id,r])),u=[],a=new Set,i=n,p=t.get(i);if(!p)return u;for(i=o?p.onSuccess:p.onFailure;i&&!a.has(i);){a.add(i);let r=t.get(i);if(!r)break;u.push(r),i=o?r.onSuccess:r.onFailure}return u}};export{f as a};
@@ -0,0 +1,7 @@
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 vt,d as Tt,e as jt,g as _t,h as Bt,i as xt,j as Ft,k as et}from"./chunk-YDXMTWAT.mjs";import{a as Ne,b as z,d as H,e as Lt,f as Xe,h as L}from"./chunk-GP5J3DGS.mjs";import{e as Ut,h as $t,i as Ht}from"./chunk-ATBQIE2V.mjs";import{d as Jt}from"./chunk-UCUFLFNK.mjs";import{da as pe,e as te,ea as Ze,ga as he,ja as Ce}from"./chunk-SZOJ7BEJ.mjs";import{h as T}from"./chunk-TZE3Y7IQ.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{Fc as Ct,Kc as Nt,Lc as X,Pc as Pe,Sc as me,Tc as Ge,Vc as Ye,Wc as Mt,Yb as Pt}from"./chunk-J347SPU6.mjs";import{b as x,e as Qe,f as M,i as It,k as ae,l as Z,o as Ee,s as Et}from"./chunk-WZQEK4WT.mjs";var Me=class{activeJobs=new Map;maxConcurrentJobs;maxCompletedJobs=50;constructor(t=5){this.maxConcurrentJobs=t}registerJob(t){this.activeJobs.set(t.id,t)}updateJobState(t,e){let n=this.activeJobs.get(t);return n?(n.state=e,(e==="JobComplete"||e==="Failed"||e==="Aborted")&&this.purgeCompletedJobs(),!0):!1}updateJobCounts(t,e,n){let o=this.activeJobs.get(t);return o?(o.numberRecordsProcessed=e,o.numberRecordsFailed=n,!0):!1}updateTotalRecords(t,e){let n=this.activeJobs.get(t);return n?(n.totalRecords=e,!0):!1}getJob(t){return this.activeJobs.get(t)}getActiveJobs(){return Array.from(this.activeJobs.values()).filter(t=>t.state==="UploadComplete"||t.state==="InProgress")}getCompletedJobs(){return Array.from(this.activeJobs.values()).filter(t=>t.state==="JobComplete"||t.state==="Failed"||t.state==="Aborted")}canStartNewJob(){return this.getActiveJobs().length<this.maxConcurrentJobs}removeJob(t){return this.activeJobs.delete(t)}get totalJobs(){return this.activeJobs.size}purgeCompletedJobs(){let t=Array.from(this.activeJobs.entries()).filter(([,e])=>["JobComplete","Failed","Aborted"].includes(e.state));if(t.length>this.maxCompletedJobs){let e=t.slice(0,t.length-this.maxCompletedJobs);for(let[n]of e)this.activeJobs.delete(n)}}clear(){this.activeJobs.clear()}};function Fn(r,t){let e=et(r,t);if(e.state==="Open")throw new Error(`Bulk API job ${r||"(no id)"} is still open after its close was sent`);return{state:e.state,...e.numberRecordsProcessed!==void 0?{numberRecordsProcessed:e.numberRecordsProcessed}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{}}}function Le(r){return{bulk2:{createJob:t=>{let e=r.bulk2.createJob(t);return{get id(){return e.id},open:async()=>{await e.open()},uploadData:n=>e.uploadData(n),close:()=>e.close(),abort:()=>e.abort(),check:async()=>Fn(Ut(e)??"",await e.check()),getAllResults:()=>e.getAllResults()}},job:(t,{id:e})=>{let n=r.bulk2.job(t,{id:e});return{check:async()=>et(e,await n.check()),getSuccessfulResults:()=>n.getSuccessfulResults(),getAllResults:()=>n.getAllResults(),abort:()=>n.abort()}}}}}var qt=100,zt=2e3,$n=20,Hn=20,Jn=Z({name:x(),label:x(),type:x(),createable:M().optional(),updateable:M().optional(),nillable:M().optional(),defaultedOnCreate:M().optional(),aggregatable:M().optional(),groupable:M().optional(),filterable:M().optional(),nameField:M().optional(),autoNumber:M().optional(),calculated:M().optional(),referenceTo:ae(x()).optional()}).loose(),ee=Z({name:x(),label:x(),queryable:M().optional(),updateable:M().optional(),deletable:M().optional(),fields:ae(Jn),childRelationships:ae(Z({childSObject:x(),field:x(),cascadeDelete:M().optional(),restrictedDelete:M().optional()}).loose()).optional()}).loose(),qn=Et(x(),It()),zn=Z({k:Ee([x(),Qe(),M()]).nullable(),n:Qe().int().nonnegative()}).loose();function Wn(r){return(r.createable===!0||r.updateable===!0)&&r.type!=="boolean"}function to(r){return r.groupable===!0&&(Wn(r)||r.nameField===!0)}function Vn(r,t){return t.createable===!0&&t.nillable===!1&&t.defaultedOnCreate!==!0||Ct(r,t.name)}function ve(r,t,e){let n=C(e);r.some(o=>o.check===t&&o.message===n)||r.push({check:t,message:n})}async function no(r,t,e,n){let o=new Map,i=[],a=[],s=(u,l)=>{i.push({fieldApiName:u.name,label:u.label,reason:l})},d=e.filter(u=>u.aggregatable===!0),f=e.filter(u=>u.aggregatable!==!0&&u.filterable===!0);for(let u of e)u.aggregatable!==!0&&u.filterable!==!0&&s(u,"not-countable");if(n===0)for(let u of[...d,...f])o.set(u.name,0);else{for(let u=0;u<d.length;u+=qt){let l=d.slice(u,u+qt);try{let g=l.map(R=>`COUNT(${T(R.name)})`).join(", "),m=await r.query(`SELECT ${g} FROM ${t}`),h=qn.parse(m.records[0]??{});l.forEach((R,y)=>{let w=h[`expr${y}`];if(typeof w!="number")throw new Error(`The org answered no count for ${t}.${R.name}.`);o.set(R.name,w)})}catch(g){ve(a,"fill",g);for(let m of l)o.delete(m.name),s(m,"refused")}}for(let[u,l]of f.entries()){if(u>=Hn){s(l,"query-budget");continue}try{let g=await r.query(`SELECT COUNT() FROM ${t} WHERE ${T(l.name)} != null`);o.set(l.name,g.totalSize)}catch(g){ve(a,"fill",g),s(l,"refused")}}}return{fields:e.filter(u=>o.has(u.name)).map(u=>({fieldApiName:u.name,label:u.label,filled:o.get(u.name)??0,required:Vn(t,u)})).sort((u,l)=>u.filled-l.filled||u.fieldApiName.localeCompare(l.fieldApiName)),unmeasured:i,errors:a}}async function ro(r,t,e,n,o){let i=[],a=n?e.find(d=>d.name.toLowerCase()===n.toLowerCase()):e.find(d=>d.name==="Email")??e.find(d=>d.nameField===!0);if(!a)return n&&i.push({check:"duplicates",message:`${t} has no field ${n} the org can group records by.`}),{duplicates:null,errors:i};let s={keyField:a.name,keyLabel:a.label,groups:[],groupCount:0,recordCount:0,truncated:!1};if(o===0)return{duplicates:s,errors:i};try{let d=await Kn(r,t,a.name),f=d.rows.map(c=>({value:String(c.value),count:c.count}));return{duplicates:{...s,groups:f.slice(0,$n),groupCount:f.length,recordCount:f.reduce((c,u)=>c+u.count,0),truncated:d.truncated},errors:i}}catch(d){return ve(i,"duplicates",d),{duplicates:null,errors:i}}}async function Kn(r,t,e){let n=T(e),o=await r.query(`SELECT ${n} k, COUNT(Id) n FROM ${t} WHERE ${n} != null GROUP BY ${n} HAVING COUNT(Id) > 1 ORDER BY COUNT(Id) DESC LIMIT ${zt}`),i=[];for(let a of o.records){let s=zn.safeParse(a);!s.success||s.data.k===null||i.push({value:s.data.k,count:s.data.n})}return{rows:i,truncated:o.records.length>=zt}}async function oo(r,t,e,n,o){let i=[];if(!e.some(a=>a.name==="LastModifiedDate"&&a.filterable===!0))return{stale:null,errors:i};if(o===0)return{stale:{days:n,records:0},errors:i};try{let a=await r.query(`SELECT COUNT() FROM ${t} WHERE LastModifiedDate < LAST_N_DAYS:${n}`);return{stale:{days:n,records:a.totalSize},errors:i}}catch(a){return ve(i,"stale",a),{stale:null,errors:i}}}var tt=1e4,je=5e4,Wt="DELETE_FAILED",Qn="UNABLE_TO_LOCK_ROW",Vt=3,Gn=2e3,Kt="FEATURENOTENABLED",nt="ContentVersion",Qt="ContentDocument",rt=new Set([nt,Qt]);async function ye(r,t,e,n,o="delete"){let i=!1,a={},s=0,d=0,f=(g,m)=>(d+=g,m()),c={bulk2:{createJob:g=>{let m=r.bulk2.createJob(g);return{get id(){return m.id},open:()=>f(1,()=>m.open()),uploadData:h=>f(1,()=>m.uploadData(h)),close:async()=>{await f(1,()=>m.close()),i=!0},abort:()=>f(1,()=>m.abort()),check:async()=>{let h=await f(1,()=>m.check());return a={state:h.state,message:h.errorMessage},h},getAllResults:async()=>{let h=await f(Ht,()=>m.getAllResults());return s=Array.isArray(h)?h.length:(h.successfulResults?.length??0)+(h.failedResults?.length??0),h}}}}},u;try{u=await new $t().executeBulk({connection:c,bulkManager:new Me(1),...n?{signal:n}:{}},t,o,e.map(g=>({Id:g})))}catch(g){if(!i){let m=g?.errorCode;return{kind:"untouched",reason:C(g),...typeof m=="string"&&m!==""?{code:m}:{},requests:d}}throw g}if(u.aborted)return{kind:"aborted",requests:d};if(a.state!=="JobComplete"&&s===0)return{kind:"untouched",reason:a.message||`job ${a.state??"not complete"}`,requests:d};let l=new Map(u.outcomes.map(g=>[g.recordIndex,g]));return{kind:"answered",requests:d,rows:e.map((g,m)=>{let h=l.get(m);return h?.success?{success:!0}:{success:!1,error:h?.error??"The job gave no result for it."}})}}function bo(r,t){let e=Le(r);return{...Ne(r,t),queryDeleted:async n=>({records:(await r.query(n,{scanAll:!0})).records}),bulkDestroy:(n,o,i)=>ye(e,n,o,i),bulkHardDestroy:(n,o,i)=>ye(e,n,o,i,"hardDelete")}}var ot=Z({success:M(),errors:ae(Ee([Z({statusCode:x().optional(),errorCode:x().optional(),message:x().optional()}).loose(),x()])).optional()}).loose();function ne(r){return r.slice(0,15)}function Te(r){return typeof r=="string"?void 0:r.statusCode??r.errorCode}function Gt(r){return Jt(r.map(({statusCode:t,message:e})=>`${t}: ${e}`),r)}function st(r){if(typeof r=="string")return r;let t=Te(r),e=r.message??"";return t&&e?`${t}: ${e}`:t||e||"The org gave no reason."}function de(r){return async t=>(await r.query(t)).records.filter(n=>typeof n=="object"&&n!==null)}function Yn(r){return new Promise(t=>setTimeout(t,r))}function Zn(r){let t=Gn*2**r;return Math.floor(t/2+Math.random()*(t/2))}async function Yt(r,t,e,n){let o=[...e];for(let i=0;i<Vt;i++){let a=o.flatMap((d,f)=>d.kind==="refused"&&d.locked===!0?[f]:[]);if(a.length===0||n.stopped?.()===!0||(await(n.wait??Yn)(Zn(i)),n.stopped?.()===!0))break;let s=await t(a.map(d=>r[d]));if(s===void 0)break;a.forEach((d,f)=>{let c=s[f];c&&(o[d]={...c,lockResends:i+1})})}return o}async function it(r,t,e,n={}){if(t===nt)return sr(r,e,n);let o=i=>Xn(r,t,i);return Yt(e,o,await o(e),n)}async function Xn(r,t,e){let n;try{n=await r.destroy(t,[...e])}catch(i){let a=C(i);return e.map(()=>({kind:"refused",reason:a,dependency:!1}))}let o=Array.isArray(n)?n:[n];return e.map((i,a)=>{let s=ot.safeParse(o[a]);if(s.success&&s.data.success)return{kind:"deleted"};let d=s.success?s.data.errors??[]:[];if(d.some(c=>Te(c)==="ENTITY_IS_DELETED"))return{kind:"gone"};let f=Gt(d.map(c=>({statusCode:Te(c)??"",message:typeof c=="string"?c:c.message??""})));return{kind:"refused",reason:d.length>0?st(d[0]):"The org gave no reason.",dependency:d.some(c=>Te(c)===Wt),...f?{locked:!0}:{}}})}async function er(r,t,e,n="recycle",o={}){let i=n==="hard"?r.bulkHardDestroy?.bind(r):r.bulkDestroy?.bind(r);if(i===void 0)return n==="hard"?{hardRefused:tr}:"untouched";let a=async d=>{let f;try{f=await i(t,d,o.signal)}catch(u){let l=C(u);return d.map(()=>({kind:"refused",reason:l,dependency:!1}))}if(f.kind==="aborted")return"aborted";if(f.kind==="untouched"){if(n!=="hard")return"untouched";if(f.code===Kt)return{hardRefused:nr(f.reason)};let u=`Not deleted for good: the job was not handed over \u2014 ${f.reason}`;return d.map(()=>({kind:"refused",reason:u,dependency:!1}))}let{rows:c}=f;return d.map((u,l)=>{let g=c[l];if(g?.success===!0)return{kind:"deleted"};let{code:m,message:h}=or(g?.error??"");return m==="ENTITY_IS_DELETED"?{kind:"gone"}:{kind:"refused",reason:m&&h?`${m}: ${h}`:g?.error||m||h||"The org gave no reason.",dependency:m===Wt,...Gt([{statusCode:m??"",message:h}])?{locked:!0}:{}}})},s=await a(e);return Array.isArray(s)?Yt(e,async d=>{let f=await a(d);return Array.isArray(f)?f:void 0},s,o):s}var tr="Records cannot be deleted for good through this connection: nothing was sent.";function nr(r){return`The user SandForge connects as may not delete records for good in this org: Salesforce refused the job before it held a record (${Kt}: ${r}). Nothing was deleted for good, and nothing was sent to the recycle bin instead.`}var rr="A file is never deleted for good: that takes a Bulk API job, which no file was ever sent by. Not sent.";function or(r){let t=/^([A-Z][A-Z0-9_]*):([\s\S]*?)(?::(?:--|[\w.,]+))?$/.exec(r.trim());return t?{code:t[1],message:t[2].trim()}:{message:r.trim()}}async function sr(r,t,e){let n;try{n=await L(r,nt,["ContentDocumentId"],t)}catch(d){let f=C(d);return t.map(()=>({kind:"refused",reason:f,dependency:!1}))}let o=new Map;for(let d of n)typeof d.Id=="string"&&typeof d.ContentDocumentId=="string"&&o.set(ne(d.Id),d.ContentDocumentId);let i=[...new Set(o.values())],a=i.length>0?await it(r,Qt,i,e):[],s=new Map(i.map((d,f)=>[d,a[f]]));return t.map(d=>{let f=o.get(ne(d));return f===void 0?{kind:"gone"}:s.get(f)??{kind:"refused",reason:"The org gave no answer for its document.",dependency:!1}})}function Zt(r){let t=[];for(let e=0;e<r.length;e+=z)t.push({ids:r.slice(e,e+z),byJob:!1});return t}function Xt(r,t,e,n="recycle"){return rt.has(t)?!1:n==="hard"||r.bulkDestroy!==void 0&&e>=tt}async function ir(r,t,e,n="recycle"){let o=[],i=!rt.has(t)&&(n==="hard"||r.bulkDestroy!==void 0),a=d=>{if(d.length===0)return;if(!i||n!=="hard"&&d.length<tt){o.push(...Zt(d));return}let f=Math.ceil(d.length/Math.ceil(d.length/je));for(let c=0;c<d.length;c+=f)o.push({ids:d.slice(c,c+f),byJob:!0})};if(!Pe(t)||e.length===0)return a(e),o;let s=new Set;try{s=new Set([...await he(de(r),e)].map(ne))}catch{}return a(e.filter(d=>!s.has(ne(d)))),a(e.filter(d=>s.has(ne(d)))),o}function en(r){return{objectApiName:r,op:"delete"}}async function tn(r,t,e,n,o){let i={stopped:o.stopped,...o.wait?{wait:o.wait}:{}},{stopped:a}=await Ft(e,{key:en(t),sizes:n.sizes,allowance:n.allowance,beforeEachSend:()=>o.stopped()?"stop":void 0,send:async s=>({answers:await it(r,t,s,i)}),limited:s=>s?.kind==="refused"?Pt([s.reason]):void 0,settle:(s,d,f,c)=>{let u=[],l=[];s.forEach((g,m)=>{if(f.has(m))return;let h=d[m]??{kind:"refused",reason:"The org gave no answer for it.",dependency:!1},R=c.get(m);u.push(g),l.push(R!==void 0&&h.kind==="refused"?{...h,dependency:!1,limit:R}:h)}),u.length>0&&o.settle(u,l)}});return a!==void 0}function at(r,t){let e=en(r),n=t.sizes.report(e);if(!n)return[];let o=[];return n.rows+n.alone+n.notSplit+n.keptWhole>0&&o.push(_t(n)),n.notSplit>0&&o.push(Bt(n.notSplit,xt(t.allowance,e),"removal")),n.keptWhole>0?o.push(jt):n.alone>0&&o.push(Tt),o}function nn(r){let t=0,e=0,n=0,o=0;for(let a of r)t++,a==="deleted"?e++:a==="gone"?n++:o++;if(t===0)return[];let i=[e>0?`${e} deleted`:"",n>0?`${n} already gone`:"",o>0?`${o} still refused`:""].filter(Boolean);return[`The org could not lock ${t} record(s) (${Qn}), each sent again up to ${Vt} times, a wait before each: ${i.join(", ")}.`]}async function rn(r,t,e,n){let o=n.mode??"recycle";if(o==="hard"&&rt.has(t))return e.length>0&&n.settle(e,e.map(()=>({kind:"refused",reason:rr,dependency:!1}))),{stopped:!1};let i=n.wait?{wait:n.wait}:{},a=await ir(r,t,e,o);for(let s=a.shift();s!==void 0;s=a.shift()){let{ids:d,byJob:f}=s;if(n.stopped())return{stopped:!0};if(await n.prepare?.(d),!f){if(await tn(r,t,d,n.splitting,{stopped:n.stopped,settle:n.settle,...i}))return{stopped:!0};continue}let c=await er(r,t,d,o,{stopped:n.stopped,...i,...n.signal?{signal:n.signal}:{}});if(c==="aborted")return{stopped:!0};if(c==="untouched"){a.unshift(...Zt(d));continue}if(!Array.isArray(c))return{stopped:!0,hardRefused:c.hardRefused};n.settle(d,c)}return{stopped:!1}}async function on(r,t){for(let e=0,n=!0;n;e++){n=!1;for(let o of r){let i=t.idsOf(o,e);if(i.length===0)continue;if(t.stopped())return!0;let a=t.deleted(o);if(await t.send(o,i,e))return!0;t.deleted(o)>a&&(n=!0)}}return!1}async function _e(r,t){let e=new Set(t.map(a=>a.objectApiName)),n=new Map;for(let{objectApiName:a}of t){let s;try{s=(ee.parse(await r.describe(a)).childRelationships??[]).map(f=>f.childSObject)}catch{continue}for(let d of s){if(d===a||!e.has(d))continue;let f=n.get(d)??new Set;f.add(a),n.set(d,f)}}let o=[...t],i=[];for(;o.length>0;){let a=o.findIndex(s=>!o.some(d=>d!==s&&n.get(d.objectApiName)?.has(s.objectApiName)));i.push(...o.splice(a>=0?a:0,1))}return i}async function dt(r,t,e){if(r.length===0)return{gone:[],unchecked:[]};let n;try{n=await t(r)}catch(a){return{gone:[],unchecked:[...r],failure:C(a)}}let o=new Set(n.map(a=>ne(String(a.Id)))),i=r.filter(a=>!o.has(ne(a)));return{gone:i.filter(e),unchecked:i.filter(a=>!e(a))}}function ar(r){return r.filter(t=>pe[t]!==void 0&&!Ze.has(t))}async function ct(r,t,e,n,o,i){let a=de(r),s=[];for(let{objectApiName:d}of t){let f=pe[d];if(!f||Ze.has(d))continue;let c;for await(let u of e.pages(d)){let l=u.filter(w=>n(d,w));if(l.length===0)continue;if(o())return{drafted:s,cancelled:!0};c??=await Ce(a,f);let g=c,m=g?.draft;if(!g||!m)break;let h=await i(d,l),R;try{R=await L(r,d,["Status"],l)}catch{continue}let y=R.filter(w=>typeof w.Id=="string"&&!h.has(w.Id.slice(0,15))).filter(w=>{let k=g.categoryOf.get(String(w.Status));return k!==void 0&&k!=="Draft"}).map(w=>({objectApiName:d,id:String(w.Id),draft:m,status:String(w.Status)}));for(let w=0;w<y.length;w+=z){if(o())return{drafted:s,cancelled:!0};let k=y.slice(w,w+z);s.push(...k);try{await r.update(d,k.map(({id:I})=>({Id:I,Status:m})))}catch{}}}}return{drafted:s,cancelled:!1}}function Ao(r,t,e,n){if(e)return`${r} ${e.id}: ${t}`;let o=n.filter(i=>i.objectApiName===r).map(i=>`${i.id} (${i.status})`);return o.length>0?`${r}: ${t} Set to Draft, with the status each had: ${o.join(", ")}.`:`${r}: ${t}`}async function sn(r,t,e){let n=[...new Set(t.map(o=>o.objectApiName))];for(let o of n){let i=t.filter(c=>c.objectApiName===o),a=new Map(i.map(c=>[c.id.slice(0,15),c])),s=i.map(c=>c.id),d;try{d=await L(r,o,["Status"],s)}catch(c){e.note(o,`Status set to ${i[0].draft} for the delete, and not read back to be restored: ${C(c)}`,!0);continue}let f=d.flatMap(c=>{let u=typeof c.Id=="string"?a.get(c.Id.slice(0,15)):void 0;return u&&c.Status===u.draft?[u]:[]});for(let c=0;c<f.length;c+=z){let u=f.slice(c,c+z),l;try{l=await r.update(o,u.map(({id:m,status:h})=>({Id:m,Status:h})))}catch(m){l=u.map(()=>({success:!1,errors:[C(m)]}))}let g=Array.isArray(l)?l:[l];u.forEach(({draft:m,status:h},R)=>{let y=ot.safeParse(g[R]);if(y.success&&y.data.success){e.note(o,`Status set to ${m} for the delete, then back to ${h}.`,!1,u[R]);return}let w=y.success?y.data.errors??[]:[],k=w.length>0?st(w[0]):"The org gave no reason.";e.note(o,`Status set to ${m} for the delete, and left there: the org refused ${h} back \u2014 ${k}`,!0,u[R])})}}}var le="DuplicateRecordSet",dr="DuplicateRecordItem",Be=2e3,cr=999,lr=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function j(r){return r.slice(0,15)}function an(r){return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function lt(r){return typeof r=="string"?Date.parse(r):Number.NaN}async function dn(r,t){return(await ur(r,t)).map(e=>({id:e.id,modified:fr(e,t)}))}async function ur(r,t){let e=t.madeFrom??t.start-2e3;if(!Number.isFinite(e)||!Number.isFinite(t.end)||t.user!==void 0&&!lr.test(t.user))return[];let n;try{let c=await r.query(`SELECT Id, CreatedDate, LastModifiedDate, LastModifiedById FROM ${le} WHERE CreatedDate >= ${an(e)} AND CreatedDate <= ${an(t.end+6e4)} LIMIT ${Be}`);if(c.records.length>=Be)return[];n=c.records.filter(u=>typeof u=="object"&&u!==null)}catch{return[]}let o=n.flatMap(c=>typeof c.Id=="string"?[c.Id]:[]);if(o.length===0)return[];let i=new Map,a=new Map,s=new Map;try{for(let c of H(o)){let u=await r.query(`SELECT Id, RecordId, DuplicateRecordSetId, CreatedDate FROM ${dr} WHERE DuplicateRecordSetId IN (${c}) LIMIT ${Be}`);if(u.records.length>=Be)return[];for(let l of u.records){let g=l??{},m=g.DuplicateRecordSetId,h=g.RecordId;if(typeof m!="string")continue;let R=lt(g.CreatedDate);if(Number.isFinite(R)&&!(R<=(s.get(j(m))??Number.NaN))&&s.set(j(m),R),typeof h!="string"||!t.has(j(h))){let y=i.get(j(m))??new Set;y.add(typeof h=="string"?j(h):`item ${String(g.Id)}`),i.set(j(m),y)}else a.set(j(m),[...a.get(j(m))??[],j(h)])}}}catch{return[]}let d=t.user!==void 0?j(t.user):void 0,f=(c,u)=>{let l=i.get(c)?.size??0;return a.has(c)?l<=1:d!==void 0&&l===0&&typeof u=="string"&&j(u)===d};return n.flatMap(c=>typeof c.Id=="string"&&f(j(c.Id),c.LastModifiedById)?[{id:c.Id,created:lt(c.CreatedDate),modified:lt(c.LastModifiedDate),...typeof c.LastModifiedById=="string"?{modifiedBy:c.LastModifiedById}:{},names:a.get(j(c.Id))??[],...s.has(j(c.Id))?{itemsMade:s.get(j(c.Id))}:{}}]:[])}function fr(r,t){let e=r.modifiedBy!==void 0?j(r.modifiedBy):"";if(t.user!==void 0&&e===j(t.user)&&r.modified<=t.end+6e4)return Math.min(r.modified,t.end);let n=t.end+6e4;return r.names.length>0&&r.created<=n&&r.modified<=n&&(r.modified===r.created||r.modified<=(r.itemsMade??Number.NaN)+cr)?Math.min(r.modified,t.end):r.modified}async function cn(r,t,e,n="recycle"){let o=T(t),i=new Set;try{for(let a of H(e)){let s=await r.queryDeleted(`SELECT Id FROM ${o} WHERE Id IN (${a}) AND IsDeleted = true`);for(let d of s.records){let f=d?.Id;typeof f=="string"&&i.add(f.slice(0,15))}}}catch(a){return{error:C(a)}}return{deleted:i,inBin:n!=="hard"}}var gr=/__kav$/i;function be(r){return gr.test(r)}function un(r){return r.replace(/v$/i,"")}var ut="Kept: its article holds a version the run did not write \u2014 a draft begun on it, or a version published since \u2014 which deleting the article would take with it. A removal that takes what changed since the run takes it too.",mr={statusCode:"ENTITY_IS_DELETED",message:"The version is no longer in the org: it went with its article."},ln=" AND IsLatestVersion = false AND PublishStatus = 'Archived'",pr="An article version is deleted through its article, over REST.",hr={success:!1,errors:[{message:"The org gave no reason."}]};function J(r){return r.slice(0,15)}function fn(r,t){let e=r.bulkDestroy?.bind(r);return{query:n=>r.query(n),queryDeleted:n=>r.queryDeleted(n),update:(n,o)=>r.update(n,o),serverTime:()=>r.serverTime(),userId:()=>r.userId(),describeGlobal:()=>r.describeGlobal(),describe:n=>be(n)?yr(r,n):r.describe(n),destroy:(n,o)=>be(n)?br(r,n,o,t):r.destroy(n,o),...e?{bulkDestroy:(n,o,i)=>be(n)?Promise.resolve({kind:"untouched",reason:pr,requests:0}):e(n,o,i)}:{}}}async function yr(r,t){let e=await r.describe(t);if(typeof e!="object"||e===null)return e;let n;try{n=(await r.describe(un(t)))?.deletable}catch{n=void 0}let o={...e};return delete o.deletable,typeof n=="boolean"?{...o,deletable:n}:o}async function gn(r,t,e){let n=T(t),o=new Map,i=new Map,a=(d,f)=>{for(let c of d){let u=c;if(typeof u?.Id!="string"||typeof u.KnowledgeArticleId!="string")continue;f?.set(J(u.Id),u.KnowledgeArticleId);let l=J(u.KnowledgeArticleId),g=i.get(l)??new Set;g.add(J(u.Id)),i.set(l,g)}};for(let d of["",ln])for(let f of H(e)){let c=await r.query(`SELECT Id, KnowledgeArticleId FROM ${n} WHERE Id IN (${f})${d}`);a(c.records,o)}let s=[...new Set(o.values())];for(let d of["",ln])for(let f of H(s)){let c=await r.query(`SELECT Id, KnowledgeArticleId FROM ${n} WHERE KnowledgeArticleId IN (${f})${d}`);a(c.records)}return{articleOf:o,versions:i}}function mn({articleOf:r,versions:t},e,n){if(n.includeChanged)return new Set;let o=new Set(e.map(J)),i=a=>[...t.get(a)??[]].some(s=>!o.has(s));return new Set([...r.values()].map(J).filter(i))}async function pn(r,t,e,n){let o=await gn(r,t,e),i=mn(o,e,n);return new Set(e.map(J).filter(a=>{let s=o.articleOf.get(a);return s!==void 0&&i.has(J(s))}))}async function br(r,t,e,n){let o=await gn(r,t,e),{articleOf:i}=o,a=[...new Set(i.values())],s=mn(o,e,n),d=a.filter(c=>!s.has(J(c))),f=new Map;if(d.length>0){let c;try{c=await r.destroy(un(t),d)}catch(l){let g=C(l);c=d.map(()=>({success:!1,errors:[{message:g}]}))}let u=Array.isArray(c)?c:[c];d.forEach((l,g)=>f.set(J(l),u[g]))}return e.map(c=>{let u=i.get(J(c));return u===void 0?{success:!1,errors:[mr]}:s.has(J(u))?{success:!1,errors:[{message:ut}]}:f.get(J(u))??hr})}var Fe="Quote",we="QuoteLineItem",Re="Opportunity",Se="OpportunityLineItem",hn=2e3;function Rr(r){return r.slice(0,15)}function yn(r){return typeof r=="string"?Date.parse(r):Number.NaN}function F(r,t){let e=r[t];return typeof e=="string"&&e!==""?Rr(e):void 0}function gt(r,t){return r.has(t)||r.otherParts?.has(t)===!0}function wr(r,t){let e=new Set,n=new Set;for(let g of r.syncing){let m=F(g,"Id"),h=F(g,"SyncedQuoteId");!m||!h||!gt(t,m)||!t.has(h)||(e.add(h),n.add(m))}if(e.size===0)return[];let o=r.quoteLines.filter(g=>{let m=F(g,"QuoteId");return m!==void 0&&e.has(m)&&F(g,"Id")!==void 0}),i=r.opportunityLines.filter(g=>{let m=F(g,"OpportunityId");return m!==void 0&&n.has(m)&&F(g,"Id")!==void 0}),a=g=>F(g,"CreatedById"),s=(g,m)=>{let h=F(g,"Id");if(!h||gt(t,h)||!m)return!1;let R=t.user??a(m),y=yn(g.CreatedDate);return R!==void 0&&a(g)===R&&y>=t.start&&y<=t.end},d=g=>({id:String(g.Id),modified:yn(g.LastModifiedDate)}),f=new Map(i.flatMap(g=>{let m=F(g,"Id");return m&&t.has(m)?[[m,g]]:[]})),c=new Map;for(let g of o){let m=F(g,"Id"),h=F(g,"OpportunityLineItemId");m&&h&&t.has(m)&&!c.has(h)&&c.set(h,g)}let u=o.filter(g=>{let m=F(g,"OpportunityLineItemId");return s(g,m?f.get(m):void 0)}).map(d),l=i.filter(g=>{let m=F(g,"Id");return s(g,m?c.get(m):void 0)}).map(d);return[...u.length>0?[{objectApiName:we,copies:u}]:[],...l.length>0?[{objectApiName:Se,copies:l}]:[]]}function bn(r,t=[]){let e=new Set(r),n=e.has(Re)||new Set(t).has(Re);if(!e.has(Fe)||!n)return[];let o=e.has(we),i=e.has(Se);return o===i?[]:[o?Se:we]}async function ft(r,t,e,n,o){let i=e.map(T).join(", "),a=[];for(let s of H(o)){let d=await r.query(`SELECT ${i} FROM ${T(t)} WHERE ${T(n)} IN (${s}) LIMIT ${hn}`);if(d.records.length>=hn)throw new Error(`More ${t} records than one read takes.`);for(let f of d.records)typeof f=="object"&&f!==null&&a.push(f)}return a}async function Rn(r,t,e,n){let o=n.has(we)||n.has(Se),i=n.has(Re)||t.otherParts?.objects.has(Re)===!0;if(e.length===0||!i||!o)return[];try{let s=(await ft(r,Re,["Id","SyncedQuoteId"],"SyncedQuoteId",e)).filter(c=>{let u=F(c,"Id");return u!==void 0&&gt(t,u)});if(s.length===0)return[];let d=await ft(r,we,["Id","QuoteId","OpportunityLineItemId","CreatedById","CreatedDate","LastModifiedDate"],"QuoteId",[...new Set(s.map(c=>String(c.SyncedQuoteId)))]),f=await ft(r,Se,["Id","OpportunityId","CreatedById","CreatedDate","LastModifiedDate"],"OpportunityId",s.map(c=>String(c.Id)));return wr({syncing:s,quoteLines:d,opportunityLines:f},t)}catch{return[]}}var Sr=5,ke=4,Ue=2e3,kr=4,Je=[["CreatedDate","LastModifiedDate","CreatedById","LastModifiedById"],["CreatedDate","LastModifiedDate","CreatedById"],["SystemModstamp"],[]],pt=1e4,Or="005",wn="ContentDocumentLink",Ar="ContentDocument",Dr="ContentVersion",Ir=5;function qe(r){let t=new Set(r.flatMap(n=>n.ids.map(b))),e=new Map;for(let{objectApiName:n,ids:o}of r)e.set(n,[...e.get(n)??[],...o]);return{objects:[...e].map(([n,o])=>({objectApiName:n,count:o.length})),pages:async function*(n){let o=e.get(n);o&&o.length>0&&(yield o)},has:n=>t.has(n)}}function re(r){return!Array.isArray(r)}function ts(r){return re(r)?r.objects.reduce((t,e)=>t+e.count,0):r.reduce((t,e)=>t+e.ids.length,0)}function ns(r){return(re(r)?r.objects:r).map(t=>t.objectApiName)}var ze=class{bits=new Uint8Array(0);add(t){let e=t>>3;if(e>=this.bits.length){let n=new Uint8Array(Math.max(e+1,this.bits.length*2,64));n.set(this.bits),this.bits=n}this.bits[e]|=1<<(t&7)}has(t){let e=t>>3;return e<this.bits.length&&(this.bits[e]&1<<(t&7))!==0}},ht=class{dates=new Float64Array(0);set(t,e){if(t>=this.dates.length){let n=new Float64Array(Math.max(t+1,this.dates.length*2,64)).fill(Number.NaN);n.set(this.dates),this.dates=n}this.dates[t]=e}at(t){return t<this.dates.length?this.dates[t]:Number.NaN}latestWithin(t,e){let n=Number.NaN;for(let o of this.dates)o>=t&&o<=e&&!(o<=n)&&(n=o);return n}};function ue(r,t){return typeof r=="string"&&t.has(b(r))}var Sn=[{created:"CreatedDate",modified:"LastModifiedDate"},{modified:"SystemModstamp"}],mt={ContentDocumentLink:{ends:["ContentDocumentId","LinkedEntityId"],cameWithRun:(r,t)=>{let e=r.LinkedEntityId;return ue(r.ContentDocumentId,t)&&(ue(e,t)||typeof e=="string"&&e.startsWith(Or))}},DuplicateRecordItem:{ends:["RecordId"],cameWithRun:(r,t)=>ue(r.RecordId,t)},ContentVersion:{ends:["ContentDocumentId"],cameWithRun:(r,t)=>ue(r.ContentDocumentId,t)},[te.objectApiName]:{ends:[te.parent,te.field],cameWithRun:(r,t)=>r[te.field]===te.value&&ue(r[te.parent],t)}};function rs(r,t){return{...Ne(r,t),serverTime:async()=>(await r.soap.getServerTimestamp()).timestamp,userId:async()=>(await r.soap.getUserInfo()).userId,queryDeleted:async e=>({records:(await r.query(e,{scanAll:!0})).records}),bulkDestroy:(e,n,o)=>ye(Le(r),e,n,o)}}function yt(r,t,e){let n=new Map;for(let o of r??[]){let i=wt(o.span,[],e);if(Number.isFinite(i.end))for(let a of o[t]??[]){let s=b(a);i.end<=(n.get(s)?.end??Number.NEGATIVE_INFINITY)||n.set(s,i)}}return n}function Er(r=[],t=[]){if(r.length===0&&t.length===0)return;let e=[...r.map(({plan:n})=>re(n)?n:qe(n)),qe(t)];return{has:n=>e.some(o=>o.has(n))}}function Pr(r=[],t=[]){return new Set([...r.map(({plan:e})=>re(e)?e.objects:e),t].flat().map(e=>e.objectApiName))}function In(r,t){return new Map([...yt(r,"wrote",t)].map(([e,{end:n}])=>[e,n]))}function En(r,t){return`The user SandForge connects as may not delete ${r} records in this org: the ${t} record(s) of the run stay, and were not sent.`}function bt(r,t){return`Not visible: ${r} record(s) found neither in the org nor in its recycle bin, as the user the removal runs as sees them \u2014 out of that user's sight, or deleted for good \u2014 are not counted as removed`+(t?` (the recycle bin could not be read: ${t})`:".")}function kn(r,t,e){for(let o of r){let i=o.deleted+o.alreadyGone+o.keptChanged+o.keptDependents+o.refused+(o.notVisible??0);o.planned>i&&(o.notReached=o.planned-i)}let n=new Set(r.map(o=>o.objectApiName));for(let{objectApiName:o,count:i}of t)i===0||n.has(o)||(n.add(o),r.push({...new Oe(o,i,e(o)).result,notReached:i}));return r}var os={objects:[],cancelled:!1,gone:[],stamps:{},left:async function*(){}};function b(r){return r.slice(0,15)}function Cr(r){return r?.errorCode==="INVALID_FIELD"||/no such column/i.test(C(r))}function Nr(r,t){let e=/no such column '(\w+)'/i.exec(C(r))?.[1],n=Je.findIndex((o,i)=>i>t&&(e===void 0||!o.includes(e)));return n===-1?Je.length:n}function N(r){return typeof r=="string"?Date.parse(r):Number.NaN}function Pn(){return{modified:new ht,missing:new Set,firstCreated:Number.NaN,lastCreated:Number.NaN,binned:new Set}}var Oe=class{result;notes=[];refused=new Map;unread;held=[];goneAt=new ze;goneLater=new Set;deletedLater=new Set;notVisible=0;notVisibleNote;secondTry=new Set;filesLeft=new Map;automationHeld=new Map;automationHeldAfter=new Set;automationHeldAlong=new Set;tookAlong=new Map;cameAlong=new Map;limitNotes=[];lockResent=new Map;constructor(t,e,n=0){this.result={objectApiName:t,planned:e,deleted:0,alreadyGone:0,keptChanged:0,keptDependents:0,refused:0,heldBy:[],...n>0?{platformCopies:n}:{},unchecked:[],reasons:[]}}note(t){this.notes.includes(t)||this.notes.push(t)}isGone(t,e){return this.goneAt.has(e)||this.goneLater.has(b(t))}waiting(){return[...[...this.refused].filter(([,t])=>t.dependency).map(([t])=>t),...this.held]}refusedSent(){return[...this.refused].filter(([,t])=>t.sent).map(([t])=>t)}refusedToSendAgain(){return[...this.refused].filter(([,t])=>t.sent&&t.limit!==!0).map(([t])=>t)}secondTryNote(){if(this.secondTry.size===0)return[];let t=0,e=0,n=0,o=0;for(let a of this.secondTry){let s=b(a);this.deletedLater.has(s)?t++:this.goneLater.has(s)?e++:this.refused.has(a)?o++:n++}return[`Refused at first, sent again once the rest had gone: ${[t>0?`${t} deleted`:"",e>0?`${e} already gone`:"",n>0?`${n} kept for records that stay`:"",o>0?`${o} refused again`:""].filter(Boolean).join(", ")}.`]}settle(){this.result.keptDependents=this.held.length,this.result.refused=this.refused.size+(this.unread?.count??0),this.notVisible>0&&(this.result.notVisible=this.notVisible),this.held.length===0&&(this.result.heldBy=[]);let t=this.held.flatMap(i=>{let a=this.automationHeld.get(b(i));return a?[a]:[]}),e=this.held.filter(i=>{let a=b(i);return this.automationHeld.has(a)&&this.automationHeldAfter.has(a)}).length,n=this.held.filter(i=>{let a=b(i);return this.automationHeld.has(a)&&this.automationHeldAlong.has(a)}).length;t.length>0?(this.result.heldByAutomation=t.length,e>0?this.result.heldByAutomationAfterRun=e:delete this.result.heldByAutomationAfterRun,n>0?this.result.heldByAutomationAlong=n:delete this.result.heldByAutomationAlong,this.result.automationHolders=[...new Set(t.flatMap(i=>[...i]))]):(delete this.result.heldByAutomation,delete this.result.heldByAutomationAfterRun,delete this.result.heldByAutomationAlong,delete this.result.automationHolders);let o=[...this.notVisibleNote?[this.notVisibleNote]:[],...this.notes,...this.limitNotes,...nn(this.lockResent.values()),...this.secondTryNote(),...this.unread?[this.unread.reason]:[],...[...this.refused.values()].map(i=>i.reason)];return this.result.reasons=[...new Set(o)].slice(0,Sr),this.filesLeft.size>0&&(this.result.filesLeft={count:this.filesLeft.size,names:[...this.filesLeft.values()].slice(0,Ir)}),this.tookAlong.size>0&&(this.result.tookAlong={count:this.tookAlong.size,objects:[...new Set(this.tookAlong.values())]}),this.cameAlong.size>0&&(this.result.cameAlong={count:this.cameAlong.size,objects:[...new Set(this.cameAlong.values())]}),this.result}};async function ss(r,t,e){let n=re(t)?t:qe(t),o=n,i=o.objects.reduce((p,S)=>p+S.count,0),a=new Map,s=p=>a.get(p)??0,d=()=>e.signal?.aborted===!0,f=e.splitting??vt(),c=()=>({objects:kn([],o.objects,s),cancelled:!0,gone:[],stamps:{},left:()=>Dn(n)}),u=new Map,l=new Map;for(let{objectApiName:p}of o.objects){let S=Pn();u.set(p,S);let O=0;for await(let A of o.pages(p)){if(d())return c();let v=A[0];v!==void 0&&!l.has(v.slice(0,3))&&l.set(v.slice(0,3),p);let E=O;if(O+=A.length,S.error!==void 0)continue;let D=await Br(r,p,A,E,S);if(S.error!==void 0||D.length===0)continue;if(d())return c();let B=await cn(r,p,D);if("error"in B)S.binError=B.error;else for(let q of B.deleted)S.binned.add(q)}}let g=new Map,m=!1,h=r.bulkDestroy?.bind(r),R={query:p=>r.query(p),destroy:(p,S)=>(m=!0,r.destroy(p,S)),...h?{bulkDestroy:(p,S)=>(m=!0,h(p,S,e.signal))}:{},update:(p,S)=>(m=!0,r.update(p,S)),serverTime:()=>r.serverTime(),userId:()=>r.userId(),queryDeleted:p=>r.queryDeleted(p),describeGlobal:()=>r.describeGlobal(),describe:p=>{let S=g.get(p);return S||(S=r.describe(p),g.set(p,S)),S}},y=fn(R,{includeChanged:e.includeChanged}),w=await _e(y,o.objects),k=await jr(y,w,(p,S)=>S-(u.get(p)?.missing.size??0)),I=new Set(k.map(p=>p.objectApiName));if(k.length>0&&e.onUndeletable&&e.previewOnly!==!0){if(d())return c();if(!await e.onUndeletable(k))return{...c(),objects:[],undeletable:k,stoppedForUndeletable:!0}}let[P,_]=await Promise.all([Ur(y),e.previewOnly===!0?void 0:$r(y)]),{start:G,end:K}=wt(e,u.values(),P.aheadMs);if(d())return c();let oe=Er(e.otherParts,e.otherPartRecords),We=Pr(e.otherParts,e.otherPartRecords),De=await xr(y,o,{start:G,end:K,...e.runUserId?{user:b(e.runUserId)}:{},...oe?{otherParts:{has:p=>oe.has(p),objects:We}}:{},undeletable:I,snapshots:u}),fe=[];if(e.runUserId&&e.alongAccepted!==!0){let p=await dn(y,{has:S=>o.has(S),start:G,end:K,user:e.runUserId});if(p.length>0&&!o.objects.some(S=>S.objectApiName===le)&&await Cn(y,le)){De.push({objectApiName:le,copies:p});for(let S of p)fe.push(S.id)}}if(De.length>0){o=await Fr(o,De,u,l);for(let{objectApiName:p,copies:S}of De)a.set(p,S.length);i=o.objects.reduce((p,S)=>p+S.count,0),w=await _e(y,o.objects)}let vn=new Map(Object.entries(e.removalStamps??{}).map(([p,S])=>[b(p),N(S)])),Tn=In(e.laterParts,P.aheadMs),se=new Set;for(let{objectApiName:p}of o.objects){let S=u.get(p);if(!S||S.error!==void 0)continue;let O=0;for await(let A of o.pages(p))for(let v of A){let E=S.modified.at(O++),D=b(v);if(S.missing.has(D))continue;E<=K||E<=(vn.get(D)??Number.NaN)||E<=(Tn.get(D)??Number.NaN)||se.add(D)}}if(e.previewOnly===!0){if(d())return c();let p=new Set,S=new Set,O=await Lr(y,o,w,{snapshots:u,changed:se,undeletable:I,includeChanged:e.includeChanged,stopped:d,copiesOf:s,kept:S,...e.previewHeld===!0?{held:{notSent:p,check:new Ae(y,{runRecords:o,reached:{has:()=>!1},stays:A=>p.has(A),runStart:G,runEnd:K,removalStart:P.start,removalUser:void 0,earlierRemovals:(e.removalSpans??[]).map(A=>({start:N(A.first),end:N(A.last),user:b(A.userId)})),includeChanged:e.includeChanged,previewing:!0,...e.goesWithParent?{goesWithParent:e.goesWithParent}:{},...e.goesWithParentReadBelow?{goesWithParentReadBelow:!0}:{},...e.alongAccepted?{alongAccepted:e.alongAccepted}:{},...e.runUserId?{runUser:b(e.runUserId)}:{},...e.laterParts?{linkedLater:yt(e.laterParts,"linked",P.aheadMs)}:{},...oe?{otherPartRecords:oe,otherPartObjects:We}:{}})}}:{}});return O?{...k.length>0?{undeletable:k}:{},objects:[],cancelled:!1,gone:[],stamps:{},left:()=>Dn(n),preview:O,...fe.length>0?{duplicateSets:fe}:{},...S.size>0?{previewKept:S}:{}}:c()}let St=await _r(y,e.otherParts??[],P.aheadMs,d);if(!St)return c();let kt=new Set,jn={has:p=>o.has(p)&&kt.has(l.get(p.slice(0,3))??"")},Ve=new Ae(y,{runRecords:o,reached:jn,stays:p=>se.has(p)&&!e.includeChanged,runStart:G,runEnd:K,removalStart:P.start,removalUser:_,earlierRemovals:(e.removalSpans??[]).map(p=>({start:N(p.first),end:N(p.last),user:b(p.userId)})),includeChanged:e.includeChanged,...e.goesWithParent?{goesWithParent:e.goesWithParent}:{},...e.goesWithParentReadBelow?{goesWithParentReadBelow:!0}:{},...e.alongAccepted?{alongAccepted:e.alongAccepted}:{},...e.alongToDraft?{alongToDraft:e.alongToDraft}:{},...e.runUserId?{runUser:b(e.runUserId)}:{},...e.automationMade?{automationMade:Ln(e.automationMade)}:{},...e.laterParts?{linkedLater:yt(e.laterParts,"linked",P.aheadMs)}:{},...oe?{otherPartRecords:oe,otherPartObjects:We}:{}});if(d())return c();await e.beforeFirstWrite?.(),e.sweep&&await e.sweep(f)&&(m=!0);let Y=[],Ot=p=>Y.find(S=>S.result.objectApiName===p);async function*Ke(p,S,O){for(let{objectApiName:A}of S){let v=Ot(A),E=0;for await(let D of p.pages(A)){let B=D.filter(q=>O(A,q,v?.isGone(q,E++)===!0));B.length>0&&(yield{objectApiName:A,ids:B})}}}let _n=()=>Ke(o,w,(p,S,O)=>{let A=u.get(p),v=b(S);return A?.modifiedColumn==="LastModifiedDate"&&!A.missing.has(v)&&!se.has(v)&&!O}),Ie=[],$=async p=>{await sn(y,Ie,{note:(D,B,q)=>{let U=Ot(D);if(!U){if(!q)return;let W=o.objects.find(V=>V.objectApiName===D);U=new Oe(D,W?.count??0,s(D)),Y.push(U)}U.note(B)}});let S=m?await On(y,_n(),{start:P.start,user:_}):{},O=[];if(m)for(let D of St)O.push(await On(y,D.unchanged(),{start:P.start,user:_}));let A=m?Hr(P,_):void 0,v=[];if(!re(t))for await(let{ids:D}of Ke(n,w,(B,q,U)=>U))for(let B of D)v.push(B);for(let D of Y)D.limitNotes=at(D.result.objectApiName,f);let E=Y.map(D=>D.settle());return{...k.length>0?{undeletable:k}:{},objects:p?kn(E,w,s):E,cancelled:p,gone:v,left:()=>Ke(n,n.objects,(D,B,q)=>!q),stamps:S,...A?{span:A}:{},...O.length>0?{otherPartStamps:O}:{},...fe.length>0?{duplicateSets:fe}:{}}};if(d())return m?$(!0):c();let At=async(p,S)=>(await Ve.heldAmong(p,S)).held,Dt=await ct(y,w,o,(p,S)=>{let O=b(S),A=u.get(p);return A!==void 0&&A.error===void 0&&!I.has(p)&&!A.missing.has(O)&&!(se.has(O)&&!e.includeChanged)},d,At);if(Ie=Dt.drafted,Dt.cancelled)return $(!0);if(e.alongToDraft){let p=await ct(y,e.alongToDraft.objects,e.alongToDraft,()=>!0,d,At);if(Ie=[...Ie,...p.drafted],p.cancelled)return $(!0)}let Q=0;for(let{objectApiName:p,count:S}of w){if(d())return $(!0);let O=new Oe(p,S,s(p));Y.push(O),kt.add(p);let A=u.get(p);if(!A||A.error!==void 0){O.unread={reason:A?.error??"The org gave no reason.",count:S},Q+=S,e.onProgress?.(Q,i,p);continue}if(I.has(p)){let U=0,W=0;for await(let V of o.pages(p))for(let ie of V){let ge=b(ie),xn=U++;A.missing.has(ge)?A.binned.has(ge)?(O.result.alreadyGone++,O.goneAt.add(xn)):O.notVisible++:W++}O.notVisible>0&&(O.notVisibleNote=bt(O.notVisible,A.binError)),W>0&&(O.unread={reason:En(p,W),count:W}),Q+=S,e.onProgress?.(Q,i,p);continue}let v=Xt(y,p,S),E=[],D=new Map,B=async()=>{let U=E,W=D;return E=[],D=new Map,An(y,Ve,O,U,{stopped:d,splitting:f,placeOf:W,onDeleted:V=>{Q+=V,e.onProgress?.(Q,i,p)},onHeld:V=>{Q+=V,e.onProgress?.(Q,i,p)}})},q=0;for await(let U of o.pages(p)){if(d())return $(!0);let W=E.length;for(let V of U){let ie=b(V),ge=q++;A.missing.has(ie)?A.binned.has(ie)?(O.result.alreadyGone++,O.goneAt.add(ge)):O.notVisible++:se.has(ie)&&!e.includeChanged?O.result.keptChanged++:(E.push(V),D.set(ie,ge))}if(O.notVisible>0&&(O.notVisibleNote=bt(O.notVisible,A.binError)),Q+=U.length-(E.length-W),!(v&&E.length<je)&&await B())return $(!0)}if(v&&E.length>0&&(d()||await B()))return $(!0)}let Bn=Y.some(p=>p.result.deleted>0);if(await on(Y,{stopped:d,idsOf:(p,S)=>{if(S>0)return p.waiting();let O=p.refusedToSendAgain();return O.length>0||Bn?[...O,...p.held]:[]},send:async(p,S,O)=>{let A=new Set(O===0?p.refusedToSendAgain():[]),v=await An(y,Ve,p,S,{stopped:d,splitting:f,onSent:E=>{for(let D of E)A.has(D)&&p.secondTry.add(D)}});for(let E of p.held)A.has(E)&&p.secondTry.add(E);return v},deleted:p=>p.result.deleted}))return $(!0);if(e.afterRemoval){if(d())return $(!0);await e.afterRemoval(f)&&(m=!0)}for(let p of Y){if(d())return $(!0);await Tr(y,p,u.get(p.result.objectApiName))}return $(!1)}async function Mr(r,t,e,n,o){let{changed:i,includeChanged:a}=o,s=[];for await(let d of t.pages(e))for(let f of d){let c=b(f);!n.has(c)&&(a||!i.has(c))&&s.push(f)}try{return{kept:await pn(r,e,s,{includeChanged:a})}}catch(d){return{kept:new Set,unread:C(d)}}}async function Lr(r,t,e,n){let o=[],i=new Set,a=new Set;for(let{objectApiName:s,count:d}of e){let f=n.copiesOf(s),c={objectApiName:s,planned:d,toDelete:0,alreadyGone:0,changedSince:0,keptChanged:0,changedBy:{},undeletable:0,notVisible:0,unread:0,...f>0?{platformCopies:f}:{},reasons:[]};o.push(c);let u=n.snapshots.get(s);if(!u||u.error!==void 0){if(c.unread=d,c.reasons.push(u?.error??"The org gave no reason."),n.held)for await(let R of t.pages(s))for(let y of R)n.held.notSent.add(b(y));continue}let l=be(s)&&!n.undeletable.has(s)?await Mr(r,t,s,u.missing,n):void 0,g=[],m=[],h=R=>{n.held?.notSent.add(R)};for await(let R of t.pages(s))for(let y of R){let w=b(y);u.missing.has(w)?u.binned.has(w)?c.alreadyGone++:c.notVisible++:n.undeletable.has(s)?(c.undeletable++,h(w)):l?.unread!==void 0?(c.unread++,h(w)):n.changed.has(w)?(c.changedSince++,g.push(y),n.includeChanged?(c.toDelete++,m.push(y)):(c.keptChanged++,h(w),n.kept?.add(w))):l?.kept.has(w)?(c.changedSince++,c.keptChanged++,h(w),n.kept?.add(w)):(c.toDelete++,m.push(y))}if(n.held&&m.length>0){if(n.stopped())return;let R=await n.held.check.heldAmong(s,m),y=m.filter(k=>R.held.has(b(k)));if(y.length>0){c.toDelete-=y.length,c.keptDependents=y.length,c.heldBy=[...R.holders];for(let I of y)n.held.notSent.add(b(I));let k=y.filter(I=>R.byAutomation.has(b(I)));k.length>0&&(c.heldByAutomation=k.length)}let w=new Map;for(let k of m)if(!R.held.has(b(k)))for(let[I,P]of R.cameAlong.get(b(k))??[])a.has(I)||(a.add(I),w.set(I,P));w.size>0&&(c.cameAlong={count:w.size,objects:[...new Set(w.values())]}),R.reason!==void 0&&c.reasons.push(R.reason),R.unchecked.size>0&&c.reasons.push(`Not checked: what hangs from them through ${[...R.unchecked].join(", ")}, which the org deletes along but does not let be read by the record it hangs from.`)}if(l?.unread!==void 0?c.reasons.push(`Its articles could not be read: ${l.unread}`):l!==void 0&&l.kept.size>0&&c.reasons.push(ut),c.notVisible>0&&c.reasons.push(bt(c.notVisible,u.binError)),c.undeletable>0&&c.reasons.push(En(s,c.undeletable)),!(g.length===0||u.modifiedColumn!=="LastModifiedDate")){if(n.stopped())return;try{let R=await L(r,s,["LastModifiedById"],g,ke);for(let y of R){let w=y.LastModifiedById;typeof w!="string"||w===""||(c.changedBy[w]=(c.changedBy[w]??0)+1,i.add(w))}}catch(R){c.reasons.push(`Who changed them since the run could not be read: ${C(R)}`)}}}if(!n.stopped())return{objects:o,userNames:await vr(r,[...i])}}async function vr(r,t){let e={};if(t.length===0)return e;try{for(let n of await L(r,"User",["Name"],[...t].sort()))typeof n.Id=="string"&&typeof n.Name=="string"&&(e[n.Id]=n.Name)}catch{}return e}async function Tr(r,t,e){let{gone:n,unchecked:o,failure:i}=await dt(t.refusedSent(),a=>L(r,t.result.objectApiName,[],a),a=>e!==void 0&&e.error===void 0&&!e.missing.has(b(a)));for(let a of n)t.refused.delete(a),t.goneLater.add(b(a)),t.result.alreadyGone++;o.length>0&&t.note(`Not checked: ${o.length} refused record(s) could not be read back once the rest had gone, to tell whether a parent deleted after them took them along`+(i?` \u2014 ${i}`:"."))}function is(r,t=[],e={}){return[...new Set([...r,...bn(r,t),...e.userKept===!0&&r.length>0?[le]:[]])]}async function jr(r,t,e){let n=[];for(let{objectApiName:o,count:i}of t){if(o===Dr||i===0)continue;let a=e(o,i);if(a!==0)try{let s=ee.safeParse(await r.describe(o));s.success&&s.data.deletable===!1&&n.push({objectApiName:o,records:a})}catch{}}return n}async function On(r,t,e){let n={},{start:o,user:i}=e;if(i===void 0||!Number.isFinite(o))return n;for await(let{objectApiName:a,ids:s}of t){let d;try{d=await L(r,a,["LastModifiedDate","LastModifiedById"],s)}catch{continue}for(let f of d)typeof f.Id=="string"&&typeof f.LastModifiedDate=="string"&&typeof f.LastModifiedById=="string"&&b(f.LastModifiedById)===i&&N(f.LastModifiedDate)>=o&&(n[f.Id]=f.LastModifiedDate)}return n}async function _r(r,t,e,n){let o=[];for(let i of t){let a=re(i.plan)?i.plan:qe(i.plan),{end:s}=wt(i.span,[],e),d=new Map(Object.entries(i.removalStamps??{}).map(([u,l])=>[b(u),N(l)])),f=In(i.laterParts,e),c=new Map;if(Number.isFinite(s))for(let{objectApiName:u}of a.objects){let l=new ze,g=0,m=!1;for await(let h of a.pages(u)){if(n())return;let R=g;if(g+=h.length,m)continue;let y;try{y=await L(r,u,["LastModifiedDate"],h,ke)}catch{m=!0;continue}let w=new Map;for(let k of y)typeof k.Id=="string"&&w.set(b(k.Id),N(k.LastModifiedDate));h.forEach((k,I)=>{let P=b(k),_=w.get(P);_!==void 0&&(_<=s||_<=(d.get(P)??Number.NaN)||_<=(f.get(P)??Number.NaN))&&l.add(R+I)})}m||c.set(u,l)}o.push({unchanged:async function*(){for(let{objectApiName:u}of a.objects){let l=c.get(u);if(!l)continue;let g=0;for await(let m of a.pages(u)){let h=m.filter(()=>l.has(g++));h.length>0&&(yield{objectApiName:u,ids:h})}}}})}return o}async function An(r,t,e,n,o){let{objectApiName:i}=e.result,a=await t.heldAmong(i,n);a.reason!==void 0&&e.note(a.reason);for(let l of a.unchecked)e.result.unchecked.includes(l)||e.result.unchecked.push(l);let s=n.filter(l=>a.held.has(b(l)));if(o.placeOf){for(let l of s)e.held.push(l);e.result.heldBy=[...new Set([...e.result.heldBy,...a.holders])]}else e.held=s,e.result.heldBy=[...a.holders];for(let l of s)e.refused.delete(l);for(let l of n){let g=b(l),m=a.byAutomation.get(g);m?e.automationHeld.set(g,m):e.automationHeld.delete(g),m&&a.automationAfter.has(g)?e.automationHeldAfter.add(g):e.automationHeldAfter.delete(g),m&&a.automationAlong.has(g)?e.automationHeldAlong.add(g):e.automationHeldAlong.delete(g)}o.onHeld?.(s.length);let d=n.filter(l=>!a.held.has(b(l))),f=new Map,c=(l,g)=>{l.forEach((m,h)=>{let R=g[h],y=b(m);if((R.lockResends!==void 0||e.lockResent.has(y))&&e.lockResent.set(y,R.kind),R.kind==="refused"){e.refused.set(m,{reason:R.reason,dependency:R.dependency,sent:!0,...R.limit?{limit:!0}:{}});return}e.refused.delete(m);let w=o.placeOf?.get(y);if(w!==void 0?e.goneAt.add(w):e.goneLater.add(y),R.kind==="deleted"){e.result.deleted++,w===void 0&&e.deletedLater.add(y);for(let k of f.get(y)??[])e.filesLeft.set(k.key,k.name);for(let[k,I]of a.along.get(y)??[])e.tookAlong.set(k,I);for(let[k,I]of a.cameAlong.get(y)??[])e.cameAlong.set(k,I)}else e.result.alreadyGone++}),o.onSent?.(l),o.onDeleted?.(l.length)},{stopped:u}=await rn(r,i,d,{stopped:o.stopped,splitting:o.splitting,prepare:async l=>{f=await t.filesOn(l)},settle:c});return u}async function Br(r,t,e,n,o){let i,a=o.modifiedColumn?Sn.filter(({modified:s})=>s===o.modifiedColumn):Sn;for(let{created:s,modified:d}of a)try{let c=await L(r,t,s?[s,d]:[d],e,ke),u=new Map;for(let g of c)typeof g.Id=="string"&&u.set(b(g.Id),N(g[d])),s&&(o.firstCreated=Nn(o.firstCreated,N(g[s])),o.lastCreated=Rt(o.lastCreated,N(g[s])));o.modifiedColumn=d;let l=[];return e.forEach((g,m)=>{let h=b(g),R=u.get(h);R===void 0&&(o.missing.add(h),l.push(g)),o.modified.set(n+m,R??Number.NaN)}),l}catch(f){i??=C(f)}return o.error=i,o.modifiedColumn=void 0,[]}async function*Dn(r){for(let{objectApiName:t}of r.objects)for await(let e of r.pages(t))e.length>0&&(yield{objectApiName:t,ids:[...e]})}async function xr(r,t,e){let n=new Set(t.objects.filter(s=>s.count>0).map(s=>s.objectApiName));if(!n.has(Fe))return[];let o=[];for await(let s of t.pages(Fe))o.push(...s);let i=await Rn(r,{has:s=>t.has(s),start:e.start,end:e.end,...e.user!==void 0?{user:e.user}:{},...e.otherParts?{otherParts:e.otherParts}:{}},o,n),a=[];for(let s of i){let{objectApiName:d}=s;if(e.undeletable.has(d))continue;let f=e.snapshots.get(d);if(f){if(f.error!==void 0||f.modifiedColumn!=="LastModifiedDate")continue}else if(!await Cn(r,d))continue;a.push(s)}return a}async function Cn(r,t){try{let e=ee.safeParse(await r.describe(t));return e.success&&e.data.deletable!==!1}catch{return!1}}async function Fr(r,t,e,n){let o=new Map(t.map(({objectApiName:s,copies:d})=>[s,d])),i=new Set(t.flatMap(({copies:s})=>s.map(d=>b(d.id)))),a=r.objects.map(s=>{let d=o.get(s.objectApiName);return d?{objectApiName:s.objectApiName,count:s.count+d.length}:s});for(let[s,d]of o){r.objects.some(l=>l.objectApiName===s)||a.push({objectApiName:s,count:d.length});let f=e.get(s);f||(f={...Pn(),modifiedColumn:"LastModifiedDate"},e.set(s,f));let c=0;for await(let l of r.pages(s))c+=l.length;for(let l of d)f.modified.set(c++,l.modified);let u=d[0]?.id.slice(0,3);u!==void 0&&!n.has(u)&&n.set(u,s)}return{objects:a,pages:async function*(s){yield*r.pages(s);let d=o.get(s);d&&d.length>0&&(yield d.map(f=>f.id))},has:s=>r.has(s)||i.has(s)}}async function Ur(r){let t=Date.now(),e=Number.NaN;try{e=N(await r.serverTime())}catch{}return Number.isFinite(e)?{start:Math.floor(e/1e3)*1e3,aheadMs:e-(t+Date.now())/2}:{start:Number.POSITIVE_INFINITY,aheadMs:Number.NaN}}async function $r(r){try{let t=await r.userId();return typeof t=="string"&&t!==""?b(t):void 0}catch{return}}function Hr(r,t){if(!(t===void 0||!Number.isFinite(r.start)))return{first:new Date(r.start).toISOString(),last:new Date(Date.now()+r.aheadMs+pt).toISOString(),userId:t}}function Nn(r,t){return Number.isNaN(r)||t<r?t:r}function Rt(r,t){return Number.isNaN(r)||t>r?t:r}var Mn=999;function Jr(r,t,e){let n=Number.NaN;for(let o of r)o.lastCreated>=t&&o.lastCreated<=e&&(n=Rt(n,o.lastCreated)),n=Rt(n,o.modified.latestWithin(t,e));return n}function wt(r,t,e){let n=qr(r,t,e),o=(r.writtenUntil?.getTime()??Number.NaN)+Mn;return Number.isFinite(n.end)&&o>n.end?{...n,end:o}:n}function qr(r,t,e){let n=[...t],o=Number.NaN;for(let f of n)o=Nn(o,f.firstCreated);let i=r.runDurationMs??0,a=(r.runRecordedAt?.getTime()??Number.NaN)+e;if(r.runEndedAt===void 0&&Number.isFinite(a)){let f=a-i-pt,c=a+pt,u=r.endedByItsWrites===!0?Jr(n,f,c):Number.NaN;return{start:r.runStartedAt?.getTime()??(o>f?o:f),end:Number.isFinite(u)?Math.min(u+Mn,c):c}}let s=r.runStartedAt?.getTime()??o,d=r.runEndedAt?.getTime()??s+i;return{start:s,end:d}}function Ln(r){let t=new Set,e=-1;return{has:n=>(r.size!==e&&(t=new Set([...r].map(b)),e=r.size),t.has(n))}}function as(r,t){let e=new Ae(r,{runRecords:t.runRecords,reached:{has:()=>!1},stays:()=>!1,runStart:t.runStart,runEnd:t.runEnd,removalStart:Number.POSITIVE_INFINITY,removalUser:void 0,earlierRemovals:(t.removalSpans??[]).map(n=>({start:N(n.first),end:N(n.last),user:b(n.userId)})),includeChanged:t.includeChanged,automationMade:Ln(t.taken),...t.runUserId?{runUser:b(t.runUserId)}:{}});return async(n,o)=>{let i=await e.heldAmong(n,o,1);return{held:i.held,holders:[...i.holders],...i.reason!==void 0?{reason:i.reason}:{}}}}var $e="IsPersonAccount";function zr(r,t){return{holding:new Set([...r.holding,...t.holding]),automation:[...r.automation,...t.automation],along:[...r.along,...t.along],goes:[...r.goes,...t.goes],unchecked:r.unchecked||t.unchecked}}var Wr=50;function He(r,t){return JSON.stringify(t.map(e=>r[e]??null))}var Ae=class{constructor(t,e){this.org=t;this.context=e}org;context;worked;statuses=new Map;lockedUnder=new Map;files=new Map;datesKept=new Map;cascadeEnds=new Map;async heldAmong(t,e,n=0){let o={held:new Set,holders:new Set,otherwise:new Set,mayBeAutomation:[],byAutomation:new Map,automationAfter:new Set,automationAlong:new Set,along:new Map,cameAlong:new Map,unchecked:new Set};if(e.length===0)return o;let i;try{let l=ee.parse(await this.org.describe(t)),g=await this.workedObjects(),m=t==="Account"&&l.fields.some(h=>h.name===$e);i=(l.childRelationships??[]).filter(h=>(h.cascadeDelete===!0||h.restrictedDelete===!0)&&g.has(h.childSObject)).map(h=>({childSObject:h.childSObject,field:h.field,restricted:h.cascadeDelete!==!0,...m&&h.childSObject==="Contact"&&h.field==="AccountId"?{personContacts:!0}:{}}))}catch(l){return o.reason=C(l),e.forEach(g=>this.hold(o,b(g))),o}let a=[];for(let l=0;l<e.length;l+=z)a.push(e.slice(l,l+z));let s=a.length>1?await Xe(i.map(l=>()=>this.anyPointing(l)),ke):i.map(()=>!0),d=i.filter((l,g)=>s[g]).flatMap(l=>a.map(g=>async()=>({relationship:l,...await this.holdingIn(l,g)}))),f=o.mayBeAutomation,c=new Map;for(let{relationship:l,holding:g,unchecked:m,automation:h,along:R,goes:y}of await Xe(d,ke)){m&&o.unchecked.add(l.childSObject),(g.size>0||h.length>0)&&o.holders.add(l.childSObject),g.forEach(w=>this.hold(o,w));for(let w of h)o.held.add(b(w.parent));f.push(...h);for(let{parent:w,key:k}of R){let I=o.along.get(w)??new Map;I.set(k,l.childSObject),o.along.set(w,I)}y.length>0&&c.set(l.childSObject,[...c.get(l.childSObject)??[],...y])}if(await this.heldBelow(c,o,n),n>0)return o;this.context.previewing!==!0&&await this.lockedPastDraft(t,e,o),Pe(t)&&await this.standardPricesHeld(e,o),t===Ye&&await this.sellingModelOptionsHeld(e,o),this.context.alongAccepted!==!0&&await this.automationHeldBelow(f,o);let u=await this.byAutomationOnly(t,f,o.otherwise);return o.byAutomation=u.objects,o.automationAfter=u.after,o.automationAlong=u.along,o}hold(t,e){t.held.add(e),t.otherwise.add(e)}async heldBelow(t,e,n){let o=(i,a,s,d)=>{let f=i.get(a)??new Map;f.set(s,d),i.set(a,f)};for(let[i,a]of t){let s=[...new Set(a.map(f=>f.id))],d=n+1<kr?await this.heldAmong(i,s,n+1):void 0;for(let{parent:f,id:c,came:u}of a){let l=b(c);if(!d||d.held.has(l)){this.hold(e,f),e.holders.add(i),d?.holders.forEach(g=>e.holders.add(g));continue}u&&o(e.cameAlong,f,l,i);for(let[g,m]of d.along.get(l)??[])o(e.along,f,g,m);for(let[g,m]of d.cameAlong.get(l)??[])o(e.cameAlong,f,g,m)}d?.unchecked.forEach(f=>e.unchecked.add(f))}}async automationHeldBelow(t,e){let n=new Map;for(let o of t)e.otherwise.has(b(o.parent))||n.set(o.object,[...n.get(o.object)??[],o]);for(let[o,i]of n){let a=await this.heldAmong(o,[...new Set(i.map(s=>s.id))],1);for(let s of i){let d=b(s.id),f=a.mayBeAutomation.some(c=>b(c.parent)===d&&c.creator!==s.creator);!a.otherwise.has(d)&&!f||(this.hold(e,b(s.parent)),a.holders.forEach(c=>e.holders.add(c)))}a.unchecked.forEach(s=>e.unchecked.add(s))}}async byAutomationOnly(t,e,n){let o=new Map,i=new Set,a=e.filter(u=>!n.has(b(u.parent)));if(a.length===0)return{objects:o,after:i,along:new Set};let s;try{let u=await L(this.org,t,["CreatedDate","CreatedById"],[...new Set(a.map(l=>l.parent))]);s=new Map(u.flatMap(l=>typeof l.Id=="string"?[[b(l.Id),l]]:[]))}catch{return{objects:o,after:i,along:new Set}}let d=new Set,f=new Set;for(let u of a){let l=b(u.parent),g=s.get(l),m=N(g?.CreatedDate),h=g?.CreatedById,R=this.context.runUser??(typeof h=="string"?b(h):void 0),y=u.created-m;if(!(R!==void 0&&u.creator===R&&y>=-2e3&&y<=6e4)){d.add(l);continue}let k=o.get(l)??new Set;k.add(u.object),o.set(l,k),u.created>this.context.runEnd&&i.add(l),u.along||f.add(l)}for(let u of d)o.delete(u),i.delete(u);let c=new Set([...o.keys()].filter(u=>!f.has(u)));return{objects:o,after:i,along:c}}async holdingIn(t,e){let n=T(t.childSObject),o=T(t.field),[i]=H(e,e.length),a=new Set(["Id",o,...mt[n]?.ends??[],...t.personContacts?[$e]:[]]),s=this.datesKept.get(n)??0;for(;s<Je.length;){let d=Je[s],f;try{f=await this.org.query(`SELECT ${[...a,...d].join(", ")} FROM ${n} WHERE ${o} IN (${i}) LIMIT ${Ue}`)}catch(R){Cr(R)?(s=Nr(R,s),this.datesKept.set(n,s)):s++;continue}if(f.records.length>=Ue){if(e.length>1){let R=Math.ceil(e.length/2);return zr(await this.holdingIn(t,e.slice(0,R)),await this.holdingIn(t,e.slice(R)))}return{holding:new Set(e.map(b)),automation:[],along:[],goes:[],unchecked:!1}}let c=new Set,u=[],l=[],g=[],m=new Map;for(let R of f.records){if(typeof R!="object"||R===null)continue;let y=R,w=y[t.field];if(typeof w!="string"||typeof y.Id!="string"||(n===wn&&o==="LinkedEntityId"&&this.noteFile(y),this.lockedUnder.get(b(y.Id))===b(w)))continue;let k={onlyIncluded:!1};if(!this.stays(y,n,t.restricted,t.personContacts,k)){if(k.onlyIncluded&&l.push({parent:b(w),key:b(y.Id)}),n!==wn&&this.goesAlongUnread(y)){let _=!(mt[n]?.cameWithRun(y,this.context.runRecords)===!0||t.personContacts===!0&&y[$e]===!0)&&!k.onlyIncluded&&k.byRemoval!==!0&&this.context.goesWithParent?.(y,this.context.runEnd)!==!0;g.push({parent:b(w),id:y.Id,came:_})}continue}let I=this.mayBeAutomation(y);if(I){let P={parent:w,id:y.Id,object:n,along:!t.restricted,...I};u.push(P),t.restricted&&m.set(y.Id,P)}else c.add(b(w))}let h=await this.ofOtherParts(n,[...m.keys()]);for(let[R,y]of m)h.has(b(R))&&(u.splice(u.indexOf(y),1),c.add(b(y.parent)));return{holding:c,automation:u,along:l,goes:g,unchecked:!1}}return{holding:new Set,automation:[],along:[],goes:[],unchecked:!t.restricted}}goesAlongUnread(t){let e=b(t.Id),{runRecords:n,otherPartRecords:o,automationMade:i,goesWithParent:a,runEnd:s}=this.context;return this.context.alongAccepted!==!0&&!n.has(e)&&o?.has(e)!==!0&&i?.has(e)!==!0&&(this.context.goesWithParentReadBelow===!0||a?.(t,s)!==!0)}async ofOtherParts(t,e){let n=new Set,{otherPartRecords:o,otherPartObjects:i,runRecords:a}=this.context;if(e.length===0||!o||!i)return n;let s=this.cascadeEnds.get(t);s||(s=(async()=>{let c=new Set;for(let u of i)try{let l=ee.parse(await this.org.describe(u));for(let g of l.childRelationships??[])g.childSObject===t&&g.cascadeDelete===!0&&c.add(g.field)}catch{}return[...c]})(),this.cascadeEnds.set(t,s));let d=await s;if(d.length===0)return n;let f;try{f=await L(this.org,t,d,e)}catch{return n}for(let c of f){if(typeof c.Id!="string")continue;let u=d.flatMap(l=>{let g=c[l];return typeof g=="string"?[b(g)]:[]});u.some(l=>a.has(l))||u.some(l=>o.has(l))&&n.add(b(c.Id))}return n}mayBeAutomation(t){let{runRecords:e,runStart:n,runEnd:o,runUser:i,otherPartRecords:a}=this.context;if(typeof t.Id!="string"||e.has(b(t.Id))||a?.has(b(t.Id))===!0||typeof t.CreatedById!="string")return;let s=b(t.CreatedById);if(i!==void 0&&s!==i)return;let d=N(t.CreatedDate);if(!(d>=n-2e3&&d<=o+6e4))return;let f=N(t.LastModifiedDate),c=typeof t.LastModifiedById=="string"?b(t.LastModifiedById):void 0;if(!(f>o&&c!==void 0&&c!==s))return{created:d,creator:s}}async anyPointing(t){try{let e=T(t.childSObject),n=T(t.field);return(await this.org.query(`SELECT Id FROM ${e} WHERE ${n} != null LIMIT 1`)).records.length>0}catch{return!0}}noteFile(t){let e=t.LinkedEntityId,n=t.ContentDocumentId;if(typeof e!="string"||typeof n!="string"||ue(n,this.context.runRecords))return;let o=this.files.get(b(e))??new Set;o.add(n),this.files.set(b(e),o)}async filesOn(t){let e=new Map;for(let i of t){let a=this.files.get(b(i));a&&a.size>0&&e.set(b(i),[...a])}let n=[...new Set([...e.values()].flat())];if(n.length===0)return new Map;let o=new Map;try{for(let i of await L(this.org,Ar,["Title"],n))typeof i.Id=="string"&&typeof i.Title=="string"&&i.Title!==""&&o.set(b(i.Id),i.Title)}catch{}return new Map([...e].map(([i,a])=>[i,a.map(s=>({key:b(s),name:o.get(b(s))??s}))]))}async lockedPastDraft(t,e,n){for(let[o,i]of Object.entries(Nt)){let a=i.find(l=>l.object===t)?.lookup,s=pe[o];if(!a||!s)continue;let d=await this.statusCategoriesOf(s);if(!d)continue;let f,c;try{f=await L(this.org,t,[a],e);let l=[...new Set(f.map(g=>g[a]).filter(g=>typeof g=="string"))];c=l.length>0?await L(this.org,o,["Status"],l):[]}catch{continue}let u=new Set(c.filter(l=>{let g=d.categoryOf.get(String(l.Status));return g!==void 0&&g!=="Draft"}).map(l=>b(String(l.Id))));for(let l of f){let g=l[a];typeof l.Id!="string"||typeof g!="string"||u.has(b(g))&&(this.hold(n,b(l.Id)),n.holders.add(o),this.lockedUnder.set(b(l.Id),b(g)))}}}statusCategoriesOf(t){let e=this.statuses.get(t);return e||(e=Ce(de(this.org),t),this.statuses.set(t,e)),e}async standardPricesHeld(t,e){try{let n=de(this.org),o=[...await he(n,t)];if(o.length===0)return;let i=await this.priceKeyFields(),a=await L(this.org,X,i,o),s=await this.pricesOfProducts(a,i),d=s.flatMap(l=>typeof l.Id=="string"?[l.Id]:[]),f=new Set([...await he(n,d)].map(b)),c=new Set(t.map(b)),u=new Set;for(let l of s){if(typeof l.Id!="string")continue;let g=b(l.Id);if(f.has(g))continue;(c.has(g)?e.held.has(g):this.stays(l,X,!0))&&u.add(He(l,i))}for(let l of a)typeof l.Id!="string"||!u.has(He(l,i))||(this.hold(e,b(l.Id)),e.holders.add(X))}catch{}}async sellingModelOptionsHeld(t,e){let n=[me,Ge];try{let o=await L(this.org,Ye,n,t),i=await this.pricesOfProducts(o,[...n,"IsActive"]),a=new Set(i.filter(s=>typeof s.Id=="string"&&s.IsActive===!0&&this.stays(s,X,!0)).map(s=>He(s,n)));for(let s of o)typeof s.Id!="string"||!a.has(He(s,n))||(this.hold(e,b(s.Id)),e.holders.add(X))}catch{}}async priceKeyFields(){let t=ee.parse(await this.org.describe(X)),e=new Set(t.fields.map(n=>n.name));return[me,...[Ge,Mt].filter(n=>e.has(n))]}async pricesOfProducts(t,e){let n=[...new Set(t.map(a=>a[me]).filter(a=>typeof a=="string"))],o=[...new Set(["Id",...e])].map(T).join(", "),i=[];for(let a of H(n,Wr)){let s=await this.org.query(`SELECT ${o} FROM ${X} WHERE ${me} IN (${a}) LIMIT ${Ue}`);if(s.records.length>=Ue)throw new Error("More prices than one read takes.");for(let d of s.records)typeof d=="object"&&d!==null&&i.push(d)}return i}stays(t,e,n=!1,o=!1,i){let a=b(t.Id),{runRecords:s,reached:d,runStart:f,runEnd:c,removalStart:u,removalUser:l,earlierRemovals:g,includeChanged:m}=this.context;if(s.has(a))return d.has(a)||this.context.stays(a);if(n)return!0;if(this.context.automationMade?.has(a)===!0||this.context.goesWithParent?.(t,c)===!0||this.context.alongToDraft?.has(a)===!0||mt[e]?.cameWithRun(t,s))return!1;if(o&&t[$e]===!0)return!(N(t.LastModifiedDate??t.SystemModstamp)<=c)&&!m;let h="CreatedDate"in t?"CreatedDate":"SystemModstamp"in t?"SystemModstamp":void 0;if(!h)return!0;let R=N(t[h]),y=N(h==="CreatedDate"?t.LastModifiedDate:t.SystemModstamp);if(!(R>=f))return!0;let w=this.context.linkedLater?.get(a);if(w&&(R<=c||R>=w.start)&&y<=w.end)return!1;let k=typeof t.CreatedById=="string"?b(t.CreatedById):void 0,I=(_,G)=>_!==void 0&&(_===l&&G>=u||g.some(K=>_===K.user&&G>=K.start&&G<=K.end));if(I(k,R))return i&&(i.byRemoval=!0),!1;if(y<=c)return!1;let P=typeof t.LastModifiedById=="string"?b(t.LastModifiedById):void 0;return R<=c&&I(P,y)?!1:(m&&i&&(i.onlyIncluded=!0),!m)}workedObjects(){return this.worked??=Lt(this.org),this.worked}};export{Me as a,zt as b,$n as c,Hn as d,ee as e,Wn as f,to as g,no as h,ro as i,Kn as j,oo as k,Le as l,tt as m,je as n,ye as o,bo as p,it as q,tr as r,rr as s,Xt as t,tn as u,at as v,nn as w,rn as x,on as y,_e as z,dt as A,ar as B,ct as C,Ao as D,sn as E,Rn as F,le as G,ur as H,pt as I,re as J,ts as K,ns as L,rs as M,os as N,ss as O,is as P,as as Q};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g,h}from"./chunk-QKEKG2LD.mjs";import"./chunk-KAZS5Z6W.mjs";import"./chunk-FITPY3L4.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};
7
+ import{a,b,c,d,e,f,g,h}from"./chunk-RCW5BZNW.mjs";import"./chunk-JRLYWVF4.mjs";import"./chunk-5JMQXHJ2.mjs";import"./chunk-HLROVOR6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-GP5J3DGS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};