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
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c}from"./chunk-OLCVHL7I.mjs";import"./chunk-DPMRIMUC.mjs";import"./chunk-SI267LYR.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-KAZS5Z6W.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-EPFCERGL.mjs";import"./chunk-IUM4NFKI.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as DX_PROJECT_FILE,b as scenarioProjectOf,c as writeRunTestFile};
@@ -1,8 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a as w,b as x}from"./chunk-KAZS5Z6W.mjs";import{b as R}from"./chunk-EPFCERGL.mjs";import{g as k}from"./chunk-PMN4PAC3.mjs";import{Ia as g,La as l,Sb as h}from"./chunk-PMWAFDUB.mjs";import{b as d,m as S,s as u,v as f}from"./chunk-WZQEK4WT.mjs";import{createHash as $}from"node:crypto";import{mkdir as y,readFile as C,rename as P,writeFile as O}from"node:fs/promises";import*as a from"node:path";var A=k,N=d().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"A record id"),p=S({version:f(1),runId:d().min(1).max(200),packId:g,packFingerprint:d().regex(/^[0-9a-f]{64}$/,"A sha256, in lower-case hexadecimal"),compile:l.refine(e=>e.seed!==void 0,{message:"The seed the pack was compiled with is kept",path:["seed"]}),openCases:u(d().min(1).max(255),N),agent:h.optional()});function F(e){return $("sha256").update(m(e)).digest("hex")}function v(e){let r={};for(let i of e.compiled.tests){let n=i.openCase?.caseKey;if(n===void 0)continue;let t=e.caseIds[n];t!==void 0&&(r[n]=t)}return p.parse({version:1,runId:e.runId,packId:e.pack.id,packFingerprint:F(e.pack),compile:{...e.options,seed:e.compiled.seed},openCases:r})}function D(e,r){return p.parse({...e,agent:r})}function U(e,r){if(r.id!==e.packId)return{ok:!1,message:`The run was seeded from the scenario ${e.packId}, not ${r.id}`};if(F(r)!==e.packFingerprint)return{ok:!1,message:`The scenario ${r.id} has changed since the run: its tests would be about subjects and addresses no record of the run holds`};try{return{ok:!0,compiled:x(r,e.compile)}}catch(i){if(i instanceof w)return{ok:!1,message:i.message};throw i}}function Z(){return{readFile:e=>C(e,"utf8"),writeFile:(e,r)=>O(e,r,"utf8"),rename:(e,r)=>P(e,r),mkdir:async e=>{await y(e,{recursive:!0})}}}function I(e,r){return a.join(e,R,`${r.replace(/[^A-Za-z0-9_-]/g,"_")}${A}`)}async function K(e,r,i){let n=p.parse(i),t=I(r,n.runId),o=`${t}.${process.pid}.tmp`;return await e.mkdir(a.dirname(t)),await e.writeFile(o,`${JSON.stringify(n,null,2)}
8
- `),await e.rename(o,t),t}async function X(e,r,i){let n=I(r,i),t;try{t=await e.readFile(n)}catch(c){if(c.code==="ENOENT")return{kind:"absent"};throw c}let o;try{o=JSON.parse(t)}catch{return{kind:"invalid",message:`${a.basename(n)} is not JSON`}}let s=p.safeParse(o);if(!s.success){let c=s.error.issues[0];return{kind:"invalid",message:`${a.basename(n)}: ${c.path.join(".")||"the file"}: ${c.message}`}}return s.data.runId!==i?{kind:"invalid",message:`${a.basename(n)} is the companion of the run ${s.data.runId}, not ${i}`}:{kind:"read",sidecar:s.data}}function m(e){return Array.isArray(e)?`[${e.map(r=>m(r??null)).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,i])=>i!==void 0).sort(([i],[n])=>i<n?-1:i>n?1:0).map(([i,n])=>`${JSON.stringify(i)}:${m(n)}`).join(",")}}`:JSON.stringify(e??null)}export{A as a,p as b,F as c,v as d,D as e,U as f,Z as g,I as h,K as i,X as j};
@@ -1,10 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a as C}from"./chunk-4TLYUZD5.mjs";import{createHash as v}from"node:crypto";var I=new Set(["unmanaged","beta","released"]);function _(c){let{namespacePrefix:a,manageableState:n}=c;return typeof a!="string"||a===""?!1:typeof n!="string"||!I.has(n)}function S(c){let a;try{a=JSON.parse(c)}catch{return!1}return typeof a!="object"||a===null?!1:_(a)}function x(c,a){let n=new Set;for(let t of[c,a])for(let[o,i]of t)S(i)&&n.add(o);let s=t=>new Map([...t].filter(([o])=>!n.has(o)));return{source:s(c),target:s(a),leftOut:n.size}}var N={components:500,seconds:90},k=4,B=3,D=30,w=240,b=class{fetchMetadata;diffEngine;reader;budget;now;constructor(a,n,s,t={}){this.fetchMetadata=a,this.diffEngine=n,this.reader=s,this.budget=t.budget??N,this.now=t.now??Date.now}async compare(a,n,s,t={includeManaged:!0},o){let i=[],d=0;for(let e of s){o?.throwIfAborted();let[p,r]=await Promise.all([this.fetchMetadata(a,e),this.fetchMetadata(n,e)]);if(t.includeManaged){i.push({componentType:e,source:p,target:r});continue}let{source:f,target:g,leftOut:h}=x(p,r);d+=h,i.push({componentType:e,source:f,target:g})}let l=O(i,e=>this.reader.batchSize(e),this.budget.components),m=await this.readPlanned(a,n,l.toRead,o);o?.throwIfAborted();let u=[];for(let{componentType:e,source:p,target:r}of i)u.push(...this.judge(e,p,r,l.toRead.get(e)??[],l.notCompared.get(e)??new Map,m.get(e)));return{items:u,managedLeftOut:d}}async readPlanned(a,n,s,t){let i=this.now()+this.budget.seconds*1e3,d=new Map,l=[];for(let[e,p]of s){let r={source:new Map,target:new Map,unread:new Set};d.set(e,r);let f=this.reader.batchSize(e)??p.length;for(let g=0;g<p.length;g+=f){let h=p.slice(g,g+f);l.push(async()=>{if(t?.throwIfAborted(),this.now()>=i){for(let M of h)r.unread.add(M);return}let[P,A]=await Promise.all([this.readOne(a,e,h,t),this.readOne(n,e,h,t)]);for(let[M,y]of P)r.source.set(M,y);for(let[M,y]of A)r.target.set(M,y)})}}let m=0,u=async()=>{for(;m<l.length;){let e=l[m];m+=1,await e()}};return await Promise.all(Array.from({length:Math.min(k,l.length)},u)),d}async readOne(a,n,s,t){try{return await this.reader.read(a,n,s)}catch(o){return t?.throwIfAborted(),C.warn(`[compare] reading ${s.length} ${n} failed: ${o instanceof Error?o.message:String(o)}`),new Map}}judge(a,n,s,t,o,i){let d=new Map(n),l=new Map(s),m=new Map,u=new Map(o);for(let e of t){let p=i?.source.get(e),r=i?.target.get(e);i?.unread.has(e)?u.set(e,"over_budget"):p===null||r===null?u.set(e,"unreadable"):p===void 0||r===void 0?u.set(e,"read_failed"):(d.set(e,T(p)),l.set(e,T(r)),m.set(e,{source:p,target:r}))}return this.diffEngine.diff(d,l,a,u).map(e=>{let p=[n,s].some(f=>{let g=f.get(e.fullName);return g!==void 0&&S(g)}),r=p?{...e,managed:p}:e;if(r.status==="modified"){let f=m.get(r.fullName),g=f?F(f.source,f.target):void 0;return{...r,sourceValue:g?.source,targetValue:g?.target}}return r.status==="unchanged"?{...r,sourceValue:void 0,targetValue:void 0}:r})}};function O(c,a,n){let s=new Map,t=new Map,o=[],i=[];for(let{componentType:u,source:e,target:p}of c){let r=[...e.keys()].filter(g=>p.has(g)).sort(),f=new Map;if(t.set(u,f),a(u)===void 0){for(let g of r)f.set(g,"unreadable");o.push([]),i.push([]);continue}o.push(r.filter(g=>e.get(g)!==p.get(g))),i.push(r.filter(g=>e.get(g)===p.get(g)))}let d=R(o.map(u=>u.length),n),l=d.reduce((u,e)=>u+e,0),m=R(i.map(u=>u.length),n-l);return c.forEach(({componentType:u},e)=>{let p=t.get(u)??new Map,r=[...o[e].slice(0,d[e]),...i[e].slice(0,m[e])];for(let f of o[e].slice(d[e]))p.set(f,"over_budget");for(let f of i[e].slice(m[e]))p.set(f,"over_budget");r.length>0&&s.set(u,r)}),{toRead:s,notCompared:t}}function R(c,a){let n=c.map(()=>0),s=c.map((i,d)=>d).sort((i,d)=>c[i]-c[d]),t=Math.max(0,a),o=s.length;for(let i of s){let d=Math.min(c[i],Math.floor(t/o));n[i]=d,t-=d,o-=1}return n}function T(c){return v("sha256").update(c).digest("hex")}function F(c,a){let n=c.split(`
8
- `),s=a.split(`
9
- `),t=0;for(;t<n.length&&t<s.length&&n[t]===s[t];)t+=1;let o=Math.max(0,t-B);return{source:E(n,o),target:E(s,o)}}function E(c,a){let n=Math.min(c.length,a+D),s=String(n).length,t=c.slice(a,n).map((o,i)=>{let d=o.length>w?`${o.slice(0,w)}\u2026`:o;return`${String(a+i+1).padStart(s)}\u2502 ${d}`});return a>0&&t.unshift("\u2026"),n<c.length&&t.push("\u2026"),t.join(`
10
- `)}export{_ as a,S as b,N as c,b as d,O as e,F as f};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g,h,i}from"./chunk-KZTZDC7H.mjs";import"./chunk-SI267LYR.mjs";import"./chunk-KAZS5Z6W.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-EPFCERGL.mjs";import"./chunk-IUM4NFKI.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as SCENARIO_PACK_FILE_SUFFIX,b as SCENARIO_PACK_SEARCH,i as findScenarioPack,e as findScenarioPackFiles,f as listScenarioPacks,c as nodeScenarioPackFiles,d as readScenarioPackText,h as saveScenarioPack,g as scenarioPackText};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- function r(...a){return new RegExp(`(?<![a-z\xE0-\xFF])(?:${a.join("|")})(?![a-z\xE0-\xFF])`)}var p=[{regex:r("sexual orientation","sexual preference","orientation sexuelle"),classification:"Confidential",confidence:.85,label:"sexual_orientation",words:!0},{regex:r("gender identity","gender","sexe?","pronouns?","pronoms?","identit[e\xE9] de genre"),classification:"PII",confidence:.85,label:"gender",words:!0},{regex:r("salutations?","civility","honorifics?","civilit[e\xE9]s?"),classification:"PII",confidence:.8,label:"salutation",words:!0},{regex:r("marital status","marital","situation familiale","situation matrimoniale"),classification:"PII",confidence:.85,label:"marital_status",words:!0},{regex:r("nationality","nationalities","citizenship","nationalit[e\xE9]s?","citoyennet[e\xE9]"),classification:"PII",confidence:.85,label:"nationality",words:!0},{regex:r("ethnicity","ethnic","race","racial","ethnie","ethnique"),classification:"Confidential",confidence:.85,label:"ethnic_origin",words:!0},{regex:r("religion","religions","religious","religieux","religieuse"),classification:"Confidential",confidence:.85,label:"religion",words:!0},{regex:r("political (?:opinion|affiliation|party|view)s?","opinions? politiques?","parti politique"),classification:"Confidential",confidence:.85,label:"political_opinion",words:!0},{regex:r("trade union","labou?r union","union member(?:ship)?","syndicat","syndicale?"),classification:"Confidential",confidence:.85,label:"union_membership",words:!0},{regex:r("disability","disabilities","handicaps?"),classification:"PHI",confidence:.85,label:"disability",words:!0}],d=/(?<![a-z])(?:(?:first|last|middle|maiden)[\s_]?name(?:local)?|surname|suppliedname)(?![a-z])/,g=new Set(["string","textarea","encryptedstring"]);function C(a){return d.test(a.toLowerCase().replace(/__c$/i,""))}var u=new Set(["string","textarea","encryptedstring"]),I=new Set(["email","emails","mail","mails","courriel","courriels"]),m=new Set(["ToAddress","CcAddress","BccAddress"]),P=new Set(["phone","phones","telephone","tel","mobile","cell","fax","sms","gsm","whatsapp","portable"]);function f(a){return a.replace(/__[a-z]+$/i,"").replace(/^[a-z0-9]+__/i,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([A-Za-z])(\d)/g,"$1 $2").replace(/(\d)([A-Za-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(i=>i!=="").map(i=>i.toLowerCase())}function h(a,i){let n=i.toLowerCase();if(n==="email")return"email";if(n==="phone")return"phone";if(!u.has(n))return;if(m.has(a))return"email";let e;for(let t of f(a))I.has(t)||t.endsWith("email")?e="email":(P.has(t)||t.endsWith("phone"))&&(e="phone");return e}function N(a,i){let n=new Set(a.detectPII("unknown",i.map(e=>({apiName:e.name,label:e.name,type:e.type}))).piiFields.map(e=>e.fieldApiName));return i.filter(e=>n.has(e.name)||h(e.name,e.type)!==void 0).map(e=>e.name)}var l=class{namePatterns;contentPatterns;constructor(){this.namePatterns=x(),this.contentPatterns=_()}detectPII(i,n,e){let t=new Map;for(let s of n)this.detectByName(s,t),this.detectByType(s,t);if(e&&e.length>0)for(let s of n)this.detectByContent(s,e,t);let c=Array.from(t.values());return{objectName:i,totalFields:n.length,piiFields:c,riskLevel:w(c.length)}}getPatterns(){let i={};for(let n of this.contentPatterns)i[n.label]=n.regex;return i}detectByName(i,n){let e=i.apiName.toLowerCase().replace(/__c$/i,""),t=f(i.apiName).join(" "),c=i.label.toLowerCase(),s=i.type.toLowerCase();for(let o of this.namePatterns){if(o.types&&!o.types.has(s))continue;let b=o.words?t:e;if(o.regex.test(b)||o.regex.test(c)){this.addDetection(n,i,{classification:o.classification,detectionMethod:"name_pattern",confidence:o.confidence,pattern:o.label});return}}}detectByType(i,n){if(n.has(i.apiName))return;let e=i.type.toLowerCase();e==="email"?this.addDetection(n,i,{classification:"PII",detectionMethod:"type_analysis",confidence:.95,pattern:"email_type"}):e==="phone"&&this.addDetection(n,i,{classification:"PII",detectionMethod:"type_analysis",confidence:.9,pattern:"phone_type"})}detectByContent(i,n,e){if(!e.has(i.apiName))for(let t of this.contentPatterns){let c=y(i.apiName,n,t.regex);if(c>0){let s=c/n.length,o=t.confidence*Math.min(s*2,1);this.addDetection(e,i,{classification:t.classification,detectionMethod:"content_pattern",confidence:o,pattern:t.label});return}}}addDetection(i,n,e){let t=i.get(n.apiName);t&&t.confidence>=e.confidence||i.set(n.apiName,{fieldApiName:n.apiName,fieldLabel:n.label,classification:e.classification,detectionMethod:e.detectionMethod,confidence:e.confidence,pattern:e.pattern})}};function x(){return[{regex:/\bemail\b/i,classification:"PII",confidence:.95,label:"email"},{regex:/\bphone\b/i,classification:"PII",confidence:.9,label:"phone"},{regex:/\bmobilephone\b/i,classification:"PII",confidence:.9,label:"mobile_phone"},{regex:/\bpersonemail\b/i,classification:"PII",confidence:.95,label:"person_email"},{regex:/\bmailingstreet\b/i,classification:"PII",confidence:.85,label:"mailing_street"},{regex:/\bbillingstreet\b/i,classification:"PII",confidence:.85,label:"billing_street"},{regex:/\bssn\b/i,classification:"PII",confidence:.99,label:"ssn"},{regex:/\bsocialsecuritynumber\b/i,classification:"PII",confidence:.99,label:"social_security_number"},{regex:/\bsocial_security\b/i,classification:"PII",confidence:.99,label:"social_security"},{regex:/\bbirthdate\b/i,classification:"PII",confidence:.9,label:"birthdate"},{regex:/\bdateofbirth\b/i,classification:"PII",confidence:.9,label:"date_of_birth"},{regex:/\bdate_of_birth\b/i,classification:"PII",confidence:.9,label:"date_of_birth_underscore"},{regex:/\bnationalid\b/i,classification:"PII",confidence:.95,label:"national_id"},{regex:/\bnational_id\b/i,classification:"PII",confidence:.95,label:"national_id_underscore"},{regex:/\bcreditcardnumber\b/i,classification:"PCI",confidence:.99,label:"credit_card_number"},{regex:/\bcreditcard\b/i,classification:"PCI",confidence:.95,label:"credit_card"},{regex:/\bcredit_card\b/i,classification:"PCI",confidence:.95,label:"credit_card_underscore"},{regex:/\biban\b/i,classification:"PCI",confidence:.95,label:"iban"},{regex:/\bbankaccount\b/i,classification:"PCI",confidence:.95,label:"bank_account"},{regex:/\bbank_account\b/i,classification:"PCI",confidence:.95,label:"bank_account_underscore"},{regex:/\bmedical\b/i,classification:"PHI",confidence:.85,label:"medical"},{regex:/\bdiagnos/i,classification:"PHI",confidence:.9,label:"diagnosis"},{regex:/\bhealth\b/i,classification:"PHI",confidence:.8,label:"health"},{regex:/\bpatient\b/i,classification:"PHI",confidence:.8,label:"patient"},{regex:/\bpassport\b/i,classification:"PII",confidence:.95,label:"passport"},{regex:/\bdriver.?licen/i,classification:"PII",confidence:.95,label:"driver_license"},{regex:/\baddress\b/i,classification:"PII",confidence:.8,label:"address"},{regex:d,classification:"PII",confidence:.85,label:"person_name",types:g},...p]}function _(){return[{regex:/[\w.-]+@[\w.-]+\.\w{2,}/,classification:"PII",confidence:.9,label:"email_content"},{regex:/\d{3}-\d{2}-\d{4}/,classification:"PII",confidence:.95,label:"ssn_content"},{regex:/\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/,classification:"PCI",confidence:.95,label:"credit_card_content"},{regex:/[A-Z]{2}\d{2}[A-Z0-9]{4,}/,classification:"PCI",confidence:.85,label:"iban_content"},{regex:/\+?\d[\d\s-]{7,}/,classification:"PII",confidence:.7,label:"phone_content"}]}function y(a,i,n){let e=0;for(let t of i){let c=t[a];typeof c=="string"&&n.test(c)&&e++}return e}function w(a){return a===0?"none":a<=2?"low":a<=5?"medium":a<=10?"high":"critical"}export{C as a,h as b,N as c,l as d};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{c as E}from"./chunk-BWWQXU2B.mjs";import{b as S}from"./chunk-T63U4OZJ.mjs";import{h as N}from"./chunk-TZE3Y7IQ.mjs";import{b as h,e as m,k as y,l as b}from"./chunk-WZQEK4WT.mjs";var z={kind:"master"};function w(i){return i.available&&i.active&&!i.master}function B(i){let t=i.find(n=>n.defaultRecordTypeMapping);if(t&&w(t))return{kind:"given",info:t,basis:"userDefault"};let e=i.filter(w);return e.length===1?{kind:"given",info:e[0],basis:"onlyOneOpen"}:z}function ie(i){if(i.kind!=="master")return{developerName:i.info.developerName,label:i.info.name,basis:i.basis}}var L=200,j=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/;function se(i,t){let e=t.filter(n=>j.test(n)).slice(0,L).map(n=>`'${n}'`);return`SELECT RecordTypeId, COUNT(Id) n FROM ${N(i)} WHERE Id IN (${e.join(", ")}) GROUP BY RecordTypeId`}var U=b({RecordTypeId:h().nullish(),n:m().int().nonnegative()});function oe(i,t){let e=y(U).safeParse(i);if(!e.success)return{read:0,types:[],unread:"the org answered rows that name no record type count"};let n=new Map;for(let{RecordTypeId:s,n:o}of e.data){let a=K(s??null,t),d=n.get(a.developerName);d?d.rows+=o:n.set(a.developerName,{...a,rows:o})}let r=[...n.values()].sort((s,o)=>o.rows-s.rows);return{read:r.reduce((s,o)=>s+o.rows,0),types:r}}function K(i,t){if(i===null||E(i)){let n=t.find(r=>r.master);return{developerName:n?.developerName??"Master",label:n?.name??"Master"}}let e=t.find(n=>n.recordTypeId.slice(0,15)===i.slice(0,15));return e?{developerName:e.developerName,label:e.name}:{developerName:i,label:i}}function ae(i){if(!i)return;let t=B(i);return t.kind==="given"?t.info.recordTypeId:i.find(e=>e.master)?.recordTypeId}function fe(i){if(typeof i!="object"||i===null)return!1;let{errorCode:t,name:e}=i;return t==="NOT_FOUND"||e==="NOT_FOUND"}import{createHash as R,createHmac as T}from"node:crypto";var p="SANDFORGE_FROZEN_SALT",me=["keep","clear","firstName","lastName","companyName","phoneE164","email","registrationSIV","contractNumber","postalCodeGeneralize","dateMonthStart","dateShift","geoRound1","kmRound10"],f=class extends Error{constructor(){super(`No pseudonymization salt. In VS Code, the first extraction makes one and keeps it in the editor's secret storage, which could not keep it here. On the command line, give it with --salt-file <file>, or set ${p} (bash or zsh: export ${p}="<salt>"; PowerShell: $env:${p} = "<salt>") and start VS Code from that shell. Use the salt the dataset was built with: another one gives the same records other pseudonyms.`),this.name="MissingSaltError"}},V=["Alix","Camille","Dominique","\xC9loi","Faustine","Gabin","H\xE9lo\xEFse","Ibrahim","Jasmine","Kylian","L\xE9a","Mathis","Nour","Oc\xE9ane","Paul","Quitterie","Rayan","Salom\xE9","Th\xE9o","Ursule","Victor","Wendy","Xavier","Yasmine","Zacharie","Ambre","Bastien","Chlo\xE9","Dorian","Emma","Fabien","Gabrielle","Hugo","In\xE8s","Jules","Klara","Louis","Manon","No\xE9","Oph\xE9lie"],H=["Arnaud","Berthelot","Chevallier","Deschamps","Etcheverry","Fontaine","Guibert","Hamonic","Imbert","Jacquin","Kermarrec","Lefebvre","Mignard","Noirot","Ollivier","Perrin","Quentin","Rochefort","Seguin","Thibault","Uberti","Vasseur","Wagner","Xuereb","Yverneau","Zimmermann","Aubry","Barbier","Charpentier","Delattre","Esnault","Fournier","Gosselin","Hervieux","Leloup","Marchand","Navarro","Pasquier","Renard","Sauvage"],v=["Aster","Boreal","C\xE9drat","Delta","Ellipse","Fulmen","Granit","Halcyon","Isatis","Jaspe","Kelvin","Lumen","M\xE9ridien","Noroit","Obsidienne","Pulsar"],k=["Conseil","Services","Industries","Solutions","Groupe","SAS","Partenaires","Logistique"],$="ABCDEFGHJKLMNPRSTUVWXYZ",x=/^(\d{4})-(\d{2})-(\d{2})$/,A=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-]\d{2}:?\d{2})$/;function Z(i){return Date.parse(i.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"))}var D=864e5,u=class{salt;constructor(t){if(!t)throw new f;this.salt=t}get saltFingerprint(){return R("sha256").update(this.salt).digest("hex").slice(0,12)}get dateShiftDays(){return 200+R("sha256").update(`${this.salt}|dateShift-offset`).digest().readUInt32BE(0)%201}pseudonymize(t,e){if(e==null)return e;switch(t){case"keep":return e;case"clear":return"";case"firstName":return this.pick(t,String(e),V);case"lastName":return this.pick(t,String(e),H);case"companyName":return this.companyName(String(e));case"phoneE164":return this.phoneE164(String(e));case"email":return this.email(String(e));case"registrationSIV":return this.registrationSIV(String(e));case"contractNumber":return this.contractNumber(String(e));case"postalCodeGeneralize":return this.postalCodeGeneralize(String(e));case"dateMonthStart":return this.dateMonthStart(String(e));case"dateShift":return this.dateShift(e);case"geoRound1":return this.roundNumber(e,1);case"kmRound10":return this.roundTo(e,10)}}digest(t,e){return T("sha256",this.salt).update(`${t}|${e}`).digest()}*bytes(t,e){let n=this.digest(t,e),r=0;for(;;){for(let s of n)yield s;r+=1,n=T("sha256",this.salt).update(`${t}|${e}|#${r}`).digest()}}pick(t,e,n){let r=this.digest(t,e);return n[r.readUInt32BE(0)%n.length]}companyName(t){let e=this.digest("companyName",t),n=v[e.readUInt32BE(0)%v.length],r=k[e.readUInt32BE(4)%k.length];return`${n} ${r}`}phoneE164(t){let e=this.bytes("phoneE164",t),n="";for(let r=0;r<4;r++)n+=String(e.next().value%10);return`+3363998${n}`}email(t){return`user-${this.digest("email",t).subarray(0,4).toString("hex")}@example.invalid`}registrationSIV(t){let e=this.bytes("registrationSIV",t),n=()=>$[e.next().value%$.length],r=()=>String(e.next().value%10);return`${n()}${n()}-${r()}${r()}${r()}-${n()}${n()}`}contractNumber(t){let e=this.bytes("contractNumber",t),n="";for(let r of t)r>="0"&&r<="9"?n+=String(e.next().value%10):r>="A"&&r<="Z"?n+=String.fromCharCode(65+e.next().value%26):r>="a"&&r<="z"?n+=String.fromCharCode(97+e.next().value%26):n+=r;return n}postalCodeGeneralize(t){let e=t.trim();if(e.length<=2)return e;if(/^\d+$/.test(e))return e.slice(0,2)+"0".repeat(e.length-2);let n=e.slice(0,2);for(let r of e.slice(2))r>="0"&&r<="9"?n+="0":r>="A"&&r<="Z"||r>="a"&&r<="z"?n+="X":n+=r;return n}dateMonthStart(t){let e=x.exec(t)??A.exec(t);return e?`${e[1]}-${e[2]}-01`:""}dateShift(t){if(typeof t=="string"&&x.test(t))return new Date(Date.parse(`${t}T00:00:00Z`)-this.dateShiftDays*D).toISOString().slice(0,10);if(typeof t=="string"&&A.test(t)){let e=Z(t);if(Number.isFinite(e))return new Date(e-this.dateShiftDays*D).toISOString()}return""}roundNumber(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=10**e,s=Math.round(n*r)/r;return typeof t=="number"?s:String(s)}roundTo(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=Math.round(n/e)*e;return typeof t=="number"?r:String(r)}};import{createHash as Y,randomBytes as X}from"node:crypto";var G=80,W=40,F=1e4,q=64,I=".invalid",g=/\.invalid$/i,C=/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g,J=/\+?(?<!\d)\d(?:[\s.()/-]{0,2}\d){6,}/g;function M(i){return/^(?:(?:00)?330?|0)63998\d{4}$/.test(i.replace(/\D/g,""))}function O(i){return`+3363998${i.replace(/\D/g,"").slice(-4)}`}var Q=/^[\d\s.()/+-]+$/;function _(i,t){if(!Q.test(i))return null;let e=t.slice(3),n=/^[\s(]*\+/.test(i)?[`33${e}`,`330${e}`]:[`0${e}`,`33${e}`,`330${e}`,`0033${e}`,`00330${e}`],r=i.replace(/\D/g,"").length,s=n.find(a=>a.length===r);if(s===void 0)return null;let o=0;return i.replace(/\d/g,()=>s[o++])}function ee(i,t={}){let e=[];for(let n of i){let r=(n.type??"").toLowerCase(),s=S(n.name,r);if(!s)continue;let o=r==="email"||r==="phone",a=r==="email"?G:r==="phone"?W:0,d=n.length!==void 0&&n.length>0?n.length:a;e.push({name:t[n.name]??n.name,kind:s,typed:o,...d>0?{maxLength:d}:{},...n.externalId===!0?{key:!0}:{}})}return e}var P=class{pseudonymizer;upsertKeys;drawnFor=new Map;taken=new Set;exhausted=0;counted=new Map;constructor(t=X(32).toString("hex"),e={}){this.pseudonymizer=new u(t),this.upsertKeys=e.upsertKeys===!0}forObject(t,e,n={}){let r=ee(e,n);if(r.length!==0)return s=>{for(let o of r){let a=s[o.name];if(typeof a!="string")continue;let d=this.neutralize(o,a);d!==a&&(d===null?delete s[o.name]:s[o.name]=d,this.count(t,o))}}}email(t,e=G,n=!1){let r=t.trim();if(r===""||g.test(r))return t;let s=`${r}${I}`;if(s.length<=e)return s;let o=this.shortAddress(r,n);return o.length<=e?o:null}phone(t,e){return/\d/.test(t)?M(t)?(this.taken.add(O(t)),t):this.fictional(t,e):t}report(){let t=[],e=0;for(let[n,r]of this.counted)for(let[s,{kind:o,values:a}]of r)t.push({objectApiName:n,field:s,kind:o,values:a}),e+=a;return{neutralized:!0,fields:t,values:e,...this.exhausted>0?{numbersExhausted:this.exhausted}:{}}}neutralize(t,e){let n=this.upsertKeys&&t.key===!0;return t.typed?t.kind==="email"?this.email(e,t.maxLength,n):this.phone(e,t.maxLength):t.kind==="email"?this.addressesIn(e,t.maxLength,n):this.numbersIn(e,t.maxLength)}addressesIn(t,e,n=!1){let r=a=>e===void 0||a.length<=e,s=t.replace(C,a=>g.test(a)?a:`${a}${I}`);if(s===t||r(s))return s;let o=t.replace(C,a=>g.test(a)?a:this.shortAddress(a,n));return r(o)?o:null}numbersIn(t,e){let n=d=>e===void 0||d.length<=e,r=!1,s=d=>t.replace(J,c=>{if(M(c))return this.taken.add(O(c)),c;let l=this.drawnNumber(c);return l===null?(r=!0,c):_(c,l)??(d?`0${l.slice(3)}`:l)}),o=s(!1);if(r)return null;if(o===t||n(o))return o;let a=s(!0);return n(a)?a:null}fictional(t,e){let n=this.drawnNumber(t);if(n===null)return null;let r=_(t,n);if(r!==null&&(e===void 0||r.length<=e))return r;if(e===void 0||n.length<=e)return n;let s=`0${n.slice(3)}`;return s.length<=e?s:null}drawnNumber(t){let e=t.replace(/[^\d+]/g,""),n=this.drawnFor.get(e);if(n!==void 0)return n;if(this.taken.size>=F)return this.exhausted+=1,null;let r=o=>String(this.pseudonymizer.pseudonymize("phoneE164",o)),s=r(e);for(let o=1;this.taken.has(s)&&o<=q;o+=1)s=r(`${e}#${o}`);for(let o=Number(s.slice(-4));this.taken.has(s);)o=(o+1)%F,s=`+3363998${String(o).padStart(4,"0")}`;return this.drawnFor.set(e,s),this.taken.add(s),s}shortAddress(t,e=!1){let n=t.toLowerCase();return e?`user-${Y("sha256").update(n).digest("hex").slice(0,16)}@example.invalid`:String(this.pseudonymizer.pseudonymize("email",n))}count(t,e){let n=this.counted.get(t)??new Map,r=n.get(e.name)??{kind:e.kind,values:0};r.values+=1,n.set(e.name,r),this.counted.set(t,n)}};export{p as a,me as b,f as c,u as d,G as e,F as f,ee as g,P as h,B as i,ie as j,L as k,se as l,oe as m,ae as n,fe as o};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- var o=class{operations=new Map;listeners=new Set;maxCompleted=50;pendingStarts=new Map;register(t,e,r,n,a){let s={operationId:t,module:e,description:r,status:"running",progressPercent:0,startedAt:Date.now(),abortController:a,notifiedNatively:!1};return this.pendingStarts.delete(t),this.operations.set(t,s),this.emit(t,"started",s),n.then(i=>{if(typeof i=="object"&&i!==null&&i.status==="failure"){this.markFailed(t,new Error("Operation finished with a failure status."));return}this.markCompleted(t)}).catch(i=>{this.markFailed(t,i)}),s}updateProgress(t,e,r){let n=this.operations.get(t);n&&(n.progressPercent=e,r!==void 0&&(n.resultSummary=r),this.emit(t,"progress",n))}abort(t){let e=this.operations.get(t);!e||e.status!=="running"||(e.abortController.abort(),e.status="aborted",e.completedAt=Date.now(),this.emit(t,"aborted",e))}holdUntilStart(t){let e=new AbortController;return this.pendingStarts.set(t,e),{signal:e.signal,release:()=>{this.pendingStarts.get(t)===e&&this.pendingStarts.delete(t)}}}cancelBeforeStart(t){let e=this.pendingStarts.get(t);return e?(e.abort(),!0):!1}markNotifiedNatively(t){let e=this.operations.get(t);e&&(e.notifiedNatively=!0)}getActiveOperations(){return[...this.operations.values()].sort((t,e)=>e.startedAt-t.startedAt).map(t=>({operationId:t.operationId,module:t.module,description:t.description,status:t.status,progressPercent:t.progressPercent,startedAt:t.startedAt,completedAt:t.completedAt,resultSummary:t.resultSummary}))}getRunning(){return[...this.operations.values()].filter(t=>t.status==="running")}has(t){return this.operations.has(t)}get(t){return this.operations.get(t)}onEvent(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}dispose(){for(let t of this.operations.values())t.status==="running"&&t.abortController.abort();for(let t of this.pendingStarts.values())t.abort();this.pendingStarts.clear(),this.operations.clear(),this.listeners.clear()}markCompleted(t,e){let r=this.operations.get(t);!r||r.status!=="running"||(r.status="completed",r.completedAt=Date.now(),r.progressPercent=100,e!==void 0&&(r.resultSummary=e),this.emit(t,"completed",r),this.evictOldCompleted())}markFailed(t,e){let r=this.operations.get(t);!r||r.status!=="running"||(r.status="failed",r.completedAt=Date.now(),r.resultSummary=e instanceof Error?e.message:String(e),this.emit(t,"failed",r))}emit(t,e,r){for(let n of this.listeners)n(t,e,r)}evictOldCompleted(){let t=[...this.operations.values()].filter(e=>e.status!=="running").sort((e,r)=>(e.completedAt??0)-(r.completedAt??0));for(;t.length>this.maxCompleted;){let e=t.shift();e&&this.operations.delete(e.operationId)}}};export{o as a};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-SI267LYR.mjs";import"./chunk-KAZS5Z6W.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-EPFCERGL.mjs";import"./chunk-IUM4NFKI.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as SCENARIO_SIDECAR_SUFFIX,f as compiledForSidecar,g as nodeScenarioSidecarFiles,j as readScenarioRunSidecar,c as scenarioPackFingerprint,d as scenarioRunSidecar,b as scenarioRunSidecarSchema,h as scenarioSidecarPath,e as withAgentChoice,i as writeScenarioRunSidecar};
@@ -1,8 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{closeSync as J,fstatSync as W,openSync as $,readSync as G,writeSync as K}from"node:fs";function dt(a){let e=$(a,"a+"),t=W(e).size;return{size:()=>t,append:n=>{let i=Buffer.from(n,"utf8"),r=0;for(;r<i.length;)r+=K(e,i,r);t+=i.length},read:(n,i)=>{let r=Buffer.alloc(i),s=0;for(;s<i;){let o=G(e,r,s,i-s,n+s);if(o===0)break;s+=o}return r.subarray(0,s)},close:()=>J(e)}}function E(a,e){return e===void 0?a:`${a}/${e}`}var M=/^[A-Za-z][A-Za-z0-9]*$/,I=/^[0-9a-f]{64}$/,H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function P(a){if(typeof a!="object"||a===null)return;let{objectApiName:e,ids:t,sha256:n,readAt:i,query:r}=a;if(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(e)||!Array.isArray(t)||!t.every(o=>typeof o=="string"&&H.test(o))||typeof n!="string"||!I.test(n)||typeof i!="string"||!Number.isFinite(Date.parse(i)))return;let s;if(typeof r=="object"&&r!==null){let{where:o,orderBy:c,limit:u}=r;s={...typeof o=="string"?{where:o}:{},...typeof c=="string"?{orderBy:c}:{},...typeof u=="number"&&Number.isInteger(u)?{limit:u}:{}}}return{objectApiName:e,ids:t,sha256:n,readAt:i,...s?{query:s}:{}}}var b=1,x=2,N=3,y=4,Y={created:b,existing:x,updated:N},_={[b]:"created",[x]:"existing",[N]:"updated"},U={[b]:"c",[x]:"e",[N]:"u",[y]:"i"},R={c:b,e:x,u:N,i:y},Z="x",q="a",V="j",D="d",T="n",v="t",F="found",Q="found-owed";function ct(a,e,t,n){return JSON.stringify([D,a,e,t,n])}function ft(a){if(!a.startsWith(`["${D}"`))return;let e;try{e=JSON.parse(a)}catch{return}if(!Array.isArray(e))return;let[,,,t,n]=e;if(!(typeof t!="string"||!Number.isFinite(Date.parse(t)))&&!(typeof n!="string"||!Number.isFinite(Date.parse(n))))return{orgAt:t,at:n}}function X(a,e=!1){return JSON.stringify([e?"w":"o",a.objectApiName,a.newId,a.sourceId??"",a.fieldName,a.sourceRefId,a.insertOnly?1:0])}var tt=1024*1024,et=1024*1024,nt=2e4,it=2e4,rt=.6,st=3;function p(a){let e=2166136261;for(let t=0;t<a.length;t++)e^=a.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function m(a){let e=2538058380;for(let t=0;t<a.length;t++)e=Math.imul(e^a.charCodeAt(t),1540483477),e^=e>>>15;return e>>>0}var A=class{constructor(e){this.keyAt=e}keyAt;capacity=1024;used=0;h1=new Uint32Array(this.capacity);h2=new Uint32Array(this.capacity);at=new Float64Array(this.capacity);len=new Uint16Array(this.capacity);code=new Uint8Array(this.capacity);get size(){return this.used}get slots(){return this.capacity}find(e,t,n,i){let r=this.capacity-1,s=n&r;for(;;){let o=this.at[s];if(o===0)return~s;if(this.h1[s]===t&&this.h2[s]===n&&(i===o-1||this.keyAt(o-1,this.len[s])===e))return s;s=s+1&r}}offsetOf(e){return this.at[e]-1}lengthOf(e){return this.len[e]}codeOf(e){return this.code[e]}put(e,t,n,i,r,s){let o=e;e<0&&(this.used+1>this.capacity*rt?(this.grow(),o=this.freeSlotFor(n)):o=~e,this.used++,this.h1[o]=t,this.h2[o]=n),this.at[o]=i+1,this.len[o]=r,this.code[o]=s}freeSlotFor(e){let t=this.capacity-1,n=e&t;for(;this.at[n]!==0;)n=n+1&t;return n}grow(){let{h1:e,h2:t,at:n,len:i,code:r}=this;this.capacity*=2,this.h1=new Uint32Array(this.capacity),this.h2=new Uint32Array(this.capacity),this.at=new Float64Array(this.capacity),this.len=new Uint16Array(this.capacity),this.code=new Uint8Array(this.capacity);for(let s=0;s<n.length;s++){if(n[s]===0)continue;let o=this.freeSlotFor(t[s]);this.h1[o]=e[s],this.h2[o]=t[s],this.at[o]=n[s],this.len[o]=i[s],this.code[o]=r[s]}}};function L(a){return a?a[0]==="p"&&a.length>=3?C(String(a[1]),String(a[2])):a[0]==="g"&&a.length>=3?j(String(a[2])):a[0]===v&&a.length>=2?B(String(a[1])):"":""}function B(a){return`t\0${a}`}function C(a,e){return`p\0${a}\0${e}`}function j(a){return`g\0${a}`}function*ot(a){let e=a.size(),t=0,n=Buffer.alloc(0),i=0;for(;t<e;){let r=a.read(t,Math.min(et,e-t));if(r.length===0)break;t+=r.length;let s=n.length>0?Buffer.concat([n,r]):r,o=0;for(;;){let c=s.indexOf(10,o);if(c<0)break;c>o&&(yield{offset:i+o,length:c-o,text:s.toString("utf8",o,c)}),o=c+1}n=s.subarray(o),i+=o}}var z=class a{constructor(e){this.file=e;this.index=new A((t,n)=>this.idOfLine(t,n)),this.marks=new A((t,n)=>L(S(this.lineAt(t,n)))),this.createdTargets=new A((t,n)=>{let i=S(this.lineAt(t,n));return i?O(String(i[2]??"")):""})}file;index;cache=new Map;pending=[];pendingBytes=0;flushQueued=!1;partStart=Number.POSITIVE_INFINITY;parts=0;mappedCount=0;counts=new Map;earlierByObject=new Map;earlierPastCheckpoint=new Map;checkpointsByObject=new Map;owedCount=0;statuses=new Map;given=new Map;marks;createdTargets;createdUnattributedKeys=new Set;readsHeld=[];withTheirRecordMarked=0;callsSent=0;foundAfterStop=new Set;foundOwingUntold=new Set;plan;rootsNamed;static open(e){let t=new a(e);return t.readWhatIsThere(),t}get partCount(){return this.parts}get resumes(){return this.checkpointsByObject.size>0||this.earlierByObject.size>0||this.owedCount>0}get earlierMapped(){return this.partStart===Number.POSITIVE_INFINITY?this.mappedCount:this.mappedBeforePart}mappedBeforePart=0;beginPart(e){this.flush(),this.mappedBeforePart=this.mappedCount,this.withTheirRecordMarked=0,this.partStart=this.file.size(),this.write({part:{n:this.parts,startedAt:e.toISOString()}}),this.parts++,this.flush()}nameSamplePlan(e){if(!I.test(e.sha256))throw new Error("Not the SHA-256 of a plan.");this.write({sample:{dir:e.dir,sha256:e.sha256}}),this.plan={dir:e.dir,sha256:e.sha256},this.flush()}get samplePlan(){return this.plan?{...this.plan}:void 0}nameRoots(e){let t=P(e);if(!t)throw new Error("Not the roots of a clone from records.");this.write({roots:t}),this.rootsNamed=t,this.flush()}get roots(){return this.rootsNamed?{...this.rootsNamed,ids:[...this.rootsNamed.ids]}:void 0}setMapping(e,t,n,i){let r=Y[e],s=p(t),o=m(t),c=this.cache.get(t),u=this.index.find(t,s,o,c?.at),h=u>=0&&this.index.codeOf(u)!==y;h&&this.uncount(t,u,c);let g=JSON.stringify([U[r],t,n,i??""]),f=this.write(g);if(this.index.put(u,s,o,f,Buffer.byteLength(g),r),r===b&&this.indexCreated(n,f,Buffer.byteLength(g)),h||this.mappedCount++,i){let d=this.countsOf(i);r===b?d.created++:r===x?d.linked++:d.updated++}this.remember(t,{at:f,code:r,targetId:n,objectApiName:i??""})}uncount(e,t,n){let i=this.index.offsetOf(t);if(i<this.partStart)return;let r=this.index.codeOf(t),s=n?.at===i?n:this.recordAt(e,t),o=s?.objectApiName?this.counts.get(s.objectApiName):void 0;o&&(r===b?o.created--:r===x?o.linked--:o.updated--)}countsOf(e){let t=this.counts.get(e);return t||(t={created:0,linked:0,updated:0},this.counts.set(e,t)),t}mapping(e){let t=this.lookUp(e);if(!(!t||t.code===y))return{kind:_[t.code],sourceId:e,targetId:t.targetId,...t.objectApiName?{objectApiName:t.objectApiName}:{},earlier:t.at<this.partStart}}createdTarget(e){let t=O(e);if(this.createdUnattributedKeys.has(t))return!0;if(this.createdTargets.size===0)return!1;let n=this.createdTargets.find(t,p(t),m(t));if(n<0)return!1;let i=this.createdTargets.offsetOf(n),r=S(this.lineAt(i,this.createdTargets.lengthOf(n)));if(!r)return!1;let s=String(r[1]),o=this.index.find(s,p(s),m(s));return o>=0&&this.index.offsetOf(o)===i&&this.index.codeOf(o)===b}indexCreated(e,t,n){let i=O(e);if(!i)return;let r=p(i),s=m(i);this.createdTargets.put(this.createdTargets.find(i,r,s),r,s,t,n,b)}targetOf(e){let t=this.lookUp(e);return t&&t.code!==y?t.targetId:void 0}get mappedSize(){return this.mappedCount}countsByObject(){let e=[];for(let[t,{created:n,linked:i,updated:r}]of this.counts)n+i+r!==0&&e.push(r>0?{objectApiName:t,created:n,linked:i,updated:r}:{objectApiName:t,created:n,linked:i});return e}linkedToCreatedCount(){let e=0;for(let f of this.counts.values())e+=f.linked;if(e===0)return 0;let t=this.partStart===Number.POSITIVE_INFINITY?0:this.partStart,n=(f,d)=>{let l=S(this.lineAt(f,d));return l?String(l[2]).slice(0,15):""},i=(f,d)=>{let l=R[String(d[0])];if(l===void 0||l===y||!d[3])return;let w=String(d[1]),k=this.index.find(w,p(w),m(w),f.offset);return k>=0&&this.index.offsetOf(k)===f.offset?l:void 0},r=(f,d)=>f.offset<t?void 0:i(f,d),s=(f,d,l)=>{let w=p(d),k=m(d);f.put(f.find(d,w,k),w,k,l.offset,l.length,0)},o=(f,d)=>f.size>0&&f.find(d,p(d),m(d))>=0,c=new A(n);for(let f of this.lines()){if(!f.text.startsWith('["'))continue;let d=S(f.text);!d||r(f,d)!==x||this.markedWithTheirRecord(String(d[1]))||s(c,String(d[2]).slice(0,15),f)}if(c.size===0)return 0;let u=new A(n),h=new Set;for(let f of this.lines()){if(!f.text.startsWith('["'))continue;let d=S(f.text);if(!d)continue;if(d[0]===T&&Array.isArray(d[2])){for(let w of d[2]){let k=String(w).slice(0,15);o(c,k)&&h.add(k)}continue}if(i(f,d)!==b)continue;let l=String(d[2]).slice(0,15);o(c,l)&&s(u,l,f)}if(u.size===0&&h.size===0)return 0;let g=0;for(let f of this.lines()){if(!f.text.startsWith('["'))continue;let d=S(f.text);if(!d||r(f,d)!==x||this.markedWithTheirRecord(String(d[1])))continue;let l=String(d[2]).slice(0,15);(o(u,l)||h.has(l))&&g++}return g}earlierRecordsOf(e,t=!1){return(t?this.earlierPastCheckpoint:this.earlierByObject).get(e)??0}*mappings(){for(let e of this.lines()){if(!e.text.startsWith('["'))continue;let t=S(e.text);if(!t)continue;let n=R[String(t[0])];if(n===void 0||n===y)continue;let i=String(t[1]),r=this.index.find(i,p(i),m(i),e.offset);if(r<0||this.index.offsetOf(r)!==e.offset)continue;let s=String(t[3]??"");yield{kind:_[n],sourceId:i,targetId:String(t[2]),...s?{objectApiName:s}:{},earlier:e.offset<this.partStart}}}noteRead(e){this.readsHeld.push(e),this.readsHeld.length>=it&&this.settleReads()}settleReads(){let e=this.readsHeld;this.readsHeld=[];for(let t of e){let n=p(t),i=m(t),r=this.index.find(t,n,i,this.cache.get(t)?.at);if(r>=0)continue;let s=JSON.stringify([U[y],t]),o=this.write(s);this.index.put(r,n,i,o,Buffer.byteLength(s),y)}}wasRead(e){return this.readsHeld.includes(e)?!0:this.index.find(e,p(e),m(e),this.cache.get(e)?.at)>=0}checkpoint(e,t,n){if(n!==void 0&&!M.test(n))throw new Error(`Not the name of a pass: ${JSON.stringify(n.slice(0,40))}`);this.settleReads(),this.write({at:{object:e,...n!==void 0?{pass:n}:{},...t}}),this.checkpointsByObject.set(E(e,n),{...t}),this.flush()}checkpoints(){return new Map(this.checkpointsByObject)}owe(e,t=!1){this.owedCount++,this.write(X(e,t))}get owed(){return this.owedCount}*owedPages(e){let t=[];for(let n of this.lines()){if(!n.text.startsWith('["o"')&&!n.text.startsWith('["w"'))continue;let i=S(n.text);if(!i||i.length<7)continue;let[r,s,o,c,u,h,g]=i;t.push({update:{objectApiName:String(s),newId:String(o),sourceId:c?String(c):void 0,fieldName:String(u),sourceRefId:String(h),...g===1?{insertOnly:!0}:{}},toRowWrittenBefore:r==="w"}),t.length>=e&&(yield t,t=[])}t.length>0&&(yield t)}patched(e,t){this.mark(JSON.stringify(["p",e,t]),C(e,t))}wasPatched(e,t){return this.hasMark(C(e,t))}mark(e,t){let n=p(t),i=m(t),r=this.marks.find(t,n,i),s=this.write(e);this.marks.put(r,n,i,s,Buffer.byteLength(e),0)}hasMark(e){return this.marks.size>0&&this.marks.find(e,p(e),m(e))>=0}owedLeftByEarlierParts(){let e=new Set;for(let n of this.lines()){if(n.offset>=this.partStart)break;if(!n.text.startsWith('["p"'))continue;let i=S(n.text);i&&i.length>=3&&e.add(`${String(i[1])}\0${String(i[2])}`)}let t=[];for(let n of this.lines()){if(n.offset>=this.partStart)break;if(!n.text.startsWith('["o"'))continue;let i=S(n.text);if(!i||i.length<7)continue;let[,r,s,o,c,u,h]=i;e.has(`${String(s)}\0${String(c)}`)||t.push({objectApiName:String(r),newId:String(s),sourceId:o?String(o):void 0,fieldName:String(c),sourceRefId:String(u),...h===1?{insertOnly:!0}:{}})}return t}oweStatus(e,t,n){this.write(JSON.stringify(["s",e,t,n])),this.tallyStatus({objectApiName:e,id:t,status:n})}tallyStatus(e){let t=this.statuses.get(e.objectApiName);t||(t={count:0,samples:[]},this.statuses.set(e.objectApiName,t)),t.count++,t.samples.length<st&&t.samples.push(e)}gaveStatus(e,t){this.statusGiven(t)||(this.mark(JSON.stringify(["g",e,t]),j(t)),this.given.set(e,(this.given.get(e)??0)+1))}statusGiven(e){return this.hasMark(j(e))}statusesOwed(){let e=new Map;for(let[t,n]of this.statuses){let i=n.count-(this.given.get(t)??0);i<=0||e.set(t,{count:i,samples:n.samples.filter(({id:r})=>!this.statusGiven(r))})}return e}*statusLines(){for(let e of this.lines()){if(!e.text.startsWith('["s"'))continue;let t=S(e.text);!t||t.length<4||(yield{objectApiName:String(t[1]),id:String(t[2]),status:String(t[3])})}}withTheirRecord(e){let t=B(e),n=p(t),i=m(t),r=this.marks.find(t,n,i),s=this.partStart===Number.POSITIVE_INFINITY?0:this.partStart;if(r>=0&&this.marks.offsetOf(r)>=s)return;let o=JSON.stringify([v,e]),c=this.write(o);this.marks.put(r,n,i,c,Buffer.byteLength(o),0),this.withTheirRecordMarked++}get withTheirRecordCount(){return this.withTheirRecordMarked}markedWithTheirRecord(e){if(this.withTheirRecordMarked===0)return!1;let t=B(e),n=this.marks.find(t,p(t),m(t)),i=this.partStart===Number.POSITIVE_INFINITY?0:this.partStart;return n>=0&&this.marks.offsetOf(n)>=i}*withTheirRecordIds(){if(this.withTheirRecordMarked!==0)for(let e of this.lines()){if(e.offset<this.partStart||!e.text.startsWith(`["${v}"`))continue;let t=S(e.text);t&&t.length>=2&&(yield String(t[1]))}}sent(e,t,n,i=new Date,r){this.callsSent++;let s=`${Math.max(0,this.parts-1)}.${this.callsSent}`;return this.write(JSON.stringify([Z,s,e,i.toISOString(),t,n.map(({sourceId:o,fingerprint:c,externalKey:u,jobKey:h})=>r!==void 0&&u!==void 0?[o,c,u]:h!==void 0?[o,c,"",h]:[o,c]),n.flatMap(({owes:o},c)=>(o??[]).map(({field:u,sourceRefId:h,insertOnly:g})=>[c,u,h,g?1:0])),...r!==void 0?[r]:[]])),this.flush(),s}answered(e){this.write(JSON.stringify([q,e]))}jobOpened(e,t){this.write(JSON.stringify([V,e,t])),this.flush()}createdUnattributed(e,t){if(t.length!==0){this.write(JSON.stringify([T,e,[...t]]));for(let n of t)this.createdUnattributedKeys.add(O(n))}}wasFoundAfterStop(e){return this.foundAfterStop.has(e)}owesUntold(e){return this.foundOwingUntold.has(e)}flush(){if(this.pending.length===0)return;let e=this.pending.join("");this.pending=[],this.pendingBytes=0,this.file.append(e)}close(){this.settleReads(),this.flush(),this.file.close()}write(e){let t=typeof e=="string"?e:JSON.stringify(e),n=this.file.size()+this.pendingBytes,i=`${t}
8
- `;return this.pending.push(i),this.pendingBytes+=Buffer.byteLength(i),this.pendingBytes>=tt?this.flush():this.flushQueued||(this.flushQueued=!0,queueMicrotask(()=>{this.flushQueued=!1,this.flush()})),n}lineAt(e,t){return e+t>this.file.size()&&this.flush(),this.file.read(e,t).toString("utf8")}idOfLine(e,t){let n=S(this.lineAt(e,t));return n?String(n[1]):""}lookUp(e){let t=this.cache.get(e);if(t)return this.cache.delete(e),this.cache.set(e,t),t;let n=this.index.find(e,p(e),m(e));if(n<0)return;let i=this.recordAt(e,n);return i&&this.remember(e,i),i}recordAt(e,t){let n=this.index.offsetOf(t),i=S(this.lineAt(n,this.index.lengthOf(t)));if(!(!i||String(i[1])!==e))return{at:n,code:this.index.codeOf(t),targetId:String(i[2]??""),objectApiName:String(i[3]??"")}}remember(e,t){if(this.cache.delete(e),this.cache.set(e,t),this.cache.size>nt){let n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}}*lines(){this.flush(),yield*ot(this.file)}readWhatIsThere(){for(let e of this.lines()){if(e.text.startsWith('["')){let n=S(e.text);n&&this.readRegistration(e,n);continue}let t;try{t=JSON.parse(e.text)}catch{continue}if(!(typeof t!="object"||t===null)){if("part"in t)this.parts++;else if("sample"in t){let n=t.sample;if(typeof n!="object"||n===null)continue;let{dir:i,sha256:r}=n;if(typeof i!="string"||i===""||typeof r!="string"||!I.test(r))continue;this.plan={dir:i,sha256:r}}else if("roots"in t){let n=P(t.roots);n&&(this.rootsNamed=n)}else if("at"in t){let n=t.at;if(typeof n!="object"||n===null)continue;let{object:i,pass:r,lastId:s,read:o,done:c}=n;if(typeof i!="string"||typeof s!="string"||typeof o!="number"||r!==void 0&&(typeof r!="string"||!M.test(r)))continue;this.checkpointsByObject.set(E(i,r),{lastId:s,read:o,...c===!0?{done:c}:{}}),r===void 0&&this.earlierPastCheckpoint.delete(i)}}}}readRegistration(e,t){let n=String(t[0]);if(n==="o"||n==="w"){this.owedCount++;return}if(n==="s"){t.length>=4&&this.tallyStatus({objectApiName:String(t[1]),id:String(t[2]),status:String(t[3])});return}if(n==="p"||n==="g"||n===v){let g=L(t);if(!g)return;let f=p(g),d=m(g),l=this.marks.find(g,f,d);if(n==="g"&&l<0){let w=String(t[1]);this.given.set(w,(this.given.get(w)??0)+1)}this.marks.put(l,f,d,e.offset,e.length,0);return}if(n===T){if(Array.isArray(t[2]))for(let g of t[2])this.createdUnattributedKeys.add(O(String(g)));return}let i=R[n];if(i===void 0)return;let r=String(t[1]);i===b&&(t[4]===F||t[4]===Q)&&(this.foundAfterStop.add(r),t[4]===F&&this.foundOwingUntold.add(r));let s=p(r),o=m(r),c=this.index.find(r,s,o),u=c>=0&&this.index.codeOf(c)!==y;if(i===y&&c>=0||(this.index.put(c,s,o,e.offset,e.length,i),i===y))return;i===b&&this.indexCreated(String(t[2]??""),e.offset,e.length),u||this.mappedCount++;let h=String(t[3]??"");h&&(this.earlierByObject.set(h,(this.earlierByObject.get(h)??0)+1),this.earlierPastCheckpoint.set(h,(this.earlierPastCheckpoint.get(h)??0)+1))}};function O(a){return a.slice(0,15)}function S(a){try{let e=JSON.parse(a);return Array.isArray(e)?e:void 0}catch{return}}export{dt as a,E as b,P as c,Z as d,q as e,V as f,D as g,T as h,v as i,F as j,Q as k,ct as l,ft as m,X as n,p as o,m as p,A as q,ot as r,z as s};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a as Ce}from"./chunk-GMY5427L.mjs";import{h as Re,i as be,j as Se,k as ke,n as Te,o as Fe}from"./chunk-TEIBWMJM.mjs";import{c as Oe}from"./chunk-BWWQXU2B.mjs";import{f as me,i as we}from"./chunk-26POJDIT.mjs";import{d as he}from"./chunk-CVHNXJH3.mjs";import{b as fe,c as q,m as pe}from"./chunk-HFSBDM7B.mjs";import{d as K}from"./chunk-OHEOJISY.mjs";import{G as se,q as te,s as ne,t as re,u as oe}from"./chunk-TNT27RBG.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{a as z,l as ie,o as ae,q as de,t as ce,u as ue,v as le}from"./chunk-ICIYL45C.mjs";import{b as ye,e as ge}from"./chunk-WUUKFE2U.mjs";import{Sc as X,id as B}from"./chunk-PMWAFDUB.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var We=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Ae(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Se(be(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ie(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function ze(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function ve(t,e){return`${t} ${e} record${t===1?"":"s"}`}function Ue(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(c=>b(c.id)===b(t)),y=i?(n.target??[]).filter(c=>c.sobjectType===i.sobjectType&&c.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:y.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function Ge(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??Te(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function Le(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${ve(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function Ee(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],y=r?.references??new Set,c={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},h=new Map,m=new Map,T=(d,l,g,k)=>{c.held.push({index:d,reason:g}),h.delete(d);let I=m.get(l);I?I.count++:m.set(l,{count:1,say:k})},w=e.operation==="insert"||e.operation==="upsert",W=w&&i.some(d=>!d.master),f=new Map;s&&w&&s.sources.forEach((d,l)=>{let g=d?.Id;typeof g=="string"&&H.test(g)&&f.set(b(g),l)});let v=new Set([...s&&w?s.later??[]:[]].map(d=>d.toLowerCase())),R=new Set(v.size===0?[]:(r?.fields??[]).flatMap(d=>d.isReference&&(d.referenceTo??[]).some(l=>v.has(l.toLowerCase()))&&!(d.nillable===!1&&d.defaultedOnCreate!==!0)?[d.name]:[]));n.forEach((d,l)=>{let g=ze(d,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){h.set(l,{payload:g,settled:new Set});return}let k=new Set;if(s)for(let p of Object.keys(g)){let C=g[p];if(p==="RecordTypeId"||!y.has(p)||typeof C!="string"||!H.test(C))continue;if(f.has(b(C))){delete g[p],c.deferred.push({index:l,field:p,parent:C});continue}let _=s.links.targetOf(C);if(_){g[p]=_,k.add(p);continue}let M=s.links.refusedObjectOf(C);if(M===void 0){R.has(p)&&(delete g[p],c.deferredAcross.push({index:l,field:p,parent:C}));continue}let G=Le(o,p,M);T(l,G.group,G.reason,G.say);return}let I=g.RecordTypeId,E,j=Oe(I);if(j)delete g.RecordTypeId;else if(typeof I=="string"&&H.test(I)){let p=Ue(I,i,s?.recordTypes);if("unmapped"in p){let C=p.unmapped,_=p.namesakes.length>0?` The target org's ${p.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";T(l,`unmapped:${C}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",M=>`RECORD_TYPE_UNMAPPED: ${ve(M,o)} held back, not sent: `+(C?`their record type ${C} has no active ${o} record type of that API name in the target org.${_} Create or activate record type ${C} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in p){let C=p.unavailable;T(l,`unavailable:${C.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${C.developerName} is closed to the running user in the target org.`,_=>`${pe({objectApiName:o,recordTypeId:C.recordTypeId,developerName:C.developerName,name:C.name,inactive:!C.active,recordCount:_})} Held back, not sent.`);return}g.RecordTypeId=p.sent,E=p.sent,p.info&&k.add("RecordTypeId")}let $=s?.sources[l]??d;if(re($)){let p=oe($,Ge(r,E,s?.recordTypes?.personTypes));for(let C of Object.keys(g))B(o,C,p)&&delete g[C]}else for(let p of Object.keys(g))B(o,p,"business")&&delete g[p];W&&!("RecordTypeId"in g)&&c.withoutRecordType.set(l,j?"masterInSource":"notRead"),h.set(l,{payload:g,settled:k})});let L=!0;for(;L;){L=!1;for(let{index:d,field:l,parent:g}of c.deferred){let k=f.get(b(g));if(!h.has(d)||k===void 0||h.has(k)||s?.links.targetOf(g)!==void 0)continue;let I=Le(o,l,o);T(d,I.group,I.reason,I.say),L=!0}}c.deferred=c.deferred.filter(({index:d})=>h.has(d)),c.deferredAcross=c.deferredAcross.filter(({index:d})=>h.has(d));for(let d of[...c.withoutRecordType.keys()])h.has(d)||c.withoutRecordType.delete(d);c.held.sort((d,l)=>d.index-l.index);let S=e.operation==="delete"?void 0:s?.currencies,O=r?.creatable.has(z)===!0,u=!O&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(d=>d.name===z)===!0,F=S&&(O||u)?ae(r?.fields??[]):void 0,P=[...r?.references??[]],A=new le;for(let[d,{payload:l,settled:g}]of[...h].sort(([k],[I])=>k-I)){for(let k of X(o,l))delete l[k];if(S&&F){let k=s?.sources[d]??n[d],I=k?.[z],E=O?de(l,{read:I,currencyFields:F,ratesOn:ie(o,k)},S):ue(l,{read:I,parent:k?ce(o,k,P,$=>s?.currencyChangesById?.get($)):void 0,currencyFields:F},S);A.add(o,E);let j=k?.Id;E&&typeof j=="string"&&s?.currencyChangesById?.set(j,E)}c.payloads.push(l),c.sentAt.push(d),c.settled.push(g)}return c.notes=[...m.values()].map(({count:d,say:l})=>l(d)),c.currencies=A.list(),c}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Be(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function yt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Be),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function gt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function ht(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ce(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function Pe(t,e,n,r){let s;try{s=await t(e)}catch(c){if(n==="delete")return{notAsked:!0};let h=Fe(c)?"notInTarget":"unread";return{refused:{why:h,message:Z(e,h,ee(c))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let y=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(y.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",y),key:y},target:s}:{target:s}}function Rt(t){return t.keepContactPoints===!0?void 0:new Re}function Ot(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function xe(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var x=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Ne=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:y}=await this.write(e,n,r);return Je(Qe(e.objectApiName,e.operation,s,o,i,y),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let u=await Pe(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in u){let F=n.map(()=>({success:!1,errors:[u.refused.message]}));return r&&$e(e,F,r),{outcomes:F,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in u&&u.target.creatable.size>0&&(s=u.target)}let o=Ee({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&xe(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=He(o.payloads,o.settled,r),y=new Map(o.held.map(({index:u,reason:F})=>[u,F])),c=u=>{let F=[],P=0;for(let A=0;A<n.length;A++){let d=y.get(A);if(d!==void 0){F.push({success:!1,errors:[d],heldBack:!0});continue}if(P>=u.length)break;F.push(u[P++])}return F},h,m=o.sentAt.filter(u=>u<(r?.standardFirst??0)).length,T=u=>this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField);try{h=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Ve(e.objectApiName,T,o.payloads.slice(0,m),o.payloads.slice(m)):await T(o.payloads)}catch(u){if(!(u instanceof x))throw u;let F=je(i,u.written),P=c(u.written);throw De(e,o.withoutRecordType,P,s,r),new x(e.objectApiName,P,[...o.notes,...u.notes],[...F?[F]:[],...u.lookupsLeftOut,...Q(U([...o.deferred,...o.deferredAcross],P))],u.writtenWithoutFields)}let w=await this.retryRefused(e,o.payloads,h,s?.references??null,o.settled);if(r)for(let u of w.ownersRefused)r.links.noteOwnerRefused(u);let W=c(w.outcomes);De(e,o.withoutRecordType,W,s,r);let f=je(i,w.outcomes),v=[...o.notes,...w.notes],R=[...f?[f]:[],...w.lookupsLeftOut],{writtenWithoutFields:L}=w,S=U(o.deferredAcross,W),O=0;if(w.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q([...U(o.deferred,W),...S])],L);if(r){$e(e,W,r),Ze(e,o.payloads,w.outcomes,r.links);let u=await this.setLookups(e,U(o.deferred,W),r.links,!1);if(R.push(...u.leftOut),O=u.unset,u.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q(S)],L)}return{outcomes:W,notes:v,currencies:o.currencies,lookupsLeftOut:R,...L?{writtenWithoutFields:L}:{},...S.length>0?{lookupsToSet:S}:{},...O>0?{lookupsUnset:O}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,y=new D;for(let{id:f,field:v,parent:R}of n){let L=r.targetOf(R),S=L!==void 0?a:s&&r.refusedObjectOf(R)===void 0?i:void 0;if(!S){y.add(f,v);continue}let O=S.get(f)??{Id:f};O[v]=L??R,S.set(f,O)}let c=new D,h=new D,m=new D,T=new D,w=!1;for(let f of[[...a.values()],[...i.values()]]){if(f.length===0)continue;if(w){for(let R of f)T.addRow(R);continue}let v;try{v=await this.executeOperation(o,"update",f,e.batchSize)}catch(R){if(!(R instanceof x)){let L=R instanceof Error?R.message:String(R);for(let S of f)m.addRow(S,L);continue}v=R.written,w=!0}f.forEach((R,L)=>{let S=v[L];S===void 0?T.addRow(R):S.success?c.addRow(R):S.errors.some(O=>J(O))?h.addRow(R):m.addRow(R,S.errors[0])})}let W=[y,h,m,T];return{...c.records>0?{set:{records:c.records,fields:c.fields()}}:{},leftOut:[y.leftOut("parentRefused"),h.leftOut("notInTarget"),m.leftOut("notSet"),T.leftOut("notReached")].flatMap(f=>f?[f]:[]),unset:new Set(W.flatMap(f=>[...f.recordIds])).size,cancelled:w}}async retryRefused(e,n,r,s,o){let a=Y(e)??void 0,i=[...r],y=[...n],c=n.map(()=>new Set),h=n.map(()=>[]),m=n.map(()=>[]),T=[],w,W=new Set;for(let S=0;S<2&&!w;S++){let O=[],u=[],F=[];if(i.forEach((A,d)=>{if(A.success)return;let l=y[d],g=o[d]??new Set;if(A.errors.some(E=>J(E))){let E=n[d]?.[N];if(typeof E=="string"&&!g.has(N)&&(A.errorDetails??[]).some(p=>J(p.statusCode)&&p.fields.includes(N))&&W.add(E),c[d].has("lookup")||!s||s.size===0)return;let j={},$=!1;for(let p of Object.keys(l)){if(s.has(p)&&!g.has(p)&&l[p]!==null&&l[p]!==void 0){$=!0;continue}j[p]=l[p]}if(!$)return;O.push(d),u.push(j),F.push(null);return}if(c[d].has("fields"))return;let k=me(A.errorDetails,l,a);if(!k||k.some(({field:E})=>g.has(E)))return;let I=new Set(k.map(({field:E})=>E));O.push(d),u.push(Object.fromEntries(Object.entries(l).filter(([E])=>!I.has(E)))),F.push(k)}),O.length===0)break;let P;try{P=await this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField)}catch(A){if(!(A instanceof x)){T.push(...Ye(O,y,u,F,A));break}P=A.written,w=A}P.forEach((A,d)=>{let l=O[d],g=F[d];c[l].add(g===null?"lookup":"fields"),g===null?h[l].push(...Object.keys(y[l]).filter(k=>!(k in u[d]))):m[l].push(...g),y[l]=u[d],i[l]=A})}let f=new Set,v=0,R,L=new Set(W);return i.forEach((S,O)=>{if(!(!S.success||c[O].size===0)){if(h[O].length>0){v++;for(let F of h[O])f.add(F);let u=n[O]?.[N];typeof u=="string"&&h[O].length===1&&h[O][0]===N&&L.add(u)}m[O].length>0&&(R=we(R,{rows:1,fields:m[O].map(u=>({...u,rows:1}))}))}}),{outcomes:i,notes:[...T,...w?.notes??[]],...R?{writtenWithoutFields:R}:{},cancelled:w!==void 0,ownersRefused:[...L],lookupsLeftOut:[...v>0?[{records:v,fields:[...f].sort(),reason:"notInTarget"}]:[],...w?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ke=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],qe=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ke.some(e=>t.includes(e))||qe.test(t)}var N="OwnerId";function He(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[N];typeof a!="string"||e[o]?.has(N)||n.links.isOwnerRefused(a)&&(delete s[N],r.add(o))}),r}function je(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[N],reason:"ownerRefusedEarlier"}}function Ye(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,y=0;return r.forEach((c,h)=>{if(c===null){y++;let m=n[h];for(let T of Object.keys(e[t[h]]))T in m||a.add(T)}else for(let{field:m}of c)i.add(m)}),[...y>0?[`${y} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-y} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var D=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function U(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function vt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new D;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Me(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Ve(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof x?new x(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function De(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[c,h]of e){let m=n[c];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(h),a.length<ke&&a.push(m.id))}let i=Ie(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),y=Ae(t.objectApiName,o,i);y&&s.createdWithoutRecordType.set(t.objectApiName,{given:y,types:i,ids:a})}function Ze(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function $e(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Me(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function Je(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var _e=1e3;function Qe(t,e,n,r=[],s=[],o){let a=0,i=0,y=0,c,h=[],m=0,T={created:0,updated:0},w={rows:0,written:0,stillLocked:0};for(let f of n)f.lockResends!==void 0&&(w.rows++,f.success?w.written++:he(f.errors,f.errorDetails)&&w.stillLocked++),f.success?(a++,f.created===!0?T.created++:f.created===!1&&T.updated++):Me(e,f)!==void 0?(y++,c??=f.errors[0]):(i++,!f.heldBack&&m++<_e&&h.push(...f.errors));let W=Math.max(0,m-_e);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:y,conflictCount:0,errors:[...h,...r],...y>0?{linkedToExisting:{records:y,...c?{refusal:c}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...w.rows>0?{sentAgainForALock:w}:{},...W>0?{refusalsDropped:W}:{},...e==="upsert"?{upsertSplit:T}:{}}}export{We as a,Ae as b,Ie as c,Ee as d,yt as e,gt as f,ht as g,Pe as h,Rt as i,Ot as j,xe as k,x as l,Ne as m,vt as n,Q as o,Me as p,Je as q,_e as r,Qe as s};
@@ -1,10 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{G as ve,m as Ce,n as Be}from"./chunk-H4CGM6YO.mjs";import{e as w,f as L,g as je,l as v,m as Te}from"./chunk-FP7CYB2F.mjs";import{a as ie}from"./chunk-NED4MBIM.mjs";import{b as $}from"./chunk-JAEDM4SI.mjs";import{Zb as _e,hb as Ne,jb as J,lb as De}from"./chunk-KB4ZHM4Q.mjs";import{j as Se}from"./chunk-23SEDORH.mjs";import{b as oe,f as we}from"./chunk-INIT2UKJ.mjs";import{k as ke,l as Ae,m as Ee}from"./chunk-D4GF4FAB.mjs";import{da as z,ea as Oe}from"./chunk-TNT27RBG.mjs";import{b as M}from"./chunk-CA5NAXSU.mjs";import{b as ne,e as V,f as re,k as ye,l as _}from"./chunk-WZQEK4WT.mjs";function dt(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function Bn(e,t){return t?"cancelled":e.every(n=>dt(n)===0)?"success":e.some(n=>n.deleted>0)?"partial":"failure"}function vn(e,t){return e!=="success"||!t||t.status==="success"?e:t.status==="cancelled"?"cancelled":"partial"}function jn(e){return e.status}function Tn(e){return e.filter(t=>t.deleted+t.refused+(t.notReached??0)>0).map(t=>({...Se(t.objectApiName),deleted:t.deleted,failed:t.refused,...(t.notReached??0)>0?{notSent:t.notReached}:{}}))}function Nn(e,t,n,r=!1){let o=R=>e.objects.reduce((C,B)=>C+R(B),0),i=o(R=>R.deleted),s=o(R=>R.alreadyGone),l=o(R=>R.keptChanged+R.keptDependents),u=o(R=>R.refused),c=o(R=>R.notVisible??0);if(i+s===0&&(!r||e.status==="cancelled"||l+u+c===0))return;let b=r?void 0:n,O=o(R=>R.platformCopies??0),E=e.status==="cancelled"?Math.max(0,t+O-i-s-l-u-c):0;return{removedAt:e.finishedAt,deleted:(b?.deleted??0)+i,alreadyGone:(b?.alreadyGone??0)+s,kept:l,refused:u,...E>0?{notReached:E}:{},...c>0?{notVisible:c}:{}}}function Dn(e,t){let n=o=>e.objects.reduce((i,s)=>i+o(s),0),r=n(o=>o.notVisible??0);return{removedAt:e.finishedAt,deleted:t.deleted,alreadyGone:t.alreadyGone,kept:n(o=>o.keptChanged+o.keptDependents),refused:n(o=>o.refused),...r>0?{notVisible:r}:{}}}function _n(...e){let t=new Set,n=[];for(let r of e.flatMap(o=>o??[])){let o=`${r.first}|${r.last}|${r.userId.slice(0,15)}`;t.has(o)||(t.add(o),n.push(r))}return n.sort((r,o)=>Date.parse(r.first)-Date.parse(o.first))}var se=5;function x(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function P(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Pe(e,t){if(!(!e&&!t))return{count:(e?.count??0)+(t?.count??0),objects:x(e?.objects??[],t?.objects??[])}}function Pn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n});continue}let o={notVisible:P(r.notVisible,n.notVisible),notReached:P(r.notReached,n.notReached),heldByAutomation:P(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:P(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:P(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:P(r.platformCopies,n.platformCopies)},i=x(r.automationHolders??[],n.automationHolders??[]),s=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:x(r.filesLeft?.names??[],n.filesLeft?.names??[],se)}:void 0,l=Pe(r.tookAlong,n.tookAlong),u=Pe(r.cameAlong,n.cameAlong);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,deleted:r.deleted+n.deleted,alreadyGone:r.alreadyGone+n.alreadyGone,keptChanged:r.keptChanged+n.keptChanged,keptDependents:r.keptDependents+n.keptDependents,refused:r.refused+n.refused,...Object.fromEntries(Object.entries(o).filter(([,c])=>c!==void 0)),heldBy:x(r.heldBy,n.heldBy),...i.length>0?{automationHolders:i}:{},unchecked:x(r.unchecked,n.unchecked),reasons:x(r.reasons,n.reasons,se),...s?{filesLeft:s}:{},...l?{tookAlong:l}:{},...u?{cameAlong:u}:{}})}return[...t.values()]}function xn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n,changedBy:{...n.changedBy}});continue}let o={...r.changedBy};for(let[s,l]of Object.entries(n.changedBy))o[s]=(o[s]??0)+l;let i=P(r.platformCopies,n.platformCopies);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,toDelete:r.toDelete+n.toDelete,alreadyGone:r.alreadyGone+n.alreadyGone,changedSince:r.changedSince+n.changedSince,keptChanged:r.keptChanged+n.keptChanged,changedBy:o,undeletable:r.undeletable+n.undeletable,notVisible:r.notVisible+n.notVisible,unread:r.unread+n.unread,...i!==void 0?{platformCopies:i}:{},reasons:x(r.reasons,n.reasons,se)})}return[...t.values()]}import{AsyncLocalStorage as ct}from"node:async_hooks";var xe=new Set(["delete","hardDelete"]),ue=1e4,$e=5e4;function $n(e){switch(e){case"production":return;case"staging":return ue;case"development":case"scratch":return $e}}var Le=new ct;function ae(){let e=Le.getStore();return e?.live?e:void 0}async function Ln(e,t){let n={approved:e.approved,live:!0};try{return await Le.run(n,t)}finally{n.live=!1}}var Ie=class{overrides=new Map;options;constructor(t){this.options=t??{}}check(t){let n=this.checkTier(t),{orgNameOf:r}=this.options;return!n.requiresConfirmation||!r?n:{...n,question:ft(t,r(t.orgId),this.options.questionWords)}}checkTier(t){switch(t.orgTier){case"production":return this.checkProduction(t);case"staging":return this.checkStaging(t);case"development":case"scratch":return this.checkDevelopment(t)}}setProductionOverride(t,n){this.overrides.set(t,n)}isProductionOverridden(t){return this.overrides.get(t)===!0}get canAskForConfirmation(){return this.options.requestConfirmation!==void 0||ae()!==void 0}async confirmIfNeeded(t,n){if(!t.allowed||!t.requiresConfirmation)return t.allowed;let r=ae();return r?r.approved:this.options.requestConfirmation?t.question===void 0?this.options.requestConfirmation(t.impactSummary,n):this.options.requestConfirmation(t.impactSummary,n,t.question):!0}declinedWithoutAsking(t,n){if(!(!t.allowed||!t.requiresConfirmation||ae())&&this.options.requestConfirmation)return this.options.declinesWithoutAsking?.(n)}async confirmRun(t){return this.options.requestRunConfirmation?await this.options.requestRunConfirmation(t)?"confirmed":"declined":"unavailable"}orgPhrase(t,n){let r=this.options.orgNameOf?.(t.orgId);return r?n.org(t.orgTier,r,!0):n.org(t.orgTier,t.orgId,!1)}checkProduction(t){let n=[],r=xe.has(t.operation),o=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${q(t.recordCount)} ${ut(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let i=this.options.questionWords??Fe;return t.operation==="deploy"?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deployRefused(this.orgPhrase(t,i)),warnings:n,impactSummary:W(t)}:r&&!o?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deleteRefused(t.operation==="hardDelete"?"hardDelete":"delete",this.orgPhrase(t,i)),warnings:n,impactSummary:W(t)}:(r&&o&&n.push("Production override is active \u2014 destructive operation permitted"),{allowed:!0,requiresConfirmation:!0,warnings:n,impactSummary:W(t)})}checkStaging(t){let n=[],r=xe.has(t.operation),o=t.operation==="deploy",i=r||o||de(t.recordCount)>ue;return r&&n.push(`Destructive operation (${t.operation}) on staging org \u2014 confirmation required`),o&&n.push("Metadata deployment on staging org \u2014 confirmation required"),de(t.recordCount)>ue&&n.push(`Large volume operation: ${q(t.recordCount)} records on staging`),{allowed:!0,requiresConfirmation:i,warnings:n,impactSummary:W(t)}}checkDevelopment(t){let n=[];return de(t.recordCount)>$e&&n.push(`Large volume operation: ${q(t.recordCount)} records on ${t.orgTier} org`),{allowed:!0,requiresConfirmation:!1,warnings:n,impactSummary:W(t)}}};function q(e){return e==="unknown"?"an unknown number of":typeof e=="number"?String(e):`at most ${e.atMost}`}function de(e){return e==="unknown"?0:typeof e=="number"?e:e.atMost}function ut(e){return e.operation==="deploy"?"components":"records"}var Fn="the related records the run adds",Fe={sentence:(e,t,n)=>{switch(e){case"insert":return`Insert ${t} into ${n}.`;case"update":return`Update ${t} in ${n}.`;case"upsert":return`Insert or update ${t} in ${n}.`;case"delete":return`Delete ${t} in ${n}.`;case"hardDelete":return`Permanently delete ${t} in ${n}.`;case"deploy":return`Deploy ${t} to ${n}.`}},counted:(e,t)=>t==="unknown"?`${e}s`:typeof t=="number"?`${t} ${e}${t===1?"":"s"}`:`at most ${t.atMost} ${e}s`,besides:(e,t)=>`${e}, plus ${t},`,org:(e,t,n)=>n?`the ${e} org "${t}"`:`the ${e} org ${t}`,deployRefused:e=>`SandForge deploys metadata only to a sandbox, a scratch org or a Developer Edition org, not to ${e}: bring the change there through your release process, as a change set or a deployment from source control.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},lt=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function ft(e,t,n=Fe){let r=e.operation==="deploy"?"component":"record",o=lt.has(e.objectName)?"":` (${e.objectName})`,i=`${n.counted(r,e.recordCount)}${o}`,s=e.alsoWrites?n.besides(i,e.alsoWrites):i,l=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,s,l)}function W(e){if(e.operation==="deploy")return`DEPLOY ${q(e.recordCount)} component(s) (${e.objectName}) to ${e.orgTier} org ${e.orgId} [module: ${e.module}]`;let t=e.alsoWrites?`, plus ${e.alsoWrites},`:"";return`${e.operation.toUpperCase()} ${q(e.recordCount)} ${e.objectName} record(s)${t} on ${e.orgTier} org ${e.orgId} [module: ${e.module}]`}function Y(e,t){return`${e} ${t}${e===1?"":"s"}`}var mt={cost:({records:e,objects:t,requests:n,seconds:r,megabytes:o,keepDays:i})=>`Checkpoint first: about ${Y(e,"record")} of ${Y(t,"object")}, ${Y(n,"API request")}, ${r} s, ${o} MB on this machine, unencrypted, and none of the org's storage, `+(i===0?"kept until you delete it.":`kept ${Y(i,"day")}.`),added:(e,t)=>`Added: ${e} \u2014 ${t}`,notHeld:(e,t)=>`Not in the checkpoint: ${e} \u2014 ${t}`,more:e=>`\u2026 and ${e} more`,unknown:"What an Apex trigger, or automation that could not be read, creates as the run writes is not known: a rewind leaves those records as they are."},ce=10;function pt(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function Un(e,t=mt){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:pt(n.bytes),keepDays:e.keepDays})],o=(i,s)=>{for(let{objectApiName:l,reason:u}of i.slice(0,ce))r.push(s(l,u));i.length>ce&&r.push(t.more(i.length-ce))};return o(e.added,t.added),o(e.notHeld,t.notHeld),r.push(t.unknown),r}var gt=300,bt=1024,ht=160,Rt=500,Je=40,yt=4,Ot=3,St=3,wt=1,kt=1e3,At=1,Ue=200,Et=60,Ct=50,Bt=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
8
- `),vt="IsDeleted = false",Ye=4;function jt(e){return e.access?.kind==="perObject"?e.access.requests:0}var Tt=1,Nt=200,Dt=3,_t=1,Pt=1,Xe=2,xt=3,It=2e3,Mt=100,Ze=["Id","SystemModstamp"],We=23,N=2.5,h=.35,$t=1,Lt=.9,S=.5,ge=.25,j=.86,Ft="ContentVersion",Ut="ContentDocument",le=200,qe=150,y={apiRequests:0,seconds:0};function d(e,t){return{apiRequests:e,seconds:e*t}}function G(e){return{apiRequests:e,seconds:g(e,je)*h}}function f(...e){return e.reduce((t,n)=>({apiRequests:t.apiRequests+n.apiRequests,seconds:t.seconds+n.seconds}),y)}function g(e,t){return e>0?Math.ceil(e/t):0}function k(e){return g(e,$)}function et(e){return oe(e,Ze).length}function Wt(e){return e.length>Mt?$/4:$}function Q(e,t){return g(e,Wt(t))*et(t)}function Ge(e,t){if(e.length===0)return 0;let n=2*(e.length-1)+2+2*(t-1);for(let r of e){let o=JSON.stringify(r,null,2),i=1;for(let s=o.indexOf(`
9
- `);s>=0;s=o.indexOf(`
10
- `,s+1))i++;n+=Buffer.byteLength(o,"utf8")+i*2*t}return n}function qt(e){let t=bt+(e.printsBytes??0),n=[];for(let r of e.objects)t+=r.records*gt+Te(r.records,2),r.records>0&&(t+=ht),t+=(r.inBin??0)*Bt,t+=(r.links??0)*(Et+Ct),r.entry!==void 0&&n.push(r.entry);return t+Ge(n,2)+Ge(e.leftOut??[],3)}function tr(e,t,n){let[,...r]=oe(t,Ze),o=n==="scanAllLive"?vt:void 0;return r.map(i=>we(e,i,o))}function He(e,t){return t.reduce((n,r)=>n+g(e,Math.max(1,r)),0)}function Gt(e,t){if(e.records===0)return{pages:0,reads:0};let n=Math.floor(e.records/t),r=e.records-n*t,o=e.otherGroups??[];return{pages:n+(r>0?1:0),reads:n*He(t,o)+He(r,o)}}function nr(e){let t=e.objects.length,n=g(e.described,L),r=e.describedAlone??0,o=G(g(e.counted??t,w)),i=(e.countedAlone??0)+g(e.recounted??0,w),s=o.apiRequests+i,l=G(g(t,w)),u=Math.min(e.pageRows,kt),c=0,b=0,O=0;for(let m of e.objects){O+=m.records;let p=Gt(m,u);c+=p.pages,b+=p.reads}let E=H(e.objects.map(m=>F(m.inBin??0))),R=Ht(e.objects),C=e.objects.filter(m=>(m.stampedSince??0)>0),B=f(H(C.flatMap(m=>[F(m.stampedSince??0),1])),G(g(C.length,w))),D=c+b+(c>0?wt:0),A=e.annexCalls??0,a={guard:yt,scope:Ot+n+r,start:St,counts:s,bin:E.apiRequests,snapshot:D+R.apiRequests+A,stability:At+l.apiRequests+B.apiRequests};return{records:O,apiRequests:Object.values(a).reduce((m,p)=>m+p,0),requestsByPhase:a,seconds:Math.ceil(n*N+(r+i+A)*h+o.seconds+l.seconds+E.seconds+B.seconds+R.seconds+c*$t+b*S),bytes:qt(e)}}function Ht(e){let t=e.filter(o=>o.links!==void 0);if(t.length===0)return y;let n=0,r=0;for(let o of t)o.links===null?n+=g(g(o.records,Ue),w):r+=o.links??0;return f(H(t.map(o=>F(o.links??0))),d(n,S),d(g(g(r,Ue),w),S))}function F(e){return Math.max(1,g(e,It))}function H(e){let t=0,n=0;for(let r=0;r<e.length;r+=w){let o=Math.max(1,...e.slice(r,r+w));t+=1,n+=o-1}return f(d(t,h),d(n,Lt))}function Qt(e){let t=new Set([...e.held,...e.moved.map(n=>n.objectApiName)]);return f(G(g(e.objects,w)),H(e.moved.flatMap(({live:n,deleted:r})=>[F(n),F(r)])),G(g(t.size,w)))}function tt(e){let t=e.reduce((n,r)=>n+k(r),0);return f(d(t*(Dt-1),S),d(t,j))}function Kt(e){return f(...e.filter(t=>t.records>0).map(({records:t,cascades:n,described:r})=>{let o=k(t);return f(d(r?0:1,N),tt([t]),d(o*g(n,w),h),d(o*_t,S))}))}function fe(e,t){let n=y;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=f(n,d(Xe,h),d(Q(o,t),S),d(J([{rows:o}]),j),d(k(o),S))}return n}function Vt(e,t,n,r){return e===0||n===0?y:f(d(r?0:1,N),d((n+k(e))*g(t,w),h))}var nt=_({childRelationships:ye(_({childSObject:ne().optional(),field:ne().optional(),cascadeDelete:re().optional(),restrictedDelete:re().optional()}).loose()).nullish()}).loose();function rr(e,t){let n=nt.parse(e).childRelationships??[],r=n.filter(u=>u.cascadeDelete===!0),o=t?.worked,i={dependents:n.filter(u=>(u.cascadeDelete===!0||u.restrictedDelete===!0)&&(o===void 0||u.childSObject!==void 0&&o.has(u.childSObject))).length,cascades:r.length,cascadeChildren:[...new Set(r.flatMap(u=>u.childSObject===void 0?[]:[u.childSObject]))]};if(t===void 0)return i;let s=n.filter(u=>u.cascadeDelete===!0&&u.childSObject!==void 0&&!t.inCheckpoint.has(u.childSObject.toLowerCase())),l=s.filter(u=>u.childSObject!==void 0&&t.worked?.has(u.childSObject)===!0);return{...i,outside:{all:s.length,worked:l.length}}}function or(e,t){return(nt.parse(e).childRelationships??[]).flatMap(n=>(n.cascadeDelete===!0||n.restrictedDelete===!0)&&n.childSObject!==void 0&&n.field!==void 0&&(t===void 0||t.has(n.childSObject))?[{childSObject:n.childSObject,field:n.field}]:[])}function be(e,t){return e?.get(t)??{dependents:We,cascades:We}}function zt(e,t){if(e<Ce||t===Ft||t===Ut)return d(J([{rows:e}]),j);let n=Math.ceil(e/Be),r=Math.ceil(e/n),o=y;for(let i=e;i>0;i-=r){let s=Math.min(i,r);o=f(o,{apiRequests:ke({stateReads:Ee(s)}),seconds:Ae(s)})}return o}function me(e,t=Number.POSITIVE_INFINITY){let n=e.filter(r=>r.records>0);return n.length===0?y:f(d(xt,h),...n.map(({records:r,dependents:o,pointing:i,objectApiName:s})=>{let l=k(r),u=0;for(let c=r;c>0;c-=t){let b=k(Math.min(c,t));u+=b>1?o+Math.min(i??o,o)*b:o}return f(d(1,h),d(l,S),d(u,ge),Yt(s,l,u),zt(r,s))}))}function Jt(e,t,n){return f(...e.filter(({count:r})=>r>0).map(({objectApiName:r,count:o})=>{let{dependents:i}=be(t,r),s=o>$?i:0;return f(d(n.has(r)?0:1,N),d(s+i*k(o),ge))}))}function Yt(e,t,n){return e===void 0||z[e]===void 0||Oe.has(e)?y:f(d(1,h),d(t,S),d(n,ge),d(t,j))}function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince}function X(e){return e.toBringBack.inBin+e.toBringBack.deletedWhileTaken+te(e)}function te(e){return e.toBringBack.carriers??0}function U(e){return e.toDelete.comesBackWithParent+te(e)}function Z(e){return e.cannotUndo.filter(t=>t.reason==="deletedWithCreatedParent"||t.reason==="deletedWithParentOutside").reduce((t,n)=>t+n.count,0)}function ee(e){return X(e)-te(e)+e.toBringBack.withParent}function rt(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}function pe(e){return e.cannotUndo.filter(t=>t.reason==="goneForGood").reduce((t,n)=>t+n.count,0)}function I(e){return e.toRecreate??0}function Xt(e){return pe(e)+I(e)}function Zt(e,t){let n=0;for(let r=e;r>0&&t>0;r-=v){let o=Math.min(r,v);n+=g(t*k(o),w)}return n}function he(e,t,n){let r=Xt(e);return{objectApiName:e.objectApiName,live:e.toGiveBack.records+e.touched+T(e)+e.unexplained,deleted:ee(e)+U(e)+Z(e),valued:e.toGiveBack.records+e.touched+e.toBringBack.withParent,backTo:ee(e)+te(e)+Z(e)>0||t.undeletable===!1&&r>0,deletes:T(e),scans:r>0&&t.undeletable!==!1,whole:e.schemaDrift!==void 0,outside:n?.get(e.objectApiName)?.outside??{all:e.outside.length,worked:e.outside.length}}}function en(e,t,n,r){let o=he(e,t,n),i=e.toBringBack,s=r?0:U(e);return{...o,live:e.toGiveBack.records+e.touched+e.unexplained+ee(e)+I(e)+s,deleted:T(e)+U(e)-s+Z(e),valued:e.toGiveBack.records+e.touched+i.inBin+i.withParent+I(e),backTo:Z(e)>0||t.undeletable===!1&&pe(e)>0,scans:pe(e)>0&&t.undeletable!==!1,deletes:s}}function ot(e,t,n,r,o,i=0,s,l=0){let u=[],c=[],b=0,O=0,E=0,R=!1,C=0;for(let{objectApiName:A,records:a,fields:m}of e){let p=t.get(A);if(p===void 0){n.has(A)&&u.push({objectApiName:A,live:0,deleted:0});continue}u.push({objectApiName:A,live:p.live,deleted:p.deleted}),b+=Q(p.valued,m),p.backTo&&!p.whole&&O++,p.scans&&c.push(H([F(a)])),p.deletes!==0&&(!p.whole&&!p.backTo&&E++,p.outside.all>0&&(R=!0),C+=Zt(p.deletes,p.outside.worked))}s!==void 0&&(R=!0);let B=s!==void 0?1:0,D=o===void 0?g(e.length+B,L):g(o.first+B,L)+g(o.later,L);return f(d(Tt,h),d(D,N),Qt({objects:e.length,held:e.filter(A=>A.records>0).map(A=>A.objectApiName),moved:u}),d(b,S),d(g(O,L),N),d(E,h),d(R?1:0,N),d(C,h),d(i,h),d(l,h),d(s?.requests??0,S),...c,d(g(g(r,Nt),w),h))}function it(e){return e.files!==void 0?{requests:e.filesRequests??0}:void 0}function st(e,t){let n=new Map(e.diff.objects.map(o=>[o.objectApiName,o])),r=new Map;for(let o of e.objects){let i=n.get(o.objectApiName);i&&r.set(o.objectApiName,t(i,o))}return r}function tn(e){let t=new Set(e.diff.objects.flatMap(n=>Object.keys(n.lastChangedBy)));return ot(e.objects,st(e,(n,r)=>he(n,r,e.relationships)),new Set(e.diff.unread.map(n=>n.objectApiName)),t.size,e.diff.described,e.diff.parentsOutsideRequests??0,it(e.diff),e.diff.fieldsRequests??0)}function Qe(e,t,n=!1){let r=!t&&(n||e.diff.objects.some(s=>U(s)>0)),o=e.diff.described,i=new Set(e.diff.objects.map(s=>s.objectApiName));return ot(e.objects,st({...e,diff:e.readDiff??e.diff},(s,l)=>i.has(s.objectApiName)?en(s,l,e.relationships,t):he(s,l,e.relationships)),new Set(e.diff.unread.map(s=>s.objectApiName)),r?1:0,o===void 0?void 0:{first:o.first+o.later,later:0},e.diff.parentsOutsideRequests??0,it(e.diff),e.diff.fieldsRequests??0)}function nn(e){return f(...e.filter(t=>t>0).map(t=>f(d(1,h),d(k(t),j))))}var rn=new Set(["activateddate","activatedbyid"]);function on(e){return f(...e.filter(({objectApiName:t,records:n})=>n>0&&z[t]!==void 0).map(({records:t})=>f(d(1,h),d(k(t),j))))}function sn(e,t){return e*Rt+t*Je}function Ke(e){return f(d(Xe,h),d(et(e),S),d(1,j),d(1,S))}function an(e,t,n,r){if(t===0)return y;let o=e==="Order"?n.find(c=>c.toLowerCase()==="status"):void 0,i=o===void 0?[]:[o],s=c=>f(fe(c,n),o?fe(c,i):y),l=f(Ke(n),o?Ke(i):y),u=d(Q(t,n),S);return f(s(t),r.held?f(u,l):y,r.held&&r.twice?f(s(t),l):y,r.nextPass?f(u,l):y)}function Ve(e,t,n,r){let o=r?.get(n.objectApiName)?.cascadeChildren;return o!==void 0?o.includes(t):e?.cascadeParents!==void 0&&e.cascadeParents.length===0?!1:e?.readOrder!==void 0&&n.readOrder!==void 0?e.readOrder<n.readOrder:!0}function dn(e){let t=e.diff.objects,n=new Map(e.objects.map(a=>[a.objectApiName,a])),r=a=>be(e.relationships,a),o=e.diff.undoCannot?e.diff.undoCannot.reduce((a,{objectApiName:m,count:p})=>a.set(m,(a.get(m)??0)+p),new Map):void 0,i=e.diff.withParentDeleted?new Map(e.diff.withParentDeleted.map(({objectApiName:a,count:m})=>[a,m])):void 0,s=a=>{if(i!==void 0)return Math.max(0,T(a)-(i.get(a.objectApiName)??0));if(o===void 0||n.get(a.objectApiName)?.undeletable!==!1)return T(a);let m=(o.get(a.objectApiName)??0)-a.toDelete.comesBackWithParent;return Math.max(0,Math.min(T(a),m))},l=t.filter(a=>s(a)>0),u=t.filter(a=>U(a)>0),c=(a,m)=>m.some(p=>p.objectApiName!==a.objectApiName&&Ve(n.get(p.objectApiName),p.objectApiName,a,e.relationships)),b=(a,m)=>m.some(p=>{let K=n.get(p.objectApiName);return K!==void 0&&p.objectApiName!==a.objectApiName&&Ve(a,a.objectApiName,K,e.relationships)}),O=t.reduce((a,m)=>a+k(X(m)),0),E=e.duplicateSets??0,R=e.reusesPreview!==!0&&t.some(a=>T(a)>0&&(e.relationships?.get(a.objectApiName)?.outside?.all??a.outside.length)>0),C=t.some(a=>X(a)>0&&r(a.objectApiName).cascades>0),B=f(d(C&&!R?1:0,N),Kt(t.map(a=>({records:X(a),cascades:r(a.objectApiName).cascades,described:e.reusesPreview!==!0}))),...t.map(a=>Vt(a.toBringBack.withParent,r(a.objectApiName).cascades,O,e.reusesPreview!==!0)),...t.map(a=>{let m=n.get(a.objectApiName);return m===void 0?y:an(a.objectApiName,rt(a),m.fields,{held:c(m,l),twice:b(m,l),nextPass:c(m,u)})}),nn(t.map(I)),on(t.map(a=>({objectApiName:a.objectApiName,records:I(a)}))),d(E>0?2+g(E,$):0,S),me([...t.map(a=>({objectApiName:a.objectApiName,records:s(a),dependents:r(a.objectApiName).dependents,pointing:r(a.objectApiName).pointing})),{objectApiName:ve,records:E,dependents:1}],ie)),D=t.flatMap(a=>{let m=n.get(a.objectApiName),p=I(a);return p===0||m===void 0?[]:z[a.objectApiName]===void 0?[]:m.fields.some(K=>rn.has(K.toLowerCase()))?[fe(p,m.fields)]:[]}),A=u.length>0||D.length>0?f(me(u.map(a=>({objectApiName:a.objectApiName,records:U(a),dependents:r(a.objectApiName).dependents,pointing:r(a.objectApiName).pointing})),ie),...D,Qe(e,!0)):y;return f(d(Pt,h),B,un(e.diff.files),Qe(e,!1,D.length>0),A)}function cn(e){return e===void 0?0:e.unlink+e.relink+e.updateLinks}function un(e){return e===void 0?y:d(g(e.unlink,le)+g(e.relink,le)+g(e.updateLinks,le),j)}function ir(e){let t=e.diff.objects,n=t.reduce((b,O)=>b+T(O)+O.toDelete.comesBackWithParent,0),r=t.reduce((b,O)=>b+O.toGiveBack.records,0),o=t.reduce((b,O)=>b+ee(O),0),i=t.reduce((b,O)=>b+I(O),0),s=n+r+o+i,l=f(d(Ye+jt(e.diff),h),e.reusesPreview===!0?y:tn({...e,diff:e.readDiff??e.diff})),u=e.diff.files;if(s===0&&cn(u)===0)return{records:0,apiRequests:l.apiRequests,seconds:Math.ceil(l.seconds),bytes:0};let c=f(l,d(e.automationRequests,S),d(e.deliverabilityRequests??0,h),d(e.muteRequests??0,h),dn(e));return{records:s,apiRequests:c.apiRequests,seconds:Math.ceil(c.seconds),bytes:sn(t.reduce((b,O)=>b+rt(O),0),n+o+2*i)+ln(u)}}function ln(e){return e===void 0?0:e.unlink*qe+e.relink*Je+e.updateLinks*qe}var fn=1;function ze(e,t){let n=y;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=f(n,d(fn,h),d(Q(o,t),S),d(J([{rows:o}]),j))}return n}function mn(e,t){let n=Math.min(e.givenBackHeld??0,e.givenBack),r=y;for(let o=e.givenBack;o>0;o-=v)r=f(r,d(Q(Math.min(o,v),t),S));return f(ze(n,t),ze(e.givenBack-n,t),r)}var pn=2;function gn(e){let t=Math.min(e.givenBackHeld??0,e.givenBack);return d(k(e.givenBack)+k(t)+k(e.givenBack-t),S)}function sr(e){let t=new Map(e.objects.map(c=>[c.objectApiName,c.fields])),n=e.rewound.reduce((c,b)=>c+b.deleted+b.broughtBack+b.givenBack,0),r=d(Ye,h);if(n===0)return{records:0,apiRequests:r.apiRequests,seconds:Math.ceil(r.seconds),bytes:0};let o=e.rewound.some(c=>c.deleted>0),i=e.rewound.some(c=>c.givenBack>0),s=new Set(e.rewound.filter(c=>c.broughtBack>0).map(c=>c.objectApiName)),l=o&&i?f(d(pn,h),...e.rewound.map(gn)):y,u=f(r,d(e.automationRequests,S),l,me(e.rewound.map(c=>({objectApiName:c.objectApiName,records:c.broughtBack,dependents:be(e.relationships,c.objectApiName).dependents}))),s.size>0?Jt(e.along??[],e.relationships,s):y,tt(e.rewound.map(c=>c.deleted)),...e.rewound.map(c=>mn(c,t.get(c.objectApiName)??[])));return{records:n,apiRequests:u.apiRequests,seconds:Math.ceil(u.seconds),bytes:0}}var bn={take:{what:"This checkpoint",then:"Take it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or pick fewer objects.",done:"No record was read."},rewind:{what:"This rewind",then:"Rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or rewind fewer of its objects at a time, which sends only theirs (the objects ticked in the preview, or --object on a command line).",done:"No record was read or written."},undo:{what:"This undo",then:"Undo the rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 while the recycle bin still holds what it brings back.",done:"No record was read or written."}},hn=_({FileStorageMB:_({Max:V(),Remaining:V()}).loose()}).loose(),Rn=_({DataStorageMB:_({Max:V().int().nonnegative()}).loose()}).loose();async function ar(e,t){let n,r;try{n=await e.request({method:"GET",url:"/limits"}),r=await Ne({request:()=>Promise.resolve(n)})}catch(l){throw new Error(`${t} did not say how many API requests it has left today: ${M(l)}`)}let o;try{o=await _e({request:()=>Promise.resolve(n)})}catch(l){o={unread:M(l)}}let i=hn.safeParse(n),s=Rn.safeParse(n);return{...r,emails:o,...i.success?{fileStorage:{max:i.data.FileStorageMB.Max,remaining:i.data.FileStorageMB.Remaining}}:{},...s.success?{dataStorageMaxMB:s.data.DataStorageMB.Max}:{}}}var yn={mute:e=>`to assign and take back the permission sets that mute ${e}'s automation`,deliverability:e=>`to read whether ${e} delivers its emails`};function On(e,t){if(e===void 0)return"";let n=Object.entries(yn).flatMap(([r,o])=>{let i=e[r]??0;return i>0&&o?[{requests:i,words:o(t)}]:[]}).map(({requests:r,words:o},i)=>`${r}${i===0?" of them":""} ${o}`);return n.length>0?` (${n.join(", ")})`:""}function dr(e,t,n,r){let o=De(t,n);if(o.verdict!=="exceeds")return;let i=bn[e];return{code:"API_BUDGET",message:`${i.what} takes about ${o.estimate} API requests${On(o.parts,r)}; ${r} has ${n.remaining} of its ${n.max} left today. ${i.then} ${i.done}`}}var Sn={rewind:{then:"Free file storage, then rewind again.",done:"Nothing was written."},undo:{then:"Free file storage, then undo the rewind again while the recycle bin still holds them.",done:"Nothing was written."}};function wn(e){let t=e/1048576;return t<1?`${Math.max(1,Math.round(t*10))/10} MB`:`${Math.ceil(t)} MB`}function cr(e,t,n,r){if(n===void 0||t.files===0||t.bytes<=n*1048576)return;let o=Sn[e];return{code:"FILE_STORAGE",message:`Bringing back ${t.files===1?"1 file":`${t.files} files`} takes ${wn(t.bytes)} of file storage; ${r} has ${n} MB left. ${o.then} ${o.done}`}}import{randomUUID as kn}from"node:crypto";var Re="\0configStore:revision",An="\0configStore";function En(e){let t=e[Re]?.value;if(t!==void 0)try{let n=JSON.parse(t);return typeof n.writer=="string"&&typeof n.write=="number"?{writer:n.writer,write:n.write}:void 0}catch{return}}var at=class{backend;logWarning;writer=kn();writes=0;written;constructor(t,n){this.backend=t,this.logWarning=n}initialize(){this.backend.getData()}get(t){let n=this.current()[t];if(n)try{return JSON.parse(n.value)}catch(r){let o=M(r);this.logWarning?.(`[ConfigStore] Failed to parse JSON for key "${t}": ${o}`);return}}set(t,n,r="general"){let o=JSON.stringify(n);this.update(i=>{let s=i[t];return s&&s.value===o&&s.category===r?!1:(i[t]={value:o,category:r},!0)})}delete(t){return this.update(n=>t in n?(delete n[t],!0):!1)}has(t){return t in this.current()}getByCategory(t){let n={};for(let[r,o]of Object.entries(this.current()))if(o.category===t)try{n[r]=JSON.parse(o.value)}catch(i){let s=M(i);this.logWarning?.(`[ConfigStore] Corrupted entry in category "${t}", key "${r}": ${s}`)}return n}getAllKeys(){return Object.keys(this.current()).filter(t=>t!==Re)}getKeysByPrefix(t){return this.getAllKeys().filter(n=>n.startsWith(t))}clearCategory(t){let n=0;return this.update(r=>{for(let[o,i]of Object.entries(r))i.category===t&&(delete r[o],n++);return n>0}),n}clearAll(){this.write({})}current(){let t=this.backend.getData(),n=En(t);return this.written&&n?.writer===this.writer&&n.write<this.writes?this.written:t}update(t){let n={...this.current()},r=t(n);return r&&this.write(n),r}write(t){this.writes+=1,t[Re]={value:JSON.stringify({writer:this.writer,write:this.writes}),category:An},this.backend.setData(t),this.written=t}};export{Bn as a,vn as b,jn as c,Tn as d,Nn as e,Dn as f,_n as g,Pn as h,xn as i,$n as j,ae as k,Ln as l,Ie as m,Fn as n,Un as o,kt as p,It as q,h as r,$t as s,j as t,tr as u,nr as v,rr as w,or as x,dn as y,ir as z,sr as A,ar as B,dr as C,cr as D,at as E};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e}from"./chunk-EPFCERGL.mjs";import"./chunk-IUM4NFKI.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as SEED_RUNS_DIR,a as SEED_RUNS_KEPT,e as SeedRunCreations,d as nodeSeedRunCreations,c as seedRunKept};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a as c}from"./chunk-QIRO4HTE.mjs";var u=new Set(["string","textarea","email","phone","url","encryptedstring","picklist","multipicklist","combobox","date","datetime","int","long","double","currency","percent"]),f=new Set(["string","textarea","email","phone","url","encryptedstring"]),p=["FirstName","MiddleName","LastName"];function k(e){return e==null?!1:typeof e!="string"||e.trim()!==""}function l(e){return u.has(e.type)}function m(e){return f.has(e.type)}var b={name_pattern:"name",type_analysis:"type",content_pattern:"content"};function D(e){return{apiName:e.name,label:e.label,type:e.type}}function F(e){return e.createable===!0||e.updateable===!0}function h(e,n){let i=e.filter(F).map(r=>r.name);return n.map(r=>{let d={};for(let a of i)d[a]=r[a];return d})}function _(e,n,i,r){let d=i.filter(l),a=new Map(d.map(t=>[t.name,t]));return e.detectPII(n,d.map(D),r&&r.length>0?h(d,r):void 0).piiFields.flatMap(t=>{let o=a.get(t.fieldApiName);return o?[{field:o,classification:t.classification,detectedBy:b[t.detectionMethod],pattern:t.pattern??t.detectionMethod}]:[]})}function y(e){if(e.filterable===!0){if(e.type==="email")return"email";if(e.type==="phone")return"phone";if(e.type==="string"){if(/email(?:__c)?$/i.test(e.name))return"email";if(/phone(?:__c)?$/i.test(e.name))return"phone"}}}function P(e){return e.fields.find(n=>n.nameField===!0&&n.filterable===!0&&n.autoNumber!==!0&&(n.type==="string"||n.type==="textarea"))}function M(e){let n=[];for(let r of e.fields){let d=y(r);d&&n.push({field:r,kind:d})}let i=P(e);return i&&n.push({field:i,kind:"name"}),n}function E(e){let n=e.fields.find(i=>i.nameField===!0&&i.autoNumber!==!0);return n&&n.updateable===!0&&m(n)?[n]:e.fields.filter(i=>p.includes(i.name))}function g(e){return c[e.name]!==void 0?"fake":e.nillable===!0?"nullify":"fake"}var x=new Set(["email_content","ssn_content"]);function N(e,n){let i=new Set,r=[],d=n.filter(t=>t.detectedBy!=="content"||x.has(t.pattern));for(let t of[...d.map(o=>o.field),...E(e)])i.has(t.name)||!l(t)||t.calculated===!0||t.autoNumber===!0||(i.add(t.name),r.push(t));let a=[],s=[];for(let t of r)t.updateable===!0?a.push({field:t,method:g(t)}):s.push(t);return{fields:a,kept:s}}export{k as a,l as b,m as c,F as d,_ as e,y as f,P as g,M as h,g as i,N as j};
@@ -1,10 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{c as It,d as Dt}from"./chunk-JE6SCT6R.mjs";import{a as Ze,c as Rn,d as Ae,e as Ot,f as At,g as St,h as Ct,j as Pt,l as En,m as Mn}from"./chunk-PWRJRL5U.mjs";import{d as sn,f as cn,g as gt,h as ht,i as wt,k as pt,l as bn,m as Bn}from"./chunk-UIOMAX56.mjs";import{a as jn}from"./chunk-L53JWJ3S.mjs";import{B as it}from"./chunk-H4CGM6YO.mjs";import{A as Fn,B as se,C as bt,E as Ue,F as dn,G as Rt,e as st,i as oe,l as Qe,p as Ln,q as lt,r as xe,s as ut,t as mt,x as kt,y as yt,z as Ee}from"./chunk-FP7CYB2F.mjs";import{b as Z,e as Ge,g as vn}from"./chunk-NED4MBIM.mjs";import{J as ft,a as rt,b as at,d as on,o as ct,x as dt,z as yn}from"./chunk-KGU4SVIT.mjs";import{b as an,d as Fe,e as ot}from"./chunk-JAEDM4SI.mjs";import{i as tt}from"./chunk-INIT2UKJ.mjs";import{E as tn}from"./chunk-YA6ATMTB.mjs";import{f as et,g as le,h as me,i as nt,p as kn}from"./chunk-M6K34KGF.mjs";import{q as mn,r as Be}from"./chunk-TNT27RBG.mjs";import{h as pn}from"./chunk-TZE3Y7IQ.mjs";import{b as Ne}from"./chunk-CA5NAXSU.mjs";import{Uc as we}from"./chunk-PMWAFDUB.mjs";import{b as Yn,k as hn,l as wn}from"./chunk-WZQEK4WT.mjs";import{randomBytes as bi}from"node:crypto";import{appendFile as Ri,readdir as Oi,rm as Ai}from"node:fs/promises";import{join as Nn}from"node:path";import{appendFile as jo,rm as Hn}from"node:fs/promises";import{join as Lo}from"node:path";import{appendFile as wo}from"node:fs/promises";import{join as po}from"node:path";var In=st*10,mo=2e3,ko="005",yo=["Id","IsDeleted","CreatedDate","LastModifiedById","LastModifiedDate","LatestPublishedVersionId","ContentSize"],Tt=1,_t=2,$t=4,Nt=8,$n=16,An=32,Sn=64,jt=1,Lt=2,vt=4,On=32768,Cn={toDelete:["createdSince","broughtBackSince"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","toRecreate"]},Tn={toDelete:["createdSince","broughtBackSince","comesBackWithParent"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","deletedWithCreatedParent","deletedWithParentOutside"]};function Me(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function Wn(e){return`${e.ContentDocumentId.slice(0,15)}${e.LinkedEntityId.slice(0,15)}`}function Wt(e){return`${e.ShareType}/${e.Visibility}`}async function*fn(e){try{for await(let n of se(e))yield n}catch(n){if(n.code==="ENOENT")return;throw n}}function Bt(e){return typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)?e:null}function _n(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function bo(e){let n=tn(e);return n===null?Number.NaN:Date.parse(n)}var ze=class{constructor(n){this.file=n}file;lines=[];count=0;async add(n){this.lines.push(`${JSON.stringify(n)}
8
- `),this.count++,this.lines.length>=mo&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await wo(this.file,n,{encoding:"utf8",mode:on,flag:"a"})}};function Ft(e,n,t){let o=we(n);return po(e,`${o}.links${t===void 0?"":`.${t}`}.ndjson`)}function*xt(e,n){let t=[];for(let o of e)t.push(o),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}var Ro=wn({sobjects:hn(et)}).loose(),xn=class{files=new Z;held=new Map;sharings=[];prefixes;now;constructor(n,t){this.prefixes=n,this.now=t}anchoredNow(n){return(this.files.flagsOf(n)&$t)!==0}anchoredThen(n){return(this.files.flagsOf(n)&_t)!==0}sharingAt(n){let t=this.sharings.indexOf(n);return t>=0?t:(this.sharings.push(n),this.sharings.length-1)}};function Oo(e,n){let t=n.fields.find(s=>s.name.toLowerCase()==="linkedentityid"),o=new Set((t?.referenceTo??[]).map(s=>s.toLowerCase()));if(o.size===0)throw new Error(`The describe of ${me} names no record a link ties a file to.`);return e.objects.map(({objectApiName:s})=>s).filter(s=>{if(s.toLowerCase()===le.toLowerCase()||!o.has(s.toLowerCase()))return!1;let i=e.changes.get(s);return i!==void 0&&!("unread"in i)&&(i.count??0)>0})}async function*Ao(e,n){let t=await xe.read(e.folder,e.snapshotId,n);for(let s=0;s<t.size;s++)yield t.idAt(s);let o=e.changes.get(n);if(!(o===void 0||"unread"in o||!o.live))for await(let s of se(o.live.file))typeof s.Id=="string"&&!t.has(s.Id)&&(yield s.Id)}async function So(e,n){let{reader:t,previewDir:o,signal:s}=e,i=n.map(l=>({...Ct(l),file:Ft(o,l)})),r=await Fn(t,i,s),a=[];for(let[l,w]of r.entries()){let p=n[l];if(w.read){a.push({objectApiName:p,file:i[l].file});continue}let c=0,u=Ao(e,p);for await(let d of Co(u,Ze*In)){let g=[...xt(d,Ze)].map(j=>({...Pt(p,j),file:Ft(o,p,c++)})),b=(await Fn(t,g,s)).find(j=>!j.read);if(b&&!b.read)throw new Error(`The links of the files of ${p} could not be read whole: ${w.reason}; read by the ids of its records, ${b.reason}`);for(let j of g)a.push({objectApiName:p,file:j.file})}}return a}async function*Co(e,n){let t=[];for await(let o of e)t.push(o),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}async function Gt(e){let n=Ro.safeParse(await e.describeGlobal());if(!n.success)throw new Error("The org\u2019s global describe does not read as one.");let t=At(n.data.sobjects,e.objects.map(({objectApiName:a})=>a)),o=Oo(e,await e.linkDescribe),s=await So(e,o),i=new xn(t,s);for await(let a of Mn(e.folder))i.files.add(a.Id,Tt|(a.anchored?_t:0));let r=await Ln.read(e.folder);for await(let a of En(e.folder))i.held.set(Wn(Ut(a,r)),i.sharingAt(Wt(a)));for(let{file:a}of s)for await(let l of se(a))typeof l.ContentDocumentId=="string"&&i.files.add(l.ContentDocumentId,$t);return i}function Ut(e,n){let t=Me(e.LinkedEntityId),o=t===void 0?void 0:n.currentOf(t);return o===void 0?e:{...e,LinkedEntityId:o}}async function Pn(e,n,t,o,s){for(let i of o)for await(let r of fn(n(t,i)))typeof r.Id=="string"&&e.add(r.Id,s)}async function Et(e){let n=0;for await(let t of fn(e))typeof t.Id=="string"&&n++;return n}async function Mt(e,n,t){let o=new Map;if(n.length===0)return o;let s=Fe([...n],Ze).map(a=>({objectApiName:le,soql:`SELECT ${yo.join(", ")} FROM ${le} WHERE Id IN (${a})`,scanAll:!0})),r=(await Ee(e,s,(a,l)=>{for(let w of l){let p=Me(w.Id);p!==void 0&&o.set(p,w)}},t)).find(a=>!a.read);if(r&&!r.read)throw new Error(`The files the checkpoint names could not be read by their ids: ${r.reason}`);return o}function Po(e,n){return n===void 0||n.version===null||e.LatestPublishedVersionId===null?!1:Me(n.version)!==Me(e.LatestPublishedVersionId)}async function zt(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=n.files,r=le;await Pn(i,o,r,Cn.toDelete,$n),await Pn(i,o,r,Cn.comesBack,An),await Pn(i,o,r,Cn.lost,Sn);let a=new Map,l=e.fileChanges;if(!("unread"in l)){for(let D of[l.live,l.deleted])if(D!==void 0)for await(let L of se(D.file)){let N=Me(L.Id);N!==void 0&&(i.add(String(L.Id),Nt),a.set(N,{version:Bt(L.LatestPublishedVersionId),size:_n(L.ContentSize)}))}}let w=await xe.read(e.folder,e.snapshotId,r),p=D=>(i.flagsOf(D)&Nt)===0&&!w.has(D),c=new ze(o(r,"createdSince")),u=new ze(o(r,"deletedWhileTaken")),d=new ze(o(r,"goneForGood")),f=new ze(o(r,"newFileVersion")),g=0,y=0,b=async D=>{let L=await Mt(t,D.filter(N=>N.anchored&&p(N.Id)).map(N=>N.Id),s);for(let N of D){if(!N.anchored)continue;let V=Me(N.Id)??"",J=a.get(V);if(p(N.Id)){let x=L.get(V);if(x===void 0){i.add(N.Id,Sn),await d.add({Id:N.Id});continue}J={version:Bt(x.LatestPublishedVersionId),size:_n(x.ContentSize)},x.IsDeleted===!0&&(i.add(N.Id,An),await u.add({Id:N.Id}))}let ee=i.flagsOf(N.Id);(ee&Sn)===0&&((ee&An)!==0&&(g+=J?.size??N.ContentSize??0),Po(N,J)&&await f.add({Id:N.Id}))}},j=[];for await(let D of Mn(e.folder))j.push(D),j.length>=Ze*In&&(await b(j),j=[]);await b(j);let C=new Z,v=[],R=async D=>{let L=await Mt(t,D,s);for(let N of D){let V=L.get(Me(N)??"");V===void 0||V.IsDeleted===!0||bo(V.CreatedDate)>=e.t0s&&(i.add(N,$n),await c.add({Id:N}),v.push(V))}},B=[];for(let{file:D}of n.now)for await(let L of se(D)){let N=L.ContentDocumentId;typeof N!="string"||(i.flagsOf(N)&Tt)!==0||!p(N)||C.add(N)&&(B.push(N),B.length>=Ze*In&&(await R(B),B=[]))}await R(B);for await(let D of fn(o(r,"createdSince"))){let L=Me(D.Id);L!==void 0&&(y+=a.get(L)?.size??0)}for await(let D of fn(o(r,"broughtBackSince")))y+=a.get(Me(D.Id)??"")?.size??0;for(let D of v)y+=_n(D.ContentSize)??0;for(let D of[c,u,d,f])await D.flush();return{files:{...await Io(e),outsideAdded:await Et(o(r,"outsideAdded")),outsideDeleted:await Et(o(r,"outsideDeleted")),storage:{bringBack:g,undo:y},...e.queryAllFiles?{}:{blindSpot:!0}},createdSince:c.count,deletedWhileTaken:u.count,goneForGood:d.count,newFileVersion:f.count,changedBy:v}}async function Io(e){let{anchors:n,classFileOf:t}=e,o=new Z,s=new Set;for(let{objectApiName:c}of e.objects){if(c.toLowerCase()===le.toLowerCase())continue;if(!e.told.has(c)){for(let[d,f]of n.prefixes)f.toLowerCase()===c.toLowerCase()&&s.add(d);continue}let u=(d,f)=>Pn(o,t,c,d,f);await u(Tn.toDelete,jt),await u(Tn.comesBack,Lt),await u(Tn.lost,vt)}let i=c=>s.has(c.LinkedEntityId.slice(0,3)),r=c=>new ze(Ae(e.previewDir,c)),a=r("linkAdded"),l=r("linkRemoved"),w=r("linkChanged");for(let{file:c}of n.now)for await(let u of se(c)){let d=Rn.safeParse(u);if(!d.success)throw new Error(`The org answered a link that does not read as one: ${d.error.message}`);let f=d.data,g=Wn(f),y=n.held.get(g);if(y!==void 0){if(n.held.set(g,y|On),i(f)||n.sharings[y&~On]===Wt(f))continue;let[b,j]=(n.sharings[y&~On]??"").split("/"),C={...f,ShareType:b,Visibility:j,now:{ShareType:f.ShareType,Visibility:f.Visibility}};await w.add(C);continue}i(f)||(n.files.flagsOf(f.ContentDocumentId)&$n)===0&&(o.flagsOf(f.LinkedEntityId)&jt)===0&&await a.add(f)}let p=await Ln.read(e.folder);for await(let c of En(e.folder)){let u=Ut(c,p);((n.held.get(Wn(u))??0)&On)!==0||i(u)||(n.files.flagsOf(u.ContentDocumentId)&(An|Sn))===0&&(o.flagsOf(u.LinkedEntityId)&(Lt|vt))===0&&await l.add(u)}for(let c of[a,l,w])await c.flush();return{unlink:a.count,relink:l.count,updateLinks:w.count}}async function qt(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=[];for(let l of Cn.toDelete)for await(let w of fn(o(le,l)))typeof w.Id=="string"&&i.push(w.Id);if(i.length===0)return{links:0,files:0};let r=new Map,a=0;for(let l of xt(Fe(i,Ze),In)){let w=l.map(u=>({objectApiName:me,soql:`SELECT Id, ContentDocumentId, LinkedEntityId FROM ${me} WHERE ContentDocumentId IN (${u})`,scanAll:!1})),c=(await Ee(t,w,(u,d)=>{for(let f of d){let g=f.LinkedEntityId,y=f.ContentDocumentId;typeof g!="string"||typeof y!="string"||g.startsWith(ko)||St({LinkedEntityId:g},n.prefixes)===void 0&&(a++,r.set(y.slice(0,15),y))}},s)).find(u=>!u.read);if(c&&!c.read)throw new Error(`The links of the files to delete to what the checkpoint does not hold could not be read: ${c.reason}`)}if(r.size>0){let l=new ze(o(le,"outsideParents"));for(let w of r.values())await l.add({Id:w});await l.flush()}return{links:a,files:r.size}}var Un=Object.freeze({kind:"org",notHeld:new Map,heldAs:()=>"org",unseenOf:()=>Promise.resolve([]),requests:()=>0,diffAccess:()=>({kind:"org"})});function Gn(e){return e.slice(0,15)}function Do(e,n,t,o){let s=n.detail!==void 0?` (${n.detail})`:"";switch(n.reason){case"noViewAll":case"noModifyAll":return`${t} ${o} View All and Modify All on ${e}`;case"parentNotSeen":return`${t} ${o} View All and Modify All on every record ${e} hangs from`+s;case"activities":return`${t} doesn't have View All Data and Modify All Data, which tasks and events need: Salesforce has no View All for activities`;case"catalog":return`${t} doesn't have View All Data and Modify All Data, which products and price books need: Salesforce has no View All or Modify All for them`;case"filesNotProven":return`${t} doesn't have View All Data and Modify All Data, which files need: nothing else proves who sees every file`;case"settingNotProven":return`${t} doesn't have View All Data and Modify All Data, which custom settings need: no permission on an object proves who sees and writes every row`}}async function as(e){let{grants:n,reader:t}=e;if(n.kind==="org"||e.userId===void 0)return Un;let o=e.checkpoint.objects,s=o.filter(f=>f.customSetting!==void 0).map(f=>f.objectApiName),i=new Map,r=n.requests,a=async f=>{let g=[...new Set(f)].filter(j=>!i.has(j.toLowerCase()));if(g.length===0)return;let y=t.calls(),b=await Promise.allSettled(g.map(j=>t.describe(j)));r+=t.calls()-y,b.forEach((j,C)=>{if(j.status==="rejected"&&j.reason instanceof oe)throw j.reason;let v=j.status==="fulfilled"&&"body"in j.value?j.value.body:void 0,R=sn.safeParse(v);i.set(g[C].toLowerCase(),R.success?R.data:void 0)})},l=()=>[...i.values()].filter(f=>f!==void 0),w=async f=>{let g=f.filter(b=>!n.objects.has(b.toLowerCase()));await a(g);let y={grants:n.objects,describes:l(),customSettings:s};return await a(It(f,y)),Dt(f,{...y,describes:l()})},p=await w(o.map(f=>f.objectApiName)),c=Gn(e.userId)===Gn(e.checkpoint.takenBy.userId)?"no longer has":"doesn't have",u=new Map,d=new Map;for(let[f,g]of p)"access"in g?u.set(f,g.access):d.set(f,Do(f,g,e.username,c));return{kind:"perObject",userKey:Gn(e.userId),notHeld:d,heldAs:f=>u.get(f),unseenOf:async f=>{let g=await w(f);return f.filter(y=>{let b=g.get(y);return b===void 0||!("access"in b)})},requests:()=>r,diffAccess:()=>({kind:"perObject",requests:r})}}var vo=["giveBack","touched","createdSince","broughtBackSince","comesBackWithParent","unexplained","inBin","withParent","deletedWhileTaken","toRecreate","goneForGood","convertedLead","activatedContract","carrier","deletedWithCreatedParent","deletedWithParentOutside","deletedByOther","outOfReach","undoCannot","outsideParents","outsideAdded","outsideDeleted","newFileVersion"],Bo="Lead",Fo="IsConverted",Eo="Contract",Mo="Status",Ht="StatusCode",To="Activated",_o=["createdSince","broughtBackSince"];function X(e,n,t){return Lo(e,`${we(n)}.${t}.ndjson`)}var Dn=1e3,$o=1440*6e4,Wo=60*6e4,xo=100,Go=2e3,Qt=["LastModifiedById","LastModifiedDate"];function ne(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function ke(e){let n=tn(e);return n===null?Number.NaN:Date.parse(n)}function Kn(e){return e.toLowerCase()===le.toLowerCase()}function Uo(e){return e==null||e===""}function je(e,n){let t=n.toLowerCase();return e.find(o=>o.toLowerCase()===t)}function zo(e){return!e.leftOutFields.some(n=>n.reason==="base64")}var ln=class{constructor(n){this.file=n}file;lines=[];written=!1;count=0;async add(n){this.lines.push(`${JSON.stringify(n)}
9
- `),this.count++,this.lines.length>=Go&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await jo(this.file,n,{encoding:"utf8",mode:on,flag:this.written?"a":"w"}),this.written=!0}async discard(){this.lines=[],this.written&&await Hn(this.file,{force:!0})}};async function Vn(e,n){await Promise.all(vo.map(t=>Hn(X(e,n,t),{force:!0})))}var zn=class{constructor(n){this.activeFrom=n}activeFrom;counts=new Map;active=new Set;add(n){let t=n.LastModifiedById;typeof t!="string"||t===""||(this.counts.set(t,(this.counts.get(t)??0)+1),ke(n.LastModifiedDate)>=this.activeFrom&&this.active.add(t))}byUser(){return Object.fromEntries([...this.counts].sort(([n],[t])=>n<t?-1:n>t?1:0))}};function Zt(e,n){let t,o=async()=>{let s=new Set;try{for await(let i of se(ct(e,n))){let r=ne(i.Id);r!==void 0&&s.add(r)}}catch(i){throw i.code!=="ENOENT"?i:new Error(`The checkpoint\u2019s list of what ${n} held in the recycle bin is not on this machine.`)}return s};return async s=>(await(t??=o())).has(s)}async function qo(e,n,t,o){let s=we(n.objectApiName),i=n.readMode==="scanAllLive",r=i?" AND IsDeleted = false":"",a=async p=>{let c=e.lane(),u=[];try{let d=await yt(c,{objectApiName:s,soql:p,scanAll:i},f=>{u.push(...f)});if(!d.read)throw new Error(d.reason);return u}finally{c.close()}},l=t.length>xo?an/4:an,w=new Map;for(let p of Fe(o,l)){let c=await tt(`SELECT ${t.join(", ")} FROM ${s} WHERE Id IN (${p})${r}`,a,{stamp:"SystemModstamp",...i?{idsWhere:"IsDeleted = false"}:{}});for(let u of c){let d=ne(u.Id);d!==void 0&&w.set(d,u)}}return w}var Ho=/__(?:c|pc|s)$/i,Ko=/^(.+)__[A-Za-z]+__s$/i,Vo=/^(.+)__pc$/i,Jo=/^[A-Za-z][A-Za-z0-9_]*$/,Qo=200;function Zo(e,n){if(!Ho.test(n)||!Jo.test(n))return;let t=Vo.exec(n);if(t)return{entity:Be,name:`${t[1]}__c`};let o=Ko.exec(n);return o?{entity:e,name:`${o[1]}__c`}:{entity:e,name:n}}var Xo=hn(wn({QualifiedApiName:Yn()}).loose());function Yo(e,n){let t=`SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${we(e)}' AND QualifiedApiName IN (`,o=r=>`${t}${r.map(a=>`'${a}'`).join(", ")})`,s=[],i=[];for(let r of n){let a=[...i,r],l=a.length>Qo||encodeURIComponent(o(a)).length>14e3;i.length>0&&l?(s.push({soql:o(i),names:i}),i=[r]):i=a}return i.length>0&&s.push({soql:o(i),names:i}),s}async function ei(e,n){let t=new Map,o=new Map;for(let[r,a]of n){let l={removed:[],hidden:[]};t.set(r,l);for(let w of a){let p=Zo(r,w);if(p===void 0){l.hidden.push(w);continue}let c=o.get(p.entity)??new Map;o.set(p.entity,c);let u=p.name.toLowerCase(),d=c.get(u)??{name:p.name,fields:[]};c.set(u,d),d.fields.push({objectApiName:r,field:w})}}let s=0,i=new Map;for(let[r,a]of o){let l=new Set,w=new Map,p=Yo(r,[...a.values()].map(({name:c})=>c));for(let c of p){s++;try{let u=await e.tooling(c.soql);if(!u.done)throw new Error("FieldDefinition answered more than one page");let d=Xo.safeParse(u.records);if(!d.success)throw new Error("FieldDefinition answered rows with no field name");for(let f of d.data)l.add(f.QualifiedApiName.toLowerCase())}catch(u){if(u instanceof oe)throw u;let d=Ne(u);for(let f of c.names)w.set(f.toLowerCase(),d)}}for(let[c,{fields:u}]of a){let d=w.get(c);for(let{objectApiName:f,field:g}of u){let y=t.get(f);if(y!==void 0)if(d!==void 0){let b=i.get(f)??{fields:[],reasons:[]};i.set(f,b),b.fields.push(g),b.reasons.includes(d)||b.reasons.push(d)}else l.has(c)?y.hidden.push(g):y.removed.push(g)}}}for(let[r,a]of t){a.removed.sort(),a.hidden.sort();let l=i.get(r);l!==void 0&&(a.uncertain={fields:l.fields.sort(),...l.reasons.length>0?{reason:l.reasons.join("; ")}:{}})}return{gone:t,requests:s}}async function Kt(e,n,t){let{checkpoint:o,folder:s,reader:i}=e,r=new Date(Date.parse(o.readFrom)-$o).toISOString(),a=await Promise.allSettled(n.map(({objectApiName:g})=>i.describe(g,r))),l,w=new Map,p=new Map;for(let[g,y]of a.entries()){let b=n[g].objectApiName;if(y.status==="rejected"){if(y.reason instanceof oe)throw y.reason;w.set(b,{unread:`The org did not answer the describe of ${b}: ${Ne(y.reason)}`});continue}if("notModified"in y.value){w.set(b,{gone:new Set});continue}let j=sn.safeParse(y.value.body);if(!j.success){w.set(b,{unread:`The describe of ${b} does not read as one.`});continue}t.set(b,j.data);try{let C=(await(l??=ft(s,o.objects))).get(b);if(C===void 0)throw new Error(`The checkpoint holds no field prints of ${b}.`);p.set(b,at(C,rt(j.data.fields)))}catch(C){w.set(b,{unread:Ne(C)})}}let c=new Map(n.map(g=>[g.objectApiName,new Set(bn(g.objectApiName,g.fields,o.ignoredFields).map(y=>y.toLowerCase()))])),u=(g,y)=>y.filter(b=>c.get(g)?.has(b.toLowerCase())===!0),d=new Map([...p].map(([g,y])=>[g,u(g,y.removed)]).filter(([,g])=>g.length>0)),f=d.size>0?await ei(i,d):{gone:new Map,requests:0};for(let[g,{removed:y,added:b,changed:j}]of p){let C=f.gone.get(g);w.set(g,{...u(g,y).length+b.length+j.length>0?{drift:{removed:C?.removed??[],added:b,changed:j,...C!==void 0&&C.hidden.length>0?{hidden:C.hidden}:{},...C?.uncertain!==void 0?{uncertain:C.uncertain}:{}}}:{},gone:new Set(y.map(v=>v.toLowerCase()))})}return{now:w,requests:f.requests}}function ni(e,n){let t=i=>{let r=n.get(i);return r!==void 0&&!("unread"in r)&&r.moved},o=e.find(({objectApiName:i})=>i===Be),s=o!==void 0&&je(o.fields,cn)!==void 0&&t(Be);return e.filter(({objectApiName:i})=>t(i)||s&&i===mn)}function ti(e,n){let t=[...e.cascadeParents,...e.restrictParents??[]].filter(s=>!n.has(s.toLowerCase()));if(e.customSetting!==void 0){let s=je(e.fields,kn(e.customSetting));s!==void 0&&!n.has(s.toLowerCase())&&!t.includes(s)&&t.push(s)}if(Kn(e.objectApiName))for(let s of gt){let i=je(e.fields,s);i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}let o=je(e.fields,cn);if(e.objectApiName===Be&&o!==void 0){let s=je(e.fields,"AccountId");for(let i of[o,s])i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}return[...t,...Qt]}async function oi(e,n,t){let{folder:o,checkpoint:s}=e.input,i=new Map,r=new Map;for(let{objectApiName:a,cascadeParents:l,restrictParents:w=[]}of n){let p=t.get(a);if(!p||"unread"in p||!p.deleted||p.deleted.rows===0)continue;let c=new Map,u=new Map;try{let d=await xe.read(o,s.snapshotId,a),f=Zt(o,a);for await(let g of se(p.deleted.file)){let y=ne(g.Id);if(y===void 0)continue;let b=v=>v.map(R=>ne(g[R])).filter(R=>R!==void 0&&R!==y),j=ne(g.LastModifiedById),C=()=>({objectApiName:a,id:String(g.Id),stamp:ke(g.SystemModstamp),parents:b(l),restricts:b(w),...j!==void 0?{by:j}:{}});if(!d.retired(g.Id)){if(!d.has(g.Id)){if(await f(y)){u.set(y,C());continue}if(ke(g.CreatedDate)>=e.t0s&&u.set(y,C()),!(ke(g.CreatedDate)<e.t0s))continue}c.set(y,C())}}}catch(d){if(d instanceof oe)throw d;continue}for(let[d,f]of c)i.set(d,f);for(let[d,f]of u)r.set(d,f)}return{back:i,gone:r}}function ii(e,n){let t=s=>e.get(s)?.stamp??n.get(s)?.stamp,o=new Set;for(let s of[e,n])for(let[i,r]of s)[...r.parents,...r.restricts].some(l=>(t(l)??0)>r.stamp)&&o.add(i);return qn(o,e,n),o}function qn(e,n,t){let o=s=>n.get(s)?.stamp??t.get(s)?.stamp;for(let s=e.size>0;s;){s=!1;for(let i of[n,t])for(let[r,a]of i){if(e.has(r))continue;a.parents.some(w=>e.has(w)&&o(w)===a.stamp)&&(e.add(r),s=!0)}}for(let s of e)n.delete(s)}function si(e,n){if(n===void 0)return new Set;let t=[...e].filter(([,o])=>o.by!==n).map(([o])=>o);return Xt(t,e)}function Xt(e,n){let t=new Set(e);for(let o=t.size>0;o;){o=!1;for(let[s,i]of n){if(t.has(s))continue;i.parents.some(a=>t.has(a)&&n.get(a)?.stamp===i.stamp)&&(t.add(s),o=!0)}}return t}function ri(e,n,t){let o=new Map(e.map(l=>[l.objectApiName,l.undeletable])),s=new Set,i=new Set,r=(l,w)=>l.parents.find(p=>!w.has(p)&&t.get(p)?.stamp===l.stamp),a=l=>l.parents.some(w=>n.get(w)?.stamp===l.stamp);for(let l of[...n.values()]){if(a(l))continue;let w=new Set,p=[],c=r(l,w),u=!1;for(;c!==void 0;){w.add(c),p.push(c);let g=t.get(c);if(!g)break;if(a(g)){u=!0;break}c=r(g,w)}let d=p[p.length-1];if(d===void 0||u)continue;let f=t.get(d);if(!(!f||o.get(f.objectApiName)!==!0)){s.add(d);for(let g of p.slice(0,-1))i.add(g)}}for(let l of[...s,...i]){let w=t.get(l);w&&n.set(l,w)}return s}function ai(e,n,t){let o=new Map;for(let[s,i]of e){if(t.has(s)){o.set(s,"deletedWithParentOutside");continue}if(n.has(s))continue;i.parents.some(a=>!e.has(a)&&n.get(a)?.stamp===i.stamp)&&o.set(s,"deletedWithCreatedParent")}for(let s=o.size>0;s;){s=!1;for(let[i,r]of e){if(o.has(i))continue;let a=r.parents.find(w=>o.has(w)&&e.get(w)?.stamp===r.stamp),l=a===void 0?void 0:o.get(a);l!==void 0&&(o.set(i,l),s=!0)}}for(let s of o.keys())e.delete(s);return o}async function ci(e,n,t,o,s,i){let r=new Set,a=new Set,l=new Set(n.map(({objectApiName:d})=>d.toLowerCase())),w=new Map(n.map(d=>[d.objectApiName,d])),p=new Map;for(let[d,f]of t)o.has(d)||s.has(d)||f.parents.some(y=>(t.get(y)??o.get(y))?.stamp===f.stamp)||p.set(f.objectApiName,[...p.get(f.objectApiName)??[],f]);if(p.size===0)return{outside:r,stuck:a,requests:0};let c=e.reader.calls(),u=async d=>{try{return await i(d)}catch(f){if(f instanceof oe)throw f;return}};for(let[d,f]of p){let g=w.get(d),y=await u(d);if(!g||!y)continue;let b=new Set([...g.cascadeParents,...g.restrictParents??[]].map(I=>I.toLowerCase())),j=y.fields.filter(I=>I.type==="reference"&&!b.has(I.name.toLowerCase())&&(I.referenceTo??[]).some(q=>!l.has(q.toLowerCase())));if(j.length===0)continue;let C=[...new Set(j.flatMap(I=>(I.referenceTo??[]).filter(q=>!l.has(q.toLowerCase()))))],v=await Promise.all(C.map(u)),R=new Map;if(v.forEach((I,q)=>{if(!I)return;let Q=I.keyPrefix;for(let U of I.childRelationships??[]){if(U.cascadeDelete!==!0||U.childSObject.toLowerCase()!==d.toLowerCase())continue;let ce=j.find(ie=>ie.name.toLowerCase()===U.field.toLowerCase());ce&&R.set(ce.name,[...R.get(ce.name)??[],{object:C[q],...typeof Q=="string"?{prefix:Q}:{}}])}}),R.size===0)continue;let B=[...R.keys()].map(pn),W=we(d),D=f.map(I=>I.id),L=new Map,N=Fe(D).map(I=>({objectApiName:W,soql:`SELECT Id, ${B.join(", ")} FROM ${W} WHERE Id IN (${I}) AND IsDeleted = true`,scanAll:!0}));if((await Ee(e.reader,N,(I,q)=>{for(let Q of q){let U=ne(Q.Id);if(U!==void 0)for(let[ce,ie]of R){let ue=Q[ce];if(typeof ue!="string"||ne(ue)===void 0)continue;let Ce=ie.length===1?ie[0]:ie.find(he=>he.prefix!==void 0&&ue.startsWith(he.prefix));Ce&&L.set(U,[...L.get(U)??[],{object:Ce.object,id:ue}])}}},e.signal)).some(I=>!I.read))continue;let J=new Map;for(let I of L.values())for(let{object:q,id:Q}of I)J.set(q,[...J.get(q)??[],Q]);let ee=[];for(let[I,q]of J){let Q=we(I);for(let U of Fe([...new Set(q)]))ee.push({object:I,read:{objectApiName:Q,soql:`SELECT Id, IsDeleted, SystemModstamp FROM ${Q} WHERE Id IN (${U})`,scanAll:!0}})}let x=new Map;await Ee(e.reader,ee.map(({read:I})=>I),(I,q)=>{for(let Q of q){let U=ne(Q.Id);U!==void 0&&Q.IsDeleted===!0&&x.set(U,ke(Q.SystemModstamp))}},e.signal);for(let I of f){let q=ne(I.id);if(q!==void 0)for(let{id:Q}of L.get(q)??[]){let U=x.get(ne(Q)??"");U!==void 0&&(U===I.stamp?r.add(q):U>I.stamp&&a.add(q))}}}return{outside:r,stuck:a,requests:e.reader.calls()-c}}async function di(e,n,t,o){let s=[...new Set([...e.values()].map(({objectApiName:l})=>l))],i=await Promise.allSettled(s.map(t)),r=new Map([...n.keys()].map(l=>[l.toLowerCase(),l])),a=new Map;for(let[l,w]of i.entries()){if(w.status==="rejected"){if(w.reason instanceof oe)throw w.reason;let p=s[l];o.set(p,Ne(w.reason));for(let[c,u]of e)u.objectApiName===p&&e.delete(c);continue}for(let p of w.value.childRelationships??[]){let c=r.get(p.childSObject.toLowerCase());if(c===void 0)continue;let u=je(n.get(c)??[],p.field);if(u===void 0)continue;let d=a.get(c);d||(d=new Set,a.set(c,d)),d.add(u)}}return new Map([...a].map(([l,w])=>[l,[...w]]))}async function fi(e,n){let t=new Set,o=e.find(({objectApiName:i})=>i===Be);if(!o||je(o.fields,cn)===void 0)return t;let s=n.get(Be);if(!s||"unread"in s||!s.live)return t;try{for await(let i of se(s.live.file)){let r=ne(i.AccountId);r!==void 0&&Bn(Be,i)&&t.add(r)}}catch{return new Set}return t}async function li(e,n,t,o){if("unread"in t)return{unread:t.unread};let{input:s,previewDir:i,t0s:r,back:a,carriers:l,stranded:w,stuck:p,others:c,personAccounts:u}=e,{folder:d,reader:f,checkpoint:g,signal:y}=s,b=n.objectApiName,j=Kn(b)?e.files:void 0,C=L=>j===void 0||j.anchoredThen(L),v=new Map,R=L=>{let N=v.get(L);return N||(N=new ln(X(i,b,L)),v.set(L,N)),N},B=L=>v.get(L)?.count??0,W=new zn(e.activeFrom),D=[];try{let L=await xe.read(d,g.snapshotId,b),N=Zt(d,b),{gone:V}=o,J=pt(b,g.ignoredFields),ee=bn(b,n.fields,[]),x=h=>J.has(h.toLowerCase())||V.has(h.toLowerCase()),I=ee.filter(h=>!x(h)).map(pn),q=ee.filter(x),Q=b===Bo?je(n.fields,Fo):void 0,U=Q!==void 0&&!V.has(Q.toLowerCase())?Q:void 0,ce=b===Eo?je(n.fields,Mo):void 0,ie=ce!==void 0&&I.includes(ce)?ce:void 0,ue=["Id","SystemModstamp",...Qt,...I,...U!==void 0&&!I.includes(U)?[U]:[],...ie!==void 0?[Ht]:[]],Ce=n.cascadeParents.filter(h=>!V.has(h.toLowerCase())),he=(n.restrictParents??[]).filter(h=>!V.has(h.toLowerCase())),Pe=b===Be&&je(n.fields,cn)!==void 0,Le=h=>Pe&&Bn(b,h),ye=zo(n)?"toRecreate":"goneForGood",He=e.access.heldAs(b)==="parent"?"outOfReach":ye,be=r-Dn,te={fields:0,cleared:0,liveNotHeld:0,deletedHeld:0},Te=h=>{let A=ne(h.Id);if(A===void 0)throw new Error(`${b} answered a record without its Id.`);return{id:String(h.Id),key:A}},ge=(h,A,P)=>h.map(M=>ne(A[M])).filter(M=>M!==void 0&&M!==P),Ie=(h,A)=>ge(Ce,h,A),Re=(h,A)=>{let P=ke(h.SystemModstamp);return Ie(h,A).some(M=>a.get(M)?.stamp===P)},en=Date.parse(g.takenAt),nn=Date.parse(s.readAt)-Dn,Ke=(h,A,P,M)=>{W.add(h);let _=Ie(h,P),S=ge(he,h,P),$=M&&ke(h.CreatedDate)>=en&&ke(h.LastModifiedDate)<=nn;n.undeletable&&_.length+S.length===0||D.push({id:A,parents:_,restricts:S,goesAlong:$,undeletable:n.undeletable})},de=new Map,_e=e.lookups.get(b)??[];if(_e.length>0&&L.size>0)for await(let h of L.records()){if(Le(h))continue;let A=ne(h.Id);if(A===void 0)continue;let P=_e.filter(M=>{let _=ne(h[M]);return _!==void 0&&a.has(_)});P.length>0&&de.set(A,{id:String(h.Id),fields:P})}let $e=async h=>{if(h.length===0)return;if(I.length===0){for(let S of h)S.stamp!==S.held&&await R("touched").add({Id:S.id});return}let A=h.map(S=>S.id),P=new Map,M=await L.chunk(A).batches(g.snapshotId,b,an);for await(let S of M??[])for(let $ of S){let Y=ne($.Id);Y!==void 0&&P.set(Y,$)}if(y?.aborted)throw new oe;let _=await qo(f,n,ue,A);for(let S of h){let $=_.get(S.key);if(!$)continue;let Y=P.get(S.key);if(!Y)throw new Error(`The checkpoint\u2019s snapshot of ${b} does not hold record ${S.id}, which its index names.`);if(U!==void 0&&Y[U]!==!0&&$[U]===!0){await R("convertedLead").add({Id:S.id});continue}if(ie!==void 0&&$[Ht]===To&&!jn(Y[ie],$[ie])){await R("activatedContract").add({Id:S.id});continue}let G=I.filter(fe=>!jn(Y[fe],$[fe]));if(G.length>0){te.fields+=G.length;let fe=(S.cleared??[]).filter(Oe=>G.includes(Oe)&&Uo($[Oe]));fe.length>0&&te.cleared++,await R("giveBack").add({Id:S.id,fields:G,...fe.length>0?{cleared:fe}:{}}),W.add($)}else ke($.SystemModstamp)!==S.held&&await R("touched").add({Id:S.id})}},De=[],ve=async h=>{De.push(h),De.length>=Qe&&(await $e(De),De=[])};if(t.live)for await(let h of se(t.live.file)){let{id:A,key:P}=Te(h),M=Le(h),_=L.stampOf(A);if(_!==void 0){if(M||!C(A))continue;let $=de.get(P)?.fields;$&&de.delete(P);let Y=b===mn&&u.delete(P),G=ke(h.SystemModstamp);($||Y||G!==_||_>=be)&&await ve({id:A,key:P,held:_,stamp:G,...$?{cleared:$}:{}});continue}if(te.liveNotHeld++,M)continue;let S=await N(P)?"broughtBackSince":ke(h.CreatedDate)>=r?"createdSince":void 0;S===void 0?await R("unexplained").add({Id:A}):j!==void 0&&!j.anchoredNow(A)?await R("outsideAdded").add({Id:A}):(await R(S).add({Id:A}),Ke(h,A,P,!0))}for(let[h,A]of de){let P=L.stampOf(A.id);P!==void 0&&await ve({id:A.id,key:h,held:P,stamp:P,cleared:A.fields})}if(b===mn)for(let h of u){let A=L.rowOf(h);if(A<0||(u.delete(h),de.has(h)))continue;let P=L.idAt(A),M=L.stampOf(P);M!==void 0&&await ve({id:P,key:h,held:M,stamp:M})}if(await $e(De),t.deleted)for await(let h of se(t.deleted.file)){let{id:A,key:P}=Te(h);if(L.retired(A))continue;let M=Le(h);if(L.has(A)){if(te.deletedHeld++,M)continue;if(!C(A)){await R("outsideDeleted").add({Id:A});continue}let _=w.get(P);c.has(P)?await R("deletedByOther").add({Id:A}):p.has(P)?await R(e.answeredGone.has(P)?He:ye).add({Id:A}):_!==void 0?await R(_).add({Id:A}):Re(h,P)?await R("withParent").add({Id:A}):n.undeletable?await R("inBin").add({Id:A}):await R(ye).add({Id:A});continue}if(l.has(P)&&!M){await R("carrier").add({Id:A});continue}if(!(M||await N(P)))if(ke(h.CreatedDate)<r){let _=w.get(P),S=C(A)?c.has(P)?"deletedByOther":p.has(P)?"goneForGood":_??"deletedWhileTaken":"outsideDeleted";await R(S).add({Id:A})}else Re(h,P)&&(await R("comesBackWithParent").add({Id:A}),Ke(h,A,P,!1))}let Ve=t.count;if(L.size>0&&Ve===void 0)throw new Error(`The org gave no count of the ${b} records it holds.`);if(L.size-((Ve??0)-te.liveNotHeld)-te.deletedHeld>0){let h=new ut(L);if(t.deleted)for await(let _ of se(t.deleted.file))h.mark(_.Id);let[A]=await Ee(f,[kt(b,n.readMode)],(_,S)=>{for(let $ of S)h.mark($.Id)},y);if(!A.read)throw new Error(A.reason);let P=[],M=async()=>{let _=new Set;if(Pe){let S=await L.chunk(P).batches(g.snapshotId,b,an);for await(let $ of S??[])for(let Y of $){let G=ne(Y.Id);G!==void 0&&Le(Y)&&_.add(G)}}for(let S of P)_.has(S.slice(0,15))||await R(C(S)?He:"outsideDeleted").add({Id:S});P=[]};for(let _ of h.ids())P.push(_),P.length>=Qe&&await M();await M()}for(let h of v.values())await h.flush();let We=B("toRecreate"),Je=B("goneForGood"),k=B("convertedLead"),F=B("activatedContract"),K=B("deletedWithCreatedParent"),H=B("deletedWithParentOutside"),m=B("deletedByOther"),O=B("outOfReach"),T=B("carrier");return{told:{diff:{objectApiName:b,toDelete:{createdSince:B("createdSince"),broughtBackSince:B("broughtBackSince"),comesBackWithParent:B("comesBackWithParent")},toGiveBack:{records:B("giveBack"),fields:te.fields,clearedLookups:te.cleared},toBringBack:{inBin:B("inBin"),withParent:B("withParent"),deletedWhileTaken:B("deletedWhileTaken"),...T>0?{carriers:T}:{}},...We>0?{toRecreate:We}:{},cannotUndo:[...Je>0?[{reason:"goneForGood",count:Je}]:[],...k>0?[{reason:"convertedLead",count:k}]:[],...F>0?[{reason:"activatedContract",count:F}]:[],...K>0?[{reason:"deletedWithCreatedParent",count:K}]:[],...H>0?[{reason:"deletedWithParentOutside",count:H}]:[],...m>0?[{reason:"deletedByOther",count:m}]:[],...O>0?[{reason:"outOfReach",count:O}]:[]],outside:[],touched:B("touched"),unexplained:B("unexplained"),lastChangedBy:W.byUser(),...o.drift?{schemaDrift:o.drift}:{},notCompared:q},people:W,pending:D}}}catch(L){for(let N of v.values())await N.discard();if(L instanceof oe)throw L;return{unread:Ne(L)}}}async function*Yt(e,n){let t=[];for(let o of _o)if(n.diff.toDelete[o]!==0)for await(let s of se(X(e,n.diff.objectApiName,o)))typeof s.Id=="string"&&(t.push(s.Id),t.length>=Qe&&(yield t,t=[]));t.length>0&&(yield t)}async function ui(e,n,t,o,s){let{input:i,previewDir:r}=e,a=n.diff.objectApiName,w=((await t(a)).childRelationships??[]).filter(C=>C.cascadeDelete===!0&&!s.has(C.childSObject.toLowerCase()));if(w.length===0)return[];let p=await o(),c=w.filter(C=>p.has(C.childSObject));if(c.length===0)return[];let u=new Set(await e.access.unseenOf([...new Set(c.map(({childSObject:C})=>C))])),d=c.filter(({childSObject:C})=>!u.has(C));if(d.length===0)return[];let f=Date.parse(i.checkpoint.takenAt);if(!Number.isFinite(f))throw new Error(`Not a date: ${i.checkpoint.takenAt}`);let g=mt(Math.ceil(f/Dn)*Dn),y=new Map,b=new Map,j=new Map;for await(let C of Yt(r,n)){let v=d;for(;v.length>0;){let R=[];for(let D of v){let L=we(D.childSObject),N=pn(D.field),V=ht(L)==="scanAllLive",J=j.get(L)??"CreatedDate";for(let ee of Fe(C))R.push({child:L,field:N,read:{objectApiName:L,soql:`SELECT Id, ${N} FROM ${L} WHERE ${N} IN (${ee}) AND ${J} >= ${g}${V?" AND IsDeleted = false":""}`,scanAll:V}})}let B=await Ee(i.reader,R.map(({read:D})=>D),(D,L)=>{let{child:N,field:V}=R[D],J=y.get(N);J||(J={records:new Set,parents:new Set},y.set(N,J));for(let ee of L){let x=ne(ee.Id),I=ne(ee[V]);x!==void 0&&J.records.add(x),I!==void 0&&(J.parents.add(I),b.set(I,String(ee[V])))}},i.signal),W=new Set;B.forEach((D,L)=>{if(D.read)return;let{child:N}=R[L];if(!j.has(N)&&/No such column 'CreatedDate'/.test(D.reason)){W.add(N);return}throw new Error(`The ${D.objectApiName} records its deletion would take along could not be read: `+D.reason)});for(let D of W)j.set(D,"SystemModstamp");v=v.filter(D=>W.has(we(D.childSObject)))}}if(b.size>0){let C=new ln(X(r,a,"outsideParents"));for(let v of b.values())await C.add({Id:v});await C.flush()}return[...y].filter(([,{records:C}])=>C.size>0).sort(([C],[v])=>C<v?-1:C>v?1:0).map(([C,{records:v,parents:R}])=>({objectApiName:C,count:v.size,parents:R.size}))}async function gi(e,n,t,o){if(e.kind==="org")return;let{objectApiName:s,toDelete:i}=n.diff,r=i.createdSince+i.broughtBackSince;if(r===0)return;let l=((await t(s)).childRelationships??[]).filter(d=>d.cascadeDelete===!0).map(d=>d.childSObject);if(l.length===0)return;let w=await o(),p=[...new Set(l.filter(d=>w.has(d)))].sort(),u=[...p.length>0?await e.unseenOf(p):[]].sort((d,f)=>+!Vt.has(d)-+!Vt.has(f));return u.length>0?{objectApiName:s,children:u,records:r}:void 0}var Vt=new Set(["Event","Task"]);async function hi(e,n){let t=new Set(n.flatMap(({pending:c})=>c.flatMap(({parents:u,restricts:d})=>[...u,...d]))),o=new Set;if(t.size>0)for(let c of n)for await(let u of Yt(e,c))for(let d of u){let f=d.slice(0,15);t.has(f)&&o.add(f)}let s=new Map(n.flatMap(({pending:c})=>c.map(u=>[u.id.slice(0,15),u]))),i=c=>c.goesAlong?c.parents.find(u=>o.has(u)):void 0,r=(c,u=new Set)=>{let d=s.get(c),f=d&&!u.has(c)?i(d):void 0;return f===void 0?c:r(f,new Set([...u,c]))},a=new Map,l=(c,u)=>{let d=a.get(c);if(d!==void 0)return d;a.set(c,!1);let f=r(c),g=u.restricts.some(y=>o.has(y)&&r(y)!==f)||u.parents.some(y=>{let b=s.get(y);return b!==void 0&&i(b)!==void 0&&l(y,b)});return a.set(c,g),g},w=[],p=[];for(let{diff:c,pending:u}of n){let d=c.objectApiName,f=R=>i(R)!==void 0&&!l(R.id.slice(0,15),R),g=u.filter(f).length;g>0&&p.push({objectApiName:d,count:g});let y=u.filter(R=>!f(R)),b=y.filter(R=>[...R.parents,...R.restricts].some(B=>o.has(B))),j=new Set(b.map(({id:R})=>R)),C=y.filter(R=>!R.undeletable&&!j.has(R.id));if(C.length+b.length===0)continue;let v=new ln(X(e,d,"undoCannot"));for(let{id:R}of C)await v.add({Id:R});for(let{id:R}of b)await v.add({Id:R,reason:"deletedBeforeParent"});await v.flush(),C.length>0&&w.push({objectApiName:d,count:C.length}),b.length>0&&w.push({objectApiName:d,count:b.length,reason:"deletedBeforeParent"})}return{undoCannot:w,withParentDeleted:p}}async function wi(e,n,t){let o={};if(n.length===0)return o;let s=Fe([...n].sort()).map(i=>({objectApiName:"User",soql:`SELECT Id, Name FROM User WHERE Id IN (${i})`,scanAll:!1}));return await Ee(e,s,(i,r)=>{for(let a of r)typeof a.Id=="string"&&typeof a.Name=="string"&&(o[a.Id]=a.Name)},t),o}function Jt(e){let{toDelete:n,toGiveBack:t,toBringBack:o}=e;return n.createdSince+n.broughtBackSince+n.comesBackWithParent+t.records+o.inBin+o.withParent+o.deletedWhileTaken+(o.carriers??0)+(e.toRecreate??0)+e.touched+e.unexplained+e.cannotUndo.reduce((s,i)=>s+i.count,0)>0||e.schemaDrift!==void 0}async function pi(e){let n=await e.describe(me),t=sn.safeParse("body"in n?n.body:null);if(!t.success)throw new Error(`The org gave no describe of ${me}.`);return t.data}function eo(e){return(n,t)=>X(e,n,t)}async function mi(e,n){let t=n.fileObject.objectApiName,o=n.changes.get(t);if(!(n.unread.has(t)||o===void 0||"unread"in o))try{return{anchors:await Gt({reader:e.reader,folder:e.folder,previewDir:n.previewDir,snapshotId:e.checkpoint.snapshotId,objects:n.ordered,changes:n.changes,linkDescribe:n.linkDescribe,describeGlobal:e.describeGlobal,...e.signal?{signal:e.signal}:{}})}}catch(s){if(s instanceof oe)throw s;return{unread:"The links of its files to the records of the checkpoint could not be read: "+Ne(s)}}}async function no(e){await Promise.all(["linkAdded","linkRemoved","linkChanged"].map(n=>Hn(Ae(e,n),{force:!0})))}async function ki(e,n){let t=n.fileObject.objectApiName,o=n.outcomes.get(t),s=n.changes.get(t);if(o===void 0||!("told"in o)||s===void 0)return;let i=new Set([...n.outcomes].filter(([,r])=>"told"in r).map(([r])=>r));try{let r=await zt({anchors:n.anchors,reader:e.reader,folder:e.folder,snapshotId:e.checkpoint.snapshotId,t0s:n.t0s,objects:n.ordered,fileChanges:s,told:i,classFileOf:eo(n.previewDir),previewDir:n.previewDir,queryAllFiles:e.checkpoint.takenBy?.queryAllFiles===!0&&e.queryAllFiles!==!1,...e.signal?{signal:e.signal}:{}}),{diff:a,people:l}=o.told;a.toDelete.createdSince+=r.createdSince,a.toBringBack.deletedWhileTaken+=r.deletedWhileTaken;for(let u of r.changedBy)l.add(u);a.lastChangedBy=l.byUser();let w=r.goneForGood,p=r.newFileVersion,c=a.cannotUndo.find(u=>u.reason==="goneForGood");return c!==void 0?c.count+=w:w>0&&a.cannotUndo.unshift({reason:"goneForGood",count:w}),a.cannotUndo.push(...p>0?[{reason:"newFileVersion",count:p}]:[]),r.files}catch(r){if(r instanceof oe)throw r;await Vn(n.previewDir,t),await no(n.previewDir),n.outcomes.set(t,{unread:Ne(r)});return}}async function yi(e,n){let t=n.fileObject.objectApiName,o=n.outcomes.get(t);if(o===void 0||!("told"in o))return;let{diff:s}=o.told;if(s.toDelete.createdSince+s.toDelete.broughtBackSince!==0)try{let{links:i,files:r}=await qt({anchors:n.anchors,reader:e.reader,classFileOf:eo(n.previewDir),...e.signal?{signal:e.signal}:{}});if(i===0)return;s.outside=[...s.outside.filter(({objectApiName:a})=>a!==me),{objectApiName:me,count:i,parents:r}].sort((a,l)=>a.objectApiName<l.objectApiName?-1:a.objectApiName>l.objectApiName?1:0)}catch(i){if(i instanceof oe)throw i;await Vn(n.previewDir,t),await no(n.previewDir),n.outcomes.set(t,{unread:Ne(i)})}}async function Ns(e){let{checkpoint:n,folder:t,reader:o,previewId:s,readAt:i,signal:r}=e,a=Date.parse(n.readFrom);if(!Number.isFinite(a))throw new Error(`Not a date: ${n.readFrom}`);let l=Date.parse(i);if(!Number.isFinite(l))throw new Error(`Not a date: ${i}`);if(r?.aborted)throw new oe;let w=a-(a%1e3+1e3)%1e3,p=dt(t,s);await yn(p);let c=[...n.objects].sort((k,F)=>k.readOrder-F.readOrder),u=e.access??Un,d=c.filter(({objectApiName:k})=>!u.notHeld.has(k)),f=new Map,g=n.files!==void 0?d.find(({objectApiName:k})=>Kn(k)):void 0,y=await bt(o,d.map(({objectApiName:k})=>k),n.readFrom,r),b=new Map(d.map(({objectApiName:k},F)=>[k,y[F]])),j=ni(d,b),C=g!==void 0?pi(o):void 0;C?.catch(()=>{});let v=await Kt(e,j,f),R=v.requests,B=new Map,W=new Set,D=[];for(let k of c){let F=k.objectApiName,K=u.notHeld.get(F);if(K!==void 0){B.set(F,K);continue}let H=b.get(F);if(H===void 0||"unread"in H){B.set(F,H?.unread??"Its newest record was not read.");continue}let m=v.now.get(F);m===void 0?(W.add(F),D.push({object:k,fields:{gone:new Set},check:H})):"unread"in m?B.set(F,m.unread):D.push({object:k,fields:m,check:H})}let L=await Rt(o,D.map(({object:k,fields:F})=>({objectApiName:k.objectApiName,readMode:k.readMode,held:k.records>0,fields:ti(k,F.gone)})),n.readFrom,p,r,D.map(({check:k})=>k)),N=new Map(D.map(({object:k},F)=>[k.objectApiName,L[F]])),V=D.filter(({object:k})=>{if(!W.has(k.objectApiName))return!1;let F=N.get(k.objectApiName);return F!==void 0&&!("unread"in F)&&F.count!==void 0&&F.count<k.records});if(V.length>0){let k=await Kt(e,V.map(({object:F})=>F),f);R+=k.requests;for(let F of V){let K=F.object.objectApiName;W.delete(K);let H=k.now.get(K);H===void 0||"unread"in H?B.set(K,H?.unread??"Its describe was not read."):F.fields=H}}let J=new Map,ee=k=>{let F=f.get(k);if(F)return Promise.resolve(F);let K=J.get(k);return K||(K=(async()=>{let H=await o.describe(k),m=sn.safeParse("body"in H?H.body:null);if(!m.success)throw new Error(`The org gave no describe of ${k}.`);return m.data})(),J.set(k,K)),K},{back:x,gone:I}=await oi({input:e,t0s:w},c,N),q=si(x,u.userKey),Q=new Map([...I,...x]),U=ii(x,I),ce=await lt.read(t);for(let k of ce.keys())(x.has(k)||I.has(k))&&U.add(k);let ie=Xt([...ce.keys()].filter(k=>Q.has(k)),Q);qn(U,x,I);for(let k of q)x.delete(k),U.delete(k);let ue=ri(c,x,I),Ce=new Map(D.map(({object:k,fields:F})=>[k.objectApiName,bn(k.objectApiName,k.fields,n.ignoredFields).filter(K=>!F.gone.has(K.toLowerCase()))])),he=await di(x,Ce,ee,B),Pe=await ci(e,D.map(({object:k})=>k),x,I,ue,ee);for(let k of Pe.stuck)U.add(k);qn(U,x,I);for(let k of[...ue])x.has(k)||ue.delete(k);let Le=ai(x,I,Pe.outside),ye=0,He=o.calls(),be=g!==void 0&&C!==void 0?await mi(e,{previewDir:p,ordered:c,changes:N,linkDescribe:C,fileObject:g,unread:B}):void 0;ye+=o.calls()-He;let te=be!==void 0&&"anchors"in be?be.anchors:void 0,Te={input:e,previewDir:p,t0s:w,activeFrom:l-Wo,back:x,carriers:ue,stranded:Le,stuck:U,answeredGone:ie,others:q,access:u,lookups:he,personAccounts:await fi(c,N),...te!==void 0?{files:te}:{}},ge=new Map;for(let{object:k,fields:F}of D){if(r?.aborted)throw new oe;let K=B.get(k.objectApiName)??(be!==void 0&&"unread"in be&&k===g?be.unread:void 0),H=N.get(k.objectApiName);ge.set(k.objectApiName,K!==void 0||H===void 0?{unread:K??"Its changes were not read."}:await li(Te,k,H,F))}let Ie;if(te!==void 0&&g!==void 0){let k=o.calls();Ie=await ki(e,{anchors:te,fileObject:g,changes:N,outcomes:ge,ordered:c,previewDir:p,t0s:w}),ye+=o.calls()-k}let Re=new Set(c.map(({objectApiName:k})=>k.toLowerCase()));if(n.files!==void 0&&g!==void 0)for(let k of[me,nt])Re.add(k.toLowerCase());let en,nn=()=>en??=ot({describeGlobal:e.describeGlobal}),Ke=[];for(let[k,F]of ge){if(!("told"in F))continue;let{toDelete:K}=F.told.diff;if(K.createdSince+K.broughtBackSince!==0)try{F.told.diff.outside=await ui(Te,F.told,ee,nn,Re);let H=await gi(u,F.told,ee,nn);H!==void 0&&Ke.push(H)}catch(H){if(H instanceof oe)throw H;await Vn(p,k),ge.set(k,{unread:Ne(H)})}}if(te!==void 0&&g!==void 0){let k=o.calls();await yi(e,{anchors:te,fileObject:g,outcomes:ge,previewDir:p}),ye+=o.calls()-k,"told"in(ge.get(g.objectApiName)??{unread:""})||(Ie=void 0)}let de=c.flatMap(({objectApiName:k})=>{let F=ge.get(k);return F&&"told"in F?[F.told]:[]}),{undoCannot:_e,withParentDeleted:$e}=await hi(p,de),De=new Set(de.map(({diff:k})=>k.objectApiName)),ve=Ke.filter(({objectApiName:k})=>De.has(k)),Ve=[...new Set(de.flatMap(({diff:k})=>Object.keys(k.lastChangedBy)))],rn=await wi(o,Ve,r),We=new Set(de.flatMap(({people:k})=>[...k.active])),Je=de.filter(({diff:k})=>W.has(k.objectApiName)&&!Jt(k)).length;return{checkpointId:n.checkpointId,previewId:s,readAt:i,objects:de.map(({diff:k})=>k).filter(Jt),undoCannot:_e,...$e.length>0?{withParentDeleted:$e}:{},...Pe.requests>0?{parentsOutsideRequests:Pe.requests}:{},...R>0?{fieldsRequests:R}:{},described:{first:j.length,later:V.length},...Je>0?{fieldsNotChecked:Je}:{},...Ie!==void 0?{files:Ie}:{},...g!==void 0?{filesRequests:ye}:{},access:u.diffAccess(),...ve.length>0?{unseen:ve}:{},unread:c.flatMap(({objectApiName:k})=>{let F=ge.get(k),K=F&&"unread"in F?F.unread:F?void 0:B.get(k);return K===void 0?[]:[{objectApiName:k,reason:K}]}),userNames:rn,activeLastHour:[...We].sort()}}var Si=1e3,Ci=25,Pi=2e3,Se=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,to=["createdSince","broughtBackSince","comesBackWithParent","giveBack","inBin","withParent","deletedWhileTaken","toRecreate","carrier"],ae={createdSince:1,broughtBackSince:2,comesBackWithParent:4,giveBack:8,inBin:16,withParent:32,deletedWhileTaken:64,toRecreate:128,carrier:256},oo=32768,Ii={createdSince:ae.createdSince|ae.comesBackWithParent|ae.carrier,broughtBackSince:ae.broughtBackSince|ae.carrier,comesBackWithParent:ae.comesBackWithParent,giveBack:ae.giveBack|ae.inBin|ae.withParent,inBin:ae.inBin,withParent:ae.withParent,deletedWhileTaken:ae.deletedWhileTaken,toRecreate:ae.toRecreate,carrier:ae.carrier},un=new Set(["createdSince","broughtBackSince"]),qe={changedSincePreview:1,changedDuringRewind:2,outsideNotAccepted:4,holdsLeft:8,noUndoNotAccepted:16,beforeParentNotAccepted:32,recreateNotAccepted:64,keyTaken:128,needsUnpickedParent:256,heldByUnpicked:512},Di=[{cls:"linkAdded",as:"unlink"},{cls:"linkRemoved",as:"relink"},{cls:"linkChanged",as:"share"}];function Hs(e,n){return[n,e.automatedProcessUserId].filter(t=>typeof t=="string"&&t!=="")}function Ks(e,n){let t=n.length>0?n.join(", "):"child";return`${e}: given back once the ${t} records hanging from it that the rewind deletes were gone, as those records held some of its values in place`}function Xe(e){let n=tn(e);return n===null?Number.NaN:Date.parse(n)}function re(e,n){let t=e.Id;if(typeof t!="string"||!Se.test(t))throw new Error(`A line of ${n} names no record: the diff it was read from is not whole.`);return t}async function*z(e){try{for await(let n of se(e))yield n}catch(n){if(n.code!=="ENOENT")throw n}}function Ni(e,n){return Nn(e,`${we(n)}.beforeParent.ndjson`)}function ji(e,n){return Nn(e,`${we(n)}.along.ndjson`)}var Ye=class{constructor(n){this.file=n}file;lines=[];written=!1;async add(n){this.lines.push(`${JSON.stringify(n)}
10
- `),this.lines.length>=Pi&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await Ri(this.file,n,{encoding:"utf8",mode:on,flag:this.written?"a":"w"}),this.written=!0}},Jn=class{entries=new Map;add(n,t,o,s,i){let r=`${n}\0${t}\0${s??""}\0${i??""}`,a=this.entries.get(r);a||(a={objectApiName:n,reason:t,...s!==void 0?{by:s}:{},...i!==void 0?{needs:i}:{},count:0,ids:[]},this.entries.set(r,a)),a.count++,a.ids.length<Ci&&a.ids.push(o)}all(n){let t=(o,s)=>(o??"")<(s??"")?-1:(o??"")>(s??"")?1:0;return[...this.entries.values()].sort((o,s)=>(n.get(o.objectApiName)??0)-(n.get(s.objectApiName)??0)||t(o.reason,s.reason)||t(o.by,s.by)||t(o.needs,s.needs))}};function io(e,n){if(!(typeof n!="string"||n===""))return e==="SetupOwnerId"&&Se.test(n)?n.slice(0,15):n}async function Li(e,n,t,o){let s=new Z;if(e.customSetting===void 0)return s;let i=kn(e.customSetting).toLowerCase(),r=e.fields.find(w=>w.toLowerCase()===i);if(r===void 0)return s;let a=new Z;for(let w of o){let p=X(t,e.objectApiName,w);for await(let c of z(p))a.add(re(c,p))}if(a.size===0)return s;let l=new Set;for await(let w of z(Ue(n,e.objectApiName))){let p=io(r,w[r]);p!==void 0&&l.add(p)}if(l.size===0)return s;for await(let w of z(dn(n,e.objectApiName))){if(typeof w.Id!="string"||!a.has(w.Id))continue;let p=io(r,w[r]);p!==void 0&&l.has(p)&&s.add(w.Id)}return s}function so(e){return{objectApiName:e,deleted:0,withParentDeleted:0,undoCannot:0,nextPassDeleted:0,broughtBack:0,backWithParent:0,recreated:0,givenBackFirst:0,givenBackAfter:0,givenBackNextPass:0,skipped:0}}function vi(e){return Object.entries(e).some(([n,t])=>n!=="objectApiName"&&t!==0)}function ro(e){return`${e.ContentDocumentId.slice(0,15)}:${e.LinkedEntityId.slice(0,15)}`}function ao(e,n,t){let s=(n==="linkChanged"?Ot:Rn).safeParse(e);if(!s.success)throw new Error(`A line of ${t} names no link: the diff it was read from is not whole.`);return s.data}function fo(e){return{unlink:{file:Ae(e,"linkAdded"),count:0},relink:{file:Ae(e,"linkRemoved"),count:0},share:{file:Ae(e,"linkChanged"),count:0}}}async function Bi(e){let n={};for(let{cls:o,as:s}of Di){let i=new Set,r=Ae(e.confirmedDir,o);for await(let p of z(r))i.add(ro(ao(p,o,r)));let a=Ae(e.freshDir,o),l=new Ye(Ae(e.dir,o)),w=0;for await(let p of z(a)){let c=ao(p,o,a);if(e.deleted(c.ContentDocumentId)||e.deleted(c.LinkedEntityId))continue;let u=e.pass===2&&o==="linkRemoved"&&(e.earlier(c.ContentDocumentId)||e.earlier(c.LinkedEntityId));if(!i.has(ro(c))&&!u){e.left.add(me,"changedSincePreview",c.Id);continue}await l.add(p),w++}await l.flush(),n[s]={file:l.file,count:w}}let t=fo(e.dir);return{unlink:n.unlink??t.unlink,relink:n.relink??t.relink,share:n.share??t.share}}var Fi=["inBin","withParent","deletedWhileTaken","carrier"],Ei=new Set(["id","createdbyid","lastmodifiedbyid","systemmodstamp","createddate","lastmodifieddate"]);function Mi(e,n){return e.flatMap(t=>{let o=n[t];return typeof o=="string"&&Se.test(o)?[o.slice(0,15)]:[]})}function co(e,n,t){let o=t===void 0?void 0:new Set(t.map(s=>s.toLowerCase()));return Object.entries(e).flatMap(([s,i])=>{let r=s.toLowerCase();if(Ei.has(r)||o!==void 0&&!o.has(r))return[];if(typeof i!="string"||!Se.test(i))return[];let a=i.slice(0,15);return n.has(a)?[{field:s,needs:n.get(a)}]:[]})}async function Ti(e,n,t){let{freshDir:o,heldRows:s}=e,i=new Map,r=new Map;for(let d of n)for(let f of[...Fi,"toRecreate","comesBackWithParent"]){let g=X(o,d.objectApiName,f);for await(let y of z(g)){let b=re(y,g).slice(0,15);i.set(b,d.objectApiName),r.set(b,f)}}let a=new Map;for(let d of n)if(d.cascadeParents.length!==0)for await(let f of z(dn(o,d.objectApiName))){if(typeof f.Id!="string"||!Se.test(f.Id))continue;let g=f.Id.slice(0,15),y=r.get(g);(y==="withParent"||y==="comesBackWithParent")&&a.set(g,Mi(d.cascadeParents,f))}let l=new Set;for(let[d,f]of r)(f==="inBin"||f==="deletedWhileTaken"||f==="carrier")&&t(i.get(d)??"")&&l.add(d);for(let d=l.size>0;d;){d=!1;for(let[f,g]of a)l.has(f)||!g.some(y=>l.has(y))||(l.add(f),d=!0)}let w=(d,f=new Set)=>{let g=i.get(d);if(!(g===void 0||f.has(d))){if(!t(g))return g;f.add(d);for(let y of a.get(d)??[]){if(l.has(y))continue;let b=w(y,f);if(b!==void 0)return b}}},p=new Map,c=new Map;for(let[d,f]of r){if(l.has(d)||f==="comesBackWithParent")continue;let g=i.get(d)??"";if(!t(g))p.set(d,g);else if(f==="withParent"){let y=w(d);c.set(d,y),p.set(d,y)}}let u=new Map;if(s===void 0)return{comes:l,left:c,fields:u};for(let d of[...n].reverse()){let f=d.objectApiName;if(!t(f))continue;let g=new Set(d.cascadeParents.map(v=>v.toLowerCase())),y=[],b=X(o,f,"toRecreate");for await(let v of z(b))y.push(re(v,b));if(y.length>0)for await(let v of s(f,y)){if(typeof v.Id!="string"||!Se.test(v.Id))continue;let R=v.Id.slice(0,15),B=co(v,p,void 0);if(B.length===0)continue;let W=B.find(({field:D})=>g.has(D.toLowerCase()));W!==void 0?(c.set(R,W.needs),p.set(R,W.needs)):u.set(R,{fields:B.map(({field:D})=>D),needs:B[0].needs})}let j=new Map,C=X(o,f,"giveBack");for await(let v of z(C)){let R=re(v,C),B=Array.isArray(v.fields)?v.fields.filter(W=>typeof W=="string"):void 0;j.set(R.slice(0,15),{id:R,differ:B})}for(let v of["inBin","withParent"]){let R=X(o,f,v);for await(let B of z(R)){let W=re(B,R);l.has(W.slice(0,15))&&j.set(W.slice(0,15),{id:W,differ:void 0})}}if(j.size!==0)for await(let v of s(f,[...j.values()].map(({id:R})=>R))){if(typeof v.Id!="string"||!Se.test(v.Id))continue;let R=v.Id.slice(0,15),B=j.get(R);if(B===void 0)continue;let W=co(v,p,B.differ);W.length>0&&u.set(R,{fields:W.map(({field:D})=>D),needs:W[0].needs})}}return{comes:l,left:c,fields:u}}function _i(e,n){let t=n!==void 0?` Rewind ${n} with it to put it back.`:"",o=n??"an object this rewind was not limited to";switch(e){case"needsUnpickedParent":return`Left: it comes back only with a parent this rewind leaves deleted, or a lookup of it names a record this rewind leaves deleted (${o}), which the org refuses to point at.${t}`;case"heldByUnpicked":return`Given back but for the values records of ${o} created since hold in place: this rewind leaves them, so the org refuses to change those values.${t}`;case"outsideNotAccepted":return`Kept: records of ${o} created since hang from it, which its deletion would take along, and deleting them was not accepted.${t}`;default:return`Kept: records of ${o} this rewind leaves as they are hang from it, and its deletion would take them along.${t}`}}async function $i(e){let{checkpoint:n,pass:t,confirmedDir:o,freshDir:s,dir:i,signal:r}=e,a=Date.parse(n.takenAt);if(!Number.isFinite(a))throw new Error(`Not a date: ${n.takenAt}`);let l=Date.parse(e.readAt);if(!Number.isFinite(l))throw new Error(`Not a date: ${e.readAt}`);let w=l-Si;if(await yn(i),(await Oi(i)).length>0)throw new Error(`A rewind's plan is written to a folder of its own: ${i} is not empty.`);let p=()=>{if(r?.aborted)throw new oe},c=[...n.objects].map(wt).sort((m,O)=>m.readOrder-O.readOrder),u=new Map(c.map(({objectApiName:m},O)=>[m,O])),d=new Map(c.map(({objectApiName:m})=>[m,so(m)])),f=m=>d.get(m)??so(m),g=new Set(e.ownWriters.map(m=>m.slice(0,15))),y=new Map(Object.entries(e.removalStamps??{}).map(([m,O])=>[m.slice(0,15),Xe(O)])),b=m=>lo(m,w,g,y),j=(m,O)=>m.flatMap(T=>{let E=O[T];return typeof E=="string"&&Se.test(E)?[E]:[]}),C=(m,O)=>j(m.cascadeParents,O),v=(m,O)=>j(m.restrictParents??[],O),R=new Jn,B=m=>e.objects===void 0||e.objects.has(m),W=e.objects!==void 0?await Ti(e,c,B):void 0,D=new Map,L=new Map,N=new Ye(Nn(i,"leftFields.ndjson")),V=0,J=(m,O,T,E)=>{if(R.add(m,O,T,void 0,E),D.set(T.slice(0,15),_i(O,E)),E===void 0)return;let h=L.get(E);h||(h=new Z,L.set(E,h)),h.add(T)},ee=new Z,x=new Z,I=new Z,q=new Z,Q=new Z,U=new Z,ce=[];for(let m of c){p();let O=m.objectApiName,T=B(O),E=(u.get(O)??0)+1,h=f(O),A=new Z;for(let S of to){let $=X(o,O,S);for await(let Y of z($))A.add(re(Y,$),ae[S])}let P=t===2?await zi(s,O,w,g,y,ce):void 0,M=new Map,_=S=>{let $=M.get(S);return $||($=new Ye(X(i,O,S)),M.set(S,$)),$};for(let S of to){if(!T&&S!=="comesBackWithParent"&&S!=="createdSince")continue;let $=X(s,O,S);for await(let Y of z($)){let G=re(Y,$),fe=(A.flagsOf(G)&Ii[S])!==0;if(!T&&!(t===2?fe:S==="comesBackWithParent"&&fe&&W?.comes.has(G.slice(0,15))))continue;fe&&A.add(G,oo),fe&&un.has(S)&&(A.flagsOf(G)&ae.carrier)!==0&&U.add(G);let Oe=P?.other.flagsOf(G)??0,Qn=T&&P?.own.has(G)===!0;if(Oe>0||!(fe||Qn)){let pe=Oe>0?"changedDuringRewind":"changedSincePreview";R.add(O,pe,G,Oe>0?ce[Oe-1]:void 0),un.has(S)&&I.add(G,qe[pe]);continue}if(W!==void 0&&T){let pe=G.slice(0,15);if(S==="comesBackWithParent"&&!W.comes.has(pe))continue;if((S==="withParent"||S==="toRecreate")&&W.left.has(pe)){J(O,"needsUnpickedParent",G,W.left.get(pe));continue}let gn=W.fields.get(pe);if(gn!==void 0&&(S==="giveBack"||S==="toRecreate"||S==="inBin"||S==="withParent")){J(O,"needsUnpickedParent",G,gn.needs),await N.add({Id:G,fields:gn.fields}),V++;let Zn=Array.isArray(Y.fields)?Y.fields:[],uo=Zn.filter(Xn=>typeof Xn=="string"&&!gn.fields.some(go=>go.toLowerCase()===Xn.toLowerCase()));if(S==="giveBack"&&Zn.length>0&&uo.length===0)continue}}if(S==="toRecreate"&&!e.acceptRecreate){R.add(O,"recreateNotAccepted",G);continue}await _(S).add(S==="giveBack"?Y:{Id:G}),S==="giveBack"&&W!==void 0&&ee.add(G,E),un.has(S)?x.add(G,E):S==="comesBackWithParent"?(q.add(G),h.nextPassDeleted++):S==="carrier"?(q.add(G),Q.add(G),h.carriers=(h.carriers??0)+1,h.nextPassDeleted++):S==="inBin"||S==="deletedWhileTaken"?h.broughtBack++:S==="withParent"?h.backWithParent++:S==="toRecreate"&&h.recreated++,(S==="inBin"||S==="withParent")&&await _("giveBack").add({Id:G})}}for(let S of M.values())await S.flush();h.skipped=T?A.count(S=>(S&oo)===0):0}await N.flush();let ie=new Map;if(W!==void 0){let m=new Z;for(let O of c){let T=O.objectApiName;if(B(T)||O.cascadeParents.length===0)continue;let E=new Z;for(let h of un){let A=X(s,T,h);for await(let P of z(A))E.add(re(P,A))}for await(let h of z(Ue(s,T))){if(typeof h.Id!="string"||!Se.test(h.Id)||x.has(h.Id))continue;let A=E.has(h.Id),P=A&&Xe(h.CreatedDate)>=a&&Xe(h.LastModifiedDate)<=w;for(let M of C(O,h)){let _=x.flagsOf(M);if(_>0){if(I.has(M)||P&&e.acceptOutside)continue;let $=c[_-1].objectApiName;ie.set(M.slice(0,15),T),P?(I.add(M,qe.outsideNotAccepted),J($,"outsideNotAccepted",M,T)):I.add(M,qe.holdsLeft);continue}let S=ee.flagsOf(M);A&&S>0&&m.add(M)&&J(c[S-1].objectApiName,"heldByUnpicked",M,T)}}}}if(n.scope.mode==="picked"&&!e.acceptOutside)for(let m of c){let O=X(s,m.objectApiName,"outsideParents");for await(let T of z(O)){let E=re(T,O);!x.has(E)||I.has(E)||U.has(E)||(I.add(E,qe.outsideNotAccepted),R.add(m.objectApiName,"outsideNotAccepted",E))}}let ue=c.map(m=>({object:m,file:Ue(s,m.objectApiName)}));for(let m=I.size>0;m;){p(),m=!1;for(let{object:O,file:T}of ue)for await(let E of z(T)){if(!I.has(E.Id))continue;let h=ie.get(String(E.Id).slice(0,15));for(let A of C(O,E))!x.has(A)||I.has(A)||(I.add(A,qe.holdsLeft),h!==void 0&&ie.set(A.slice(0,15),h),m=!0)}}for(let{object:m,file:O}of ue)for await(let T of z(O))if(x.has(T.Id)&&I.flagsOf(T.Id)===qe.holdsLeft){let E=re(T,O),h=ie.get(E.slice(0,15));h!==void 0?J(m.objectApiName,"holdsLeft",E,h):R.add(m.objectApiName,"holdsLeft",E)}let Ce=new Z,he=m=>x.has(m)&&!I.has(m),Pe=new Map,Le=m=>{let O=m.slice(0,15);return Pe.get(O)??O},ye=new Z,He=[...c].reverse(),be=[],te=[];for(let m of He){p();let O=m.objectApiName,T=Ue(s,O),E=new Ye(Ni(i,O)),h=new Ye(ji(i,O)),A=0,P=0;for await(let M of z(T)){let _=typeof M.Id=="string"?M.Id:"";if(!he(_))continue;let S=Xe(M.LastModifiedDate),$=C(m,M).filter(he);if($.length>0&&Xe(M.CreatedDate)>=a&&(S<=w||S<=(y.get(_.slice(0,15))??Number.NaN))){let Oe=Le($[0]);if(!($.some(pe=>ye.has(pe))||v(m,M).some(pe=>he(pe)&&Le(pe)!==Oe))){Ce.add(_),Pe.set(_.slice(0,15),Oe),f(O).withParentDeleted++,await h.add({Id:_,parent:Oe}),P++;continue}ye.add(_)}let G=[...C(m,M),...v(m,M)].filter(he);if(m.undeletable&&G.length===0)continue;let fe=G.length>0?"beforeParentNotAccepted":"noUndoNotAccepted";e.acceptNoUndo?(f(O).undoCannot++,G.length>0&&(await E.add({Id:_,parents:G}),A++)):(I.add(_,qe[fe]),R.add(O,fe,_))}await E.flush(),A>0&&be.push({objectApiName:O,count:A,file:E.file}),await h.flush(),P>0&&te.push({objectApiName:O,count:P,file:h.file})}let Te=new Ge(`${i}/deletes`),ge=new Ge(`${i}/along-to-draft`),Ie={},Re=new Z,en=0;for(let m of c){p();let O=m.objectApiName,T=Ue(s,O),E=0;for await(let h of z(T)){let A=typeof h.Id=="string"?h.Id:"";if(x.has(A)&&(en++,!I.has(A))){for(let P of C(m,h))Re.has(P)||Re.add(P,(u.get(O)??0)+1);if(Ce.has(A)){it([O]).length>0&&await ge.add(O,A);continue}await Te.add(O,A),E++,t===2&&b(h)&&typeof h.LastModifiedDate=="string"&&(Ie[A]=h.LastModifiedDate)}}f(O).deleted=E}if(en!==x.size)throw new Error("The fresh diff's reads do not hold every record its classes name to delete.");let nn=await vn.of(Te),Ke=await vn.of(ge),de=new Z;if(t===1&&q.size>0){for(let m of c)for await(let O of z(dn(s,m.objectApiName)))if(q.has(O.Id))for(let T of C(m,O))de.add(T)}let _e=new Map;for(let m of c){let O=await Li(m,s,i,["inBin","deletedWhileTaken"]);if(O.size===0)continue;_e.set(m.objectApiName,O);let T=f(m.objectApiName);T.broughtBack-=O.size,T.keyTaken=O.size;for(let E of["inBin","deletedWhileTaken"]){let h=X(i,m.objectApiName,E);for await(let A of z(h)){let P=re(A,h);O.has(P)&&R.add(m.objectApiName,"keyTaken",P)}}}let $e=new Ge(`${i}/giveBackFirst`),De=new Ge(`${i}/giveBackAfter`),ve=[];for(let m of c){p();let O=m.objectApiName,T=X(i,O,"giveBack"),E=!1;for await(let _ of z(T))if(Re.has(_.Id)){E=!0;break}let h=new Z;if(E)for await(let _ of z(Ue(s,O)))Re.has(_.Id)&&C(m,_).some(he)&&h.add(String(_.Id));let A=f(O),P=new Set,M=_e.get(O);for await(let _ of z(T)){let S=re(_,T);if(M?.has(S)===!0)continue;let $=Re.flagsOf(S),Y=h.has(S);if($>0){if(await De.add(O,S),A.givenBackAfter++,P.add(c[$-1].objectApiName),!Y)continue}else if(!Y&&de.has(S)){A.givenBackNextPass++;continue}await $e.add(O,S),A.givenBackFirst++}P.size>0&&ve.push({objectApiName:O,by:[...P]})}let Ve=new Ge(`${i}/bringBack`),rn=new Ge(`${i}/recreate`);for(let m of He){let O=_e.get(m.objectApiName);for(let E of["carrier","inBin","deletedWhileTaken"]){let h=X(i,m.objectApiName,E);for await(let A of z(h)){let P=re(A,h);O?.has(P)!==!0&&await Ve.add(m.objectApiName,P)}}let T=X(i,m.objectApiName,"toRecreate");for await(let E of z(T))await rn.add(m.objectApiName,re(E,T))}let We=new Z;if(t===2)for(let m of c)for(let O of["inBin","withParent","deletedWhileTaken","carrier","toRecreate"]){let T=X(o,m.objectApiName,O);for await(let E of z(T))We.add(re(E,T))}let Je=n.files===void 0||!B(le)?fo(i):await Bi({confirmedDir:o,freshDir:s,dir:i,pass:t,deleted:m=>Se.test(m)&&he(m),earlier:m=>Se.test(m)&&(We.has(m)||We.has(e.recreated?.originalOf(m.slice(0,15))??m)),left:R}),k=new Ge(`${i}/unlinkFrom`);for(let m of un){let O=X(i,le,m);for await(let T of z(O)){let E=re(T,O);(I.flagsOf(E)&qe.outsideNotAccepted)!==0&&await k.add(le,E)}}let F={...e.removalStamps,...Ie},K=Object.keys(F).length>0,H=c.map(({objectApiName:m})=>f(m)).filter(vi);return{pass:t,dir:i,deletes:nn,removal:{runStartedAt:new Date(a),runEndedAt:new Date(w),includeChanged:!1,...K?{removalStamps:F}:{},...e.removalSpans&&e.removalSpans.length>0?{removalSpans:[...e.removalSpans]}:{}},bringBack:await Ve.finish(),carriers:Q,goesAlong:Ce,along:te.reverse(),alongToDraft:Ke,recreate:await rn.finish(),giveBack:{beforeDeletes:await $e.finish(),afterDeletes:await De.finish(),heldBy:ve},restore:{changedAfter:e.readAt,ownWriters:[...e.ownWriters],includeChanged:!1,...K?{stamps:F}:{}},objects:H,undoCannot:H.filter(m=>m.undoCannot>0).map(({objectApiName:m,undoCannot:O})=>({objectApiName:m,count:O})),beforeParent:be.reverse(),left:R.all(u),links:{...Je,unlinkFrom:await k.finish()},...W!==void 0?{limited:{objects:c.map(({objectApiName:m})=>m).filter(B),needs:[...L].sort(([m],[O])=>(u.get(m)??0)-(u.get(O)??0)).map(([m,O])=>({objectApiName:m,records:O.size})),why:D,leftFields:{file:N.file,count:V}}}:{}}}function Vs(e,n){if(n===void 0)return e;let t=i=>i.filter(r=>n.has(r.objectApiName)),{files:o,...s}=e;return{...s,objects:t(e.objects),undoCannot:t(e.undoCannot),unread:t(e.unread),...e.withParentDeleted?{withParentDeleted:t(e.withParentDeleted)}:{},...e.unseen?{unseen:t(e.unseen)}:{},...o!==void 0&&n.has(le)?{files:o}:{}}}var Wi=200;function Js(e,n){return async function*(t,o){if(o.length===0)return;let s=await xe.read(n,e.snapshotId,t);for(let i=0;i<o.length;i+=Qe){let r=await s.chunk(o.slice(i,i+Qe)).batches(e.snapshotId,t,Wi);for await(let a of r??[])yield*a}}}var xi=new Set(["needsUnpickedParent","heldByUnpicked","outsideNotAccepted","holdsLeft","keyTaken"]);async function Gi(e,n){let t=0;for await(let o of z(X(e,n,"giveBack")))Array.isArray(o.fields)&&t++;return t}async function Ui(e){let n=new Set(e.limited?.objects??e.objects.map(i=>i.objectApiName)),t=[];for(let i of e.objects){let r={objectApiName:i.objectApiName,picked:n.has(i.objectApiName),toDelete:i.deleted+i.withParentDeleted+i.nextPassDeleted-(i.carriers??0),...i.withParentDeleted>0?{withParent:i.withParentDeleted}:{},toGiveBack:await Gi(e.dir,i.objectApiName),toBringBack:i.broughtBack+i.backWithParent,toRecreate:i.recreated};r.toDelete+r.toGiveBack+r.toBringBack+r.toRecreate>0&&t.push(r)}let o=new Map;for(let i of e.left){if(!n.has(i.objectApiName)||!xi.has(i.reason))continue;let r=`${i.objectApiName}\0${i.reason}`,a=o.get(r);a?a.count+=i.count:o.set(r,{objectApiName:i.objectApiName,reason:i.reason,count:i.count})}let s=e.undoCannot.flatMap(({objectApiName:i,count:r})=>{let a=e.beforeParent.find(w=>w.objectApiName===i),l=r-(a?.count??0);return[...l>0?[{objectApiName:i,count:l}]:[],...a!==void 0&&a.count>0?[{objectApiName:i,count:a.count,reason:"deletedBeforeParent"}]:[]]});return{objects:[...n],acts:t,left:[...o.values()],needs:e.limited?.needs??[],undoCannot:s}}async function Qs(e){let n=Nn(e.previewDir,`selection-${bi(4).toString("hex")}`);try{let t=await $i({checkpoint:e.checkpoint,pass:1,confirmedDir:e.previewDir,freshDir:e.previewDir,readAt:e.readAt,ownWriters:[],acceptOutside:e.acceptOutside,acceptNoUndo:!0,acceptRecreate:!0,...e.objects?{objects:e.objects}:{},...e.heldRows?{heldRows:e.heldRows}:{},dir:n,...e.signal?{signal:e.signal}:{}});return await Ui(t)}finally{await Ai(n,{recursive:!0,force:!0})}}function lo(e,n,t,o){let s=Xe(e.LastModifiedDate);if(!(s>n))return!1;let i=typeof e.Id=="string"?e.Id:"",r=typeof e.LastModifiedById=="string"?e.LastModifiedById:"";return s<=(o.get(i.slice(0,15))??Number.NaN)||t.has(r.slice(0,15))}async function zi(e,n,t,o,s,i){let r={own:new Z,other:new Z};for(let a of[Ue(e,n),dn(e,n)])for await(let l of z(a)){if(!(Xe(l.LastModifiedDate)>t))continue;let p=re(l,a);if(lo(l,t,o,s)){r.own.add(p);continue}let c=typeof l.LastModifiedById=="string"?l.LastModifiedById:"",u=i.indexOf(c);u<0&&(i.push(c),u=i.length-1),r.other.add(p,u+1)}return r}export{Un as a,as as b,X as c,zo as d,Ns as e,Hs as f,Ks as g,$i as h,Vs as i,Js as j,Ui as k,Qs as l};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-DPMRIMUC.mjs";import"./chunk-SI267LYR.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-KAZS5Z6W.mjs";import"./chunk-BBRWFKS5.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-EPFCERGL.mjs";import"./chunk-IUM4NFKI.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AGENT_TEST_RUN_WAIT_MINUTES,a as AGENT_TEST_SPECS_DIR,e as agentTestApiName,f as agentTestCommands,d as agentTestSpecFileName,c as agentTestSpecYaml,g as nodeAgentTestSpecFiles,h as writeAgentTestSpec,i as writeScenarioTestSpec,j as yamlOf};